Shares 5pc - #148
Conversation
| use std::ops::{Add, Mul, Sub}; | ||
|
|
||
| /// Number of parties. | ||
| pub const RSS5_PARTIES: usize = 5; |
There was a problem hiding this comment.
minor: re-use previously defined constant
There was a problem hiding this comment.
+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; |
There was a problem hiding this comment.
minor: i prefer shares to slots for readability
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)]
| /// to `p` uses only slots that `p` holds. | ||
| /// | ||
| /// Taken from Appendix C of Baccarini, Blanton and Yuan. | ||
| const MUL_ASSIGN: [&[usize]; RSS5_SLOTS_HELD] = [ |
There was a problem hiding this comment.
minor: maybe operand_assign or something
There was a problem hiding this comment.
Changing it to MUL_OPERAND_ASSIGN.
| // Dealing and reconstruction agree before any arithmetic happens. | ||
| assert_eq!(reconstruct_shares(&a), RingElement(a_t)); | ||
|
|
||
| // Multiplication |
There was a problem hiding this comment.
done -> all local computations over RSS5
need to be done? -> going from 5-of-5 additive to RSS5 replicated state
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
LGTM. Responded to PR comments.
| use std::ops::{Add, Mul, Sub}; | ||
|
|
||
| /// Number of parties. | ||
| pub const RSS5_PARTIES: usize = 5; |
There was a problem hiding this comment.
+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; |
There was a problem hiding this comment.
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) { |
| /// to `p` uses only slots that `p` holds. | ||
| /// | ||
| /// Taken from Appendix C of Baccarini, Blanton and Yuan. | ||
| const MUL_ASSIGN: [&[usize]; RSS5_SLOTS_HELD] = [ |
There was a problem hiding this comment.
Changing it to MUL_OPERAND_ASSIGN.
| // Dealing and reconstruction agree before any arithmetic happens. | ||
| assert_eq!(reconstruct_shares(&a), RingElement(a_t)); | ||
|
|
||
| // Multiplication |
There was a problem hiding this comment.
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.
Adds
RssShare, a 3-of-5 replicated share type, the 5-party counterpart to the 3-partyShare.What is added:
RssShare<T>=[RingElement<T>; 6]in place ofShare'saandb. Slots are storedrelative 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 fromAppendix C of Baccarini, Blanton and Yuan.