Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 47 additions & 4 deletions Cargo.lock

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

57 changes: 53 additions & 4 deletions barretenberg_static_lib/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 barretenberg_static_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]

common = { path = "../common" }
barretenberg_wrapper = { git = "https://github.com/noir-lang/aztec-connect", rev = "f12f3e6b838330ea8094284f7a3c0fcc346d46fe" }
barretenberg_wrapper = { git = "https://github.com/noir-lang/aztec-connect", rev = "d79bbda6ec1fae6650256479a5f044843912ae2c" }

sha2 = "0.9.3"
blake2 = "0.9.1"
Expand Down
4 changes: 3 additions & 1 deletion barretenberg_static_lib/src/acvm_interop/proof_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ impl ProofSystemCompiler for Plonk {
fn get_exact_circuit_size(&self, circuit: Circuit) -> u32 {
let constraint_system = serialise_circuit(&circuit);

let circuit_size = StandardComposer::get_exact_circuit_size(&constraint_system);
let mut composer = StandardComposer::new(constraint_system);

let circuit_size = composer.get_exact_circuit_size();

circuit_size
}
Expand Down
4 changes: 2 additions & 2 deletions barretenberg_static_lib/src/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ impl StandardComposer {
}
}

pub fn get_exact_circuit_size(constraint_system: &ConstraintSystem) -> u32 {
pub fn get_exact_circuit_size(&self) -> u32 {
unsafe {
barretenberg_wrapper::composer::get_exact_circuit_size(
constraint_system.to_bytes().as_slice().as_ptr(),
self.constraint_system.to_bytes().as_slice().as_ptr(),
)
}
}
Expand Down
10 changes: 10 additions & 0 deletions barretenberg_wasm/src/acvm_interop/proof_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ impl ProofSystemCompiler for Plonk {
fn np_language(&self) -> Language {
Language::PLONKCSat { width: 3 }
}

fn get_exact_circuit_size(&self, circuit: Circuit) -> u32 {
let constraint_system = serialise_circuit(&circuit);

let mut composer = StandardComposer::new(constraint_system);

let circuit_size = composer.get_exact_circuit_size();

circuit_size
}
}
Binary file modified barretenberg_wasm/src/barretenberg.wasm
Binary file not shown.
25 changes: 25 additions & 0 deletions barretenberg_wasm/src/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,31 @@ impl StandardComposer {
}
}

pub fn get_exact_circuit_size(&mut self) -> u32 {
let cs_buf = self.constraint_system.to_bytes();
let cs_ptr = self.barretenberg.allocate(&cs_buf);

let func = self
.barretenberg
.instance
.exports
.get_function("standard_example__get_exact_circuit_size")
.unwrap();

let params: Vec<_> = vec![cs_ptr.clone()];
match func.call(&params) {
Ok(vals) => {
let i32_bytes = vals.first().cloned().unwrap().unwrap_i32().to_be_bytes();
let u32_val = u32::from_be_bytes(i32_bytes);
self.barretenberg.free(cs_ptr);
u32_val
}
Err(_) => {
unreachable!("failed on standard_example__get_exact_circuit_size call");
}
}
}

pub fn create_proof(&mut self, witness: WitnessAssignments) -> Vec<u8> {
let now = std::time::Instant::now();

Expand Down
17 changes: 17 additions & 0 deletions barretenberg_wasm/src/pedersen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,20 @@ impl Barretenberg {
(point_x, point_y)
}
}

#[test]
fn pedersen_hash_to_point() {
let mut barretenberg = Barretenberg::new();
let (x, y) = barretenberg.encrypt(vec![FieldElement::zero(), FieldElement::one()]);
let expected_x = FieldElement::from_hex(
"0x229fb88be21cec523e9223a21324f2e305aea8bff9cdbcb3d0c6bba384666ea1",
)
.unwrap();
let expected_y = FieldElement::from_hex(
"0x296b4b4605e586a91caa3202baad557628a8c56d0a1d6dff1a7ca35aed3029d5",
)
.unwrap();

assert_eq!(expected_x.to_hex(), x.to_hex());
assert_eq!(expected_y.to_hex(), y.to_hex());
}
2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
acvm = { git = "https://github.com/noir-lang/noir", rev = "cc5ee63072e09779bebd7e7dd054ae16be307d7f", features = [
acvm = { git = "https://github.com/noir-lang/noir", rev = "7460dda929130589bccfd6619f9409834b72a135", features = [
"bn254",
] }

Expand Down