Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
rust:
- 1.83.0
- 1.85.0
target:
- wasm32-unknown-unknown
steps:
Expand All @@ -37,7 +37,7 @@ jobs:
strategy:
matrix:
rust:
- 1.83.0
- 1.85.0
target:
- x86_64-unknown-linux-gnu
steps:
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
matrix:
include:
- target: x86_64-unknown-linux-gnu
rust: 1.83.0 # MSRV
rust: 1.85.0 # MSRV
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@v1
Expand All @@ -98,7 +98,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.83.0 # MSRV
toolchain: 1.85.0 # MSRV
components: clippy
override: true
profile: minimal
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
name = "synedrion"
authors = ['Entropy Cryptography <engineering@entropy.xyz>']
version = "0.4.0-dev"
edition = "2021"
rust-version = "1.83"
edition = "2024"
rust-version = "1.85"
license = "AGPL-3.0-or-later"
description = "Threshold signing library based on Canetti-Gennaro-Goldfeder-Makriyannis-Peled '24 scheme"
repository = "https://github.com/entropyxyz/synedrion"
readme = "README.md"
categories = ["cryptography", "no-std"]

[dependencies]
manul = { git = "https://github.com/entropyxyz/manul.git", rev = "d23fcb8cc9e88729a55006874c464d918197a965" }
manul = { git = "https://github.com/entropyxyz/manul.git", rev = "4bed1944dc225c51c880330baba74f1e514c9339" }
signature = { version = "2", default-features = false }
rand_core = { version = "0.6.4", default-features = false }
digest = { version = "0.10", default-features = false, features = ["alloc"] }
Expand Down Expand Up @@ -44,7 +44,7 @@ sha3 = { version = "0.10", optional = true, default-features = false }
dudect-bencher = { version = "0.6", optional = true }

[dev-dependencies]
manul = { git = "https://github.com/entropyxyz/manul.git", rev = "d23fcb8cc9e88729a55006874c464d918197a965", features = ["dev"] }
manul = { git = "https://github.com/entropyxyz/manul.git", rev = "4bed1944dc225c51c880330baba74f1e514c9339", features = ["dev"] }
serde_assert = "0.8"
tokio = { version = "1", features = ["rt", "sync", "time", "macros"] }
rand = { version = "0.8", features = ["getrandom"] }
Expand Down
6 changes: 3 additions & 3 deletions benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::collections::BTreeSet;

use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
use elliptic_curve::FieldBytes;
use manul::{
dev::{run_sync, BinaryFormat, TestSessionParams, TestSigner, TestVerifier},
dev::{BinaryFormat, TestSessionParams, TestSigner, TestVerifier, run_sync},
signature::Keypair,
};
use rand_core::{OsRng, RngCore};
use synedrion::{dev::TestParams, AuxGen, AuxInfo, InteractiveSigning, KeyInit, KeyShare, SchemeParams};
use synedrion::{AuxGen, AuxInfo, InteractiveSigning, KeyInit, KeyShare, SchemeParams, dev::TestParams};

fn bench_happy_paths(c: &mut Criterion) {
let mut group = c.benchmark_group("happy path");
Expand Down
2 changes: 1 addition & 1 deletion benches/zk_proofs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::LazyLock;

use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
use rand_core::OsRng;
use synedrion::{k256::ProductionParams112, private_benches::zk_proofs::*};

Expand Down
2 changes: 1 addition & 1 deletion src/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod bip32;

pub use ecdsa::RecoverableSignature;

pub(crate) use arithmetic::{chain_curve, secret_split, Point, Scalar};
pub(crate) use arithmetic::{Point, Scalar, chain_curve, secret_split};

#[cfg(feature = "bip32")]
pub use bip32::{DeriveChildKey, PublicTweakable, SecretTweakable};
Expand Down
18 changes: 9 additions & 9 deletions src/curve/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign};
use digest::XofReader;
use ecdsa::VerifyingKey;
use elliptic_curve::{
Curve, CurveArithmetic, Field, FieldBytes, FieldBytesSize, Group, NonZeroScalar, PrimeField, ScalarPrimitive,
bigint::{ArrayEncoding, Concat, NonZero, Split, Zero},
generic_array::{typenum::marker_traits::Unsigned, GenericArray},
generic_array::{GenericArray, typenum::marker_traits::Unsigned},
group::Curve as _,
ops::Reduce,
point::AffineCoordinates,
scalar::FromUintUnchecked,
sec1::{EncodedPoint, FromEncodedPoint, ModulusSize, ToEncodedPoint},
subtle::{Choice, ConditionallySelectable, CtOption},
Curve, CurveArithmetic, Field, FieldBytes, FieldBytesSize, Group, NonZeroScalar, PrimeField, ScalarPrimitive,
};
use rand_core::CryptoRngCore;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
Expand All @@ -24,7 +24,7 @@ use ::{ecdsa::SigningKey, elliptic_curve::SecretKey};

