Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend_barretenberg generateProof throwing unreachable on recursive proof #4618

Closed
signorecello opened this issue Mar 22, 2024 · 5 comments
Closed
Labels
bug Something isn't working js Noir's JavaScript packages recursion Recursive proving / proof aggregation

Comments

@signorecello
Copy link
Contributor

Aim

I want to create a proof that verifies another proof by generating the witness of the recursive inputs and feeding them to backend_barretenberg. Example:

	const { proof, publicInputs } = await noirMain.generateProof(inputs);
	const { proofAsFields, vkAsFields, vkHash } =
		await mainBackend.generateRecursiveProofArtifacts(
			{ publicInputs, proof },
			1
		);
	const recursiveInputs = {
		verification_key: vkAsFields.map((e) => e.toString()),
		proof: proofAsFields,
		public_inputs: publicInputs,
		key_hash: vkHash,
	};

	// doesn't work
	const { recursiveWitness } = await noirRecursive.execute(recursiveInputs);
	const finalProofData = await recursionBackend.generateProof(
		recursiveWitness
	);

Expected Behavior

I expect it to produce a valid proof

Bug

Instead, it throws an unreachable error:

Error [RuntimeError]: unreachable
    at wasm://wasm/01fd9442:wasm-function[17622]:0x78a386
    at wasm://wasm/01fd9442:wasm-function[41]:0x2432b
    at wasm://wasm/01fd9442:wasm-function[4475]:0x1ec954
    at wasm://wasm/01fd9442:wasm-function[4477]:0x1ec9b0
    at wasm://wasm/01fd9442:wasm-function[4464]:0x1ec563
    at wasm://wasm/01fd9442:wasm-function[5751]:0x1fbbc4
    at wasm://wasm/01fd9442:wasm-function[4069]:0x1e5360
    at wasm://wasm/01fd9442:wasm-function[4066]:0x1e5269
    at wasm://wasm/01fd9442:wasm-function[4065]:0x1e5157
    at wasm://wasm/01fd9442:wasm-function[4083]:0x1e588b

To Reproduce

  1. Clone this repository
  2. Follow the instructions in the readme

Project Impact

None

Impact Context

No response

Workaround

None

Workaround Description

The workaround is to use noir generateProof directly:

	// doesn't work
	const { recursiveWitness } = await noirRecursive.execute(recursiveInputs);
	const finalProofData = await recursionBackend.generateProof(
		recursiveWitness
	);

	// // works
	// const finalProofData = await noirRecursive.generateProof(recursiveInputs);

Additional Context

No response

Installation Method

None

Nargo Version

No response

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@signorecello signorecello added the bug Something isn't working label Mar 22, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Mar 22, 2024
@signorecello signorecello changed the title backend_barretenberg generateProof throwing unreachable backend_barretenberg generateProof throwing unreachable on recursive proof Mar 22, 2024
@Savio-Sou
Copy link
Collaborator

What are noirRecursive and recursionBackend?

@jzaki
Copy link
Contributor

jzaki commented Apr 5, 2024

@Savio-Sou Reproduced in similar code on this line. The first line is the console log

...
Generating outer proof...
Error [RuntimeError]: unreachable
    at wasm://wasm/01fea53a:wasm-function[17700]:0x78e7f4
    at wasm://wasm/01fea53a:wasm-function[223]:0x31fe6
    at wasm://wasm/01fea53a:wasm-function[226]:0x321ae
    at wasm://wasm/01fea53a:wasm-function[8451]:0x34a196
    at wasm://wasm/01fea53a:wasm-function[8450]:0x34a141
    at wasm://wasm/01fea53a:wasm-function[8449]:0x34a0fd
    at wasm://wasm/01fea53a:wasm-function[9188]:0x3d078c
    at wasm://wasm/01fea53a:wasm-function[9184]:0x3d0489
    at wasm://wasm/01fea53a:wasm-function[9180]:0x3cfd7c
    at wasm://wasm/01fea53a:wasm-function[7847]:0x2999f6
Done in 55.02s.

@signorecello
Copy link
Contributor Author

What are noirRecursive and recursionBackend?

Hey sorry indeed the example didn't instantiate them. In this example noirRecursive is an instance of the Noir class and recursionBackend is an instance of the BackendBarretenberg class

@Savio-Sou Savio-Sou added js Noir's JavaScript packages recursion Recursive proving / proof aggregation labels Apr 9, 2024
@Savio-Sou Savio-Sou moved this from 📋 Backlog to 🚧 Blocked in Noir Apr 10, 2024
@TomAFrench
Copy link
Member

example repository isn't debuggable.

@TomAFrench TomAFrench closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2024
@github-project-automation github-project-automation bot moved this from 🚧 Blocked to ✅ Done in Noir Apr 21, 2024
@Savio-Sou
Copy link
Collaborator

Not sure if this was what @TomAFrench referred to, but this is what I get running node main.js on the repo:

% node main.js
(node:19357) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
TypeError: Cannot read properties of undefined (reading '0')
    at decompressSync (file:///.../noir-bug-in-recursive-proofs/node_modules/fflate/esm/index.mjs:1641:17)
    at BarretenbergBackend.generateProof (file:///.../noir-bug-in-recursive-proofs/node_modules/@noir-lang/backend_barretenberg/lib/esm/index.js:53:120)
    at async main (file:///.../noir-bug-in-recursive-proofs/main.js:35:25)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working js Noir's JavaScript packages recursion Recursive proving / proof aggregation
Projects
Archived in project
Development

No branches or pull requests

4 participants