Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inv-tshare: Threshold (re-)sharing protocol #542

Merged
merged 74 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
b0d074b
inv-tshare: Threshold (re-)sharing protocol
Jul 20, 2024
acbfc83
Include Lagrange
emmorais Aug 19, 2024
b1dee3d
Call Tshare once for sharing k
emmorais Aug 21, 2024
44a983c
Include tshare for chi
emmorais Aug 22, 2024
8008d7e
Add test for lagrange coefficient at zero, conversion works
emmorais Aug 30, 2024
2acd393
Create unit test to validate auxinfo ids
emmorais Aug 30, 2024
edca2a2
Unit test for checking auxinfo id consistency
emmorais Aug 30, 2024
37f88fe
Conver test cases for the input
emmorais Aug 30, 2024
a7d6aef
Check constant terms consistency
emmorais Aug 30, 2024
3b038d5
Check constant terms
emmorais Aug 30, 2024
9f32b5f
Check the share is consistent
emmorais Aug 30, 2024
9de4431
Fmt
emmorais Sep 3, 2024
798ecca
Warnings and clippy
emmorais Sep 3, 2024
4a691a8
Public key checks
emmorais Sep 6, 2024
0a95528
Include unit test for lagrange at zero
emmorais Sep 6, 2024
b680b94
Fmt, clippy and warnings
emmorais Sep 6, 2024
609a91e
More warnings
emmorais Sep 6, 2024
ee4ea23
Merge branch 'main' into inv-tshare
emmorais Sep 6, 2024
1924882
Clippy
emmorais Sep 6, 2024
7a47396
Documentation
emmorais Sep 6, 2024
a90c0d4
Fix the public key validation
emmorais Sep 8, 2024
830dafd
Fix saved public key values, protocol working
emmorais Sep 8, 2024
bcd66f9
Use participant_coordinate instead of incrementing the index
emmorais Sep 10, 2024
272d067
Fmt
emmorais Sep 10, 2024
89d77c0
Remove unused module
emmorais Sep 10, 2024
64bef43
Testing cases for the full protocol
emmorais Sep 12, 2024
8068f07
Full protocol test for 2/3 threshold sharing
emmorais Sep 13, 2024
516dae2
Negative test cases
emmorais Sep 13, 2024
edb525d
Refactor the t-out-of-t sub-protocol
emmorais Sep 13, 2024
4e213bd
Remove unused code
emmorais Sep 13, 2024
b68c071
More adjustments
emmorais Sep 13, 2024
6dbc750
Introduce dedicated type for evaluations
emmorais Sep 13, 2024
b478441
Remove old TODOs
emmorais Sep 13, 2024
0207eac
Remove unneeded variable
emmorais Sep 16, 2024
eeb06eb
Use Scalar instead of BigInt
emmorais Sep 16, 2024
80f605a
Remove old TODOs
emmorais Sep 16, 2024
b4b948e
Minor adjustments
emmorais Sep 16, 2024
ae88cb1
Remove unneeded operation in share.rs
emmorais Oct 4, 2024
767ca09
Remove unnecessary clone derivation
emmorais Oct 4, 2024
d855355
Remove unnecessary validations
emmorais Oct 4, 2024
ce0977d
Update old comment
emmorais Oct 7, 2024
6fa035f
Add new comment
emmorais Oct 7, 2024
560683c
Update comment
emmorais Oct 7, 2024
b432f0e
Replace Schnorr proofs for all coefficients by a single proof for the…
emmorais Oct 7, 2024
9f70a3d
Fmt
emmorais Oct 7, 2024
679e9c9
Fmt
emmorais Oct 7, 2024
8410c77
Remove public_share from commitment
emmorais Oct 8, 2024
6715a9a
Move encryption of shares one round earlier
emmorais Oct 9, 2024
abf946c
Continue moving encrypted shares to second round
emmorais Oct 9, 2024
7e3b0ac
Renaming variables
emmorais Oct 9, 2024
c578fc9
Remove commented code
emmorais Oct 9, 2024
6550a2b
Minor adjustments
emmorais Oct 9, 2024
fa1c8c5
Add chain_code to keygen output
emmorais Sep 23, 2024
703bc57
Add shift to signature generation
emmorais Sep 25, 2024
1d3a030
Improve error message
emmorais Sep 25, 2024
22496d2
Refactor expect expression
emmorais Sep 25, 2024
37c8ebe
Refactor repeated code
emmorais Sep 25, 2024
387dae7
Refactor the hash calculation
emmorais Sep 25, 2024
1afb305
Distributed chain code finished and included in the transcript
emmorais Sep 26, 2024
81dfbd4
Remove unnecessary copyright
emmorais Sep 26, 2024
0160e10
If CKD fails, try again with incremented counter
emmorais Sep 26, 2024
4cd32aa
Introduce auxiliary macro to xor 256 bits
emmorais Sep 27, 2024
29cd712
Replace keccak by hmac512
emmorais Sep 29, 2024
ce5541e
Introduce first unit test from test vectors
emmorais Sep 30, 2024
8357a0a
Child derivation key unit test from test vectors
emmorais Oct 1, 2024
d9576c6
Clippy
emmorais Oct 1, 2024
0825068
Use CKDOutput instead of tuple
emmorais Oct 2, 2024
3946c17
Retry master key generation on failure
emmorais Oct 9, 2024
aaa33ad
Merge branch 'main' into inv-tshare
emmorais Oct 10, 2024
e5102ab
Fmt
emmorais Oct 10, 2024
ab5a265
Typo
emmorais Oct 10, 2024
f1cdc3e
n=2 working, but n=3 not
emmorais Oct 14, 2024
1389fe7
Minor adjustments
emmorais Oct 15, 2024
f42dbdc
Create maybe_finish_round2
emmorais Oct 15, 2024
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ sha2 = "0.10.8"
thiserror = "1"
tracing = "0.1.37"
zeroize = "1.5"
itertools = "0.13.0"
sodiumoxide = "0.2.7"

