mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
added test for automorphism on automorphism key
This commit is contained in:
@@ -74,15 +74,15 @@ impl<B: Backend> Module<B> {
|
||||
}
|
||||
|
||||
// Returns gen^-1
|
||||
pub fn galois_element_inv(&self, generator: i64) -> i64 {
|
||||
if generator == 0 {
|
||||
pub fn galois_element_inv(&self, gal_el: i64) -> i64 {
|
||||
if gal_el == 0 {
|
||||
panic!("cannot invert 0")
|
||||
}
|
||||
((mod_exp_u64(
|
||||
generator.abs() as u64,
|
||||
gal_el.abs() as u64,
|
||||
(self.cyclotomic_order() - 1) as usize,
|
||||
) & (self.cyclotomic_order() - 1)) as i64)
|
||||
* generator.signum()
|
||||
* gal_el.signum()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -574,6 +574,7 @@ impl<BACKEND: Backend> VecZnxOps for Module<BACKEND> {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
assert_eq!(a.n(), self.n());
|
||||
assert!(k & 1 != 0, "invalid galois element: must be odd but is {}", k);
|
||||
}
|
||||
unsafe {
|
||||
vec_znx::vec_znx_automorphism(
|
||||
|
||||
Reference in New Issue
Block a user