| 113 | |
| 114 | #[test] |
| 115 | fn test_double() { |
| 116 | println!("Fr.double: {} bytes", Fr::double(0).len()); |
| 117 | let m = BigUint::from_str_radix(Fr::MODULUS, 16).unwrap(); |
| 118 | |
| 119 | for _ in 0..100 { |
| 120 | let a: BigUint = m.clone().sub(BigUint::new(vec![1])); |
| 121 | |
| 122 | let a = a.rem(&m); |
| 123 | let c: BigUint = a.clone().add(a.clone()).rem(&m); |
| 124 | |
| 125 | let script = script! { |
| 126 | { Fr::push_u32_le(&a.to_u32_digits()) } |
| 127 | { Fr::double(0) } |
| 128 | { Fr::push_u32_le(&c.to_u32_digits()) } |
| 129 | { Fr::equalverify(1, 0) } |
| 130 | OP_TRUE |
| 131 | }; |
| 132 | run(script); |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | #[test] |
| 137 | fn test_neg() { |