1
0
mirror of synced 2025-01-21 21:20:28 +00:00

Save before attempt to change input reading

This commit is contained in:
thomaslavaur 2024-09-09 08:46:43 +02:00
parent c6f13496a5
commit 1682124af2
4 changed files with 26 additions and 9 deletions

View File

@ -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"] }
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" }

View File

@ -26,4 +26,9 @@ ark-ec = "0.4.0"
crypto-bigint = { version = "0.5.5", features = ["serde"] }
[features]
metal = ["risc0-zkvm/metal"]
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" }

View File

@ -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<UniversalParams<Bls12_381>> = 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

View File

@ -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);
}