| 895 | |
| 896 | #[test] |
| 897 | fn test_double() { |
| 898 | println!("Fq.double: {} bytes", Fq::double(0).len()); |
| 899 | let m = BigUint::from_str_radix(Fq::MODULUS, 16).unwrap(); |
| 900 | |
| 901 | for _ in 0..100 { |
| 902 | let a: BigUint = m.clone().sub(BigUint::new(vec![1])); |
| 903 | |
| 904 | let a = a.rem(&m); |
| 905 | let c: BigUint = a.clone().add(a.clone()).rem(&m); |
| 906 | |
| 907 | let script = script! { |
| 908 | { Fq::push_u32_le(&a.to_u32_digits()) } |
| 909 | { Fq::double(0) } |
| 910 | { Fq::push_u32_le(&c.to_u32_digits()) } |
| 911 | { Fq::equalverify(1, 0) } |
| 912 | OP_TRUE |
| 913 | }; |
| 914 | run(script); |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | #[test] |
| 919 | fn test_neg() { |