use crate::{
params::SchemeParams,
tools::{hashing::Chain, BoxedRng, Secret},
tools::{Secret, hashing::Chain},
uint::BoxedEncoding,
};

Expand Down Expand Up @@ -67,12 +67,12 @@ impl<P: SchemeParams> Scalar<P> {
Self(backend_scalar)
}

pub fn random(rng: &mut dyn CryptoRngCore) -> Self {
Self(ScalarPrimitive::<P::Curve>::random(&mut BoxedRng(rng)).into())
pub fn random(rng: &mut impl CryptoRngCore) -> Self {
Self(ScalarPrimitive::<P::Curve>::random(rng).into())
}

pub fn random_nonzero(rng: &mut dyn CryptoRngCore) -> Self {
Self(*NonZeroScalar::<P::Curve>::random(&mut BoxedRng(rng)).as_ref())
pub fn random_nonzero(rng: &mut impl CryptoRngCore) -> Self {
Self(*NonZeroScalar::<P::Curve>::random(rng).as_ref())
}

pub fn mul_by_generator(&self) -> Point<P> {
Expand Down Expand Up @@ -156,7 +156,7 @@ impl<P: SchemeParams> Secret<Scalar<P>> {
}

pub(crate) fn secret_split<P: SchemeParams>(
rng: &mut dyn CryptoRngCore,
rng: &mut impl CryptoRngCore,
scalar: Secret<Scalar<P>>,
num: usize,
) -> Vec<Secret<Scalar<P>>> {
Expand Down Expand Up @@ -523,7 +523,7 @@ mod test {
use rand_chacha::ChaChaRng;

use super::Scalar;
use crate::{dev::TestParams, SchemeParams};
use crate::{SchemeParams, dev::TestParams};

#[test_log::test]
fn to_and_from_bytes() {
Expand Down
4 changes: 2 additions & 2 deletions src/curve/bip32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use alloc::vec::Vec;

use bip32::{ChainCode, DerivationPath, PrivateKeyBytes, PublicKey as _};
use digest::Digest;
use ecdsa::{hazmat::DigestPrimitive, VerifyingKey};
use ecdsa::{VerifyingKey, hazmat::DigestPrimitive};
use elliptic_curve::{
sec1::{FromEncodedPoint, ModulusSize, ToEncodedPoint},
Curve, CurveArithmetic, PrimeCurve,
sec1::{FromEncodedPoint, ModulusSize, ToEncodedPoint},
};

/// Used for deriving child keys from a parent type.
Expand Down
7 changes: 2 additions & 5 deletions src/curve/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ use rand_core::CryptoRngCore;
use super::arithmetic::{Point, Scalar};
use crate::SchemeParams;

#[cfg(test)]
use crate::tools::BoxedRng;

/// A wrapper for a signature and public key recovery info.
#[derive(Debug, Clone)]
pub struct RecoverableSignature<P: SchemeParams> {
Expand All @@ -22,8 +19,8 @@ where
P: SchemeParams,
{
#[cfg(test)]
pub(crate) fn random(rng: &mut dyn CryptoRngCore) -> Option<Self> {
let sk = ecdsa::SigningKey::random(&mut BoxedRng(rng));
pub(crate) fn random(rng: &mut impl CryptoRngCore) -> Option<Self> {
let sk = ecdsa::SigningKey::random(rng);
let (signature, recovery_id) = sk.sign_recoverable(b"test message").ok()?;
Some(Self { signature, recovery_id })
}
Expand Down
12 changes: 7 additions & 5 deletions src/entities/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use manul::{protocol::PartyId, session::LocalError, utils::SerializableMap};
use rand_core::CryptoRngCore;

use crate::{
curve::{secret_split, Point, Scalar},
curve::{Point, Scalar, secret_split},
paillier::{
PublicKeyPaillier, PublicKeyPaillierWire, RPParams, RPParamsWire, SecretKeyPaillier, SecretKeyPaillierWire,
},
Expand Down Expand Up @@ -382,7 +382,7 @@ mod tests {
use rand_core::OsRng;

use super::KeyShare;
use crate::{dev::TestParams, SchemeParams};
use crate::{SchemeParams, dev::TestParams};

#[test]
fn key_share_centralized() {
Expand All @@ -397,8 +397,10 @@ mod tests {
&ids,
Some(&sk),
);
assert!(shares
.values()
.all(|share| &share.verifying_key() == sk.verifying_key()));
assert!(
shares
.values()
.all(|share| &share.verifying_key() == sk.verifying_key())
);
}
}
2 changes: 1 addition & 1 deletion src/entities/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use manul::protocol::PartyId;
use serde::{Deserialize, Serialize};

use crate::{
params::{chain_scheme_params, SchemeParams},
params::{SchemeParams, chain_scheme_params},
tools::hashing::{Chain, HashOutput, Hasher},
};

Expand Down
4 changes: 2 additions & 2 deletions src/entities/threshold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ use crate::{
curve::{Point, Scalar},
params::SchemeParams,
tools::{
sss::{interpolation_coeff, shamir_evaluation_points, shamir_join_points, shamir_split, ShareId},
Secret,
sss::{ShareId, interpolation_coeff, shamir_evaluation_points, shamir_join_points, shamir_split},
},
};

#[cfg(feature = "bip32")]
use crate::curve::{apply_tweaks_public, derive_tweaks, DeriveChildKey, PublicTweakable, SecretTweakable};
use crate::curve::{DeriveChildKey, PublicTweakable, SecretTweakable, apply_tweaks_public, derive_tweaks};

/// A threshold variant of the key share, where any `threshold` shares our of the total number
/// is enough to perform signing.
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ pub use entities::{AuxInfo, KeyShare, KeyShareChange, ThresholdKeyShare};
pub use paillier::PaillierParams;
pub use params::SchemeParams;
pub use protocols::{
AuxGen, AuxGenAssociatedData, AuxGenProtocol, InteractiveSigning, InteractiveSigningAssociatedData,
InteractiveSigningProtocol, KeyInit, KeyInitAssociatedData, KeyInitProtocol, KeyRefresh, KeyRefreshAssociatedData,
KeyRefreshProtocol, KeyResharing, KeyResharingProtocol, NewHolder, OldHolder, PrehashedMessage,
AuxGen, AuxGenProtocol, AuxGenSharedData, InteractiveSigning, InteractiveSigningProtocol,
InteractiveSigningSharedData, KeyInit, KeyInitProtocol, KeyInitSharedData, KeyRefresh, KeyRefreshProtocol,
KeyRefreshSharedData, KeyResharing, KeyResharingProtocol, NewHolder, OldHolder, PrehashedMessage,
};
pub use uint::{BoxedEncoding, Extendable, MulWide};

Expand Down
8 changes: 4 additions & 4 deletions src/paillier/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use core::{
};

use crypto_bigint::{
Integer, Invert, Monty,
modular::Retrieve,
subtle::{Choice, ConditionallyNegatable},
Integer, Invert, Monty,
};
use rand_core::CryptoRngCore;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -48,7 +48,7 @@ impl<P: PaillierParams> Randomizer<P> {
}
}

pub fn random(rng: &mut dyn CryptoRngCore, pk: &PublicKeyPaillier<P>) -> Self {
pub fn random(rng: &mut impl CryptoRngCore, pk: &PublicKeyPaillier<P>) -> Self {
let randomizer = Secret::init_with(|| pk.random_invertible_residue(rng));
Self::new(pk, randomizer)
}
Expand Down Expand Up @@ -197,7 +197,7 @@ impl<P: PaillierParams> Ciphertext<P> {

/// Encrypts the plaintext with a random randomizer.
#[cfg(any(test, feature = "private-benches"))]
pub fn new(rng: &mut dyn CryptoRngCore, pk: &PublicKeyPaillier<P>, plaintext: &SecretSigned<P::Uint>) -> Self {
pub fn new(rng: &mut impl CryptoRngCore, pk: &PublicKeyPaillier<P>, plaintext: &SecretSigned<P::Uint>) -> Self {
Self::new_with_randomizer(pk, plaintext, &Randomizer::random(rng, pk))
}

Expand Down Expand Up @@ -368,7 +368,7 @@ where

#[cfg(test)]
mod tests {
use crypto_bigint::{subtle::ConditionallySelectable, AddMod, Bounded, Integer, NonZero};
use crypto_bigint::{AddMod, Bounded, Integer, NonZero, subtle::ConditionallySelectable};
use rand_core::OsRng;
use zeroize::Zeroize;

Expand Down
12 changes: 6 additions & 6 deletions src/paillier/keys.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use core::fmt::Debug;

use crypto_bigint::{
modular::Retrieve,
subtle::{Choice, ConditionallySelectable},
CheckedAdd, CheckedSub, Integer, InvMod, Invert, Monty, NonZero, Odd, PowBoundedExp, ShrVartime, Square,
WrappingAdd,
modular::Retrieve,
subtle::{Choice, ConditionallySelectable},
};
use digest::XofReader;
use rand_core::CryptoRngCore;
Expand All @@ -26,13 +26,13 @@ pub(crate) struct SecretKeyPaillierWire<P: PaillierParams> {

impl<P: PaillierParams> SecretKeyPaillierWire<P> {
#[cfg(test)]
pub fn random_small(rng: &mut dyn CryptoRngCore) -> Self {
pub fn random_small(rng: &mut impl CryptoRngCore) -> Self {
Self {
primes: SecretPrimesWire::<P>::random_small_paillier_blum(rng),
}
}

pub fn random(rng: &mut dyn CryptoRngCore) -> Self {
pub fn random(rng: &mut impl CryptoRngCore) -> Self {
Self {
primes: SecretPrimesWire::<P>::random_paillier_blum(rng),
}
Expand Down Expand Up @@ -264,7 +264,7 @@ where
/// Returns a random invertible $w ∈ [0, N)$ such that $w$ is not a square modulo $N$,
/// where $N$ is the public key
/// (or, equivalently, such that the Jacobi symbol $(w|N) = -1$).
pub fn random_nonsquare_residue(&self, rng: &mut dyn CryptoRngCore) -> P::Uint {
pub fn random_nonsquare_residue(&self, rng: &mut impl CryptoRngCore) -> P::Uint {
/*
(The sampling method and the explanation by Thomas Pornin)

Expand Down Expand Up @@ -387,7 +387,7 @@ impl<P: PaillierParams> PublicKeyPaillier<P> {
}

/// Returns a uniformly chosen number in range $[0, N)$ such that it is invertible modulo $N$, in Montgomery form.
pub fn random_invertible_residue(&self, rng: &mut dyn CryptoRngCore) -> P::Uint {
pub fn random_invertible_residue(&self, rng: &mut impl CryptoRngCore) -> P::Uint {
self.modulus.random_invertible_residue(rng)
}

Expand Down
2 changes: 1 addition & 1 deletion src/paillier/params.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crypto_bigint::{
Bounded, Gcd, Integer, InvMod, Invert, PowBoundedExp, RandomBits, RandomMod,
modular::Retrieve,
subtle::{ConditionallyNegatable, ConditionallySelectable, ConstantTimeGreater, CtOption},
Bounded, Gcd, Integer, InvMod, Invert, PowBoundedExp, RandomBits, RandomMod,
};
use crypto_primes::RandomPrimeWithRng;
use zeroize::Zeroize;
Expand Down
Loading
Loading