Skip to content

Shares 5pc - #148

Merged
marsenis merged 7 commits into
tfhard-5pcfrom
shares-5pc
Sep 3, 2026
Merged

Shares 5pc#148
marsenis merged 7 commits into
tfhard-5pcfrom
shares-5pc

Conversation

@evagelia

Copy link
Copy Markdown
Contributor

Adds RssShare, a 3-of-5 replicated share type, the 5-party counterpart to the 3-party Share.

What is added:

  • RssShare<T> = [RingElement<T>; 6] in place of Share's a and b. Slots are stored
    relative to the holder's role, so every party runs identical code
  • SLOT_OFFSETS / slot_pair() — the slot ↔ party-pair mapping as data rather than prose.
  • Add, Sub, Mul<T> (public constant). Componentwise, no communication.
  • MUL_ASSIGN + Mul<Self> for &RssShare<T>. 5PC has 100 cross terms, partitioned into five sets of 20 via a table from
    Appendix C of Baccarini, Blanton and Yuan.

@gayathrigarimella
gayathrigarimella changed the base branch from tfhard-5pc to tfhard/claude/networking-prf August 30, 2026 07:34
Comment thread ampc-secret-sharing/src/shares/rss5.rs Outdated
use std::ops::{Add, Mul, Sub};

/// Number of parties.
pub const RSS5_PARTIES: usize = 5;

@gayathrigarimella gayathrigarimella Sep 2, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: re-use previously defined constant

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. I'm fixing this by defining the constant here instead so that we don't introduce a circular
dependency between the ampc-actor-utils and ampc-secret-sharing crates.

pub const RSS5_PARTIES: usize = 5;

/// Number of shares held by each party: `C(4, 2)`.
pub const RSS5_SLOTS_HELD: usize = 6;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: i prefer shares to slots for readability

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with either. Up to you.


/// The index pair of slot `slot` as held by party `role`, as an
/// ordered pair of absolute role indices.
pub fn slot_pair(role: usize, slot: usize) -> (usize, usize) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verfied fn slot_pair(). Optionally add this to the comments for readability.
// Role 0: [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
// Role 1: [(2, 3), (2, 4), (0, 2), (3, 4), (0, 3), (0, 4)]
// Role 2: [(3, 4), (0, 3), (1, 3), (0, 4), (1, 4), (0, 1)]
// Role 3: [(0,4), (1, 4), (2, 4), (0, 1), (0, 2), (1, 2)]
// Role 4: [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Adding.

Base automatically changed from tfhard/claude/networking-prf to tfhard-5pc September 2, 2026 18:50
Comment thread ampc-secret-sharing/src/shares/rss5.rs Outdated
/// to `p` uses only slots that `p` holds.
///
/// Taken from Appendix C of Baccarini, Blanton and Yuan.
const MUL_ASSIGN: [&[usize]; RSS5_SLOTS_HELD] = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: maybe operand_assign or something

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing it to MUL_OPERAND_ASSIGN.

// Dealing and reconstruction agree before any arithmetic happens.
assert_eq!(reconstruct_shares(&a), RingElement(a_t));

// Multiplication

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done -> all local computations over RSS5
need to be done? -> going from 5-of-5 additive to RSS5 replicated state

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looks like it. I think the non-local computation touches functions in the ampc-actor-utils
crate. We can address that on a separate PR.

@gayathrigarimella gayathrigarimella left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :) Left a few minor comments. Noting that this PR implements all local computation for RSS5 for linear operations and local computation for multiplication.

@marsenis marsenis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Responded to PR comments.

Comment thread ampc-secret-sharing/src/shares/rss5.rs Outdated
use std::ops::{Add, Mul, Sub};

/// Number of parties.
pub const RSS5_PARTIES: usize = 5;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. I'm fixing this by defining the constant here instead so that we don't introduce a circular
dependency between the ampc-actor-utils and ampc-secret-sharing crates.

pub const RSS5_PARTIES: usize = 5;

/// Number of shares held by each party: `C(4, 2)`.
pub const RSS5_SLOTS_HELD: usize = 6;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with either. Up to you.


/// The index pair of slot `slot` as held by party `role`, as an
/// ordered pair of absolute role indices.
pub fn slot_pair(role: usize, slot: usize) -> (usize, usize) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Adding.

Comment thread ampc-secret-sharing/src/shares/rss5.rs Outdated
/// to `p` uses only slots that `p` holds.
///
/// Taken from Appendix C of Baccarini, Blanton and Yuan.
const MUL_ASSIGN: [&[usize]; RSS5_SLOTS_HELD] = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing it to MUL_OPERAND_ASSIGN.

// Dealing and reconstruction agree before any arithmetic happens.
assert_eq!(reconstruct_shares(&a), RingElement(a_t));

// Multiplication

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looks like it. I think the non-local computation touches functions in the ampc-actor-utils
crate. We can address that on a separate PR.

@marsenis
marsenis marked this pull request as ready for review September 2, 2026 23:33
@marsenis
marsenis merged commit 18354fe into tfhard-5pc Sep 3, 2026
10 of 11 checks passed
@marsenis
marsenis deleted the shares-5pc branch September 3, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants