You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
859 B

  1. use ark_r1cs_std::{
  2. alloc::AllocVar, fields::nonnative::NonNativeFieldVar, R1CSVar, ToConstraintFieldGadget,
  3. };
  4. use ark_relations::r1cs::ConstraintSystem;
  5. #[test]
  6. fn to_constraint_field_test() {
  7. type F = ark_bls12_377::Fr;
  8. type CF = ark_bls12_377::Fq;
  9. let cs = ConstraintSystem::<CF>::new_ref();
  10. let a = NonNativeFieldVar::Constant(F::from(12u8));
  11. let b = NonNativeFieldVar::new_input(cs.clone(), || Ok(F::from(6u8))).unwrap();
  12. let b2 = &b + &b;
  13. let a_to_constraint_field = a.to_constraint_field().unwrap();
  14. let b2_to_constraint_field = b2.to_constraint_field().unwrap();
  15. assert_eq!(a_to_constraint_field.len(), b2_to_constraint_field.len());
  16. for (left, right) in a_to_constraint_field
  17. .iter()
  18. .zip(b2_to_constraint_field.iter())
  19. {
  20. assert_eq!(left.value(), right.value());
  21. }
  22. }