Allows to perform simple algebraic operations over a finite field
value- number be represented asvalue % modulomodulo- An integer corresponding to the size of the modular space. For this to be a finite field it must be a prime number!
- addition
- subtraction
- multiplication
- division
- inversion
// Simple operations within a finite fielduse finitefields::{FF,Finitefield,primes};fnmain(){// Pick a primelet modulo = primes::PRIMES31[0];// Define numbers to be cast into our fieldlet num1:FF = 23742687;let num2:FF = 87129774;let fnum1 = Finitefield::new(num1, modulo).unwrap();let fnum2 = Finitefield::new(num2, modulo).unwrap();// Compute productlet product = fnum1 * fnum2;assert_eq!(product.value,174523906);// Compute the inverse of the productlet product_inv = product.inverse().unwrap();assert_eq!(product_inv.value,486606559);// Multiply by the productassert_eq!((product * product_inv).value,1);}