mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Update to the latest patch-polkadot-sdk
Removes several dependencies.
This commit is contained in:
@@ -22,7 +22,7 @@ borsh = { version = "1", default-features = false, features = ["derive", "de_str
|
||||
bitvec = { version = "1", default-features = false, features = ["alloc"] }
|
||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"], optional = true }
|
||||
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }
|
||||
sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "ece373ca1e8aaee67844eebcca28b5e016136dba", default-features = false }
|
||||
sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "9451a7e8d8ff28571bd9bc8cdea91dacd80e1ab0", default-features = false }
|
||||
|
||||
ciphersuite = { path = "../../crypto/ciphersuite", default-features = false, features = ["alloc"] }
|
||||
schnorr-signatures = { path = "../../crypto/schnorr", default-features = false }
|
||||
|
||||
@@ -5,7 +5,7 @@ use sp_core::{ConstU32, bounded::BoundedVec};
|
||||
|
||||
use ciphersuite::{
|
||||
group::{ff::FromUniformBytes, GroupEncoding},
|
||||
Ciphersuite,
|
||||
WrappedGroup, GroupCanonicalEncoding,
|
||||
};
|
||||
use embedwards25519::Embedwards25519;
|
||||
use secq256k1::Secq256k1;
|
||||
@@ -114,16 +114,16 @@ impl ExternalKey {
|
||||
pub enum EmbeddedEllipticCurveKeys {
|
||||
/// The embedded elliptic curve keys for a Bitcoin validator.
|
||||
Bitcoin(
|
||||
<<Embedwards25519 as Ciphersuite>::G as GroupEncoding>::Repr,
|
||||
<<Secq256k1 as Ciphersuite>::G as GroupEncoding>::Repr,
|
||||
<<Embedwards25519 as WrappedGroup>::G as GroupEncoding>::Repr,
|
||||
<<Secq256k1 as WrappedGroup>::G as GroupEncoding>::Repr,
|
||||
),
|
||||
/// The embedded elliptic curve keys for an Ethereum validator.
|
||||
Ethereum(
|
||||
<<Embedwards25519 as Ciphersuite>::G as GroupEncoding>::Repr,
|
||||
<<Secq256k1 as Ciphersuite>::G as GroupEncoding>::Repr,
|
||||
<<Embedwards25519 as WrappedGroup>::G as GroupEncoding>::Repr,
|
||||
<<Secq256k1 as WrappedGroup>::G as GroupEncoding>::Repr,
|
||||
),
|
||||
/// The embedded elliptic curve key for a Monero validator.
|
||||
Monero(<<Embedwards25519 as Ciphersuite>::G as GroupEncoding>::Repr),
|
||||
Monero(<<Embedwards25519 as WrappedGroup>::G as GroupEncoding>::Repr),
|
||||
}
|
||||
|
||||
impl EmbeddedEllipticCurveKeys {
|
||||
@@ -170,7 +170,7 @@ impl scale::Decode for EmbeddedEllipticCurveKeys {
|
||||
fn decode<I: scale::Input>(input: &mut I) -> Result<Self, scale::Error> {
|
||||
let network_id = ExternalNetworkId::decode(&mut *input)?;
|
||||
let embedwards25519 =
|
||||
<<Embedwards25519 as Ciphersuite>::G as GroupEncoding>::Repr::decode(&mut *input)?;
|
||||
<<Embedwards25519 as WrappedGroup>::G as GroupEncoding>::Repr::decode(&mut *input)?;
|
||||
Ok(match network_id {
|
||||
ExternalNetworkId::Bitcoin => {
|
||||
let secq256k1 = <[u8; 33]>::decode(&mut *input)?;
|
||||
@@ -192,20 +192,20 @@ impl scale::DecodeWithMemTracking for EmbeddedEllipticCurveKeys {}
|
||||
pub enum SignedEmbeddedEllipticCurveKeys {
|
||||
/// The signed embedded elliptic curve keys for a Bitcoin validator.
|
||||
Bitcoin(
|
||||
<<Embedwards25519 as Ciphersuite>::G as GroupEncoding>::Repr,
|
||||
<<Secq256k1 as Ciphersuite>::G as GroupEncoding>::Repr,
|
||||
<<Embedwards25519 as WrappedGroup>::G as GroupEncoding>::Repr,
|
||||
<<Secq256k1 as WrappedGroup>::G as GroupEncoding>::Repr,
|
||||
[u8; 64],
|
||||
[u8; 65],
|
||||
),
|
||||
/// The signed embedded elliptic curve keys for an Ethereum validator.
|
||||
Ethereum(
|
||||
<<Embedwards25519 as Ciphersuite>::G as GroupEncoding>::Repr,
|
||||
<<Secq256k1 as Ciphersuite>::G as GroupEncoding>::Repr,
|
||||
<<Embedwards25519 as WrappedGroup>::G as GroupEncoding>::Repr,
|
||||
<<Secq256k1 as WrappedGroup>::G as GroupEncoding>::Repr,
|
||||
[u8; 64],
|
||||
[u8; 65],
|
||||
),
|
||||
/// The signed embedded elliptic curve key for a Monero validator.
|
||||
Monero(<<Embedwards25519 as Ciphersuite>::G as GroupEncoding>::Repr, [u8; 64]),
|
||||
Monero(<<Embedwards25519 as WrappedGroup>::G as GroupEncoding>::Repr, [u8; 64]),
|
||||
}
|
||||
|
||||
impl SignedEmbeddedEllipticCurveKeys {
|
||||
@@ -251,8 +251,10 @@ impl SignedEmbeddedEllipticCurveKeys {
|
||||
Self::Bitcoin(e, _, e_sig, _) | Self::Ethereum(e, _, e_sig, _) | Self::Monero(e, e_sig) => {
|
||||
let sig = SchnorrSignature::<Embedwards25519>::read(&mut e_sig.as_slice()).ok()?;
|
||||
if !sig.verify(
|
||||
Embedwards25519::read_G(&mut e.as_slice()).ok()?,
|
||||
<<Embedwards25519 as Ciphersuite>::F as FromUniformBytes<_>>::from_uniform_bytes(
|
||||
Option::<<Embedwards25519 as WrappedGroup>::G>::from(
|
||||
Embedwards25519::from_canonical_bytes(e),
|
||||
)?,
|
||||
<<Embedwards25519 as WrappedGroup>::F as FromUniformBytes<_>>::from_uniform_bytes(
|
||||
&challenge,
|
||||
),
|
||||
) {
|
||||
@@ -264,8 +266,8 @@ impl SignedEmbeddedEllipticCurveKeys {
|
||||
Self::Bitcoin(_, s, _, s_sig) | Self::Ethereum(_, s, _, s_sig) => {
|
||||
let sig = SchnorrSignature::<Secq256k1>::read(&mut s_sig.as_slice()).ok()?;
|
||||
if !sig.verify(
|
||||
Secq256k1::read_G(&mut s.as_slice()).ok()?,
|
||||
<<Secq256k1 as Ciphersuite>::F as FromUniformBytes<_>>::from_uniform_bytes(&challenge),
|
||||
Option::<<Secq256k1 as WrappedGroup>::G>::from(Secq256k1::from_canonical_bytes(s))?,
|
||||
<<Secq256k1 as WrappedGroup>::F as FromUniformBytes<_>>::from_uniform_bytes(&challenge),
|
||||
) {
|
||||
None?;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use alloc::vec::Vec;
|
||||
use zeroize::Zeroize;
|
||||
use borsh::{BorshSerialize, BorshDeserialize};
|
||||
|
||||
use ciphersuite::{group::GroupEncoding, Ciphersuite};
|
||||
use ciphersuite::{group::GroupEncoding, GroupIo};
|
||||
use dalek_ff_group::Ristretto;
|
||||
|
||||
use crate::{
|
||||
@@ -109,8 +109,7 @@ impl ExternalValidatorSet {
|
||||
let mut keys = Vec::new();
|
||||
for key in set_keys {
|
||||
keys.push(
|
||||
<Ristretto as Ciphersuite>::read_G::<&[u8]>(&mut key.0.as_ref())
|
||||
.expect("invalid participant"),
|
||||
<Ristretto as GroupIo>::read_G::<&[u8]>(&mut key.0.as_ref()).expect("invalid participant"),
|
||||
);
|
||||
}
|
||||
Public(dkg::musig_key::<Ristretto>(self.musig_context(), &keys).unwrap().to_bytes())
|
||||
|
||||
Reference in New Issue
Block a user