mirror of
https://github.com/arnaucube/phantom-zone.git
synced 2026-01-10 16:11:30 +01:00
add more multi-party parameters
This commit is contained in:
@@ -910,7 +910,10 @@ where
|
||||
BoolParameters<M::MatElement>,
|
||||
InteractiveMultiPartyCrs<[u8; 32]>,
|
||||
> {
|
||||
assert_eq!(self.parameters().variant(), &ParameterVariant::MultiParty);
|
||||
assert_eq!(
|
||||
self.parameters().variant(),
|
||||
&ParameterVariant::InteractiveMultiParty
|
||||
);
|
||||
assert!(user_id < total_users);
|
||||
|
||||
let sk_rlwe = client_key.sk_rlwe();
|
||||
@@ -1060,7 +1063,10 @@ where
|
||||
S: PartialEq + Clone,
|
||||
M: Clone,
|
||||
{
|
||||
assert_eq!(self.parameters().variant(), &ParameterVariant::MultiParty);
|
||||
assert_eq!(
|
||||
self.parameters().variant(),
|
||||
&ParameterVariant::InteractiveMultiParty
|
||||
);
|
||||
assert!(shares.len() > 0);
|
||||
|
||||
let total_users = shares.len();
|
||||
|
||||
@@ -27,6 +27,8 @@ static MULTI_PARTY_CRS: OnceLock<InteractiveMultiPartyCrs<[u8; 32]>> = OnceLock:
|
||||
|
||||
pub enum ParameterSelector {
|
||||
InteractiveLTE2Party,
|
||||
InteractiveLTE4Party,
|
||||
InteractiveLTE8Party,
|
||||
}
|
||||
|
||||
/// Select Interactive multi-party parameter variant
|
||||
@@ -35,7 +37,12 @@ pub fn set_parameter_set(select: ParameterSelector) {
|
||||
ParameterSelector::InteractiveLTE2Party => {
|
||||
BOOL_EVALUATOR.with_borrow_mut(|v| *v = Some(BoolEvaluator::new(I_2P)));
|
||||
}
|
||||
|
||||
ParameterSelector::InteractiveLTE4Party => {
|
||||
BOOL_EVALUATOR.with_borrow_mut(|v| *v = Some(BoolEvaluator::new(I_4P)));
|
||||
}
|
||||
ParameterSelector::InteractiveLTE8Party => {
|
||||
BOOL_EVALUATOR.with_borrow_mut(|v| *v = Some(BoolEvaluator::new(I_8P_LB_SR)));
|
||||
}
|
||||
_ => {
|
||||
panic!("Paramerter not supported")
|
||||
}
|
||||
@@ -355,8 +362,10 @@ mod tests {
|
||||
let rlwe_modop = parameters.default_rlwe_modop();
|
||||
|
||||
for _ in 0..500 {
|
||||
let now = std::time::Instant::now();
|
||||
let ct_out =
|
||||
BoolEvaluator::with_local_mut(|e| e.nand(&ct0, &ct1, RuntimeServerKey::global()));
|
||||
println!("Time: {:?}", now.elapsed());
|
||||
|
||||
let m_expected = !(m0 && m1);
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ pub(crate) enum SecretKeyDistribution {
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub(crate) enum ParameterVariant {
|
||||
SingleParty,
|
||||
MultiParty,
|
||||
InteractiveMultiParty,
|
||||
NonInteractiveMultiParty,
|
||||
}
|
||||
#[derive(Clone, PartialEq)]
|
||||
@@ -544,7 +544,7 @@ pub(crate) const MP_BOOL_PARAMS: BoolParameters<u64> = BoolParameters::<u64> {
|
||||
non_interactive_ui_to_s_key_switch_decomposer: None,
|
||||
g: 5,
|
||||
w: 10,
|
||||
variant: ParameterVariant::MultiParty,
|
||||
variant: ParameterVariant::InteractiveMultiParty,
|
||||
};
|
||||
|
||||
pub(crate) const SMALL_MP_BOOL_PARAMS: BoolParameters<u64> = BoolParameters::<u64> {
|
||||
@@ -568,7 +568,7 @@ pub(crate) const SMALL_MP_BOOL_PARAMS: BoolParameters<u64> = BoolParameters::<u6
|
||||
non_interactive_ui_to_s_key_switch_decomposer: None,
|
||||
g: 5,
|
||||
w: 10,
|
||||
variant: ParameterVariant::MultiParty,
|
||||
variant: ParameterVariant::InteractiveMultiParty,
|
||||
};
|
||||
|
||||
pub(crate) const I_2P: BoolParameters<u64> = BoolParameters::<u64> {
|
||||
@@ -579,20 +579,92 @@ pub(crate) const I_2P: BoolParameters<u64> = BoolParameters::<u64> {
|
||||
br_q: 1 << 11,
|
||||
rlwe_n: PolynomialSize(1 << 11),
|
||||
lwe_n: LweDimension(480),
|
||||
lwe_decomposer_params: (DecompostionLogBase(1), DecompositionCount(11)),
|
||||
lwe_decomposer_params: (DecompostionLogBase(1), DecompositionCount(12)),
|
||||
rlrg_decomposer_params: (
|
||||
DecompostionLogBase(16),
|
||||
DecompostionLogBase(17),
|
||||
(DecompositionCount(1), DecompositionCount(1)),
|
||||
),
|
||||
rgrg_decomposer_params: Some((
|
||||
DecompostionLogBase(8),
|
||||
(DecompositionCount(6), DecompositionCount(6)),
|
||||
DecompostionLogBase(7),
|
||||
(DecompositionCount(6), DecompositionCount(5)),
|
||||
)),
|
||||
auto_decomposer_params: (DecompostionLogBase(24), DecompositionCount(1)),
|
||||
non_interactive_ui_to_s_key_switch_decomposer: None,
|
||||
g: 5,
|
||||
w: 10,
|
||||
variant: ParameterVariant::MultiParty,
|
||||
variant: ParameterVariant::InteractiveMultiParty,
|
||||
};
|
||||
|
||||
pub(crate) const I_4P: BoolParameters<u64> = BoolParameters::<u64> {
|
||||
rlwe_secret_key_dist: SecretKeyDistribution::TernaryDistribution,
|
||||
lwe_secret_key_dist: SecretKeyDistribution::ErrorDistribution,
|
||||
rlwe_q: CiphertextModulus::new_non_native(18014398509404161),
|
||||
lwe_q: CiphertextModulus::new_non_native(1 << 16),
|
||||
br_q: 1 << 11,
|
||||
rlwe_n: PolynomialSize(1 << 11),
|
||||
lwe_n: LweDimension(520),
|
||||
lwe_decomposer_params: (DecompostionLogBase(1), DecompositionCount(13)),
|
||||
rlrg_decomposer_params: (
|
||||
DecompostionLogBase(17),
|
||||
(DecompositionCount(1), DecompositionCount(1)),
|
||||
),
|
||||
rgrg_decomposer_params: Some((
|
||||
DecompostionLogBase(6),
|
||||
(DecompositionCount(7), DecompositionCount(6)),
|
||||
)),
|
||||
auto_decomposer_params: (DecompostionLogBase(24), DecompositionCount(1)),
|
||||
non_interactive_ui_to_s_key_switch_decomposer: None,
|
||||
g: 5,
|
||||
w: 10,
|
||||
variant: ParameterVariant::InteractiveMultiParty,
|
||||
};
|
||||
|
||||
pub(crate) const I_8P_HB_FR: BoolParameters<u64> = BoolParameters::<u64> {
|
||||
rlwe_secret_key_dist: SecretKeyDistribution::TernaryDistribution,
|
||||
lwe_secret_key_dist: SecretKeyDistribution::ErrorDistribution,
|
||||
rlwe_q: CiphertextModulus::new_non_native(18014398509404161),
|
||||
lwe_q: CiphertextModulus::new_non_native(1 << 16),
|
||||
br_q: 1 << 11,
|
||||
rlwe_n: PolynomialSize(1 << 11),
|
||||
lwe_n: LweDimension(520),
|
||||
lwe_decomposer_params: (DecompostionLogBase(1), DecompositionCount(13)),
|
||||
rlrg_decomposer_params: (
|
||||
DecompostionLogBase(17),
|
||||
(DecompositionCount(1), DecompositionCount(1)),
|
||||
),
|
||||
rgrg_decomposer_params: Some((
|
||||
DecompostionLogBase(4),
|
||||
(DecompositionCount(12), DecompositionCount(11)),
|
||||
)),
|
||||
auto_decomposer_params: (DecompostionLogBase(24), DecompositionCount(1)),
|
||||
non_interactive_ui_to_s_key_switch_decomposer: None,
|
||||
g: 5,
|
||||
w: 10,
|
||||
variant: ParameterVariant::InteractiveMultiParty,
|
||||
};
|
||||
|
||||
pub(crate) const I_8P_LB_SR: BoolParameters<u64> = BoolParameters::<u64> {
|
||||
rlwe_secret_key_dist: SecretKeyDistribution::TernaryDistribution,
|
||||
lwe_secret_key_dist: SecretKeyDistribution::ErrorDistribution,
|
||||
rlwe_q: CiphertextModulus::new_non_native(18014398509404161),
|
||||
lwe_q: CiphertextModulus::new_non_native(1 << 17),
|
||||
br_q: 1 << 11,
|
||||
rlwe_n: PolynomialSize(1 << 11),
|
||||
lwe_n: LweDimension(560),
|
||||
lwe_decomposer_params: (DecompostionLogBase(1), DecompositionCount(14)),
|
||||
rlrg_decomposer_params: (
|
||||
DecompostionLogBase(17),
|
||||
(DecompositionCount(1), DecompositionCount(1)),
|
||||
),
|
||||
rgrg_decomposer_params: Some((
|
||||
DecompostionLogBase(5),
|
||||
(DecompositionCount(8), DecompositionCount(7)),
|
||||
)),
|
||||
auto_decomposer_params: (DecompostionLogBase(24), DecompositionCount(1)),
|
||||
non_interactive_ui_to_s_key_switch_decomposer: None,
|
||||
g: 5,
|
||||
w: 10,
|
||||
variant: ParameterVariant::InteractiveMultiParty,
|
||||
};
|
||||
|
||||
pub(crate) const NI_2P: BoolParameters<u64> = BoolParameters::<u64> {
|
||||
|
||||
@@ -322,7 +322,7 @@ where
|
||||
// LWE key switches LWE_in = LWE_{Q_ks,N, s}(m) = (b, a_0, ... a_N) -> LWE_out =
|
||||
// LWE_{Q_{ks}, n, z}(m) = (b', a'_0, ..., a'n)
|
||||
// If LWE_in = (0, a = {a_0, ..., a_N}), then LWE_out = LWE(-a \cdot s_{rlwe})
|
||||
for _ in 0..10 {
|
||||
for _ in 0..100 {
|
||||
let mut lwe_in = M::R::zeros(rlwe_n + 1);
|
||||
RandomFillUniformInModulus::random_fill(&mut rng, lwe_q, &mut lwe_in.as_mut()[1..]);
|
||||
|
||||
@@ -367,7 +367,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "interactive_mp")]
|
||||
fn qwerty() {
|
||||
fn interactive_key_noise() {
|
||||
use crate::{
|
||||
aggregate_public_key_shares, aggregate_server_key_shares,
|
||||
bool::{
|
||||
@@ -379,7 +379,7 @@ mod tests {
|
||||
random::DefaultSecureRng,
|
||||
set_common_reference_seed, set_parameter_set,
|
||||
utils::WithLocal,
|
||||
BoolEvaluator, DefaultDecomposer, ModularOpsU64, Ntt, NttBackendU64,
|
||||
BoolEvaluator, DefaultDecomposer, ModularOpsU64, NttBackendU64,
|
||||
};
|
||||
|
||||
set_parameter_set(crate::ParameterSelector::InteractiveLTE2Party);
|
||||
@@ -414,6 +414,11 @@ mod tests {
|
||||
_,
|
||||
>(parameters, &cks, &server_key_eval);
|
||||
|
||||
println!(
|
||||
"Common reference seeded server key share key size size: {} Bits",
|
||||
server_key_shares[0].size()
|
||||
);
|
||||
|
||||
println!(
|
||||
"Rgsw nsm std log2 {}",
|
||||
server_key_stats.brk_rgsw_cts.0.std_dev().abs().log2()
|
||||
|
||||
Reference in New Issue
Block a user