cleanups, supress warnings

This commit is contained in:
kilic 2020-05-01 15:54:39 +03:00
parent 4f8dae2707
commit f35bdfe228
3 changed files with 10 additions and 16 deletions

View File

@ -242,11 +242,7 @@ where
Ok(())
}
fn mul_mds_matrix<CS: ConstraintSystem<E>>(
&mut self,
mut cs: CS,
ctx: &mut RoundCtx<E>,
) -> Result<(), SynthesisError> {
fn mul_mds_matrix<CS: ConstraintSystem<E>>(&mut self, ctx: &mut RoundCtx<E>) -> Result<(), SynthesisError> {
assert_eq!(ctx.width(), self.elements.len());
if !ctx.is_last_round() {
@ -328,7 +324,7 @@ where
_ => {
let round_number = ctx.round_number();
state.sbox(cs.namespace(|| format!("sbox {}", round_number)), &mut ctx)?;
state.mul_mds_matrix(cs.namespace(|| format!("mds {}", round_number)), &mut ctx)?;
state.mul_mds_matrix::<CS>(&mut ctx)?;
}
}
}
@ -356,7 +352,7 @@ fn test_poseidon_circuit() {
})
.collect();
let mut circuit = PoseidonCircuit::<Bn256>::new(params.clone());
let circuit = PoseidonCircuit::<Bn256>::new(params.clone());
let res_allocated = circuit.alloc(cs.namespace(|| "hash alloc"), allocated_inputs).unwrap();
let result = res_allocated.get_value().unwrap();
let mut poseidon = PoseidonHasher::new(params.clone());

View File

@ -320,17 +320,14 @@ mod test {
circuit.synthesize(&mut cs).unwrap();
let unsatisfied = cs.which_is_unsatisfied();
if unsatisfied.is_some() {
println!("unsatisfied\n{}", unsatisfied.unwrap());
// panic!("unsatisfied\n{}", unsatisfied.unwrap());
panic!("unsatisfied\n{}", unsatisfied.unwrap());
}
let unconstrained = cs.find_unconstrained();
if !unconstrained.is_empty() {
// panic!("unconstrained\n{}", unconstrained);
println!("unconstrained\n{}", unconstrained);
panic!("unconstrained\n{}", unconstrained);
}
// assert!(cs.is_satisfied());
println!("{}", cs.is_satisfied());
println!("number of constaints {}", cs.num_constraints());
assert!(cs.is_satisfied());
println!("number of constaints: {}", cs.num_constraints());
}
{
@ -352,9 +349,11 @@ mod test {
key_size += parameters.b_g1.len() * point_size;
key_size += parameters.b_g2.len() * point_size * 2;
println!("prover key size in bytes: {}", key_size);
let now = Instant::now();
let proof = create_random_proof(circuit, &parameters, &mut rng).unwrap();
println!("prover time {}", now.elapsed().as_millis() as f64 / 1000.0);
println!("prover time: {}", now.elapsed().as_millis() as f64 / 1000.0);
let verifing_key = prepare_verifying_key(&parameters.vk);
assert!(verify_proof(&verifing_key, &proof, &inputs.public_inputs()).unwrap());

View File

@ -240,6 +240,5 @@ fn test_poseidon_hash() {
let r1: Fr = hasher.hash(input1.to_vec());
let input2: Vec<Fr> = ["0", "0"].iter().map(|e| Fr::from_str(e).unwrap()).collect();
let r2: Fr = hasher.hash(input2.to_vec());
println!("{}", r2);
assert_eq!(r1, r2, "just to see if internal state resets");
}