-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Switch to new pedersen implementation (#3151)
Co-authored-by: vezenovm <mvezenov@gmail.com>
- Loading branch information
1 parent
a2c8ebd
commit 35fb3f7
Showing
21 changed files
with
232 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,14 @@ | ||
use std::{ | ||
fs::File, | ||
io::{Cursor, Read}, | ||
path::{Path, PathBuf}, | ||
}; | ||
use std::path::PathBuf; | ||
|
||
const BARRETENBERG_ARCHIVE: &str = "BARRETENBERG_ARCHIVE"; | ||
const BARRETENBERG_BIN_DIR: &str = "BARRETENBERG_BIN_DIR"; | ||
|
||
const BARRETENBERG_ARCHIVE_FALLBACK: &str = "https://github.com/AztecProtocol/barretenberg/releases/download/barretenberg-v0.5.0/acvm_backend.wasm.tar.gz"; | ||
// const ARCHIVE_SHA256: &str = "1xpycikqlvsjcryi3hkbc4mwmmdz7zshw6f76vyf1qssq53asyfx"; | ||
|
||
fn unpack_wasm(archive_path: &Path, target_dir: &Path) -> Result<(), String> { | ||
if archive_path.exists() && archive_path.is_file() { | ||
let archive = File::open(archive_path).map_err(|_| "Could not read archive")?; | ||
unpack_archive(archive, target_dir); | ||
|
||
Ok(()) | ||
} else { | ||
Err(format!("Unable to locate {BARRETENBERG_ARCHIVE} - Please set the BARRETENBERG_BIN_DIR env var to the directory where it exists, or ensure it's located at {}", archive_path.display())) | ||
} | ||
} | ||
|
||
fn unpack_archive<T: Read>(archive: T, target_dir: &Path) { | ||
use flate2::read::GzDecoder; | ||
use tar::Archive; | ||
|
||
let gz_decoder = GzDecoder::new(archive); | ||
let mut archive = Archive::new(gz_decoder); | ||
|
||
archive.unpack(target_dir).unwrap(); | ||
} | ||
|
||
/// Try to download the specified URL into a buffer which is returned. | ||
fn download_binary_from_url(url: &str) -> Result<Cursor<Vec<u8>>, String> { | ||
let response = reqwest::blocking::get(url).map_err(|error| error.to_string())?; | ||
|
||
let bytes = response.bytes().unwrap(); | ||
Ok(Cursor::new(bytes.to_vec())) | ||
} | ||
|
||
fn main() -> Result<(), String> { | ||
let out_dir = std::env::var("OUT_DIR").unwrap(); | ||
|
||
match std::env::var(BARRETENBERG_ARCHIVE) { | ||
Ok(archive_path) => { | ||
unpack_wasm(&PathBuf::from(archive_path), &PathBuf::from(&out_dir))?; | ||
println!("cargo:rustc-env={BARRETENBERG_BIN_DIR}={out_dir}"); | ||
Ok(()) | ||
} | ||
Err(_) => { | ||
let wasm_bytes = download_binary_from_url(BARRETENBERG_ARCHIVE_FALLBACK) | ||
.expect("download should succeed"); | ||
let dest_path = PathBuf::from(out_dir.clone()).join("acvm_backend.wasm"); | ||
|
||
unpack_archive(wasm_bytes, &PathBuf::from(&out_dir)); | ||
println!("cargo:rustc-env={BARRETENBERG_BIN_DIR}={out_dir}"); | ||
println!("cargo:rustc-env={BARRETENBERG_BIN_DIR}={out_dir}"); | ||
std::fs::copy("./src/acvm_backend.wasm", dest_path).unwrap(); | ||
|
||
Ok(()) | ||
} | ||
} | ||
Ok(()) | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2 Bytes
(100%)
tooling/nargo_cli/tests/acir_artifacts/brillig_pedersen/target/witness.gz
Binary file not shown.
Binary file modified
BIN
-3 Bytes
(99%)
tooling/nargo_cli/tests/acir_artifacts/brillig_schnorr/target/witness.gz
Binary file not shown.
Binary file modified
BIN
+30 Bytes
(100%)
tooling/nargo_cli/tests/acir_artifacts/double_verify_proof/target/witness.gz
Binary file not shown.
Binary file modified
BIN
-19 Bytes
(100%)
tooling/nargo_cli/tests/acir_artifacts/merkle_insert/target/witness.gz
Binary file not shown.
Binary file modified
BIN
+2 Bytes
(100%)
tooling/nargo_cli/tests/acir_artifacts/pedersen_check/target/witness.gz
Binary file not shown.
Binary file modified
BIN
-3 Bytes
(100%)
tooling/nargo_cli/tests/acir_artifacts/schnorr/target/witness.gz
Binary file not shown.
Binary file modified
BIN
-4 Bytes
(100%)
tooling/nargo_cli/tests/acir_artifacts/simple_shield/target/witness.gz
Binary file not shown.
Binary file modified
BIN
+1 Byte
(100%)
tooling/nargo_cli/tests/acir_artifacts/strings/target/witness.gz
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 68 additions & 8 deletions
76
tooling/nargo_cli/tests/execution_success/brillig_schnorr/Prover.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,70 @@ | ||
message = [0,1,2,3,4,5,6,7,8,9] | ||
message = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | ||
message_field = "0x010203040506070809" | ||
pub_key_x = "0x17cbd3ed3151ccfd170efe1d54280a6a4822640bf5c369908ad74ea21518a9c5" | ||
pub_key_y = "0x0e0456e3795c1a31f20035b741cd6158929eeccd320d299cfcac962865a6bc74" | ||
pub_key_x = "0x04b260954662e97f00cab9adb773a259097f7a274b83b113532bce27fa3fb96a" | ||
pub_key_y = "0x2fd51571db6c08666b0edfbfbc57d432068bccd0110a39b166ab243da0037197" | ||
signature = [ | ||
5, 202, 31, 146, 81, 242, 246, 69, 43, 107, 249, 153, 198, 44, 14, 111, 191, 121, 137, 166, | ||
160, 103, 18, 181, 243, 233, 226, 95, 67, 16, 37, 128, 85, 76, 19, 253, 30, 77, 192, 53, 138, | ||
205, 69, 33, 236, 163, 83, 194, 84, 137, 184, 221, 176, 121, 179, 27, 63, 70, 54, 16, 176, | ||
250, 39, 239, | ||
] | ||
1, | ||
13, | ||
119, | ||
112, | ||
212, | ||
39, | ||
233, | ||
41, | ||
84, | ||
235, | ||
255, | ||
93, | ||
245, | ||
172, | ||
186, | ||
83, | ||
157, | ||
253, | ||
76, | ||
77, | ||
33, | ||
128, | ||
178, | ||
15, | ||
214, | ||
67, | ||
105, | ||
107, | ||
177, | ||
234, | ||
77, | ||
48, | ||
27, | ||
237, | ||
155, | ||
84, | ||
39, | ||
84, | ||
247, | ||
27, | ||
22, | ||
8, | ||
176, | ||
230, | ||
24, | ||
115, | ||
145, | ||
220, | ||
254, | ||
122, | ||
135, | ||
179, | ||
171, | ||
4, | ||
214, | ||
202, | ||
64, | ||
199, | ||
19, | ||
84, | ||
239, | ||
138, | ||
124, | ||
12, | ||
] |
Oops, something went wrong.