diff --git a/Cargo.lock b/Cargo.lock index e91cb8ee7..40e42974f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4221,6 +4221,7 @@ dependencies = [ "debugless-unwrap", "hex", "parity-scale-codec 3.6.9", + "postcard", "rand_core 0.6.4", "serde", "serdect", diff --git a/pallets/dkg/frost/Cargo.toml b/pallets/dkg/frost/Cargo.toml index 6aa3909ed..fff282658 100644 --- a/pallets/dkg/frost/Cargo.toml +++ b/pallets/dkg/frost/Cargo.toml @@ -13,7 +13,7 @@ serde = { workspace = true } serdect = { workspace = true, features = ["alloc"] } sp-std = { workspace = true } subtle = { workspace = true } - +postcard = { version = "1.0.0", default-features = false, features = ["alloc"] } hex = { workspace = true, features = ["alloc"] } rand_core = { workspace = true, optional = true } debugless-unwrap = "0.0.4" diff --git a/pallets/dkg/frost/src/error.rs b/pallets/dkg/frost/src/error.rs index 6102f3568..f4f7d2c5f 100644 --- a/pallets/dkg/frost/src/error.rs +++ b/pallets/dkg/frost/src/error.rs @@ -31,6 +31,11 @@ pub enum Error { /// An error related to a Group (usually an elliptic curve or constructed from one) or one of /// its Elements. Group(GroupError), + /// Serialization error + SerializationError, + /// Deserialization error + DeserializationError, + IdentifierDerivationNotSupported, /// An error related to a Malformed Signature. MalformedSignature, /// An error related to an invalid signature verification @@ -50,6 +55,10 @@ impl Debug for Error { Error::InvalidSignature => write!(f, "Invalid Signature error"), Error::MalformedVerifyingKey => write!(f, "Malformed VerifyingKey"), Error::MalformedSigningKey => write!(f, "Malformed SigningKey"), + Error::SerializationError => write!(f, "Serialization error"), + Error::DeserializationError => write!(f, "Deserialization error"), + Error::IdentifierDerivationNotSupported => + write!(f, "Identifier derivation not supported"), } } } diff --git a/pallets/dkg/frost/src/identifier.rs b/pallets/dkg/frost/src/identifier.rs new file mode 100644 index 000000000..f81425188 --- /dev/null +++ b/pallets/dkg/frost/src/identifier.rs @@ -0,0 +1,190 @@ +use core::{ + fmt::Debug, + hash::{Hash, Hasher}, +}; + +use crate::{ + error::{Error, FieldError}, + serialization::ScalarSerialization, + traits::{Ciphersuite, Field, Group, Scalar}, + util::scalar_is_valid, +}; + +#[derive(Copy, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(bound = "C: Ciphersuite")] +#[serde(try_from = "ScalarSerialization")] +#[serde(into = "ScalarSerialization")] +pub struct Identifier(Scalar); + +impl Identifier +where + C: Ciphersuite, +{ + /// Create a new Identifier from a scalar. For internal use only. + fn new(scalar: Scalar) -> Result { + if scalar == <::Field>::zero() { + Err(FieldError::InvalidZeroScalar.into()) + } else { + Ok(Self(scalar)) + } + } + + /// Derive an Identifier from an arbitrary byte string. + /// + /// This feature is not part of the specification and is just a convenient + /// way of creating identifiers. + /// + /// Each possible byte string will map to an uniformly random identifier. + /// Returns an error if the ciphersuite does not support identifier derivation, + /// or if the mapped identifier is zero (which is unpredictable, but should happen + /// with negligible probability). + pub fn derive(s: &[u8]) -> Result { + let scalar = C::HID(s).ok_or(Error::IdentifierDerivationNotSupported)?; + Self::new(scalar) + } + + /// Serialize the identifier using the ciphersuite encoding. + pub fn serialize(&self) -> <::Field as Field>::Serialization { + <::Field>::serialize(&self.0) + } + + /// Deserialize an Identifier from a serialized buffer. + /// Returns an error if it attempts to deserialize zero. + pub fn deserialize( + buf: &<::Field as Field>::Serialization, + ) -> Result { + let scalar = <::Field>::deserialize(buf)?; + Self::new(scalar) + } + + /// Check if the identifier is valid aka not zero + pub fn is_valid(&self) -> bool { + scalar_is_valid::(&self.0) + } +} + +impl TryFrom> for Identifier +where + C: Ciphersuite, +{ + type Error = Error; + + fn try_from(value: ScalarSerialization) -> Result { + Self::deserialize(&value.0) + } +} + +impl From> for ScalarSerialization +where + C: Ciphersuite, +{ + fn from(value: Identifier) -> Self { + Self(value.serialize()) + } +} + +impl Eq for Identifier where C: Ciphersuite {} + +impl Debug for Identifier +where + C: Ciphersuite, +{ + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + f.debug_tuple("Identifier") + .field(&hex::encode(<::Field>::serialize(&self.0).as_ref())) + .finish() + } +} + +#[allow(clippy::derived_hash_with_manual_eq)] +impl Hash for Identifier +where + C: Ciphersuite, +{ + fn hash(&self, state: &mut H) { + <::Field>::serialize(&self.0).as_ref().hash(state) + } +} + +impl Ord for Identifier +where + C: Ciphersuite, +{ + fn cmp(&self, other: &Self) -> core::cmp::Ordering { + let serialized_self = <::Field>::little_endian_serialize(&self.0); + let serialized_other = <::Field>::little_endian_serialize(&other.0); + // The default cmp uses lexicographic order; so we need the elements in big endian + serialized_self + .as_ref() + .iter() + .rev() + .cmp(serialized_other.as_ref().iter().rev()) + } +} + +impl PartialOrd for Identifier +where + C: Ciphersuite, +{ + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl core::ops::Mul> for Identifier +where + C: Ciphersuite, +{ + type Output = Scalar; + + fn mul(self, scalar: Scalar) -> Scalar { + self.0 * scalar + } +} + +impl core::ops::MulAssign> for Scalar +where + C: Ciphersuite, +{ + fn mul_assign(&mut self, identifier: Identifier) { + *self = *self * identifier.0 + } +} + +impl core::ops::Sub for Identifier +where + C: Ciphersuite, +{ + type Output = Self; + + fn sub(self, rhs: Identifier) -> Self::Output { + Self(self.0 - rhs.0) + } +} + +impl TryFrom for Identifier +where + C: Ciphersuite, +{ + type Error = Error; + + fn try_from(n: u16) -> Result, Self::Error> { + if n == 0 { + Err(FieldError::InvalidZeroScalar.into()) + } else { + // Classic left-to-right double-and-add algorithm that skips the first bit 1 (since + // identifiers are never zero, there is always a bit 1), thus `sum` starts with 1 too. + let one = <::Field>::one(); + let mut sum = <::Field>::one(); + + let bits = (n.to_be_bytes().len() as u32) * 8; + for i in (0..(bits - n.leading_zeros() - 1)).rev() { + sum = sum + sum; + if n & (1 << i) != 0 { + sum = sum + one; + } + } + Ok(Self(sum)) + } + } +} diff --git a/pallets/dkg/frost/src/keys.rs b/pallets/dkg/frost/src/keys.rs new file mode 100644 index 000000000..da76ad5f3 --- /dev/null +++ b/pallets/dkg/frost/src/keys.rs @@ -0,0 +1,148 @@ +use core::fmt::Debug; + +use crate::{ + error::Error, + identifier::Identifier, + serialization::{Deserialize, ElementSerialization, Serialize}, + traits::{Ciphersuite, Element, Group}, + util::element_is_valid, + verifying_key::VerifyingKey, + Header, +}; +use alloc::collections::BTreeMap; +use sp_std::vec::Vec; + +/// A public group element that represents a single signer's public verification share. +#[derive(Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[serde(bound = "C: Ciphersuite")] +#[serde(try_from = "ElementSerialization")] +#[serde(into = "ElementSerialization")] +pub struct VerifyingShare(pub(super) Element) +where + C: Ciphersuite; + +impl VerifyingShare +where + C: Ciphersuite, +{ + /// Create a new [`VerifyingShare`] from a element. + pub fn new(element: Element) -> Self { + Self(element) + } + + /// Get the inner element. + #[cfg(feature = "internals")] + pub fn to_element(&self) -> Element { + self.0 + } + + /// Deserialize from bytes + pub fn deserialize(bytes: ::Serialization) -> Result { + ::deserialize(&bytes) + .map(|element| Self(element)) + .map_err(|e| e.into()) + } + + /// Serialize to bytes + pub fn serialize(&self) -> ::Serialization { + ::serialize(&self.0) + } + + /// Verifies that a verifying share is valid aka not zero or the base point + pub fn is_valid(&self) -> bool { + element_is_valid::(&self.0) + } +} + +impl Debug for VerifyingShare +where + C: Ciphersuite, +{ + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + f.debug_tuple("VerifyingShare").field(&hex::encode(self.serialize())).finish() + } +} + +impl TryFrom> for VerifyingShare +where + C: Ciphersuite, +{ + type Error = Error; + + fn try_from(value: ElementSerialization) -> Result { + Self::deserialize(value.0) + } +} + +impl From> for ElementSerialization +where + C: Ciphersuite, +{ + fn from(value: VerifyingShare) -> Self { + Self(value.serialize()) + } +} + +#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[serde(bound = "C: Ciphersuite")] +#[serde(deny_unknown_fields)] +pub struct PublicKeyPackage { + /// Serialization header + pub header: Header, + /// The verifying shares for all participants. Used to validate signature + /// shares they generate. + pub verifying_shares: BTreeMap, VerifyingShare>, + /// The joint public key for the entire group. + pub verifying_key: VerifyingKey, +} + +impl PublicKeyPackage +where + C: Ciphersuite, +{ + /// Serialize the struct into a Vec. + pub fn serialize(&self) -> Result, Error> { + Serialize::serialize(&self) + } + + /// Deserialize the struct from a slice of bytes. + pub fn deserialize(bytes: &[u8]) -> Result { + Deserialize::deserialize(bytes) + } +} + +// Default byte-oriented serialization for structs that need to be communicated. +// +// Note that we still manually implement these methods in each applicable type, +// instead of making these traits `pub` and asking users to import the traits. +// The reason is that ciphersuite traits would need to re-export these traits, +// parametrized with the ciphersuite, but trait aliases are not currently +// supported: + +#[cfg(feature = "serialization")] +pub(crate) trait Serialize { + /// Serialize the struct into a Vec. + fn serialize(&self) -> Result, Error>; +} + +#[cfg(feature = "serialization")] +pub(crate) trait Deserialize { + /// Deserialize the struct from a slice of bytes. + fn deserialize(bytes: &[u8]) -> Result + where + Self: std::marker::Sized; +} + +#[cfg(feature = "serialization")] +impl Serialize for T { + fn serialize(&self) -> Result, Error> { + postcard::to_stdvec(self).map_err(|_| Error::SerializationError) + } +} + +#[cfg(feature = "serialization")] +impl serde::Deserialize<'de>, C: Ciphersuite> Deserialize for T { + fn deserialize(bytes: &[u8]) -> Result { + postcard::from_bytes(bytes).map_err(|_| Error::DeserializationError) + } +} diff --git a/pallets/dkg/frost/src/lib.rs b/pallets/dkg/frost/src/lib.rs index 63990c603..308accadc 100644 --- a/pallets/dkg/frost/src/lib.rs +++ b/pallets/dkg/frost/src/lib.rs @@ -26,6 +26,8 @@ extern crate alloc; pub mod challenge; pub mod const_crc32; pub mod error; +pub mod identifier; +pub mod keys; pub mod serialization; pub mod signature; pub mod signing_key; @@ -33,9 +35,11 @@ pub mod traits; pub mod util; pub mod verifying_key; +use core::marker::PhantomData; + #[cfg(feature = "std")] use rand_core::{CryptoRng, RngCore}; -#[cfg(feature = "std")] +use serde::{Deserialize, Serialize}; use traits::{Ciphersuite, Field, Group, Scalar}; /// Generates a random nonzero scalar. @@ -51,3 +55,13 @@ pub fn random_nonzero(rng: &mut R) -> Sc } } } + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub struct Header { + /// Format version + pub version: u8, + /// Ciphersuite ID + pub ciphersuite: (), + #[serde(skip)] + pub phantom: PhantomData, +} diff --git a/pallets/dkg/frost/src/serialization.rs b/pallets/dkg/frost/src/serialization.rs index 0544f18e7..2920e3689 100644 --- a/pallets/dkg/frost/src/serialization.rs +++ b/pallets/dkg/frost/src/serialization.rs @@ -1,8 +1,10 @@ //! Serialization support. +use crate::error::Error; + use super::traits::{Ciphersuite, Field, Group}; use alloc::string::String; -use sp_std::vec; +use sp_std::{vec, vec::Vec}; /// Helper struct to serialize a Scalar. pub(crate) struct ScalarSerialization( @@ -97,7 +99,7 @@ where use serde::Serialize; if s.is_human_readable() { - C::ID.serialize(s) + s.serialize_str(C::ID) } else { serde::Serialize::serialize(&short_id::(), s) } @@ -150,30 +152,26 @@ where // parametrized with the ciphersuite, but trait aliases are not currently // supported: -#[cfg(feature = "serialization")] -pub(crate) trait Serialize { +pub(crate) trait Serialize { /// Serialize the struct into a Vec. - fn serialize(&self) -> Result, Error>; + fn serialize(&self) -> Result, Error>; } -#[cfg(feature = "serialization")] -pub(crate) trait Deserialize { +pub(crate) trait Deserialize { /// Deserialize the struct from a slice of bytes. - fn deserialize(bytes: &[u8]) -> Result> + fn deserialize(bytes: &[u8]) -> Result where - Self: std::marker::Sized; + Self: core::marker::Sized; } -#[cfg(feature = "serialization")] -impl Serialize for T { - fn serialize(&self) -> Result, Error> { - postcard::to_stdvec(self).map_err(|_| Error::SerializationError) +impl Serialize for T { + fn serialize(&self) -> Result, Error> { + postcard::to_allocvec(self).map_err(|_| Error::SerializationError) } } -#[cfg(feature = "serialization")] -impl serde::Deserialize<'de>, C: Ciphersuite> Deserialize for T { - fn deserialize(bytes: &[u8]) -> Result> { +impl serde::Deserialize<'de>> Deserialize for T { + fn deserialize(bytes: &[u8]) -> Result { postcard::from_bytes(bytes).map_err(|_| Error::DeserializationError) } } diff --git a/pallets/dkg/frost/src/verifying_key.rs b/pallets/dkg/frost/src/verifying_key.rs index 9391cb1b9..7587d8543 100644 --- a/pallets/dkg/frost/src/verifying_key.rs +++ b/pallets/dkg/frost/src/verifying_key.rs @@ -14,8 +14,10 @@ use parity_scale_codec::{Decode, Encode}; use sp_std::vec::Vec; /// A valid verifying key for Schnorr signatures over a FROST [`Ciphersuite::Group`]. -#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, serde::Serialize, serde::Deserialize)] +#[serde(bound = "C: Ciphersuite")] +#[serde(try_from = "ElementSerialization")] +#[serde(into = "ElementSerialization")] pub struct VerifyingKey where C: Ciphersuite, diff --git a/pallets/dkg/src/functions.rs b/pallets/dkg/src/functions.rs index 8c474184c..05d894a1a 100644 --- a/pallets/dkg/src/functions.rs +++ b/pallets/dkg/src/functions.rs @@ -133,14 +133,14 @@ impl Pallet { ) -> DispatchResult { match data.signature_scheme { DigitalSignatureScheme::Ecdsa => - verify_ecdsa_signature::(&data.data, &data.signature, &data.signing_key), + verify_ecdsa_signature::(&data.data, &data.signature, &data.verifying_key), DigitalSignatureScheme::SchnorrSr25519 => verify_schnorr_sr25519_signature::( &data.data, &data.signature, - &data.signing_key, + &data.verifying_key, ), DigitalSignatureScheme::Bls381 => - verify_bls12_381_signature::(&data.data, &data.signature, &data.signing_key), + verify_bls12_381_signature::(&data.data, &data.signature, &data.verifying_key), DigitalSignatureScheme::SchnorrEd25519 | DigitalSignatureScheme::SchnorrEd448 | DigitalSignatureScheme::SchnorrP256 | @@ -150,7 +150,7 @@ impl Pallet { data.signature_scheme, &data.data, &data.signature, - &data.signing_key, + &data.verifying_key, ), _ => Err(Error::::InvalidSignature.into()), } @@ -193,7 +193,7 @@ impl Pallet { DigitalSignatureScheme::Bls381 => verify_bls12_381_signature::(&data.new_key, &data.signature, &data.key) .map(|_| emit_event(data))?, - _ => Err(Error::::InvalidSignature.into()), // unimplemented + _ => Err(Error::::InvalidSignatureScheme.into()), // unimplemented } } } diff --git a/pallets/dkg/src/lib.rs b/pallets/dkg/src/lib.rs index 6fafe9e7e..a878344b3 100644 --- a/pallets/dkg/src/lib.rs +++ b/pallets/dkg/src/lib.rs @@ -28,8 +28,8 @@ pub use pallet::*; mod functions; mod misbehavior; -mod signatures_schemes; -mod types; +pub mod signatures_schemes; +pub mod types; mod weights; #[cfg(test)] @@ -126,8 +126,14 @@ pub mod pallet { DuplicateSignature, /// Invalid signature submitted InvalidSignature, + /// Invalid signature scheme + InvalidSignatureScheme, + /// Invalid signature deserialization + InvalidSignatureDeserialization, /// Invalid verifying key submitted InvalidVerifyingKey, + /// Invalid verifying key deserialization + InvalidVerifyingKeyDeserialization, /// Signed with a different key SigningKeyMismatch, /// Invalid participant public key diff --git a/pallets/dkg/src/signatures_schemes/schnorr_frost.rs b/pallets/dkg/src/signatures_schemes/schnorr_frost.rs index 20967be7f..49d427764 100644 --- a/pallets/dkg/src/signatures_schemes/schnorr_frost.rs +++ b/pallets/dkg/src/signatures_schemes/schnorr_frost.rs @@ -30,10 +30,10 @@ macro_rules! verify_signature { ($impl_type:ty, $key:expr, $signature:expr, $msg:expr, $key_default:expr, $sig_default:expr) => {{ let verifying_key: VerifyingKey<$impl_type> = VerifyingKey::deserialize($key.try_into().unwrap_or($key_default)) - .map_err(|_| Error::::InvalidVerifyingKey)?; + .map_err(|_| Error::::InvalidVerifyingKeyDeserialization)?; let sig: Signature<$impl_type> = Signature::deserialize($signature.try_into().unwrap_or($sig_default)) - .map_err(|_| Error::::InvalidSignature)?; + .map_err(|_| Error::::InvalidSignatureDeserialization)?; verifying_key.verify($msg, &sig).map_err(|_| Error::::InvalidSignature)? }}; } diff --git a/pallets/dkg/src/tests.rs b/pallets/dkg/src/tests.rs index e432b3310..4a13190bf 100644 --- a/pallets/dkg/src/tests.rs +++ b/pallets/dkg/src/tests.rs @@ -310,7 +310,7 @@ fn dkg_signature_verification_works_bls() { DKGTSSSignatureResult { signature_scheme: DigitalSignatureScheme::Bls381, signature: signature.as_bytes().to_vec().try_into().unwrap(), - signing_key: pub_key.as_bytes().to_vec().try_into().unwrap(), + verifying_key: pub_key.as_bytes().to_vec().try_into().unwrap(), data: BLS_DATA_TO_SIGN.to_vec().try_into().unwrap(), }; @@ -325,7 +325,7 @@ fn dkg_signature_verification_works_bls() { signature_scheme: DigitalSignatureScheme::Bls381, signature: signature.as_bytes()[..10].to_vec().try_into().unwrap(), data: BLS_DATA_TO_SIGN.to_vec().try_into().unwrap(), - signing_key: pub_key.as_uncompressed_bytes().to_vec().try_into().unwrap(), + verifying_key: pub_key.as_uncompressed_bytes().to_vec().try_into().unwrap(), }; // Should fail for an invalid signature @@ -338,7 +338,7 @@ fn dkg_signature_verification_works_bls() { DKGTSSSignatureResult { signature_scheme: DigitalSignatureScheme::Bls381, signature: signature.as_bytes().to_vec().try_into().unwrap(), - signing_key: pub_key.as_uncompressed_bytes().to_vec().try_into().unwrap(), + verifying_key: pub_key.as_uncompressed_bytes().to_vec().try_into().unwrap(), data: BLS_DATA_TO_SIGN.to_vec().try_into().unwrap(), }; @@ -357,7 +357,7 @@ fn dkg_signature_verification_works_ecdsa() { signature_scheme: DigitalSignatureScheme::Ecdsa, signature: signature.try_into().unwrap(), data: pub_key.to_raw_vec().try_into().unwrap(), - signing_key: pub_key.to_raw_vec().try_into().unwrap(), + verifying_key: pub_key.to_raw_vec().try_into().unwrap(), }; // should fail for invalid keys @@ -371,7 +371,7 @@ fn dkg_signature_verification_works_ecdsa() { signature_scheme: DigitalSignatureScheme::Ecdsa, signature: signature.try_into().unwrap(), data: pub_key.to_raw_vec().try_into().unwrap(), - signing_key: pub_key.to_raw_vec().try_into().unwrap(), + verifying_key: pub_key.to_raw_vec().try_into().unwrap(), }; // should work with correct params @@ -390,7 +390,7 @@ fn dkg_signature_verification_works_schnorr() { signature_scheme: DigitalSignatureScheme::SchnorrSr25519, signature: signature.try_into().unwrap(), data: pub_key.to_raw_vec().try_into().unwrap(), - signing_key: pub_key.to_raw_vec().try_into().unwrap(), + verifying_key: pub_key.to_raw_vec().try_into().unwrap(), }; // should fail for invalid keys @@ -404,7 +404,7 @@ fn dkg_signature_verification_works_schnorr() { signature_scheme: DigitalSignatureScheme::SchnorrSr25519, signature: signature.try_into().unwrap(), data: pub_key.to_raw_vec().try_into().unwrap(), - signing_key: pub_key.to_raw_vec().try_into().unwrap(), + verifying_key: pub_key.to_raw_vec().try_into().unwrap(), }; // should work with correct params diff --git a/pallets/jobs/src/functions.rs b/pallets/jobs/src/functions.rs index 251c87026..94039ea57 100644 --- a/pallets/jobs/src/functions.rs +++ b/pallets/jobs/src/functions.rs @@ -352,26 +352,14 @@ impl Pallet { // Validate existing result ensure!(phase_one_result.ttl >= now, Error::::ResultExpired); - // ensure the participants are the expected participants from job - let mut participant_keys: Vec = Default::default(); - - let participants = phase_one_result.participants().ok_or(Error::::InvalidJobPhase)?; - for participant in participants { - let key = T::RolesHandler::get_validator_role_key(participant); - ensure!(key.is_some(), Error::::ValidatorRoleKeyNotFound); - let pub_key = sp_core::ecdsa::Public::from_slice(&key.expect("checked above")[0..33]) - .map_err(|_| Error::::InvalidValidator)?; - participant_keys.push(pub_key); - } - - let signing_key = match phase_one_result.result { + let verifying_key = match phase_one_result.result { JobResult::DKGPhaseOne(result) => result.key, _ => return Err(Error::::InvalidJobPhase.into()), }; let job_result = JobResult::DKGPhaseTwo(DKGTSSSignatureResultOf:: { signature: info.signature.clone(), data: info.data, - signing_key, + verifying_key, signature_scheme: info.signature_scheme, }); diff --git a/pallets/jobs/src/tests.rs b/pallets/jobs/src/tests.rs index b7615ed14..b22137b59 100644 --- a/pallets/jobs/src/tests.rs +++ b/pallets/jobs/src/tests.rs @@ -241,7 +241,7 @@ fn jobs_submission_e2e_works_for_dkg() { RoleType::Tss(threshold_signature_role_type), 1, JobResult::DKGPhaseTwo(DKGTSSSignatureResult { - signing_key: vec![].try_into().unwrap(), + verifying_key: vec![].try_into().unwrap(), signature: vec![].try_into().unwrap(), data: vec![].try_into().unwrap(), signature_scheme: DigitalSignatureScheme::Ecdsa diff --git a/precompiles/staking/src/mock.rs b/precompiles/staking/src/mock.rs index 0f503392c..c27b4c41a 100644 --- a/precompiles/staking/src/mock.rs +++ b/precompiles/staking/src/mock.rs @@ -493,7 +493,6 @@ pub fn new_test_ext_raw_authorities(authorities: Vec) -> sp_io::TestE /// Used to run to the specified block number pub(crate) fn run_to_block(n: BlockNumber) { while System::block_number() < n { - println!("System nlock number : {}", System::block_number()); as OnFinalize>::on_finalize(System::block_number()); as OnFinalize>::on_finalize(System::block_number()); as OnFinalize>::on_finalize(System::block_number()); @@ -506,9 +505,6 @@ pub(crate) fn run_to_block(n: BlockNumber) { as OnInitialize>::on_initialize( System::block_number(), ); - - let current_era = Staking::current_era().unwrap_or(0); - println!("current_era : {}", current_era); } } @@ -519,7 +515,6 @@ pub(crate) fn start_session(session_index: SessionIndex) { } else { Offset::get() + (session_index.saturating_sub(1) as u64) * Period::get() }; - println!("RUNTOBLOCK: {}", end); run_to_block(end); // session must have progressed properly. assert_eq!( diff --git a/primitives/src/jobs/tss.rs b/primitives/src/jobs/tss.rs index dc34b1452..ea2b20a2b 100644 --- a/primitives/src/jobs/tss.rs +++ b/primitives/src/jobs/tss.rs @@ -117,8 +117,8 @@ pub struct DKGTSSSignatureResult< /// The signature to verify pub signature: BoundedVec, - /// The expected key for the signature - pub signing_key: BoundedVec, + /// The expected key for verifying the signature + pub verifying_key: BoundedVec, } #[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo, Clone, MaxEncodedLen)]