mirror of
https://github.com/arnaucube/circom-compat.git
synced 2026-01-09 07:21:33 +01:00
Early exit in error callback from Wasm (#9)
* Early exit in error callback from Wasm This avoids Wasm execution hanging due to problems such as wrong public input. Mimics circom_runtime behaviour with less detailed debug information. See https://github.com/iden3/circom_runtime/blob/master/js/witness_calculator.js#L52-L64 Adds test for wrong public input. Without early exit, the test stalls. With it, the Circom build step fails as expected. * chore: clean up error handling * ci: add caching Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
@@ -37,3 +37,24 @@ fn groth16_proof() -> Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn groth16_proof_wrong_input() {
|
||||
let cfg = CircomConfig::<Bn254>::new(
|
||||
"./test-vectors/mycircuit.wasm",
|
||||
"./test-vectors/mycircuit.r1cs",
|
||||
)
|
||||
.unwrap();
|
||||
let mut builder = CircomBuilder::new(cfg);
|
||||
builder.push_input("a", 3);
|
||||
// This isn't a public input to the circuit, should faild
|
||||
builder.push_input("foo", 11);
|
||||
|
||||
// create an empty instance for setting it up
|
||||
let circom = builder.setup();
|
||||
|
||||
let mut rng = thread_rng();
|
||||
let _params = generate_random_parameters::<Bn254, _, _>(circom, &mut rng).unwrap();
|
||||
|
||||
builder.build().unwrap_err();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user