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.

24 lines
852 B

  1. use ark_r1cs_std::alloc::AllocVar;
  2. use ark_r1cs_std::fields::nonnative::{NonNativeFieldMulResultVar, NonNativeFieldVar};
  3. use ark_r1cs_std::R1CSVar;
  4. use ark_relations::r1cs::ConstraintSystem;
  5. use ark_std::UniformRand;
  6. #[test]
  7. fn from_test() {
  8. type F = ark_bls12_377::Fr;
  9. type CF = ark_bls12_377::Fq;
  10. let mut rng = ark_std::test_rng();
  11. let cs = ConstraintSystem::<CF>::new_ref();
  12. let f = F::rand(&mut rng);
  13. let f_var = NonNativeFieldVar::<F, CF>::new_input(cs.clone(), || Ok(f)).unwrap();
  14. let f_var_converted = NonNativeFieldMulResultVar::<F, CF>::from(&f_var);
  15. let f_var_converted_reduced = f_var_converted.reduce().unwrap();
  16. let f_var_value = f_var.value().unwrap();
  17. let f_var_converted_reduced_value = f_var_converted_reduced.value().unwrap();
  18. assert_eq!(f_var_value, f_var_converted_reduced_value);
  19. }