diff --git a/proof_of_equivalence/proof_statements/Cargo.toml b/proof_of_equivalence/proof_statements/Cargo.toml index 79f65709..0be12e86 100644 --- a/proof_of_equivalence/proof_statements/Cargo.toml +++ b/proof_of_equivalence/proof_statements/Cargo.toml @@ -6,4 +6,8 @@ edition = "2021" [dependencies] cl = { path = "../../cl/cl" } serde = { version = "1.0", features = ["derive"] } -crypto-bigint = { version = "0.5.5", features = ["serde"] } \ No newline at end of file +crypto-bigint = { version = "0.5.5", features = ["serde"] } + +[patch.crates-io] +# add RISC Zero accelerator support for all downstream usages of the following crates. +crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.5-risczero.0" } \ No newline at end of file diff --git a/proof_of_equivalence/risc0/prover/Cargo.toml b/proof_of_equivalence/risc0/prover/Cargo.toml index 8a551267..2f86c548 100644 --- a/proof_of_equivalence/risc0/prover/Cargo.toml +++ b/proof_of_equivalence/risc0/prover/Cargo.toml @@ -26,4 +26,9 @@ ark-ec = "0.4.0" crypto-bigint = { version = "0.5.5", features = ["serde"] } [features] -metal = ["risc0-zkvm/metal"] \ No newline at end of file +metal = ["risc0-zkvm/metal"] + +[patch.crates-io] +# add RISC Zero accelerator support for all downstream usages of the following crates. +sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" } +crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.5-risczero.0" } \ No newline at end of file diff --git a/proof_of_equivalence/risc0/prover/src/lib.rs b/proof_of_equivalence/risc0/prover/src/lib.rs index 2136bee4..ebc2b541 100644 --- a/proof_of_equivalence/risc0/prover/src/lib.rs +++ b/proof_of_equivalence/risc0/prover/src/lib.rs @@ -53,7 +53,7 @@ mod test { use ark_ec::pairing::Pairing; use crypto_bigint::{U256}; - const BLOB_SIZE: usize = 32; + const BLOB_SIZE: usize = 2048; static GLOBAL_PARAMETERS: Lazy> = Lazy::new(|| { let mut rng = rand::thread_rng(); @@ -85,6 +85,9 @@ mod test { //recover x_0 let mut hasher = Sha256::new(); hasher.update(da_commitment.clone()); + for i in 0..BLOB_SIZE { + hasher.update(coefficients[i]); + } let x_0 = Fr::from_be_bytes_mod_order(&hasher.finalize()); let y_0 = bls_polynomial.evaluate(&x_0); // EVAL OF x0 diff --git a/proof_of_equivalence/risc0/risc0_proofs/proof_of_equivalence/src/main.rs b/proof_of_equivalence/risc0/risc0_proofs/proof_of_equivalence/src/main.rs index 07419377..60f84b17 100644 --- a/proof_of_equivalence/risc0/risc0_proofs/proof_of_equivalence/src/main.rs +++ b/proof_of_equivalence/risc0/risc0_proofs/proof_of_equivalence/src/main.rs @@ -2,9 +2,9 @@ use equivalence_proof_statements::{EquivalencePrivate, EquivalencePublic}; use risc0_zkvm::guest::env; use sha2::{Digest, Sha256}; -use crypto_bigint::{U256, impl_modulus, const_residue, modular::constant_mod::ResidueParams}; +use crypto_bigint::{U256, impl_modulus, const_residue, modular::constant_mod::ResidueParams, Encoding}; -const BLOB_SIZE: usize = 32; +const BLOB_SIZE: usize = 2048; impl_modulus!( Fr, @@ -19,7 +19,7 @@ fn mul_mod(a: U256, b: U256) -> U256 { } fn main() { - let start = env::cycle_count(); + let start_start = env::cycle_count(); let public_inputs: EquivalencePublic = env::read(); let EquivalencePrivate { @@ -27,7 +27,7 @@ fn main() { } = env::read(); let private_inputs = EquivalencePrivate { coefficients }; let end = env::cycle_count(); - eprintln!("inputs load: {}", end - start); + eprintln!("inputs load: {}", end - start_start); let start = env::cycle_count(); // BLS scalar field modulus @@ -39,6 +39,9 @@ fn main() { let start = env::cycle_count(); let mut hasher = Sha256::new(); hasher.update(public_inputs.da_commitment.clone()); + for i in 0..BLOB_SIZE { + hasher.update(private_inputs.coefficients[i].to_be_bytes()); + } let x_0 : [u8; 32] = hasher.finalize().into(); let end = env::cycle_count(); eprintln!("draw random point: {}", end - start); @@ -67,7 +70,9 @@ fn main() { let start = env::cycle_count(); env::commit(&public_inputs); - let end = env::cycle_count(); - eprintln!("public input: {}", end - start); + let end_end = env::cycle_count(); + eprintln!("public input: {}", end_end - start); + + eprintln!("total: {}", end_end - start_start); }