| 227 | |
| 228 | #[test] |
| 229 | fn test_div2() { |
| 230 | println!("U254.div2: {} bytes", U254::div2().len()); |
| 231 | let mut prng = ChaCha20Rng::seed_from_u64(0); |
| 232 | for _ in 0..100 { |
| 233 | let a: BigUint = prng.sample(RandomBits::new(254)); |
| 234 | let c: BigUint = a.clone().shr(1); |
| 235 | |
| 236 | let script = script! { |
| 237 | { U254::push_u32_le(&a.to_u32_digits()) } |
| 238 | { U254::div2() } |
| 239 | { U254::push_u32_le(&c.to_u32_digits()) } |
| 240 | { U254::equalverify(1, 0) } |
| 241 | OP_TRUE |
| 242 | }; |
| 243 | run(script); |
| 244 | } |
| 245 | |
| 246 | for _ in 0..100 { |
| 247 | let a: BigUint = prng.sample(RandomBits::new(64)); |
| 248 | let c: BigUint = a.clone().shr(1); |
| 249 | |
| 250 | let script = script! { |
| 251 | { U64::push_u32_le(&a.to_u32_digits()) } |
| 252 | { U64::div2() } |
| 253 | { U64::push_u32_le(&c.to_u32_digits()) } |
| 254 | { U64::equalverify(1, 0) } |
| 255 | OP_TRUE |
| 256 | }; |
| 257 | run(script); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | #[test] |
| 262 | fn test_div3() { |