Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ampc-actor-utils/src/network/mpc/handle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::network::mpc::handle::control_channel::{ControlChannel, MeshControlCh
use crate::network::tcp::connection::client::{BoxTcpClient, TcpClient, TlsClient};
use crate::network::tcp::connection::server::{BoxTcpServer, TcpServer, TlsServer};
use crate::network::tcp::{self, TcpStreamConn, TlsClientConfig, TlsConfig, TlsServerConfig};
use crate::protocol::prf::ORBIT5_PARTY_COUNT;
use ampc_secret_sharing::shares::rss5::ORBIT5_PARTY_COUNT;
use async_trait::async_trait;
use eyre::Result;
use itertools::izip;
Expand Down Expand Up @@ -81,7 +81,7 @@ pub async fn build_network_handle(

let identities = match args.addresses.len() {
3 => generate_local_identities(),
n if n == ORBIT5_PARTY_COUNT as usize => generate_local_identities_orbit5(),
n if n == ORBIT5_PARTY_COUNT => generate_local_identities_orbit5(),
n => eyre::bail!("unsupported party count {n}: expected 3 or {ORBIT5_PARTY_COUNT}"),
};
let role_assignments: RoleAssignment = identities
Expand Down
19 changes: 10 additions & 9 deletions ampc-actor-utils/src/protocol/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ use crate::execution::session::{NetworkSession, Session, SessionHandles};
use crate::network::mpc::{NetworkInt, NetworkValue};
use crate::protocol::binary::{bit_inject, extract_msb_batch, lift, lift_to_ring48, open_bin};
use crate::protocol::prf::{
orbit5_roles, PairwisePrfKeys, PartyPair, Prf, PrfSeed, ThresholdPrfKeys, ORBIT5_PARTY_COUNT,
orbit5_roles, PairwisePrfKeys, PartyPair, Prf, PrfSeed, ThresholdPrfKeys,
};
use ampc_secret_sharing::shares::bit::Bit;
use ampc_secret_sharing::shares::rss5::ORBIT5_PARTY_COUNT;
use ampc_secret_sharing::shares::share::DistanceShare;
use ampc_secret_sharing::shares::RingRandFillable;
use ampc_secret_sharing::shares::{
Expand Down Expand Up @@ -151,7 +152,7 @@ fn decode_prf_seed(msg: Result<NetworkValue>, from: Role) -> Result<PrfSeed> {
pub async fn setup_threshold_prf_keys(session: &mut NetworkSession) -> Result<ThresholdPrfKeys> {
let own_role = session.own_role();
let num_parties = session.role_assignments.len();
if num_parties != ORBIT5_PARTY_COUNT as usize {
if num_parties != ORBIT5_PARTY_COUNT {
bail!(
"threshold PRF key setup requires exactly {ORBIT5_PARTY_COUNT} parties, found {num_parties}"
);
Expand Down Expand Up @@ -203,7 +204,7 @@ pub async fn setup_threshold_prf_keys(session: &mut NetworkSession) -> Result<Th
pub async fn setup_pairwise_prf_keys(session: &mut NetworkSession) -> Result<PairwisePrfKeys> {
let own_role = session.own_role();
let num_parties = session.role_assignments.len();
if num_parties != ORBIT5_PARTY_COUNT as usize {
if num_parties != ORBIT5_PARTY_COUNT {
bail!(
"pairwise PRF key setup requires exactly {ORBIT5_PARTY_COUNT} parties, found {num_parties}"
);
Expand Down Expand Up @@ -845,7 +846,7 @@ mod tests {
let mut seeds = Vec::new();
for i in 0..ORBIT5_PARTY_COUNT {
let mut seed = [0_u8; 16];
seed[0] = i;
seed[0] = i as u8;
seeds.push(seed);
}
let runtime = LocalRuntime::new(identities.clone(), seeds.clone())
Expand Down Expand Up @@ -877,7 +878,7 @@ mod tests {
// Every threshold key must be agreed identically by all three owners.
for a in 0..ORBIT5_PARTY_COUNT {
for b in (a + 1)..ORBIT5_PARTY_COUNT {
let (role_a, role_b) = (Role::new(a as usize), Role::new(b as usize));
let (role_a, role_b) = (Role::new(a), Role::new(b));
let mut agreed_value: Option<u64> = None;
let mut num_owners = 0;
for (threshold, _) in by_role.iter_mut() {
Expand All @@ -898,10 +899,10 @@ mod tests {
// Every pairwise key must be agreed identically by both parties.
for a in 0..ORBIT5_PARTY_COUNT {
for b in (a + 1)..ORBIT5_PARTY_COUNT {
let role_a = Role::new(a as usize);
let role_b = Role::new(b as usize);
let a_value = by_role[a as usize].1.get_mut(role_b).unwrap().next_u64();
let b_value = by_role[b as usize].1.get_mut(role_a).unwrap().next_u64();
let role_a = Role::new(a);
let role_b = Role::new(b);
let a_value = by_role[a].1.get_mut(role_b).unwrap().next_u64();
let b_value = by_role[b].1.get_mut(role_a).unwrap().next_u64();
assert_eq!(a_value, b_value);
}
}
Expand Down
7 changes: 2 additions & 5 deletions ampc-actor-utils/src/protocol/prf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::protocol::shuffle::Permutation;
use ampc_secret_sharing::shares::{
int_ring::IntRing2k,
ring_impl::{RingElement, RingRandFillable, VecRingElement},
rss5::ORBIT5_PARTY_COUNT,
};
use eyre::{bail, Result};
use rand::{distributions::Standard, prelude::Distribution, Rng, SeedableRng};
Expand Down Expand Up @@ -170,12 +171,8 @@ fn seed_to_rng(seed: PrfSeed) -> PrfRng {
}
}

/// Number of parties in the ORBIT5 (5-party) protocol configuration used by
/// [`ThresholdPrfKeys`] and [`PairwisePrfKeys`].
pub const ORBIT5_PARTY_COUNT: u8 = 5;

/// The roles of all ORBIT5 parties, in index order.
pub fn orbit5_roles() -> [Role; ORBIT5_PARTY_COUNT as usize] {
pub fn orbit5_roles() -> [Role; ORBIT5_PARTY_COUNT] {
std::array::from_fn(Role::new)
}

Expand Down
1 change: 1 addition & 0 deletions ampc-secret-sharing/src/shares/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod bit;
pub mod int_ring;
pub mod ring48;
pub mod ring_impl;
pub mod rss5;
pub mod share;
pub mod vecshare;
pub mod vecshare_bittranspose;
Expand Down
Loading
Loading