pub(crate) mod evaluator; mod keys; mod noise; pub(crate) mod parameters; pub(crate) use keys::PublicKey; #[cfg(feature = "interactive_mp")] #[cfg(not(feature = "non_interactive_mp"))] mod mp_api; #[cfg(feature = "non_interactive_mp")] mod ni_mp_api; #[cfg(feature = "non_interactive_mp")] pub use ni_mp_api::*; #[cfg(feature = "interactive_mp")] #[cfg(not(feature = "non_interactive_mp"))] pub use mp_api::*; pub type ClientKey = keys::ClientKey<[u8; 32], u64>; pub enum ParameterSelector { MultiPartyLessThanOrEqualTo16, NonInteractiveMultiPartyLessThanOrEqualTo16, } mod common_mp_enc_dec { use super::BoolEvaluator; use crate::{ pbs::{sample_extract, PbsInfo}, utils::WithLocal, Matrix, MultiPartyDecryptor, RowEntity, SampleExtractor, }; type Mat = Vec>; impl MultiPartyDecryptor::R> for super::keys::ClientKey<[u8; 32], E> { type DecryptionShare = ::MatElement; fn gen_decryption_share(&self, c: &::R) -> Self::DecryptionShare { BoolEvaluator::with_local(|e| e.multi_party_decryption_share(c, self)) } fn aggregate_decryption_shares( &self, c: &::R, shares: &[Self::DecryptionShare], ) -> bool { BoolEvaluator::with_local(|e| e.multi_party_decrypt(shares, c)) } } impl SampleExtractor<::R> for Mat { fn extract(&self, index: usize) -> ::R { // input is RLWE ciphertext assert!(self.dimension().0 == 2); let ring_size = self.dimension().1; assert!(index < ring_size); BoolEvaluator::with_local(|e| { let mut lwe_out = ::R::zeros(ring_size + 1); sample_extract(&mut lwe_out, self, e.pbs_info().modop_rlweq(), index); lwe_out }) } } }