Update everything which uses dkg to the new APIs

This commit is contained in:
Luke Parker
2025-08-18 02:21:31 -04:00
parent b6edc94bcd
commit 72e80c1a3d
11 changed files with 29 additions and 14 deletions

3
Cargo.lock generated
View File

@@ -8483,6 +8483,7 @@ dependencies = [
"ciphersuite", "ciphersuite",
"const-hex", "const-hex",
"dalek-ff-group", "dalek-ff-group",
"dkg-pedpop",
"dockertest", "dockertest",
"env_logger", "env_logger",
"ethereum-serai", "ethereum-serai",
@@ -8667,7 +8668,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"borsh", "borsh",
"ciphersuite", "ciphersuite",
"dkg", "dkg-musig",
"parity-scale-codec", "parity-scale-codec",
"scale-info", "scale-info",
"serai-primitives", "serai-primitives",

View File

@@ -37,6 +37,7 @@ serde_json = { version = "1", default-features = false, features = ["std"] }
ciphersuite = { path = "../crypto/ciphersuite", default-features = false, features = ["std", "ristretto"] } ciphersuite = { path = "../crypto/ciphersuite", default-features = false, features = ["std", "ristretto"] }
transcript = { package = "flexible-transcript", path = "../crypto/transcript", default-features = false, features = ["std"] } transcript = { package = "flexible-transcript", path = "../crypto/transcript", default-features = false, features = ["std"] }
dkg-pedpop = { path = "../crypto/dkg/pedpop", default-features = false }
frost = { package = "modular-frost", path = "../crypto/frost", default-features = false, features = ["ristretto"] } frost = { package = "modular-frost", path = "../crypto/frost", default-features = false, features = ["ristretto"] }
frost-schnorrkel = { path = "../crypto/schnorrkel", default-features = false } frost-schnorrkel = { path = "../crypto/schnorrkel", default-features = false }

View File

@@ -7,11 +7,10 @@ use rand_chacha::ChaCha20Rng;
use transcript::{Transcript, RecommendedTranscript}; use transcript::{Transcript, RecommendedTranscript};
use ciphersuite::group::GroupEncoding; use ciphersuite::group::GroupEncoding;
use dkg_pedpop::*;
use frost::{ use frost::{
curve::{Ciphersuite, Ristretto}, curve::{Ciphersuite, Ristretto},
dkg::{ dkg::{DkgError, Participant, ThresholdParams, ThresholdCore, ThresholdKeys},
DkgError, Participant, ThresholdParams, ThresholdCore, ThresholdKeys, encryption::*, pedpop::*,
},
}; };
use log::info; use log::info;

View File

@@ -19,7 +19,7 @@ workspace = true
zeroize = { version = "^1.5", features = ["derive"], optional = true } zeroize = { version = "^1.5", features = ["derive"], optional = true }
ciphersuite = { path = "../../../crypto/ciphersuite", version = "0.4", default-features = false, features = ["alloc", "ristretto"] } ciphersuite = { path = "../../../crypto/ciphersuite", version = "0.4", default-features = false, features = ["alloc", "ristretto"] }
dkg = { path = "../../../crypto/dkg", version = "0.5", default-features = false } dkg-musig = { path = "../../../crypto/dkg/musig", default-features = false }
borsh = { version = "1", default-features = false, features = ["derive", "de_strict_order"], optional = true } borsh = { version = "1", default-features = false, features = ["derive", "de_strict_order"], optional = true }
serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true } serde = { version = "1", default-features = false, features = ["derive", "alloc"], optional = true }
@@ -33,7 +33,7 @@ sp-std = { git = "https://github.com/serai-dex/substrate", default-features = fa
serai-primitives = { path = "../../primitives", default-features = false } serai-primitives = { path = "../../primitives", default-features = false }
[features] [features]
std = ["zeroize", "ciphersuite/std", "dkg/std", "borsh?/std", "serde?/std", "scale/std", "scale-info/std", "sp-core/std", "sp-std/std", "serai-primitives/std"] std = ["zeroize", "ciphersuite/std", "dkg-musig/std", "borsh?/std", "serde?/std", "scale/std", "scale-info/std", "sp-core/std", "sp-std/std", "serai-primitives/std"]
borsh = ["dep:borsh", "serai-primitives/borsh"] borsh = ["dep:borsh", "serai-primitives/borsh"]
serde = ["dep:serde", "serai-primitives/serde"] serde = ["dep:serde", "serai-primitives/serde"]
default = ["std"] default = ["std"]

View File

@@ -107,8 +107,13 @@ impl Zeroize for KeyPair {
} }
/// The MuSig context for a validator set. /// The MuSig context for a validator set.
pub fn musig_context(set: ValidatorSet) -> Vec<u8> { pub fn musig_context(set: ValidatorSet) -> [u8; 32] {
[b"ValidatorSets-musig_key".as_ref(), &set.encode()].concat() let mut context = [0; 32];
const DST: &[u8] = b"ValidatorSets-musig_key";
context[.. DST.len()].copy_from_slice(DST);
let set = set.encode();
context[DST.len() .. (DST.len() + set.len())].copy_from_slice(set.len());
context
} }
/// The MuSig public key for a validator set. /// The MuSig public key for a validator set.
@@ -122,7 +127,7 @@ pub fn musig_key(set: ValidatorSet, set_keys: &[Public]) -> Public {
.expect("invalid participant"), .expect("invalid participant"),
); );
} }
Public(dkg::musig::musig_key::<Ristretto>(&musig_context(set), &keys).unwrap().to_bytes()) Public(dkg_musig::musig_key_vartime::<Ristretto>(musig_context(set), &keys).unwrap().to_bytes())
} }
/// The message for the set_keys signature. /// The message for the set_keys signature.