[dependencies.gmp-mpfr-sys]
Expand Down Expand Up @@ -76,4 +77,4 @@ harness = false
# This isn't strictly necessary but helps certain IDEs (Clion) find the code.
[[example]]
name = "threaded_example"
path = "examples/threaded_example/threaded.rs"
path = "examples/threaded_example/threaded.rs"
3 changes: 2 additions & 1 deletion examples/threaded_example/threaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ impl Worker {
let key_shares = self.key_gen_material.retrieve(&key_id).public_key_shares();
let record = self.presign_records.take(&key_id);

let inputs = sign::Input::new(b"hello world", record, key_shares.to_vec(), None);
let threshold = key_shares.len();
let inputs = sign::Input::new(b"hello world", record, key_shares.to_vec(), threshold, None);
self.new_sub_protocol::<SignParticipant>(sid, inputs, key_id)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/broadcast/participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub(crate) struct BroadcastParticipant {
pub(crate) enum BroadcastTag {
AuxinfoR1CommitHash,
KeyGenR1CommitHash,
TshareR1CommitHash,
KeyRefreshR1CommitHash,
PresignR1Ciphertexts,
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ mod protocol;
mod ring_pedersen;
pub mod sign;
pub mod slip0010;
pub mod tshare;
mod utils;
mod zkp;
mod zkstar;
Expand Down
31 changes: 31 additions & 0 deletions src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub enum MessageType {
Auxinfo(AuxinfoMessageType),
/// Keygen messages
Keygen(KeygenMessageType),
/// Tshare messages
Tshare(TshareMessageType),
/// Keyrefresh messages
Keyrefresh(KeyrefreshMessageType),
/// Presign messages
Expand Down Expand Up @@ -68,6 +70,22 @@ pub enum KeygenMessageType {
R3Proof,
}

/// An enum consisting of all tshare message types
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub enum TshareMessageType {
/// Signal to self that we're ready to run the protocol
Ready,
/// A hash commitment to the public keyshare and associated proofs
R1CommitHash,
/// The information committed to in Round 1
R2Decommit,
/// The encrypted private share from a participant to another.
R2PrivateShare,
/// A proof of knowledge of the discrete log of the value decommitted in
/// Round 2
R3Proof,
}

/// An enum consisting of all keyrefresh message types
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub enum KeyrefreshMessageType {
Expand Down Expand Up @@ -211,4 +229,17 @@ impl Message {
}
Ok(())
}

/// Check if the message type is one of the valid options.
pub(crate) fn check_one_of_type(&self, expected_types: &[MessageType]) -> Result<()> {
if !expected_types.contains(&self.message_type()) {
error!(
"A message was misrouted. Expected one of {:?}, Got {:?}",
expected_types,
self.message_type()
);
return Err(InternalError::InternalInvariantFailed);
}
Ok(())
}
}
2 changes: 1 addition & 1 deletion src/participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ pub enum Status {
/// This variant is used by
/// [`InteractiveSignParticipant`](crate::sign::InteractiveSignParticipant)
RunningPresign,
/// Participant completed presign and is running sign.
/// Participant received a ready message and is running tshare.
///
/// This variant is used by
/// [`InteractiveSignParticipant`](crate::sign::InteractiveSignParticipant)
Expand Down
2 changes: 1 addition & 1 deletion src/presign/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ mod tests {

/// Simulate creation of a random presign record. Do not use outside of
/// testing.
fn simulate(rng: &mut StdRng) -> PresignRecord {
pub(crate) fn simulate(rng: &mut StdRng) -> PresignRecord {
let mask_point = CurvePoint::random(StdRng::from_seed(rng.gen()));
let mask_share = Scalar::random(StdRng::from_seed(rng.gen()));
let masked_key_share = Scalar::random(rng);
Expand Down
Loading
Loading