Skip to content

Commit

Permalink
feat: update to target ACVM 0.15.0 (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Jun 19, 2023
1 parent a3fcf96 commit 1aaf057
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 40 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ rust-version = "1.66"
crate-type = ["cdylib"]

[dependencies]
acvm = "0.14.4"
iter-extended = { git = "https://github.com/noir-lang/noir", rev = "a0cef17d8ce552d73b1720916bb6f8b79bb7f959"}
noirc_abi = { git = "https://github.com/noir-lang/noir", rev = "a0cef17d8ce552d73b1720916bb6f8b79bb7f959"}
acvm = "0.15.0"
iter-extended = { git = "https://github.com/noir-lang/noir", rev = "3109239f2c0a7ad4767a3cd1bcc4436a367a8860"}
noirc_abi = { git = "https://github.com/noir-lang/noir", rev = "3109239f2c0a7ad4767a3cd1bcc4436a367a8860"}
wasm-bindgen = { version = "0.2.86", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.4.36"
serde = { version = "1.0.136", features = ["derive"] }
Expand Down
31 changes: 6 additions & 25 deletions src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use acvm::{
BlackBoxFunc,
},
pwg::{
block::Blocks, witness_to_value, OpcodeResolution, OpcodeResolutionError,
insert_value, witness_to_value, Blocks, OpcodeResolution, OpcodeResolutionError,
PartialWitnessGeneratorStatus,
},
FieldElement, PartialWitnessGenerator,
Expand Down Expand Up @@ -94,7 +94,7 @@ impl PartialWitnessGenerator for SimulatedBackend {
dbg!("signature has failed to verify");
}

initial_witness.insert(*output, FieldElement::from(valid_signature));
insert_value(output, FieldElement::from(valid_signature), initial_witness)?;
Ok(OpcodeResolution::Solved)
}

Expand All @@ -113,8 +113,8 @@ impl PartialWitnessGenerator for SimulatedBackend {
let (res_x, res_y) = self.blackbox_vendor.encrypt(scalars).map_err(|err| {
OpcodeResolutionError::BlackBoxFunctionFailed(BlackBoxFunc::Pedersen, err.to_string())
})?;
initial_witness.insert(outputs[0], res_x);
initial_witness.insert(outputs[1], res_y);
insert_value(&outputs[0], res_x, initial_witness)?;
insert_value(&outputs[1], res_y, initial_witness)?;
Ok(OpcodeResolution::Solved)
}

Expand All @@ -133,8 +133,8 @@ impl PartialWitnessGenerator for SimulatedBackend {
)
})?;

initial_witness.insert(outputs[0], pub_x);
initial_witness.insert(outputs[1], pub_y);
insert_value(&outputs[0], pub_x, initial_witness)?;
insert_value(&outputs[1], pub_y, initial_witness)?;
Ok(OpcodeResolution::Solved)
}
}
Expand Down Expand Up @@ -207,22 +207,3 @@ async fn process_oracle_calls(

Ok(())
}

fn insert_value(
witness: &Witness,
value_to_insert: FieldElement,
initial_witness: &mut WitnessMap,
) -> Result<(), OpcodeResolutionError> {
let optional_old_value = initial_witness.insert(*witness, value_to_insert);

let old_value = match optional_old_value {
Some(old_value) => old_value,
None => return Ok(()),
};

if old_value != value_to_insert {
return Err(OpcodeResolutionError::UnsatisfiedConstrain);
}

Ok(())
}

0 comments on commit 1aaf057

Please sign in to comment.