diff --git a/src/math/ecc.rs b/src/math/ecc.rs index 02d0062..f10f703 100644 --- a/src/math/ecc.rs +++ b/src/math/ecc.rs @@ -1,7 +1,8 @@ #![allow(dead_code)] /// eliptic curve cryptography /// -/// This module implements structs and functionalities used for ECC. +/// This module implements structs and functionalities used for eliptic curve cryptography (ECC). +/// Do not expect it to actually be secure, I made this for cryptography lectures. /// /// Author: Christoph J. Scherr /// License: MIT diff --git a/src/math/gallois.rs b/src/math/gallois.rs index 1226de1..a46ea70 100644 --- a/src/math/gallois.rs +++ b/src/math/gallois.rs @@ -18,7 +18,6 @@ use crate::{math::modexp, cplex::printing::seperator}; use core::fmt; -use std::{fmt::Debug, ops::{AddAssign, Add}}; use num::Integer; @@ -394,7 +393,7 @@ impl GalloisField { /// get multiplicative inverse pub fn py_inverse(&self, n: u128) -> PyResult { match self.inverse(n) { - Ok(v) => Ok(v), + Ok(v) => {return Ok(v)}, Err(e) => { let py_e = PyValueError::new_err(e.to_string()); return Err(py_e) @@ -424,6 +423,11 @@ fn test_gallois_inverse() { assert_eq!(field.inverse(54).unwrap(), 20); assert!(field.inverse(0).is_err()); + let field = GalloisField::new(23, true); + assert_eq!(field.inverse(17).unwrap(), 19); + assert_eq!(field.inverse(7).unwrap(), 10); + assert!(field.inverse(0).is_err()); + // TODO i think this test does not catch all edge cases. In some cases, something seems to be // wrong.