View File

@@ -26,7 +26,7 @@ rand_core = { version = "0.6", default-features = false }
blake2 = "0.10" blake2 = "0.10"
ciphersuite = { path = "../../crypto/ciphersuite", default-features = false, features = ["ristretto", "secp256k1"] } ciphersuite = { path = "../../crypto/ciphersuite", default-features = false, features = ["ristretto", "secp256k1"] }
schnorrkel = "0.11" schnorrkel = "0.11"
dkg = { path = "../../crypto/dkg", default-features = false, features = ["tests"] } dkg = { path = "../../crypto/dkg", default-features = false }
messages = { package = "serai-processor-messages", path = "../../processor/messages" } messages = { package = "serai-processor-messages", path = "../../processor/messages" }

View File

@@ -24,7 +24,7 @@ rand_core = { version = "0.6", default-features = false, features = ["getrandom"
curve25519-dalek = "4" curve25519-dalek = "4"
ciphersuite = { path = "../../crypto/ciphersuite", default-features = false, features = ["secp256k1", "ristretto"] } ciphersuite = { path = "../../crypto/ciphersuite", default-features = false, features = ["secp256k1", "ristretto"] }
dkg = { path = "../../crypto/dkg", default-features = false, features = ["tests"] } dkg = { path = "../../crypto/dkg", default-features = false }
bitcoin-serai = { path = "../../networks/bitcoin" } bitcoin-serai = { path = "../../networks/bitcoin" }

View File

@@ -3,7 +3,7 @@ use std::{
time::{SystemTime, Duration}, time::{SystemTime, Duration},
}; };
use dkg::{Participant, tests::clone_without}; use dkg::Participant;
use messages::{coordinator::*, SubstrateContext}; use messages::{coordinator::*, SubstrateContext};

View File

@@ -1,6 +1,6 @@
use std::{collections::HashMap, time::SystemTime}; use std::{collections::HashMap, time::SystemTime};
use dkg::{Participant, ThresholdParams, tests::clone_without}; use dkg::{Participant, ThresholdParams};
use serai_client::{ use serai_client::{
primitives::{BlockHash, PublicKey, EXTERNAL_NETWORKS}, primitives::{BlockHash, PublicKey, EXTERNAL_NETWORKS},

View File

@@ -15,6 +15,15 @@ mod send;
pub(crate) const COORDINATORS: usize = 4; pub(crate) const COORDINATORS: usize = 4;
pub(crate) const THRESHOLD: usize = ((COORDINATORS * 2) / 3) + 1; pub(crate) const THRESHOLD: usize = ((COORDINATORS * 2) / 3) + 1;
fn clone_without<K: Clone + core::cmp::Eq + core::hash::Hash, V: Clone>(
map: &HashMap<K, V>,
without: &K,
) -> HashMap<K, V> {
let mut res = map.clone();
res.remove(without).unwrap();
res
}
fn new_test( fn new_test(
network: ExternalNetworkId, network: ExternalNetworkId,
) -> (Vec<(Handles, <Ristretto as Ciphersuite>::F)>, DockerTest) { ) -> (Vec<(Handles, <Ristretto as Ciphersuite>::F)>, DockerTest) {

View File

@@ -3,7 +3,7 @@ use std::{
time::{SystemTime, Duration}, time::{SystemTime, Duration},
}; };
use dkg::{Participant, tests::clone_without}; use dkg::Participant;
use messages::{sign::SignId, SubstrateContext}; use messages::{sign::SignId, SubstrateContext};