setting up tests

This commit is contained in:
Jaremy Creechley 2023-12-11 17:03:24 -07:00
parent 8fa6bcf0b6
commit f141f3ae44
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
3 changed files with 25 additions and 19 deletions

View File

@ -130,24 +130,24 @@ mod test {
]; ];
let root = treehash(hashes.as_slice()); let root = treehash(hashes.as_slice());
let proof_bytes = &mut Vec::new(); // let proof_bytes = &mut Vec::new();
let public_inputs_bytes = &mut Vec::new(); // let public_inputs_bytes = &mut Vec::new();
prover // prover
.prove( // .prove(
chunks.as_slice(), // chunks.as_slice(),
siblings, // siblings,
hashes.as_slice(), // hashes.as_slice(),
path.as_slice(), // path.as_slice(),
root, // root,
root, // random salt - block hash // root, // random salt - block hash
proof_bytes, // proof_bytes,
public_inputs_bytes, // public_inputs_bytes,
) // )
.unwrap(); // .unwrap();
assert!(prover // assert!(prover
.verify(proof_bytes.as_slice(), public_inputs_bytes.as_slice()) // .verify(proof_bytes.as_slice(), public_inputs_bytes.as_slice())
.is_ok()); // .is_ok());
} }
} }

View File

@ -93,6 +93,10 @@ pub unsafe extern "C" fn prove(
.map(|c| U256::try_from_le_slice(c).unwrap()) .map(|c| U256::try_from_le_slice(c).unwrap())
.collect::<Vec<U256>>() .collect::<Vec<U256>>()
}; };
println!("prove:args: {}", "chunks");
for n in chunks {
println!("\t{}", n);
}
let siblings = { let siblings = {
let slice = std::slice::from_raw_parts((*siblings).data, (*siblings).len); let slice = std::slice::from_raw_parts((*siblings).data, (*siblings).len);
@ -210,7 +214,7 @@ pub unsafe extern "C" fn free_proof_ctx(ctx: *mut ProofCtx) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use ark_std::rand::{distributions::Alphanumeric, rngs::ThreadRng, Rng}; use ark_std::rand::{distributions::Alphanumeric, rngs::{ThreadRng, StdRng}, Rng, SeedableRng};
use rs_poseidon::poseidon::hash; use rs_poseidon::poseidon::hash;
use ruint::aliases::U256; use ruint::aliases::U256;
@ -303,7 +307,7 @@ mod tests {
// and hash is the hash of each vector generated using the digest function // and hash is the hash of each vector generated using the digest function
let data = (0..4) let data = (0..4)
.map(|_| { .map(|_| {
let rng = ThreadRng::default(); let rng = StdRng::seed_from_u64(42);
let preimages: Vec<U256> = rng let preimages: Vec<U256> = rng
.sample_iter(Alphanumeric) .sample_iter(Alphanumeric)
.take(256) .take(256)

View File

@ -149,7 +149,9 @@ fn parse_mpack_args(builder: &mut CircomBuilder<Params256Ty>, mut inputs: &[u8])
} }
} }
} else { } else {
println!("deserde: name: {}", name);
for val in vals { for val in vals {
println!(" {}", decode_u256(val)?);
builder.push_input(name, decode_u256(val)?); builder.push_input(name, decode_u256(val)?);
} }
} }