mirror of
https://github.com/arnaucube/phantom-zone.git
synced 2026-01-08 23:21:29 +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
|
||||
// the shares and produce the collective public key `pk`
|
||||
|
||||
let pk_shares = cks
|
||||
.iter()
|
||||
.map(|k| interactive_multi_party_round1_share(k))
|
||||
.collect_vec();
|
||||
let pk_shares = cks.iter().map(|k| collective_pk_share(k)).collect_vec();
|
||||
|
||||
// Clients aggregate public key shares to produce collective public key `pk`
|
||||
let pk = aggregate_public_key_shares(&pk_shares);
|
||||
@@ -67,7 +64,7 @@ fn main() {
|
||||
let server_key_shares = cks
|
||||
.iter()
|
||||
.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();
|
||||
|
||||
// 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())
|
||||
}
|
||||
|
||||
/// Generate client's share for collective public key, i.e round 1 share, in
|
||||
/// round 1 of the 2 round protocol
|
||||
pub fn interactive_multi_party_round1_share(
|
||||
/// Generate client's share for collective public key, i.e round 1 share, of the
|
||||
/// 2 round protocol
|
||||
pub fn collective_pk_share(
|
||||
ck: &ClientKey,
|
||||
) -> CommonReferenceSeededCollectivePublicKeyShare<Vec<u64>, [u8; 32], BoolParameters<u64>> {
|
||||
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
|
||||
/// protocol
|
||||
pub fn gen_mp_keys_phase2<R, ModOp>(
|
||||
/// 2 round protocol
|
||||
pub fn collective_server_key_share<R, ModOp>(
|
||||
ck: &ClientKey,
|
||||
user_id: usize,
|
||||
total_users: usize,
|
||||
@@ -322,10 +322,7 @@ mod tests {
|
||||
let cks = (0..parties).map(|_| gen_client_key()).collect_vec();
|
||||
|
||||
// round 1
|
||||
let pk_shares = cks
|
||||
.iter()
|
||||
.map(|k| interactive_multi_party_round1_share(k))
|
||||
.collect_vec();
|
||||
let pk_shares = cks.iter().map(|k| collective_pk_share(k)).collect_vec();
|
||||
|
||||
// collective pk
|
||||
let pk = aggregate_public_key_shares(&pk_shares);
|
||||
|
||||
@@ -392,7 +392,7 @@ mod tests {
|
||||
evaluator::InteractiveMultiPartyCrs,
|
||||
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,
|
||||
random::DefaultSecureRng,
|
||||
set_common_reference_seed, set_parameter_set,
|
||||
@@ -411,16 +411,13 @@ mod tests {
|
||||
|
||||
for i in 0..2 {
|
||||
let cks = (0..parties).map(|_| gen_client_key()).collect_vec();
|
||||
let pk_shares = cks
|
||||
.iter()
|
||||
.map(|k| interactive_multi_party_round1_share(k))
|
||||
.collect_vec();
|
||||
let pk_shares = cks.iter().map(|k| collective_pk_share(k)).collect_vec();
|
||||
|
||||
let pk = aggregate_public_key_shares(&pk_shares);
|
||||
let server_key_shares = cks
|
||||
.iter()
|
||||
.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();
|
||||
|
||||
// In 0th iteration measure server key size
|
||||
@@ -490,7 +487,7 @@ mod tests {
|
||||
},
|
||||
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,
|
||||
random::DefaultSecureRng,
|
||||
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();
|
||||
|
||||
// round 1
|
||||
let pk_shares = cks
|
||||
.iter()
|
||||
.map(|k| interactive_multi_party_round1_share(k))
|
||||
.collect_vec();
|
||||
let pk_shares = cks.iter().map(|k| collective_pk_share(k)).collect_vec();
|
||||
|
||||
let pk = aggregate_public_key_shares(&pk_shares);
|
||||
|
||||
@@ -521,7 +515,7 @@ mod tests {
|
||||
let server_key_shares = cks
|
||||
.iter()
|
||||
.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();
|
||||
|
||||
let server_key = aggregate_server_key_shares(&server_key_shares);
|
||||
|
||||
Reference in New Issue
Block a user