diff --git a/Cargo.toml b/Cargo.toml index 9e9fba28..bce848bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ test = [] parallel = ["rayon"] [dependencies] -openfhe = { git = "https://github.com/MachinaIO/openfhe-rs.git", branch = "refactor2" } +openfhe = { git = "https://github.com/MachinaIO/openfhe-rs.git", branch = "feat/get_coeffs_to_bytes_perf" } digest = "0.10" num-bigint = { version = "0.4", default-features = false } num-traits = "0.2" diff --git a/src/poly/dcrt/poly.rs b/src/poly/dcrt/poly.rs index 08cff0bb..6c32f4dd 100644 --- a/src/poly/dcrt/poly.rs +++ b/src/poly/dcrt/poly.rs @@ -11,6 +11,7 @@ use num_bigint::BigUint; use openfhe::{ cxx::UniquePtr, ffi::{self, DCRTPoly as DCRTPolyCxx}, + parse_coefficients_bytes, }; use std::{ @@ -75,11 +76,11 @@ impl Poly for DCRTPoly { type Params = DCRTPolyParams; fn coeffs(&self) -> Vec { - let coeffs = self.ptr_poly.GetCoefficients(); - let modulus = self.ptr_poly.GetModulus(); - parallel_iter!(coeffs) - .map(|s| FinRingElem::from_str(&s, &modulus).expect("invalid string")) - .collect() + let poly_encoding = self.ptr_poly.GetCoefficientsBytes(); + let parsed_values = parse_coefficients_bytes(&poly_encoding); + let coeffs = parsed_values.coefficients; + let modulus = parsed_values.modulus; + parallel_iter!(coeffs).map(|s| FinRingElem::new(s, Arc::new(modulus.clone()))).collect() } fn from_coeffs(params: &Self::Params, coeffs: &[Self::Elem]) -> Self {