mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 04:09:23 +00:00
Update everything which uses dkg to the new APIs
This commit is contained in:
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -8483,6 +8483,7 @@ dependencies = [
|
||||
"ciphersuite",
|
||||
"const-hex",
|
||||
"dalek-ff-group",
|
||||
"dkg-pedpop",
|
||||
"dockertest",
|
||||
"env_logger",
|
||||
"ethereum-serai",
|
||||
@@ -8667,7 +8668,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"borsh",
|
||||
"ciphersuite",
|
||||
"dkg",
|
||||
"dkg-musig",
|
||||
"parity-scale-codec",
|
||||
"scale-info",
|
||||
"serai-primitives",
|
||||
|
||||
@@ -37,6 +37,7 @@ serde_json = { version = "1", default-features = false, features = ["std"] }
|
||||
ciphersuite = { path = "../crypto/ciphersuite", default-features = false, features = ["std", "ristretto"] }
|
||||
|
||||
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-schnorrkel = { path = "../crypto/schnorrkel", default-features = false }
|
||||
|
||||
|
||||
@@ -7,11 +7,10 @@ use rand_chacha::ChaCha20Rng;
|
||||
|
||||
use transcript::{Transcript, RecommendedTranscript};
|
||||
use ciphersuite::group::GroupEncoding;
|
||||
use dkg_pedpop::*;
|
||||
use frost::{
|
||||
curve::{Ciphersuite, Ristretto},
|
||||
dkg::{
|
||||
DkgError, Participant, ThresholdParams, ThresholdCore, ThresholdKeys, encryption::*, pedpop::*,
|
||||
},
|
||||
dkg::{DkgError, Participant, ThresholdParams, ThresholdCore, ThresholdKeys},
|
||||
};
|
||||
|
||||
use log::info;
|
||||
|
||||
@@ -19,7 +19,7 @@ workspace = true
|
||||
zeroize = { version = "^1.5", features = ["derive"], optional = true }
|
||||
|
||||
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 }
|
||||
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 }
|
||||
|
||||
[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"]
|
||||
serde = ["dep:serde", "serai-primitives/serde"]
|
||||
default = ["std"]
|
||||
|
||||
@@ -107,8 +107,13 @@ impl Zeroize for KeyPair {
|
||||
}
|
||||
|
||||
/// The MuSig context for a validator set.
|
||||
pub fn musig_context(set: ValidatorSet) -> Vec<u8> {
|
||||
[b"ValidatorSets-musig_key".as_ref(), &set.encode()].concat()
|
||||
pub fn musig_context(set: ValidatorSet) -> [u8; 32] {
|
||||
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.
|
||||
@@ -122,7 +127,7 @@ pub fn musig_key(set: ValidatorSet, set_keys: &[Public]) -> Public {
|
||||
.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.
|
||||
|
||||
@@ -26,7 +26,7 @@ rand_core = { version = "0.6", default-features = false }
|
||||
blake2 = "0.10"
|
||||
ciphersuite = { path = "../../crypto/ciphersuite", default-features = false, features = ["ristretto", "secp256k1"] }
|
||||
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" }
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ rand_core = { version = "0.6", default-features = false, features = ["getrandom"
|
||||
|
||||
curve25519-dalek = "4"
|
||||
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" }
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{
|
||||
time::{SystemTime, Duration},
|
||||
};
|
||||
|
||||
use dkg::{Participant, tests::clone_without};
|
||||
use dkg::Participant;
|
||||
|
||||
use messages::{coordinator::*, SubstrateContext};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::{collections::HashMap, time::SystemTime};
|
||||
|
||||
use dkg::{Participant, ThresholdParams, tests::clone_without};
|
||||
use dkg::{Participant, ThresholdParams};
|
||||
|
||||
use serai_client::{
|
||||
primitives::{BlockHash, PublicKey, EXTERNAL_NETWORKS},
|
||||
|
||||
@@ -15,6 +15,15 @@ mod send;
|
||||
pub(crate) const COORDINATORS: usize = 4;
|
||||
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(
|
||||
network: ExternalNetworkId,
|
||||
) -> (Vec<(Handles, <Ristretto as Ciphersuite>::F)>, DockerTest) {
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{
|
||||
time::{SystemTime, Duration},
|
||||
};
|
||||
|
||||
use dkg::{Participant, tests::clone_without};
|
||||
use dkg::Participant;
|
||||
|
||||
use messages::{sign::SignId, SubstrateContext};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user