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 proof_bytes = &mut Vec::new();
let public_inputs_bytes = &mut Vec::new();
// let proof_bytes = &mut Vec::new();
// let public_inputs_bytes = &mut Vec::new();
prover
.prove(
chunks.as_slice(),
siblings,
hashes.as_slice(),
path.as_slice(),
root,
root, // random salt - block hash
proof_bytes,
public_inputs_bytes,
)
.unwrap();
// prover
// .prove(
// chunks.as_slice(),
// siblings,
// hashes.as_slice(),
// path.as_slice(),
// root,
// root, // random salt - block hash
// proof_bytes,
// public_inputs_bytes,
// )
// .unwrap();
assert!(prover
.verify(proof_bytes.as_slice(), public_inputs_bytes.as_slice())
.is_ok());
// assert!(prover
// .verify(proof_bytes.as_slice(), public_inputs_bytes.as_slice())
// .is_ok());
}
}

View File

@ -93,6 +93,10 @@ pub unsafe extern "C" fn prove(
.map(|c| U256::try_from_le_slice(c).unwrap())
.collect::<Vec<U256>>()
};
println!("prove:args: {}", "chunks");
for n in chunks {
println!("\t{}", n);
}
let siblings = {
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)]
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 ruint::aliases::U256;
@ -303,7 +307,7 @@ mod tests {
// and hash is the hash of each vector generated using the digest function
let data = (0..4)
.map(|_| {
let rng = ThreadRng::default();
let rng = StdRng::seed_from_u64(42);
let preimages: Vec<U256> = rng
.sample_iter(Alphanumeric)
.take(256)

View File

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