finitefields 0.1.1

Perform algebraic operations between integers over a finite field
Documentation
  • Coverage
  • 44.44%
    8 out of 18 items documented1 out of 10 items with examples
  • Size
  • Source code size: 91.35 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.18 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • apelloni/finitefields
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • apelloni

finitefields

crates.io documentation Build Status Byy Me A Coffee

Allows to perform simple algebraic operations over a finite field

Arguments

  • value - number be represented as value % modulo
  • modulo - An integer corresponding to the size of the modular space. For this to be a finite field it must be a prime number!

Operations

  • addition
  • subtraction
  • multiplication
  • division
  • inversion

Examples

// Simple operations within a finite field

use finitefields::{FF,Finitefield,primes};

fn main(){
    // Pick a prime
    let modulo = primes::PRIMES31[0];
    // Define numbers to be cast into our field
    let num1: FF = 23742687;
    let num2: FF = 87129774;

    let fnum1 = Finitefield::new(num1, modulo).unwrap();
    let fnum2 = Finitefield::new(num2, modulo).unwrap();

    // Compute product
    let product = fnum1 * fnum2;
    assert_eq!(product.value, 174523906);

    // Compute the inverse of the product
    let product_inv = product.inverse().unwrap();
    assert_eq!(product_inv.value, 486606559);

    // Multiply by the product
    assert_eq!((product * product_inv).value, 1);
}