INNER CODE UNIT · Rust

fuzz_modulo_invert

ZenGo-X/curv · src/arithmetic/mod.rs:294

        fn fuzz_modulo_invert(a in 0..(u32::MAX - 4)) {
            modulo_invert(a, u32::MAX - 4)
        }
    }

    fn modulo_invert(a: u32, m: u32) {
        let (a, m) = (BigInt::from(a), BigInt::from(m));
        let inv = BigInt::mod_inv(&a, &m).unwrap();
        assert!(BigInt::zero() <= inv && inv < m);
        let one = BigInt::mod_mul(&a, &inv, &m);
        assert_eq!(one, BigInt::one());
    }

    #[test]
    #[should_panic]
    fn mod_pow_panics_if_exp_is_negative() {
        BigInt::mod_pow(&BigInt::from(3), &(-BigInt::one()), &BigInt::from(7));
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…