Skip to content

Commit

Permalink
chore!: update to ACVM 0.19.0 (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Jul 18, 2023
1 parent c915a03 commit 7f49911
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 106 deletions.
67 changes: 47 additions & 20 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rust-version = "1.66"
crate-type = ["cdylib"]

[dependencies]
acvm = "0.17.0"
acvm = "0.19.0"
wasm-bindgen = { version = "0.2.86", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.4.36"
serde = { version = "1.0.136", features = ["derive"] }
Expand Down
26 changes: 10 additions & 16 deletions src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use acvm::{
acir::{circuit::Circuit, BlackBoxFunc},
pwg::{ACVMStatus, OpcodeResolutionError, ACVM},
BlackBoxFunctionSolver, FieldElement,
pwg::{ACVMStatus, ACVM},
BlackBoxFunctionSolver, BlackBoxResolutionError, FieldElement,
};

use wasm_bindgen::prelude::wasm_bindgen;
Expand Down Expand Up @@ -30,7 +30,7 @@ impl BlackBoxFunctionSolver for SimulatedBackend {
public_key_y: &FieldElement,
signature: &[u8],
message: &[u8],
) -> Result<bool, OpcodeResolutionError> {
) -> Result<bool, BlackBoxResolutionError> {
let pub_key_bytes: Vec<u8> =
public_key_x.to_be_bytes().iter().copied().chain(public_key_y.to_be_bytes()).collect();

Expand All @@ -39,32 +39,26 @@ impl BlackBoxFunctionSolver for SimulatedBackend {
let sig_e: [u8; 32] = signature[32..64].try_into().unwrap();

self.blackbox_vendor.verify_signature(pub_key, sig_s, sig_e, message).map_err(|err| {
OpcodeResolutionError::BlackBoxFunctionFailed(
BlackBoxFunc::SchnorrVerify,
err.to_string(),
)
BlackBoxResolutionError::Failed(BlackBoxFunc::SchnorrVerify, err.to_string())
})
}

fn pedersen(
&self,
inputs: &[FieldElement],
domain_separator: u32,
) -> Result<(FieldElement, FieldElement), OpcodeResolutionError> {
self.blackbox_vendor.encrypt(inputs.to_vec(), domain_separator).map_err(|err| {
OpcodeResolutionError::BlackBoxFunctionFailed(BlackBoxFunc::Pedersen, err.to_string())
})
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> {
self.blackbox_vendor
.encrypt(inputs.to_vec(), domain_separator)
.map_err(|err| BlackBoxResolutionError::Failed(BlackBoxFunc::Pedersen, err.to_string()))
}

fn fixed_base_scalar_mul(
&self,
input: &FieldElement,
) -> Result<(FieldElement, FieldElement), OpcodeResolutionError> {
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> {
self.blackbox_vendor.fixed_base(input).map_err(|err| {
OpcodeResolutionError::BlackBoxFunctionFailed(
BlackBoxFunc::FixedBaseScalarMul,
err.to_string(),
)
BlackBoxResolutionError::Failed(BlackBoxFunc::FixedBaseScalarMul, err.to_string())
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/foreign_call/inputs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use acvm::acir::brillig_vm::Value;
use acvm::brillig_vm::brillig::Value;

use crate::js_witness_map::field_element_to_js_string;

Expand Down
2 changes: 1 addition & 1 deletion src/foreign_call/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use acvm::{acir::brillig_vm::ForeignCallResult, pwg::ForeignCallWaitInfo};
use acvm::{brillig_vm::brillig::ForeignCallResult, pwg::ForeignCallWaitInfo};

use js_sys::JsString;
use wasm_bindgen::{prelude::wasm_bindgen, JsValue};
Expand Down
2 changes: 1 addition & 1 deletion src/foreign_call/outputs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use acvm::acir::brillig_vm::{ForeignCallOutput, ForeignCallResult, Value};
use acvm::brillig_vm::brillig::{ForeignCallOutput, ForeignCallResult, Value};
use wasm_bindgen::JsValue;

use crate::js_witness_map::js_value_to_field_element;
Expand Down
20 changes: 9 additions & 11 deletions test/shared/complex_foreign_call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { WitnessMap } from "../../result/";
// foreign_call_results: vec![],
// bytecode: vec![
// // Oracles are named 'foreign calls' in brillig
// brillig_vm::Opcode::ForeignCall {
// brillig::Opcode::ForeignCall {
// function: "complex".into(),
// inputs: vec![
// RegisterOrMemory::HeapArray(HeapArray { pointer: 0.into(), size: 3 }),
Expand All @@ -74,16 +74,14 @@ import { WitnessMap } from "../../result/";
// };

export const bytecode = Uint8Array.from([
205, 146, 75, 10, 194, 64, 12, 134, 109, 235, 163, 199, 169, 55, 240, 1, 162,
91, 61, 65, 209, 48, 12, 196, 105, 25, 93, 212, 101, 110, 48, 51, 209, 35,
104, 17, 241, 14, 94, 195, 219, 72, 133, 110, 92, 184, 153, 89, 52, 171, 36,
36, 225, 231, 203, 127, 78, 45, 213, 51, 45, 17, 165, 184, 56, 186, 78, 181,
206, 79, 204, 198, 186, 247, 36, 243, 139, 113, 228, 125, 34, 11, 35, 36, 238,
138, 144, 196, 95, 8, 221, 54, 82, 9, 4, 54, 28, 226, 69, 33, 232, 118, 3, 12,
183, 230, 237, 15, 134, 13, 164, 125, 137, 48, 106, 147, 212, 88, 122, 44, 10,
13, 82, 168, 121, 142, 200, 245, 182, 104, 250, 21, 211, 125, 9, 121, 249,
221, 116, 189, 132, 158, 107, 16, 242, 112, 4, 189, 82, 59, 168, 162, 159, 58,
118, 255, 199, 95, 198, 124, 0,
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 83, 91, 10, 128, 32, 16, 28, 221, 30,
30, 199, 110, 208, 93, 162, 191, 162, 62, 59, 126, 138, 10, 171, 244, 17, 180,
66, 14, 44, 35, 227, 42, 195, 14, 107, 0, 40, 4, 12, 174, 116, 60, 123, 141,
144, 35, 245, 205, 145, 237, 55, 76, 74, 238, 47, 91, 203, 163, 110, 192, 35,
85, 240, 8, 150, 255, 15, 243, 150, 204, 69, 116, 126, 244, 176, 63, 157, 171,
30, 97, 191, 60, 198, 200, 134, 205, 90, 49, 45, 221, 47, 199, 126, 110, 235,
69, 69, 11, 143, 166, 212, 117, 193, 111, 222, 100, 184, 1, 94, 206, 212, 58,
16, 4, 0, 0,
]);
export const initialWitnessMap: WitnessMap = new Map([
[1, "0x0000000000000000000000000000000000000000000000000000000000000001"],
Expand Down
9 changes: 4 additions & 5 deletions test/shared/fixed_base_scalar_mul.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// let fixed_base_scalar_mul = Opcode::BlackBoxFuncCall(BlackBoxFuncCall::FixedBaseScalarMul {
// input: FunctionInput { witness: Witness(1), num_bits: FieldElement::max_num_bits() },
// outputs: vec![Witness(2), Witness(3)],
// outputs: (Witness(2), Witness(3)),
// });

// let circuit = Circuit {
Expand All @@ -10,10 +10,9 @@
// return_values: PublicInputs(BTreeSet::from_iter(vec![Witness(2), Witness(3)])),
// };
export const bytecode = Uint8Array.from([
1, 53, 0, 202, 255, 148, 4, 145, 129, 176, 66, 108, 97, 99, 107, 66, 111, 120,
70, 117, 110, 99, 67, 97, 108, 108, 129, 178, 70, 105, 120, 101, 100, 66, 97,
115, 101, 83, 99, 97, 108, 97, 114, 77, 117, 108, 146, 146, 1, 204, 254, 146,
2, 3, 144, 146, 2, 3,
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 77, 136, 81, 10, 0, 80, 4, 192, 246, 60,
95, 238, 127, 94, 33, 138, 213, 90, 77, 129, 71, 83, 181, 169, 167, 146, 126,
22, 57, 173, 31, 204, 136, 111, 48, 60, 0, 0, 0,
]);

export const initialWitnessMap = new Map([
Expand Down
31 changes: 13 additions & 18 deletions test/shared/foreign_call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { WitnessMap } from "../../result/";
// let w_x_plus_y = Witness(6);
// let w_equal_res = Witness(7);

// let equal_opcode = brillig_vm::Opcode::BinaryFieldOp {
// let equal_opcode = brillig::Opcode::BinaryFieldOp {
// op: BinaryFieldOp::Equals,
// lhs: RegisterIndex::from(0),
// rhs: RegisterIndex::from(1),
Expand Down Expand Up @@ -38,7 +38,7 @@ import { WitnessMap } from "../../result/";
// bytecode: vec![
// equal_opcode,
// // Oracles are named 'foreign calls' in brillig
// brillig_vm::Opcode::ForeignCall {
// brillig::Opcode::ForeignCall {
// function: "invert".into(),
// destinations: vec![RegisterOrMemory::RegisterIndex(RegisterIndex::from(1))],
// inputs: vec![RegisterOrMemory::RegisterIndex(RegisterIndex::from(0))],
Expand Down Expand Up @@ -74,22 +74,17 @@ import { WitnessMap } from "../../result/";
// };

export const bytecode = Uint8Array.from([
205, 145, 79, 78, 194, 64, 20, 198, 41, 180, 234, 113, 102, 58, 45, 157, 238,
20, 149, 132, 149, 137, 158, 160, 165, 143, 250, 146, 161, 226, 80, 137, 46,
231, 6, 195, 12, 92, 161, 70, 13, 119, 240, 26, 222, 198, 63, 145, 16, 216,
78, 23, 188, 213, 151, 183, 248, 37, 223, 247, 91, 157, 173, 213, 235, 64,
162, 16, 88, 174, 141, 106, 238, 176, 42, 5, 88, 109, 204, 215, 57, 113, 59,
234, 181, 192, 232, 58, 35, 200, 174, 148, 118, 135, 217, 95, 218, 116, 38,
224, 100, 27, 122, 219, 112, 170, 141, 218, 12, 176, 202, 228, 203, 16, 65,
20, 55, 179, 85, 183, 185, 126, 124, 202, 196, 188, 227, 169, 143, 225, 131,
4, 44, 171, 203, 76, 8, 219, 96, 181, 0, 89, 47, 213, 230, 22, 74, 156, 215,
32, 71, 85, 1, 207, 222, 225, 163, 243, 169, 222, 47, 36, 214, 247, 83, 168,
113, 108, 181, 61, 22, 43, 63, 12, 70, 250, 81, 4, 73, 8, 148, 209, 140, 132,
105, 206, 99, 18, 197, 121, 159, 83, 78, 99, 30, 23, 33, 103, 12, 120, 196,
147, 52, 79, 19, 146, 210, 136, 1, 157, 196, 41, 155, 252, 67, 252, 22, 204,
190, 93, 161, 132, 113, 141, 11, 80, 205, 232, 111, 82, 227, 7, 123, 147, 45,
173, 123, 91, 63, 208, 238, 117, 247, 69, 154, 22, 6, 236, 181, 32, 50, 112,
151, 160, 245, 55,
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 181, 147, 75, 10, 195, 48, 12, 68, 149,
111, 115, 28, 201, 159, 88, 222, 245, 42, 53, 117, 160, 155, 46, 74, 233, 249,
91, 168, 3, 34, 241, 46, 202, 128, 145, 25, 204, 195, 35, 161, 9, 0, 6, 248,
107, 252, 157, 22, 246, 90, 189, 107, 169, 120, 76, 212, 40, 178, 90, 61, 22,
86, 162, 171, 177, 59, 193, 28, 75, 93, 189, 75, 165, 215, 242, 222, 11, 175,
41, 117, 18, 156, 199, 243, 147, 95, 239, 166, 242, 74, 122, 85, 117, 186, 49,
79, 27, 173, 197, 217, 185, 28, 76, 38, 75, 55, 52, 49, 177, 71, 231, 211,
204, 196, 228, 217, 223, 13, 91, 155, 217, 113, 136, 41, 6, 140, 228, 108,
166, 197, 71, 187, 20, 88, 175, 247, 47, 148, 99, 25, 54, 141, 214, 202, 46,
217, 160, 216, 7, 129, 220, 173, 245, 81, 118, 167, 152, 127, 128, 243, 214,
250, 11, 123, 58, 90, 201, 243, 4, 0, 0,
]);
export const initialWitnessMap: WitnessMap = new Map([
[1, "0x0000000000000000000000000000000000000000000000000000000000000002"],
Expand Down
20 changes: 10 additions & 10 deletions test/shared/noir_program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { WitnessMap } from "../../result/web/acvm_js";
// x + y
// }
export const bytecode = Uint8Array.from([
205, 147, 189, 13, 194, 48, 16, 133, 69, 254, 88, 199, 23, 219, 201, 185, 3,
137, 134, 49, 72, 184, 8, 23, 80, 88, 86, 122, 111, 128, 99, 196, 8, 72, 176,
17, 219, 64, 65, 147, 218, 70, 202, 13, 240, 73, 223, 123, 247, 110, 235, 187,
123, 109, 141, 182, 167, 51, 89, 221, 135, 107, 152, 222, 27, 22, 119, 176,
250, 50, 56, 107, 132, 160, 182, 38, 224, 112, 96, 181, 234, 80, 50, 33, 187,
6, 1, 65, 162, 60, 214, 200, 57, 161, 192, 86, 117, 170, 101, 10, 4, 39, 24,
164, 226, 195, 15, 146, 37, 96, 228, 209, 42, 204, 61, 119, 218, 80, 111, 245,
72, 238, 177, 191, 140, 100, 236, 148, 23, 179, 200, 124, 136, 79, 44, 47,
124, 2, 223, 50, 129, 111, 114, 179, 210, 47, 164, 201, 217, 155, 47, 35, 110,
248, 207, 246, 98, 25, 41, 182, 87, 197, 55, 230, 51, 95, 125, 0,
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 205, 147, 65, 14, 195, 32, 12, 4, 73, 210,
164, 223, 177, 49, 14, 246, 173, 95, 41, 42, 249, 255, 19, 170, 86, 32, 161,
228, 136, 145, 178, 23, 251, 52, 242, 238, 202, 79, 231, 220, 230, 174, 90,
202, 124, 149, 9, 125, 194, 169, 97, 17, 236, 33, 228, 232, 51, 18, 190, 193,
107, 18, 134, 192, 105, 23, 20, 100, 225, 143, 23, 162, 44, 65, 162, 38, 141,
160, 24, 40, 227, 193, 74, 71, 129, 205, 134, 172, 197, 206, 227, 255, 174,
154, 221, 163, 236, 147, 113, 142, 149, 125, 230, 246, 230, 176, 26, 230, 48,
202, 247, 58, 192, 183, 101, 255, 174, 209, 141, 251, 193, 246, 206, 145, 127,
14, 125, 66, 203, 63, 223, 12, 123, 174, 221, 206, 77, 207, 63, 254, 23, 111,
38, 61, 74, 76, 5, 0, 0,
]);

export const initialWitnessMap: WitnessMap = new Map([
Expand Down
8 changes: 4 additions & 4 deletions test/shared/pedersen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// witness: Witness(1),
// num_bits: FieldElement::max_num_bits(),
// }],
// outputs: vec![Witness(2), Witness(3)],
// outputs: (Witness(2), Witness(3)),
// domain_separator: 0,
// });

Expand All @@ -14,9 +14,9 @@
// return_values: PublicInputs(BTreeSet::from_iter(vec![Witness(2), Witness(3)])),
// };
export const bytecode = Uint8Array.from([
1, 45, 0, 210, 255, 148, 4, 145, 129, 176, 66, 108, 97, 99, 107, 66, 111, 120,
70, 117, 110, 99, 67, 97, 108, 108, 129, 168, 80, 101, 100, 101, 114, 115,
101, 110, 147, 145, 146, 1, 204, 254, 0, 146, 2, 3, 144, 146, 2, 3,
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 93, 136, 129, 9, 0, 48, 8, 195, 50, 39,
254, 127, 177, 168, 40, 8, 6, 74, 219, 40, 240, 104, 170, 237, 124, 159, 45,
153, 207, 34, 199, 7, 17, 37, 243, 208, 72, 0, 0, 0,
]);

export const initialWitnessMap = new Map([
Expand Down
23 changes: 11 additions & 12 deletions test/shared/schnorr_verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@
// return_values: PublicInputs(BTreeSet::from_iter(vec![output])),
// };
export const bytecode = Uint8Array.from([
5, 128, 71, 74, 3, 1, 0, 0, 237, 142, 189, 247, 222, 123, 239, 61, 38, 26,
107, 78, 130, 247, 176, 42, 138, 75, 2, 11, 130, 30, 243, 3, 51, 232, 197, 63,
8, 62, 36, 79, 240, 45, 33, 124, 61, 228, 115, 127, 241, 48, 29, 188, 198,
179, 239, 201, 183, 76, 144, 72, 135, 97, 238, 247, 46, 120, 206, 100, 163,
232, 254, 49, 122, 121, 250, 248, 182, 188, 80, 180, 162, 80, 252, 47, 139,
89, 137, 85, 88, 141, 53, 88, 139, 96, 29, 214, 99, 3, 54, 98, 19, 54, 99, 11,
182, 98, 27, 182, 99, 7, 118, 98, 23, 118, 99, 15, 246, 98, 31, 246, 227, 0,
14, 226, 16, 14, 227, 8, 142, 226, 24, 142, 227, 4, 78, 226, 20, 78, 227, 12,
206, 226, 28, 206, 227, 2, 46, 226, 18, 46, 227, 10, 174, 226, 26, 174, 227,
6, 110, 226, 22, 110, 227, 14, 238, 226, 30, 238, 227, 1, 30, 226, 17, 30,
227, 9, 198, 240, 20, 227, 252, 152, 192, 51, 60, 199, 36, 94, 224, 37, 94,
225, 53, 222, 224, 45, 169, 207, 124, 170, 4,
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 77, 210, 85, 142, 66, 65, 16, 5, 208, 30,
97, 220, 221, 221, 221, 5, 119, 103, 23, 236, 127, 9, 132, 247, 194, 33, 112,
147, 155, 147, 238, 250, 172, 234, 134, 16, 38, 194, 32, 177, 9, 246, 162, 78,
50, 111, 62, 21, 117, 46, 234, 52, 19, 156, 225, 44, 135, 157, 231, 2, 23,
185, 196, 101, 174, 112, 149, 107, 92, 231, 6, 55, 185, 197, 109, 238, 112,
151, 123, 220, 231, 1, 15, 121, 196, 99, 158, 240, 148, 103, 60, 231, 5, 47,
121, 197, 107, 222, 240, 150, 119, 188, 231, 3, 31, 249, 196, 103, 190, 240,
149, 111, 124, 231, 7, 63, 249, 197, 111, 254, 240, 151, 127, 252, 103, 146,
41, 166, 153, 97, 150, 57, 230, 89, 96, 113, 108, 143, 113, 74, 222, 101, 86,
88, 101, 141, 117, 54, 216, 100, 139, 109, 118, 194, 40, 195, 91, 140, 255,
250, 206, 187, 136, 233, 156, 2, 0, 0,
]);

export const initialWitnessMap = new Map([
Expand Down
Loading

0 comments on commit 7f49911

Please sign in to comment.