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

Function test_add

bitvm/src/bn254/fq.rs:841–866  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

839
840 #[test]
841 fn test_add() {
842 println!("Fq.add: {} bytes", Fq::add(0, 1).len());
843
844 let m = BigUint::from_str_radix(Fq::MODULUS, 16).unwrap();
845
846 let mut prng = ChaCha20Rng::seed_from_u64(0);
847
848 for _ in 0..100 {
849 let a: BigUint = prng.sample(RandomBits::new(254));
850 let b: BigUint = prng.sample(RandomBits::new(254));
851
852 let a = a.rem(&m);
853 let b = b.rem(&m);
854 let c: BigUint = a.clone().add(b.clone()).rem(&m);
855
856 let script = script! {
857 { Fq::push_u32_le(&a.to_u32_digits()) }
858 { Fq::push_u32_le(&b.to_u32_digits()) }
859 { Fq::add(1, 0) }
860 { Fq::push_u32_le(&c.to_u32_digits()) }
861 { Fq::equalverify(1, 0) }
862 OP_TRUE
863 };
864 run(script);
865 }
866 }
867
868 #[test]
869 fn test_sub() {

Callers

nothing calls this directly

Calls 3

runFunction · 0.85
cloneMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected