Updated all crates to edition 2024 and set workspace resolver to "3".

`gen` is reserved keyword in 2024. So modigied `galois_element` function in base2k/src/module.rs for compat
This commit is contained in:
Janmajaya Mall
2025-04-28 11:17:16 +05:30
parent 54148acf6b
commit 78b6e9544d
4 changed files with 16 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
[workspace] [workspace]
members = ["base2k", "rlwe", "sampling", "utils"] members = ["base2k", "rlwe", "sampling", "utils"]
resolver = "3"
[workspace.dependencies] [workspace.dependencies]
rug = "1.27" rug = "1.27"

View File

@@ -1,7 +1,7 @@
[package] [package]
name = "base2k" name = "base2k"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2024"
[dependencies] [dependencies]
rug = {workspace = true} rug = {workspace = true}

View File

@@ -3,10 +3,11 @@ use std::path::absolute;
fn main() { fn main() {
println!( println!(
"cargo:rustc-link-search=native={}", "cargo:rustc-link-search=native={}",
absolute("./spqlios-arithmetic/build/spqlios") absolute("spqlios-arithmetic/build/spqlios")
.unwrap() .unwrap()
.to_str() .to_str()
.unwrap() .unwrap()
); );
println!("cargo:rustc-link-lib=static=spqlios"); //"cargo:rustc-link-lib=dylib=spqlios" println!("cargo:rustc-link-lib=static=spqlios");
// println!("cargo:rustc-link-lib=dylib=spqlios")
} }

View File

@@ -65,21 +65,24 @@ impl<B: Backend> Module<B> {
(self.n() << 1) as _ (self.n() << 1) as _
} }
// Returns GALOISGENERATOR^|gen| * sign(gen) // Returns GALOISGENERATOR^|generator| * sign(generator)
pub fn galois_element(&self, gen: i64) -> i64 { pub fn galois_element(&self, generator: i64) -> i64 {
if gen == 0 { if generator == 0 {
return 1; return 1;
} }
((mod_exp_u64(GALOISGENERATOR, gen.abs() as usize) & (self.cyclotomic_order() - 1)) as i64) * gen.signum() ((mod_exp_u64(GALOISGENERATOR, generator.abs() as usize) & (self.cyclotomic_order() - 1)) as i64) * generator.signum()
} }
// Returns gen^-1 // Returns gen^-1
pub fn galois_element_inv(&self, gen: i64) -> i64 { pub fn galois_element_inv(&self, generator: i64) -> i64 {
if gen == 0 { if generator == 0 {
panic!("cannot invert 0") panic!("cannot invert 0")
} }
((mod_exp_u64(gen.abs() as u64, (self.cyclotomic_order() - 1) as usize) & (self.cyclotomic_order() - 1)) as i64) ((mod_exp_u64(
* gen.signum() generator.abs() as u64,
(self.cyclotomic_order() - 1) as usize,
) & (self.cyclotomic_order() - 1)) as i64)
* generator.signum()
} }
pub fn free(self) { pub fn free(self) {