MCPcopy Create free account
hub / github.com/BitVM/BitVM / test_mul

Function test_mul

bitvm/src/bigint/mul.rs:49–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47
48 #[test]
49 fn test_mul() {
50 let mut prng = ChaCha20Rng::seed_from_u64(0);
51 for _ in 0..3 {
52 let a: BigUint = prng.sample(RandomBits::new(254));
53 let b: BigUint = prng.sample(RandomBits::new(254));
54 let c: BigUint = (a.clone().mul(b.clone())).rem(BigUint::one().shl(254));
55
56 let script = script! {
57 { U254::push_u32_le(&a.to_u32_digits()) }
58 { U254::push_u32_le(&b.to_u32_digits()) }
59 { U254::mul() }
60 { U254::push_u32_le(&c.to_u32_digits()) }
61 { U254::equalverify(1, 0) }
62 OP_TRUE
63 };
64 run(script);
65 }
66
67 for _ in 0..3 {
68 let a: BigUint = prng.sample(RandomBits::new(64));
69 let b: BigUint = prng.sample(RandomBits::new(64));
70 let c: BigUint = (a.clone().mul(b.clone())).rem(BigUint::one().shl(64));
71
72 let script = script! {
73 { U64::push_u32_le(&a.to_u32_digits()) }
74 { U64::push_u32_le(&b.to_u32_digits()) }
75 { U64::mul() }
76 { U64::push_u32_le(&c.to_u32_digits()) }
77 { U64::equalverify(1, 0) }
78 OP_TRUE
79 };
80 run(script);
81 }
82 }
83}

Callers

nothing calls this directly

Calls 3

runFunction · 0.85
mulMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected