gallois calc order of an element
This commit is contained in:
parent
d454bde3c3
commit
d494db5216
|
@ -15,7 +15,7 @@
|
|||
/// License: MIT
|
||||
/// Source: <https://git.cscherr.de/PlexSheep/plexcryptool/>
|
||||
|
||||
use crate::{math::modexp, cplex::printing::seperator, math::modred::modred};
|
||||
use crate::{math::modexp::{self, modular_exponentiation_wrapper}, cplex::printing::seperator, math::modred::modred};
|
||||
|
||||
use core::fmt;
|
||||
|
||||
|
@ -379,6 +379,19 @@ impl GalloisField {
|
|||
self.cha = i;
|
||||
return i;
|
||||
}
|
||||
|
||||
/// calculate the order of a element
|
||||
pub fn calc_ord(self, n: u128) -> Option<u128> {
|
||||
if n == 0 {
|
||||
return None;
|
||||
}
|
||||
for ord in 2..self.base {
|
||||
if self.pow(n, ord) == 1 {
|
||||
return Some(ord);
|
||||
}
|
||||
}
|
||||
panic!("No order was found, but n is not 0 and all possibilities have been tried");
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
|
|
Loading…
Reference in New Issue