1 unstable release
0.1.0 | Jul 19, 2020 |
---|
#16 in #galois-field
8KB
136 lines
Derive macro for Galois Field
Quick Start
use macro_galois_field::Field;
#[derive(Field, Debug, Default, Copy, Clone)]
#[prime = 2]
struct Fp2(u64);
let a = Fp2(3);
let b = Fp2(3);
assert_eq!(a + b, Fp2(0), "{} + {}", a.0, b.0);
assert_eq!(a - b, Fp2(0), "{} - {}", a.0, b.0);
assert_eq!(a - b, Fp2(2), "{} - {}", a.0, b.0);
assert_eq!(a * b, Fp2(1), "{} * {}", a.0, b.0);
assert_eq!(a * b, Fp2(3), "{} * {}", a.0, b.0);
assert_eq!(a / b, Fp2(1), "{} / {}", a.0, b.0);
let a = Fp2(3);
let b = Fp2(100);
assert_eq!(a + b, Fp2(1), "{} + {}", a.0, b.0);
assert_eq!(a - b, Fp2(1), "{} - {}", a.0, b.0);
Dependencies
~2MB
~48K SLoC