mirror of
https://github.com/arnaucube/phantom-zone.git
synced 2026-01-09 23:51:30 +01:00
fix apis for mp-interactive
This commit is contained in:
@@ -43,10 +43,7 @@ fn main() {
|
|||||||
// After receiving others public key shares clients independently aggregate
|
// After receiving others public key shares clients independently aggregate
|
||||||
// the shares and produce the collective public key `pk`
|
// the shares and produce the collective public key `pk`
|
||||||
|
|
||||||
let pk_shares = cks
|
let pk_shares = cks.iter().map(|k| collective_pk_share(k)).collect_vec();
|
||||||
.iter()
|
|
||||||
.map(|k| interactive_multi_party_round1_share(k))
|
|
||||||
.collect_vec();
|
|
||||||
|
|
||||||
// Clients aggregate public key shares to produce collective public key `pk`
|
// Clients aggregate public key shares to produce collective public key `pk`
|
||||||
let pk = aggregate_public_key_shares(&pk_shares);
|
let pk = aggregate_public_key_shares(&pk_shares);
|
||||||
@@ -67,7 +64,7 @@ fn main() {
|
|||||||
let server_key_shares = cks
|
let server_key_shares = cks
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(user_id, k)| gen_mp_keys_phase2(k, user_id, no_of_parties, &pk))
|
.map(|(user_id, k)| collective_server_key_share(k, user_id, no_of_parties, &pk))
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
||||||
// Each client encrypts their private inputs using the collective public key
|
// Each client encrypts their private inputs using the collective public key
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ pub fn gen_client_key() -> ClientKey {
|
|||||||
BoolEvaluator::with_local(|e| e.client_key())
|
BoolEvaluator::with_local(|e| e.client_key())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate client's share for collective public key, i.e round 1 share, in
|
/// Generate client's share for collective public key, i.e round 1 share, of the
|
||||||
/// round 1 of the 2 round protocol
|
/// 2 round protocol
|
||||||
pub fn interactive_multi_party_round1_share(
|
pub fn collective_pk_share(
|
||||||
ck: &ClientKey,
|
ck: &ClientKey,
|
||||||
) -> CommonReferenceSeededCollectivePublicKeyShare<Vec<u64>, [u8; 32], BoolParameters<u64>> {
|
) -> CommonReferenceSeededCollectivePublicKeyShare<Vec<u64>, [u8; 32], BoolParameters<u64>> {
|
||||||
BoolEvaluator::with_local(|e| {
|
BoolEvaluator::with_local(|e| {
|
||||||
@@ -73,8 +73,8 @@ pub fn interactive_multi_party_round1_share(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Generate clients share for collective server key, i.e. round 2, of the
|
/// Generate clients share for collective server key, i.e. round 2, of the
|
||||||
/// protocol
|
/// 2 round protocol
|
||||||
pub fn gen_mp_keys_phase2<R, ModOp>(
|
pub fn collective_server_key_share<R, ModOp>(
|
||||||
ck: &ClientKey,
|
ck: &ClientKey,
|
||||||
user_id: usize,
|
user_id: usize,
|
||||||
total_users: usize,
|
total_users: usize,
|
||||||
@@ -322,10 +322,7 @@ mod tests {
|
|||||||
let cks = (0..parties).map(|_| gen_client_key()).collect_vec();
|
let cks = (0..parties).map(|_| gen_client_key()).collect_vec();
|
||||||
|
|
||||||
// round 1
|
// round 1
|
||||||
let pk_shares = cks
|
let pk_shares = cks.iter().map(|k| collective_pk_share(k)).collect_vec();
|
||||||
.iter()
|
|
||||||
.map(|k| interactive_multi_party_round1_share(k))
|
|
||||||
.collect_vec();
|
|
||||||
|
|
||||||
// collective pk
|
// collective pk
|
||||||
let pk = aggregate_public_key_shares(&pk_shares);
|
let pk = aggregate_public_key_shares(&pk_shares);
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ mod tests {
|
|||||||
evaluator::InteractiveMultiPartyCrs,
|
evaluator::InteractiveMultiPartyCrs,
|
||||||
keys::{key_size::KeySize, ServerKeyEvaluationDomain},
|
keys::{key_size::KeySize, ServerKeyEvaluationDomain},
|
||||||
},
|
},
|
||||||
gen_client_key, gen_mp_keys_phase2, interactive_multi_party_round1_share,
|
collective_pk_share, collective_server_key_share, gen_client_key,
|
||||||
parameters::CiphertextModulus,
|
parameters::CiphertextModulus,
|
||||||
random::DefaultSecureRng,
|
random::DefaultSecureRng,
|
||||||
set_common_reference_seed, set_parameter_set,
|
set_common_reference_seed, set_parameter_set,
|
||||||
@@ -411,16 +411,13 @@ mod tests {
|
|||||||
|
|
||||||
for i in 0..2 {
|
for i in 0..2 {
|
||||||
let cks = (0..parties).map(|_| gen_client_key()).collect_vec();
|
let cks = (0..parties).map(|_| gen_client_key()).collect_vec();
|
||||||
let pk_shares = cks
|
let pk_shares = cks.iter().map(|k| collective_pk_share(k)).collect_vec();
|
||||||
.iter()
|
|
||||||
.map(|k| interactive_multi_party_round1_share(k))
|
|
||||||
.collect_vec();
|
|
||||||
|
|
||||||
let pk = aggregate_public_key_shares(&pk_shares);
|
let pk = aggregate_public_key_shares(&pk_shares);
|
||||||
let server_key_shares = cks
|
let server_key_shares = cks
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(index, k)| gen_mp_keys_phase2(k, index, parties, &pk))
|
.map(|(index, k)| collective_server_key_share(k, index, parties, &pk))
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
||||||
// In 0th iteration measure server key size
|
// In 0th iteration measure server key size
|
||||||
@@ -490,7 +487,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
print_noise::collect_server_key_stats,
|
print_noise::collect_server_key_stats,
|
||||||
},
|
},
|
||||||
gen_client_key, gen_mp_keys_phase2, interactive_multi_party_round1_share,
|
collective_pk_share, collective_server_key_share, gen_client_key,
|
||||||
parameters::CiphertextModulus,
|
parameters::CiphertextModulus,
|
||||||
random::DefaultSecureRng,
|
random::DefaultSecureRng,
|
||||||
set_common_reference_seed, set_parameter_set,
|
set_common_reference_seed, set_parameter_set,
|
||||||
@@ -510,10 +507,7 @@ mod tests {
|
|||||||
let cks = (0..no_of_parties).map(|_| gen_client_key()).collect_vec();
|
let cks = (0..no_of_parties).map(|_| gen_client_key()).collect_vec();
|
||||||
|
|
||||||
// round 1
|
// round 1
|
||||||
let pk_shares = cks
|
let pk_shares = cks.iter().map(|k| collective_pk_share(k)).collect_vec();
|
||||||
.iter()
|
|
||||||
.map(|k| interactive_multi_party_round1_share(k))
|
|
||||||
.collect_vec();
|
|
||||||
|
|
||||||
let pk = aggregate_public_key_shares(&pk_shares);
|
let pk = aggregate_public_key_shares(&pk_shares);
|
||||||
|
|
||||||
@@ -521,7 +515,7 @@ mod tests {
|
|||||||
let server_key_shares = cks
|
let server_key_shares = cks
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(user_id, k)| gen_mp_keys_phase2(k, user_id, no_of_parties, &pk))
|
.map(|(user_id, k)| collective_server_key_share(k, user_id, no_of_parties, &pk))
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
||||||
let server_key = aggregate_server_key_shares(&server_key_shares);
|
let server_key = aggregate_server_key_shares(&server_key_shares);
|
||||||
|
|||||||
Reference in New Issue
Block a user