message: added a few more tests for xor64
diff: @@ -5,6 +5,7 @@ use crate::circuits::{
  use ark_ec::AffineCurve;
  use mina_curves::pasta::{Fp, Pallas, Vesta};
  +use rand::Rng;
  type PallasField = <Pallas as AffineCurve>::BaseField;
  @@ -21,7 +22,8 @@ fn create_test_constraint_system() -> ConstraintSystem<Fp> {
  }
  #[test]
  -fn test_64bit_xor() {
  +// Test a XOR of 64bit whose output is all ones with alternating inputs
  +fn test_xor64_alternating() {
  let cs = create_test_constraint_system();
  let zero_ones: u64 = 6510615555426900570;
  @@ -46,3 +48,72 @@ fn test_64bit_xor() {
  assert_eq!(witness[2][4], PallasField::from(2u32.pow(16) - 1));
  assert_eq!(witness[2][5], PallasField::from(0));
  }
  +
  +#[test]
  +// Test a XOR of 64bit whose inputs are zero. Checks it works fine with non-dense values.
  +fn test_xor64_zeros() {
  + let cs = create_test_constraint_system();
  +
  + let zero: u64 = 0;
  + let witness = create(zero, zero);
  +
  + for row in 0..=5 {
  + assert_eq!(
  + cs.gates[row].verify_witness::<Vesta>(
  + row,
  + &witness,
  + &cs,
  + &witness[0][0..cs.public].to_vec()
  + ),
  + Ok(())
  + );
  + }
  + assert_eq!(witness[2][1], PallasField::from(zero));
  +}
  +
  +#[test]
  +// Test a XOR of 64bit whose inputs are all zero and all one. Checks it works fine with non-dense values.
  +fn test_xor64_zero_one() {
  + let cs = create_test_constraint_system();
  +
  + let zero: u64 = 0;
  + let all_ones: u64 = (2u128.pow(64) - 1) as u64;
  + let witness = create(zero, all_ones);
  +
  + for row in 0..=5 {
  + assert_eq!(
  + cs.gates[row].verify_witness::<Vesta>(
  + row,
  + &witness,
  + &cs,
  + &witness[0][0..cs.public].to_vec()
  + ),
  + Ok(())
  + );
  + }
  + assert_eq!(witness[2][1], PallasField::from(all_ones));
  +}
  +
  +#[test]
  +// Tests a XOR of 64 bits for a random input
  +fn test_xor64_random() {
  + let cs = create_test_constraint_system();
  +
  + let input1 = rand::thread_rng().gen_range(0..(2u128.pow(64) - 1)) as u64;
  + let input2 = rand::thread_rng().gen_range(0..(2u128.pow(64) - 1)) as u64;
  + let output = input1 ^ input2;
  + let witness = create(input1, input2);
  +
  + for row in 0..=5 {
  + assert_eq!(
  + cs.gates[row].verify_witness::<Vesta>(
  + row,
  + &witness,
  + &cs,
  + &witness[0][0..cs.public].to_vec()
  + ),
  + Ok(())
  + );
  + }
  + assert_eq!(witness[2][1], PallasField::from(output));
  +}
  