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.

26 lines
833 B

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