Skip to content

Commit

Permalink
Merge final_frost
Browse files Browse the repository at this point in the history
  • Loading branch information
Fiono11 committed May 17, 2024
2 parents 443a40f + f67a4f3 commit 38a7a86
Show file tree
Hide file tree
Showing 8 changed files with 754 additions and 679 deletions.
14 changes: 5 additions & 9 deletions benches/olaf_benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@ use criterion::criterion_main;

mod olaf_benches {
use criterion::{criterion_group, BenchmarkId, Criterion};
use schnorrkel::{olaf::AllMessage, Keypair, PublicKey};
use schnorrkel::keys::{PublicKey, Keypair};
use schnorrkel::olaf::simplpedpop::AllMessage;

fn benchmark_simplpedpop(c: &mut Criterion) {
let mut group = c.benchmark_group("SimplPedPoP");

group
.sample_size(10)
.warm_up_time(std::time::Duration::from_secs(2))
.measurement_time(std::time::Duration::from_secs(300));

for &n in [3, 10, 100, 1000].iter() {
let participants = n;
let threshold = (n * 2 + 2) / 3;

let keypairs: Vec<Keypair> = (0..participants).map(|_| Keypair::generate()).collect();
let public_keys: Vec<PublicKey> = keypairs.iter().map(|kp| kp.public).collect();

// Each participant creates an AllMessage
let mut all_messages = Vec::new();
let mut all_messages: Vec<AllMessage> = Vec::new();

for i in 0..participants {
let message: AllMessage = keypairs[i]
let message = keypairs[i]
.simplpedpop_contribute_all(threshold as u16, public_keys.clone())
.unwrap();
all_messages.push(message);
Expand Down
18 changes: 5 additions & 13 deletions benches/schnorr_benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ mod schnorr_benches {
let msg: &[u8] = b"";

let ctx = signing_context(b"this signature does this thing");
c.bench_function("Schnorr signing", move |b| {
b.iter(|| keypair.sign(ctx.bytes(msg)))
});
c.bench_function("Schnorr signing", move |b| b.iter(|| keypair.sign(ctx.bytes(msg))));
}

fn verify(c: &mut Criterion) {
Expand All @@ -47,10 +45,8 @@ mod schnorr_benches {
let keypairs: Vec<Keypair> = (0..size).map(|_| Keypair::generate()).collect();
let msg: &[u8] = b"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
let ctx = signing_context(b"this signature does this thing");
let signatures: Vec<Signature> = keypairs
.iter()
.map(|key| key.sign(ctx.bytes(msg)))
.collect();
let signatures: Vec<Signature> =
keypairs.iter().map(|key| key.sign(ctx.bytes(msg))).collect();
let public_keys: Vec<PublicKey> = keypairs.iter().map(|key| key.public).collect();
b.iter(|| {
let transcripts = ::std::iter::once(ctx.bytes(msg)).cycle().take(size);
Expand All @@ -61,9 +57,7 @@ mod schnorr_benches {
}

fn key_generation(c: &mut Criterion) {
c.bench_function("Schnorr keypair generation", move |b| {
b.iter(|| Keypair::generate())
});
c.bench_function("Schnorr keypair generation", move |b| b.iter(|| Keypair::generate()));
}

criterion_group! {
Expand All @@ -77,6 +71,4 @@ mod schnorr_benches {
}
}

criterion_main!(
schnorr_benches::schnorr_benches,
);
criterion_main!(schnorr_benches::schnorr_benches,);
48 changes: 0 additions & 48 deletions src/olaf/errors.rs

This file was deleted.

39 changes: 21 additions & 18 deletions src/olaf/mod.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
//! Implementation of the Olaf protocol (<https://eprint.iacr.org/2023/899>), which is composed of the Distributed
//! Key Generation (DKG) protocol SimplPedPoP and the Threshold Signing protocol FROST.
/// Implementation of the SimplPedPoP protocol.
pub mod simplpedpop;

use curve25519_dalek::{constants::RISTRETTO_BASEPOINT_POINT, RistrettoPoint, Scalar};
use crate::{PublicKey, SecretKey};
use crate::context::SigningTranscript;
use merlin::Transcript;
use zeroize::ZeroizeOnDrop;
use crate::{context::SigningTranscript, Keypair, PublicKey};

pub mod errors;
pub mod simplpedpop;
mod tests;
mod types;
pub(super) const MINIMUM_THRESHOLD: u16 = 2;
pub(super) const GENERATOR: RistrettoPoint = RISTRETTO_BASEPOINT_POINT;
pub(super) const COMPRESSED_RISTRETTO_LENGTH: usize = 32;
pub(crate) const SCALAR_LENGTH: usize = 32;

pub use types::AllMessage;
/// The threshold public key generated in the SimplPedPoP protocol, used to validate the threshold signatures of the FROST protocol.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct ThresholdPublicKey(pub(crate) PublicKey);

const MINIMUM_THRESHOLD: u16 = 2;
const GENERATOR: RistrettoPoint = RISTRETTO_BASEPOINT_POINT;
/// The verifying share of a participant generated in the SimplPedPoP protocol, used to verify its signatures shares in the FROST protocol.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct VerifyingShare(pub(crate) PublicKey);

/// The group public key generated by the SimplPedPoP protocol.
pub struct GroupPublicKey(PublicKey);
/// The verifying share of a participant in the SimplPedPoP protocol, used to verify its signature share.
pub struct VerifyingShare(PublicKey);
/// The signing share of a participant in the SimplPedPoP protocol, used to produce its signature share.
pub struct SigningShare(SecretKey);
/// The signing keypair of a participant generated in the SimplPedPoP protocol, used to produce its signatures shares in the FROST protocol.
#[derive(Clone, Debug, ZeroizeOnDrop)]
pub struct SigningKeypair(pub(crate) Keypair);

/// The identifier of a participant in the Olaf protocol.
#[derive(Clone, Copy)]
pub struct Identifier(Scalar);
/// The identifier of a participant, which must be the same in the SimplPedPoP protocol and in the FROST protocol.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct Identifier(pub(crate) Scalar);

impl Identifier {
pub(super) fn generate(recipients_hash: &[u8; 16], index: u16) -> Identifier {
Expand Down
Loading

0 comments on commit 38a7a86

Please sign in to comment.