Skip to content

Commit

Permalink
Merge #33
Browse files Browse the repository at this point in the history
33: feat: eddsa signing protocol r=jfdreis a=jfdreis

Implementation of the State Machines for the EdDSA signature

## Motivation

<!--
Explain the context and why you're making that change. What is the problem
you're trying to solve? In some cases there is not a problem and this can be
thought of as being the motivation for your change.
-->

## Solution

<!--
Summarize the solution and provide any necessary context needed to understand
the code change.
-->


Fixes #
Design discussion issue (if applicable) #

## Merge requirement checklist

* [ ] [CONTRIBUTING](https://github.com/NillionNetwork/nillion/blob/main/CONTRIBUTING.md) guidelines followed
* [x] Unit tests added/updated (if applicable)
* [ ] Breaking change analysis completed (if applicable). "Will this change require all network cluster operators to update? Does it break public APIs?"
* [ ] For new features or breaking changes, created a documentation issue in [nillion-docs](https://github.com/NillionNetwork/nillion-docs/issues/new/choose)


Co-authored-by: jfdreis <[email protected]>
  • Loading branch information
nilogy-bors[bot] and jfdreis authored Feb 21, 2025
2 parents 9949195 + 9b91df2 commit df002d1
Show file tree
Hide file tree
Showing 14 changed files with 411 additions and 78 deletions.
82 changes: 17 additions & 65 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/client-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
key-share = { version = "0.5.0", default-features = false, features = ["spof"] }
key-share = { version = "0.6.0", default-features = false, features = ["spof"] }

basic-types = { path = "../basic-types" }
threshold-keypair = { path = "../../libs/threshold-keypair", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion libs/execution-engine/mpc-vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ rstest = "0.21.0"
serde = { version = "1", features = ["derive"] }
test-programs = { path = "../../../nada-lang/test-programs" }
mpc-vm = { path = ".", features = ["simulator"] }
cggmp21 = { version = "0.5.0", features = ["curve-secp256k1"] }
cggmp21 = { version = "0.6.0", features = ["curve-secp256k1"] }

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion libs/nada-value/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
anyhow = "1.0.86"
enum-as-inner = "0.6.1"
indexmap = { version = "2.6.0" }
key-share = { version = "0.5.0", default-features = false, features = ["spof"] }
key-share = { version = "0.6.0", default-features = false, features = ["spof"] }
generic-ec = { version = "0.4.2", default-features = false, features = ["alloc", "curve-secp256k1"] }
givre = { version = "0.2.0", features = ["ciphersuite-secp256k1", "ciphersuite-ed25519", "spof", "cggmp21-keygen"] }
num-bigint = "0.4.6"
Expand Down
8 changes: 5 additions & 3 deletions libs/protocols/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ edition = "2021"
[dependencies]
anyhow = "1"
itertools = "0.13"
key-share = { version = "0.5.0", default-features = false, features = ["spof"] }
key-share = { version = "0.6.0", default-features = false, features = ["spof"] }
num-bigint = "0.4"
rand = "0.8"
rand_chacha = "0.3.1"
rayon = { version = "1.10", optional = true }
round-based = "0.3"
round-based = "0.4"
serde = { version = "1", features = ["derive"] }
thiserror = "1"
uuid = { version = "1.10", features = ["v4"], optional = true }
Expand All @@ -24,12 +24,14 @@ state-machine-derive = { path = "../state-machine-derive" }
state-machine-macros = { path = "../state-machine-macros" }

threshold-keypair = { path = "../threshold-keypair" }
cggmp21 = { version = "0.5.0", features = ["curve-secp256k1", "state-machine"] }
cggmp21 = { version = "0.6.0", features = ["curve-secp256k1", "state-machine"] }
gmp-mpfr-sys = { version = "1.6.4", features = ["force-cross"] }
sha2 = "0.10"
serde_json = "1"
once_cell = "1.20.1"

givre = { version = "0.2.0", features = ["ciphersuite-ed25519", "full-signing", "serde" ] }

[dev-dependencies]
criterion = "0.5.1"
num-bigint = "0.4.6"
Expand Down
1 change: 1 addition & 0 deletions libs/protocols/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub mod multiplication;
pub mod random;
pub mod reveal;
pub mod threshold_ecdsa;
pub mod threshold_eddsa;

#[cfg(any(test, feature = "validation"))]
pub mod simulator;
6 changes: 3 additions & 3 deletions libs/protocols/src/threshold_ecdsa/signing/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl EcdsaSignProtocol {

impl Protocol for EcdsaSignProtocol {
type State = EcdsaSignState;
type PrepareOutput = EcdsSignConfig;
type PrepareOutput = EcdsaSignConfig;

fn prepare(&self, parties: &[PartyId]) -> Result<Self::PrepareOutput, Error> {
let sorted_parties = SortedParties::new(parties.to_vec());
Expand All @@ -76,7 +76,7 @@ impl Protocol for EcdsaSignProtocol {
private_key_shares.insert(party_id.clone(), pk_share.clone());
}

Ok(EcdsSignConfig {
Ok(EcdsaSignConfig {
eid: self.eid.clone(),
parties: parties.to_vec(),
private_key_shares,
Expand Down Expand Up @@ -112,7 +112,7 @@ impl Protocol for EcdsaSignProtocol {
}

/// The internal configuration of a EcdsSignConfig protocol.
struct EcdsSignConfig {
struct EcdsaSignConfig {
eid: Vec<u8>,
parties: Vec<PartyId>,
private_key_shares: PartyShares<ThresholdPrivateKeyShare<Secp256k1>>,
Expand Down
4 changes: 4 additions & 0 deletions libs/protocols/src/threshold_eddsa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Signing protocol

- This protocol is the main singing protocol of the FROST EdDSA Signing protocol from the [givre](https://docs.rs/givre/latest/givre/index.html) library.
- It generates a signature that is sent to the client.
12 changes: 12 additions & 0 deletions libs/protocols/src/threshold_eddsa/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//! Threshold EdDSA protocol
pub mod output;
pub mod state;

pub use state::*;
#[cfg(test)]
pub mod test;

use state_machine::StateMachine;

/// The Eddsa Signing state machine.
pub type EddsaSignStateMachine = StateMachine<EddsaSignState>;
28 changes: 28 additions & 0 deletions libs/protocols/src/threshold_eddsa/output.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! Outputs for the EdDSA signing protocol.
use givre::signing::round2::SigningError;
use std::fmt::Display;
use threshold_keypair::signature::EddsaSignature;

/// The EdDSA signing output.
pub enum EddsaSignatureOutput {
/// The protocol was successful.
Success {
/// The output elements.
element: EddsaSignature,
},

/// This or a subprotocol aborted by chance.
Abort {
/// The reason why it aborted
reason: SigningError,
},
}

impl Display for EddsaSignatureOutput {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Success { .. } => write!(f, "Success"),
Self::Abort { .. } => write!(f, "Abort"),
}
}
}
Loading

0 comments on commit df002d1

Please sign in to comment.