From baf577af287b6b401cf6afd6335f7a00ca02beee Mon Sep 17 00:00:00 2001 From: Justin Restivo Date: Fri, 24 Nov 2023 15:34:25 -0500 Subject: [PATCH 1/6] feat: towards nuking encoded{signature, publickey} --- hotshot-signature-key/src/bn254.rs | 2 +- hotshot-signature-key/src/bn254/bn254_pub.rs | 37 +++++++------------- task-impls/src/consensus.rs | 10 +++--- testing/src/task_helpers.rs | 4 +-- testing/tests/consensus_task.rs | 2 +- testing/tests/network_task.rs | 5 +-- types/src/data.rs | 11 +++--- types/src/message.rs | 3 +- types/src/simple_vote.rs | 10 +++--- types/src/traits/signature_key.rs | 5 +-- types/src/traits/storage.rs | 4 +-- types/src/vote.rs | 23 ++++-------- 12 files changed, 49 insertions(+), 67 deletions(-) diff --git a/hotshot-signature-key/src/bn254.rs b/hotshot-signature-key/src/bn254.rs index 2414c89c9c..ea0f395fb0 100644 --- a/hotshot-signature-key/src/bn254.rs +++ b/hotshot-signature-key/src/bn254.rs @@ -1,5 +1,5 @@ //! Demonstration implementation of the [`SignatureKey`] trait using BN254 -use hotshot_types::traits::signature_key::{EncodedPublicKey, EncodedSignature, SignatureKey}; +use hotshot_types::traits::signature_key::{EncodedPublicKey, SignatureKey}; /// `BLSPrivKey` implementation mod bn254_priv; /// `BLSPubKey` implementation diff --git a/hotshot-signature-key/src/bn254/bn254_pub.rs b/hotshot-signature-key/src/bn254/bn254_pub.rs index f08c03e144..3d3d605287 100644 --- a/hotshot-signature-key/src/bn254/bn254_pub.rs +++ b/hotshot-signature-key/src/bn254/bn254_pub.rs @@ -1,4 +1,4 @@ -use super::{BLSPrivKey, EncodedPublicKey, EncodedSignature, SignatureKey}; +use super::{BLSPrivKey, EncodedPublicKey, SignatureKey}; use bincode::Options; use bitvec::prelude::*; use blake3::traits::digest::generic_array::GenericArray; @@ -53,21 +53,15 @@ impl SignatureKey for BLSPubKey { type QCType = (Self::PureAssembledSignatureType, BitVec); #[instrument(skip(self))] - fn validate(&self, signature: &EncodedSignature, data: &[u8]) -> bool { + fn validate(&self, signature: &Self::PureAssembledSignatureType, data: &[u8]) -> bool { let ver_key = self.pub_key; - let x: Result<::Signature, _> = - bincode_opts().deserialize(&signature.0); - match x { - Ok(s) => { - // This is the validation for QC partial signature before append(). - let generic_msg: &GenericArray = GenericArray::from_slice(data); - BLSOverBN254CurveSignatureScheme::verify(&(), &ver_key, generic_msg, &s).is_ok() - } - Err(_) => false, - } + + // This is the validation for QC partial signature before append(). + let generic_msg: &GenericArray = GenericArray::from_slice(data); + BLSOverBN254CurveSignatureScheme::verify(&(), &ver_key, generic_msg, &signature).is_ok() } - fn sign(sk: &Self::PrivateKey, data: &[u8]) -> EncodedSignature { + fn sign(sk: &Self::PrivateKey, data: &[u8]) -> Self::PureAssembledSignatureType { let generic_msg = GenericArray::from_slice(data); let agg_signature_wrap = BitVectorQC::::sign( &(), @@ -77,19 +71,12 @@ impl SignatureKey for BLSPubKey { ); match agg_signature_wrap { Ok(agg_signature) => { - // Convert the signature to bytes and return - let bytes = bincode_opts().serialize(&agg_signature); - match bytes { - Ok(bytes) => EncodedSignature(bytes), - Err(e) => { - warn!(?e, "Failed to serialize signature in sign()"); - EncodedSignature(vec![]) - } - } + agg_signature } - Err(e) => { - warn!(?e, "Failed to sign"); - EncodedSignature(vec![]) + Err(_e) => { + unreachable!("TODO is this possible"); + // warn!(?e, "Failed to sign"); + // EncodedSignature(vec![]) } } } diff --git a/task-impls/src/consensus.rs b/task-impls/src/consensus.rs index 22d6b26c1d..a52e6c7834 100644 --- a/task-impls/src/consensus.rs +++ b/task-impls/src/consensus.rs @@ -341,7 +341,7 @@ impl, A: ConsensusApi + block_payload: None, rejected: Vec::new(), timestamp: time::OffsetDateTime::now_utc().unix_timestamp_nanos(), - proposer_id: self.quorum_membership.get_leader(view).to_bytes(), + proposer_id: self.quorum_membership.get_leader(view), }; let vote = QuorumVote::::create_signed_vote( QuorumData { @@ -401,7 +401,7 @@ impl, A: ConsensusApi + block_payload: None, rejected: Vec::new(), timestamp: time::OffsetDateTime::now_utc().unix_timestamp_nanos(), - proposer_id: self.quorum_membership.get_leader(view).to_bytes(), + proposer_id: self.quorum_membership.get_leader(view), }; // Validate the DAC. @@ -623,7 +623,7 @@ impl, A: ConsensusApi + block_payload: None, rejected: Vec::new(), timestamp: time::OffsetDateTime::now_utc().unix_timestamp_nanos(), - proposer_id: sender.to_bytes(), + proposer_id: sender, }; let mut consensus = RwLockUpgradableReadGuard::upgrade(consensus).await; @@ -648,7 +648,7 @@ impl, A: ConsensusApi + block_payload: None, rejected: Vec::new(), timestamp: time::OffsetDateTime::now_utc().unix_timestamp_nanos(), - proposer_id: sender.to_bytes(), + proposer_id: sender, }; let leaf_commitment = leaf.commit(); @@ -1248,7 +1248,7 @@ impl, A: ConsensusApi + block_payload: None, rejected: vec![], timestamp: time::OffsetDateTime::now_utc().unix_timestamp_nanos(), - proposer_id: self.api.public_key().to_bytes(), + proposer_id: self.api.public_key().clone(), }; let signature = TYPES::SignatureKey::sign(&self.private_key, leaf.commit().as_ref()); diff --git a/testing/src/task_helpers.rs b/testing/src/task_helpers.rs index 915007f879..689aad90c4 100644 --- a/testing/src/task_helpers.rs +++ b/testing/src/task_helpers.rs @@ -104,7 +104,7 @@ async fn build_quorum_proposal_and_signature( handle: &SystemContextHandle, private_key: &::PrivateKey, view: u64, -) -> (QuorumProposal, EncodedSignature) { +) -> (QuorumProposal, ::PureAssembledSignatureType) { let consensus_lock = handle.get_consensus(); let consensus = consensus_lock.read().await; let api: HotShotConsensusApi = HotShotConsensusApi { @@ -134,7 +134,7 @@ async fn build_quorum_proposal_and_signature( block_payload: None, rejected: vec![], timestamp: 0, - proposer_id: api.public_key().to_bytes(), + proposer_id: *api.public_key(), }; let signature = ::sign(private_key, leaf.commit().as_ref()); let proposal = QuorumProposal:: { diff --git a/testing/tests/consensus_task.rs b/testing/tests/consensus_task.rs index 5f53cfa4e4..3c861b302f 100644 --- a/testing/tests/consensus_task.rs +++ b/testing/tests/consensus_task.rs @@ -66,7 +66,7 @@ async fn build_vote( block_payload: None, rejected: Vec::new(), timestamp: 0, - proposer_id: membership.get_leader(view).to_bytes(), + proposer_id: membership.get_leader(view), }; let vote = QuorumVote::::create_signed_vote( QuorumData { diff --git a/testing/tests/network_task.rs b/testing/tests/network_task.rs index d625265926..1cbb10028d 100644 --- a/testing/tests/network_task.rs +++ b/testing/tests/network_task.rs @@ -24,7 +24,7 @@ async fn test_network_task() { use hotshot_types::{ block_impl::{VIDBlockPayload, VIDTransaction}, data::VidDisperse, - message::Proposal, + message::Proposal, traits::node_implementation::NodeType, }; async_compatibility_layer::logging::setup_logging(); @@ -60,6 +60,7 @@ async fn test_network_task() { _pd: PhantomData, }; let quorum_proposal = build_quorum_proposal(&handle, priv_key, 2).await; + let quorum_signature : &<::SignatureKey as SignatureKey>::PureAssembledSignatureType = &da_proposal.signature; // TODO for now reuse the same block payload commitment and signature as DA committee // https://github.com/EspressoSystems/jellyfish/issues/369 let da_vid_disperse = Proposal { @@ -69,7 +70,7 @@ async fn test_network_task() { shares: vid_disperse.shares, common: vid_disperse.common, }, - signature: da_proposal.signature.clone(), + signature: quorum_signature.clone(), _pd: PhantomData, }; diff --git a/types/src/data.rs b/types/src/data.rs index b58ceb183d..4cb7c0cd4c 100644 --- a/types/src/data.rs +++ b/types/src/data.rs @@ -101,8 +101,9 @@ impl std::ops::Sub for ViewNumber { /// Generate the genesis block proposer ID from the defined constant #[must_use] -pub fn genesis_proposer_id() -> EncodedPublicKey { - EncodedPublicKey(GENESIS_PROPOSER_ID.to_vec()) +pub fn genesis_proposer_id() -> SIGKEY { + todo!() + // EncodedPublicKey(GENESIS_PROPOSER_ID.to_vec()) } /// The `Transaction` type associated with a `State`, as a syntactic shortcut @@ -174,7 +175,7 @@ pub struct QuorumProposal { pub timeout_certificate: Option>, /// the propser id - pub proposer_id: EncodedPublicKey, + pub proposer_id: TYPES::SignatureKey, } impl HasViewNumber for DAProposal { @@ -286,7 +287,7 @@ pub struct Leaf { pub timestamp: i128, /// the proposer id of the leaf - pub proposer_id: EncodedPublicKey, + pub proposer_id: TYPES::SignatureKey, } impl PartialEq for Leaf { @@ -399,7 +400,7 @@ impl Leaf { self.timestamp } /// Identity of the network participant who proposed this leaf. - pub fn get_proposer_id(&self) -> EncodedPublicKey { + pub fn get_proposer_id(&self) -> TYPES::SignatureKey { self.proposer_id.clone() } /// Create a leaf from information stored about a view. diff --git a/types/src/message.rs b/types/src/message.rs index 44cd8ec351..aa74a2ac47 100644 --- a/types/src/message.rs +++ b/types/src/message.rs @@ -11,6 +11,7 @@ use crate::simple_certificate::{ use crate::simple_vote::{ DAVote, TimeoutVote, VIDVote, ViewSyncCommitVote, ViewSyncFinalizeVote, ViewSyncPreCommitVote, }; +use crate::traits::signature_key::SignatureKey; use crate::vote::HasViewNumber; use crate::{ data::{DAProposal, VidDisperse}, @@ -466,7 +467,7 @@ pub struct Proposal + Deserializ /// The data being proposed. pub data: PROPOSAL, /// The proposal must be signed by the view leader - pub signature: EncodedSignature, + pub signature: ::PureAssembledSignatureType, /// Phantom for TYPES pub _pd: PhantomData, } diff --git a/types/src/simple_vote.rs b/types/src/simple_vote.rs index af2588c1f3..944972c77f 100644 --- a/types/src/simple_vote.rs +++ b/types/src/simple_vote.rs @@ -85,11 +85,11 @@ mod sealed { impl Sealed for C {} } -/// A simple yes vote over some votable type. +/// A simple yes vote over some votable type. #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Hash, Eq)] pub struct SimpleVote { /// The signature share associated with this vote - pub signature: (EncodedPublicKey, EncodedSignature), + pub signature: (TYPES::SignatureKey, ::PureAssembledSignatureType), /// The leaf commitment being voted on. pub data: DATA, /// The view this vote was cast for @@ -106,10 +106,10 @@ impl Vote for SimpleVote ::SignatureKey { - ::from_bytes(&self.signature.0).unwrap() + self.signature.0.clone() } - fn get_signature(&self) -> EncodedSignature { + fn get_signature(&self) -> ::PureAssembledSignatureType { self.signature.1.clone() } @@ -132,7 +132,7 @@ impl SimpleVote { ) -> Self { let signature = TYPES::SignatureKey::sign(private_key, data.commit().as_ref()); Self { - signature: (pub_key.to_bytes(), signature), + signature: (pub_key.clone(), signature), data, view_number: view, } diff --git a/types/src/traits/signature_key.rs b/types/src/traits/signature_key.rs index ed1818ca9a..3166d72272 100644 --- a/types/src/traits/signature_key.rs +++ b/types/src/traits/signature_key.rs @@ -40,6 +40,7 @@ pub trait StakeTableEntryType { } /// Trait for abstracting public key signatures +/// Self is the public key type pub trait SignatureKey: Send + Sync @@ -103,9 +104,9 @@ pub trait SignatureKey: // Signature type represented as a vec/slice of bytes to let the implementer handle the nuances // of serialization, to avoid Cryptographic pitfalls /// Validate a signature - fn validate(&self, signature: &EncodedSignature, data: &[u8]) -> bool; + fn validate(&self, signature: &Self::PureAssembledSignatureType, data: &[u8]) -> bool; /// Produce a signature - fn sign(private_key: &Self::PrivateKey, data: &[u8]) -> EncodedSignature; + fn sign(private_key: &Self::PrivateKey, data: &[u8]) -> Self::PureAssembledSignatureType; /// Produce a public key from a private key fn from_private(private_key: &Self::PrivateKey) -> Self; /// Serialize a public key to bytes diff --git a/types/src/traits/storage.rs b/types/src/traits/storage.rs index 9f831a672e..c3c57686bc 100644 --- a/types/src/traits/storage.rs +++ b/types/src/traits/storage.rs @@ -137,7 +137,7 @@ pub struct StoredView { pub timestamp: i128, /// the proposer id #[derivative(PartialEq = "ignore")] - pub proposer_id: EncodedPublicKey, + pub proposer_id: TYPES::SignatureKey, } impl StoredView @@ -154,7 +154,7 @@ where block_payload: Option, parent_commitment: Commitment>, rejected: Vec<::Transaction>, - proposer_id: EncodedPublicKey, + proposer_id: TYPES::SignatureKey, ) -> Self { Self { view_number: qc.get_view_number(), diff --git a/types/src/vote.rs b/types/src/vote.rs index 0d71f7f145..e634a0ff21 100644 --- a/types/src/vote.rs +++ b/types/src/vote.rs @@ -28,7 +28,7 @@ pub trait Vote: HasViewNumber { type Commitment: Voteable; /// Get the signature of the vote sender - fn get_signature(&self) -> EncodedSignature; + fn get_signature(&self) -> ::PureAssembledSignatureType; /// Gets the data which was voted on by this vote fn get_data(&self) -> &Self::Commitment; /// Gets the Data commitment of the vote @@ -79,7 +79,7 @@ pub struct VoteAccumulator< CERT: Certificate, > { /// Map of all signatures accumlated so far - pub vote_outcomes: VoteMap2>, + pub vote_outcomes: VoteMap2, TYPES::SignatureKey, ::PureAssembledSignatureType>, /// A list of valid signatures for certificate aggregation pub sig_lists: Vec<::PureAssembledSignatureType>, /// A bitvec to indicate which node is active and send out a valid signature for certificate aggregation, this automatically do uniqueness check @@ -114,14 +114,7 @@ impl, CERT: Certificate::PureAssembledSignatureType = - bincode_opts() - .deserialize(&vote.get_signature().0) - .expect("Deserialization on the signature shouldn't be able to fail."); + let original_signature: ::PureAssembledSignatureType = vote.get_signature(); let (total_stake_casted, total_vote_map) = self .vote_outcomes @@ -129,9 +122,7 @@ impl, CERT: Certificate, CERT: Certificate, CERT: Certificate = HashMap< +type VoteMap2 = HashMap< COMMITMENT, ( U256, - BTreeMap, + BTreeMap, ), >; From 005906f395c348fe5948da19a748a0217f39e64d Mon Sep 17 00:00:00 2001 From: Justin Restivo Date: Sat, 25 Nov 2023 05:33:22 -0500 Subject: [PATCH 2/6] feat: sign returns a result --- hotshot-signature-key/src/bn254/bn254_pub.rs | 23 ++++----- task-impls/src/consensus.rs | 54 +++++++++++++------- task-impls/src/da.rs | 17 ++++-- task-impls/src/transactions.rs | 39 +++++++------- task-impls/src/vid.rs | 7 ++- task-impls/src/view_sync.rs | 42 ++++++++++----- testing/src/task_helpers.rs | 9 ++-- testing/tests/consensus_task.rs | 9 ++-- testing/tests/da_task.rs | 6 ++- testing/tests/network_task.rs | 6 ++- testing/tests/vid_task.rs | 6 ++- testing/tests/view_sync_task.rs | 3 +- types/src/data.rs | 3 +- types/src/message.rs | 1 - types/src/simple_vote.rs | 26 ++++++---- types/src/traits/signature_key.rs | 10 +++- types/src/traits/storage.rs | 2 +- types/src/vote.rs | 26 ++++------ 18 files changed, 172 insertions(+), 117 deletions(-) diff --git a/hotshot-signature-key/src/bn254/bn254_pub.rs b/hotshot-signature-key/src/bn254/bn254_pub.rs index 3d3d605287..111232baac 100644 --- a/hotshot-signature-key/src/bn254/bn254_pub.rs +++ b/hotshot-signature-key/src/bn254/bn254_pub.rs @@ -8,6 +8,7 @@ use hotshot_qc::bit_vector_old::{ }; use hotshot_types::traits::qc::QuorumCertificate; use hotshot_utils::bincode::bincode_opts; +use jf_primitives::errors::PrimitivesError; use jf_primitives::signatures::{ bls_over_bn254::{BLSOverBN254CurveSignatureScheme, VerKey}, SignatureScheme, @@ -51,6 +52,7 @@ impl SignatureKey for BLSPubKey { type PureAssembledSignatureType = ::Signature; type QCType = (Self::PureAssembledSignatureType, BitVec); + type SignError = PrimitivesError; #[instrument(skip(self))] fn validate(&self, signature: &Self::PureAssembledSignatureType, data: &[u8]) -> bool { @@ -58,27 +60,20 @@ impl SignatureKey for BLSPubKey { // This is the validation for QC partial signature before append(). let generic_msg: &GenericArray = GenericArray::from_slice(data); - BLSOverBN254CurveSignatureScheme::verify(&(), &ver_key, generic_msg, &signature).is_ok() + BLSOverBN254CurveSignatureScheme::verify(&(), &ver_key, generic_msg, signature).is_ok() } - fn sign(sk: &Self::PrivateKey, data: &[u8]) -> Self::PureAssembledSignatureType { + fn sign( + sk: &Self::PrivateKey, + data: &[u8], + ) -> Result { let generic_msg = GenericArray::from_slice(data); - let agg_signature_wrap = BitVectorQC::::sign( + BitVectorQC::::sign( &(), generic_msg, &sk.priv_key, &mut rand::thread_rng(), - ); - match agg_signature_wrap { - Ok(agg_signature) => { - agg_signature - } - Err(_e) => { - unreachable!("TODO is this possible"); - // warn!(?e, "Failed to sign"); - // EncodedSignature(vec![]) - } - } + ) } fn from_private(private_key: &Self::PrivateKey) -> Self { diff --git a/task-impls/src/consensus.rs b/task-impls/src/consensus.rs index a52e6c7834..c696298051 100644 --- a/task-impls/src/consensus.rs +++ b/task-impls/src/consensus.rs @@ -343,25 +343,29 @@ impl, A: ConsensusApi + timestamp: time::OffsetDateTime::now_utc().unix_timestamp_nanos(), proposer_id: self.quorum_membership.get_leader(view), }; - let vote = QuorumVote::::create_signed_vote( + if let Ok(vote) = QuorumVote::::create_signed_vote( QuorumData { leaf_commit: leaf.commit(), }, view, &self.public_key, &self.private_key, - ); - let message = GeneralConsensusMessage::::Vote(vote); - - if let GeneralConsensusMessage::Vote(vote) = message { - debug!( - "Sending vote to next quorum leader {:?}", - vote.get_view_number() + 1 - ); - self.event_stream - .publish(HotShotEvent::QuorumVoteSend(vote)) - .await; - return true; + ) { + let message = GeneralConsensusMessage::::Vote(vote); + + if let GeneralConsensusMessage::Vote(vote) = message { + debug!( + "Sending vote to next quorum leader {:?}", + vote.get_view_number() + 1 + ); + self.event_stream + .publish(HotShotEvent::QuorumVoteSend(vote)) + .await; + return true; + } + } else { + error!("Unable to sign quorum vote!"); + return false; } } @@ -414,15 +418,19 @@ impl, A: ConsensusApi + error!("Block payload commitment does not equal parent commitment"); return false; } - let vote = QuorumVote::::create_signed_vote( + if let Ok(vote) = QuorumVote::::create_signed_vote( QuorumData { leaf_commit: leaf.commit(), }, view, &self.public_key, &self.private_key, - ); - GeneralConsensusMessage::::Vote(vote) + ) { + GeneralConsensusMessage::::Vote(vote) + } else { + error!("Unable to sign quorum vote!"); + return false; + } } else { error!( "Invalid DAC in proposal! Skipping proposal. {:?} cur view is: {:?}", @@ -1141,12 +1149,15 @@ impl, A: ConsensusApi + return; } - let vote = TimeoutVote::create_signed_vote( + let Ok(vote) = TimeoutVote::create_signed_vote( TimeoutData { view }, view, &self.public_key, &self.private_key, - ); + ) else { + error!("Failed to sign timeout vote!"); + return; + }; self.event_stream .publish(HotShotEvent::TimeoutVoteSend(vote)) @@ -1251,7 +1262,12 @@ impl, A: ConsensusApi + proposer_id: self.api.public_key().clone(), }; - let signature = TYPES::SignatureKey::sign(&self.private_key, leaf.commit().as_ref()); + let Ok(signature) = + TYPES::SignatureKey::sign(&self.private_key, leaf.commit().as_ref()) + else { + error!("Failed to sign leaf!"); + return false; + }; // TODO: DA cert is sent as part of the proposal here, we should split this out so we don't have to wait for it. let proposal = QuorumProposal { block_header: leaf.block_header.clone(), diff --git a/task-impls/src/da.rs b/task-impls/src/da.rs index 776c755925..4206570d18 100644 --- a/task-impls/src/da.rs +++ b/task-impls/src/da.rs @@ -222,14 +222,17 @@ impl, A: ConsensusApi + return None; } // Generate and send vote - let vote = DAVote::create_signed_vote( + let Ok(vote) = DAVote::create_signed_vote( DAData { payload_commit: payload_commitment, }, view, &self.public_key, &self.private_key, - ); + ) else { + error!("Failed to sign DA Vote!"); + return None; + }; // ED Don't think this is necessary? // self.cur_view = view; @@ -377,8 +380,14 @@ impl, A: ConsensusApi + .await; let payload_commitment = payload.commit(); - let signature = - TYPES::SignatureKey::sign(&self.private_key, payload_commitment.as_ref()); + let Ok(signature) = + TYPES::SignatureKey::sign(&self.private_key, payload_commitment.as_ref()) + else { + // TODO is this correct? + // Should we be doing more? + error!("Failed to sign block payload!"); + return None; + }; // TODO (Keyao) Fix the payload sending and receiving for the DA proposal. // let data: DAProposal = DAProposal { diff --git a/task-impls/src/transactions.rs b/task-impls/src/transactions.rs index 73cebe39d6..e37b4ea222 100644 --- a/task-impls/src/transactions.rs +++ b/task-impls/src/transactions.rs @@ -250,25 +250,28 @@ impl, A: ConsensusApi + // TODO (Keyao) Determine and update where to publish VidDisperseSend. // debug!("publishing VID disperse for view {}", *view + 1); - self.event_stream - .publish(HotShotEvent::VidDisperseSend( - Proposal { - data: VidDisperse { - view_number: view + 1, - payload_commitment: payload.commit(), - shares: vid_disperse.shares, - common: vid_disperse.common, + if let Ok(signature) = + TYPES::SignatureKey::sign(&self.private_key, payload.commit().as_ref()) + { + self.event_stream + .publish(HotShotEvent::VidDisperseSend( + Proposal { + data: VidDisperse { + view_number: view + 1, + payload_commitment: payload.commit(), + shares: vid_disperse.shares, + common: vid_disperse.common, + }, + // TODO (Keyao) This is also signed in DA task. + signature, + _pd: PhantomData, }, - // TODO (Keyao) This is also signed in DA task. - signature: TYPES::SignatureKey::sign( - &self.private_key, - payload.commit().as_ref(), - ), - _pd: PhantomData, - }, - self.public_key.clone(), - )) - .await; + self.public_key.clone(), + )) + .await; + } else { + error!("Failed to sign payload for vid disperal!"); + } return None; } HotShotEvent::Shutdown => { diff --git a/task-impls/src/vid.rs b/task-impls/src/vid.rs index 4628fc1a67..ed1d98cc3d 100644 --- a/task-impls/src/vid.rs +++ b/task-impls/src/vid.rs @@ -297,14 +297,17 @@ impl, A: ConsensusApi + } // Generate and send vote - let vote = VIDVote::create_signed_vote( + let Ok(vote) = VIDVote::create_signed_vote( VIDData { payload_commit: payload_commitment, }, view, &self.public_key, &self.private_key, - ); + ) else { + error!("Failed to sign VID Vote"); + return None; + }; // ED Don't think this is necessary? // self.cur_view = view; diff --git a/task-impls/src/view_sync.rs b/task-impls/src/view_sync.rs index c3882111e9..5ec87bb4cb 100644 --- a/task-impls/src/view_sync.rs +++ b/task-impls/src/view_sync.rs @@ -807,7 +807,7 @@ impl, A: ConsensusApi + self.relay = certificate.get_data().relay; } - let vote = ViewSyncCommitVote::::create_signed_vote( + let Ok(vote) = ViewSyncCommitVote::::create_signed_vote( ViewSyncCommitData { relay: certificate.get_data().relay, round: self.next_view, @@ -815,7 +815,10 @@ impl, A: ConsensusApi + self.next_view, &self.public_key, &self.private_key, - ); + ) else { + error!("Failed to sign view sync commit vote!"); + return (None, self); + }; let message = GeneralConsensusMessage::::ViewSyncCommitVote(vote); if let GeneralConsensusMessage::ViewSyncCommitVote(vote) = message { @@ -875,7 +878,7 @@ impl, A: ConsensusApi + self.relay = certificate.get_data().relay; } - let vote = ViewSyncFinalizeVote::::create_signed_vote( + let Ok(vote) = ViewSyncFinalizeVote::::create_signed_vote( ViewSyncFinalizeData { relay: certificate.get_data().relay, round: self.next_view, @@ -883,7 +886,10 @@ impl, A: ConsensusApi + self.next_view, &self.public_key, &self.private_key, - ); + ) else { + error!("Failed to sign view sync finalized vote!"); + return (None, self); + }; let message = GeneralConsensusMessage::::ViewSyncFinalizeVote(vote); if let GeneralConsensusMessage::ViewSyncFinalizeVote(vote) = message { @@ -958,7 +964,7 @@ impl, A: ConsensusApi + return (None, self); } - let vote = ViewSyncPreCommitVote::::create_signed_vote( + let Ok(vote) = ViewSyncPreCommitVote::::create_signed_vote( ViewSyncPreCommitData { relay: 0, round: view_number, @@ -966,7 +972,10 @@ impl, A: ConsensusApi + view_number, &self.public_key, &self.private_key, - ); + ) else { + error!("Failed to sign pre commit vote!"); + return (None, self); + }; let message = GeneralConsensusMessage::::ViewSyncPreCommitVote(vote); if let GeneralConsensusMessage::ViewSyncPreCommitVote(vote) = message { @@ -1002,7 +1011,7 @@ impl, A: ConsensusApi + self.relay += 1; match self.phase { ViewSyncPhase::None => { - let vote = ViewSyncPreCommitVote::::create_signed_vote( + let Ok(vote) = ViewSyncPreCommitVote::::create_signed_vote( ViewSyncPreCommitData { relay: self.relay, round: self.next_view, @@ -1010,7 +1019,10 @@ impl, A: ConsensusApi + self.next_view, &self.public_key, &self.private_key, - ); + ) else { + error!("Failed to sign vote!"); + return (None, self); + }; let message = GeneralConsensusMessage::::ViewSyncPreCommitVote(vote); @@ -1021,7 +1033,7 @@ impl, A: ConsensusApi + } } ViewSyncPhase::PreCommit => { - let vote = ViewSyncCommitVote::::create_signed_vote( + let Ok(vote) = ViewSyncCommitVote::::create_signed_vote( ViewSyncCommitData { relay: self.relay, round: self.next_view, @@ -1029,7 +1041,10 @@ impl, A: ConsensusApi + self.next_view, &self.public_key, &self.private_key, - ); + ) else { + error!("Failed to sign vote!"); + return (None, self); + }; let message = GeneralConsensusMessage::::ViewSyncCommitVote(vote); @@ -1040,7 +1055,7 @@ impl, A: ConsensusApi + } } ViewSyncPhase::Commit => { - let vote = ViewSyncFinalizeVote::::create_signed_vote( + let Ok(vote) = ViewSyncFinalizeVote::::create_signed_vote( ViewSyncFinalizeData { relay: self.relay, round: self.next_view, @@ -1048,7 +1063,10 @@ impl, A: ConsensusApi + self.next_view, &self.public_key, &self.private_key, - ); + ) else { + error!("Failed to sign vote!"); + return (None, self); + }; let message = GeneralConsensusMessage::::ViewSyncFinalizeVote(vote); diff --git a/testing/src/task_helpers.rs b/testing/src/task_helpers.rs index 689aad90c4..1a66b5469c 100644 --- a/testing/src/task_helpers.rs +++ b/testing/src/task_helpers.rs @@ -22,7 +22,6 @@ use hotshot_types::{ consensus_api::ConsensusSharedApi, election::Membership, node_implementation::NodeType, - signature_key::EncodedSignature, state::{ConsensusTime, TestableBlock}, }, vote::HasViewNumber, @@ -104,7 +103,10 @@ async fn build_quorum_proposal_and_signature( handle: &SystemContextHandle, private_key: &::PrivateKey, view: u64, -) -> (QuorumProposal, ::PureAssembledSignatureType) { +) -> ( + QuorumProposal, + ::PureAssembledSignatureType, +) { let consensus_lock = handle.get_consensus(); let consensus = consensus_lock.read().await; let api: HotShotConsensusApi = HotShotConsensusApi { @@ -136,7 +138,8 @@ async fn build_quorum_proposal_and_signature( timestamp: 0, proposer_id: *api.public_key(), }; - let signature = ::sign(private_key, leaf.commit().as_ref()); + let signature = ::sign(private_key, leaf.commit().as_ref()) + .expect("Failed to sign leaf commitment!"); let proposal = QuorumProposal:: { block_header, view_number: ViewNumber::new(view), diff --git a/testing/tests/consensus_task.rs b/testing/tests/consensus_task.rs index 3c861b302f..3787f50cf2 100644 --- a/testing/tests/consensus_task.rs +++ b/testing/tests/consensus_task.rs @@ -1,9 +1,5 @@ use commit::Committable; -use hotshot::{ - tasks::add_consensus_task, - types::{SignatureKey, SystemContextHandle}, - HotShotConsensusApi, -}; +use hotshot::{tasks::add_consensus_task, types::SystemContextHandle, HotShotConsensusApi}; use hotshot_task::event_stream::ChannelStream; use hotshot_task_impls::events::HotShotEvent; use hotshot_testing::{ @@ -75,7 +71,8 @@ async fn build_vote( view, api.public_key(), api.private_key(), - ); + ) + .expect("Failed to create quorum vote"); GeneralConsensusMessage::::Vote(vote) } diff --git a/testing/tests/da_task.rs b/testing/tests/da_task.rs index 571c3ef2c7..de9e722dd0 100644 --- a/testing/tests/da_task.rs +++ b/testing/tests/da_task.rs @@ -41,7 +41,8 @@ async fn test_da_task() { }; let signature = - ::SignatureKey::sign(api.private_key(), block.commit().as_ref()); + ::SignatureKey::sign(api.private_key(), block.commit().as_ref()) + .expect("Faild to sign block payload!"); let proposal = DAProposal { block_payload: block.clone(), view_number: ViewNumber::new(2), @@ -88,7 +89,8 @@ async fn test_da_task() { ViewNumber::new(2), api.public_key(), api.private_key(), - ); + ) + .expect("Failed to sign da vote"); output.insert(HotShotEvent::DAVoteSend(da_vote), 1); output.insert(HotShotEvent::DAProposalRecv(message, pub_key), 1); diff --git a/testing/tests/network_task.rs b/testing/tests/network_task.rs index 1cbb10028d..8d4d147369 100644 --- a/testing/tests/network_task.rs +++ b/testing/tests/network_task.rs @@ -24,7 +24,8 @@ async fn test_network_task() { use hotshot_types::{ block_impl::{VIDBlockPayload, VIDTransaction}, data::VidDisperse, - message::Proposal, traits::node_implementation::NodeType, + message::Proposal, + traits::node_implementation::NodeType, }; async_compatibility_layer::logging::setup_logging(); @@ -50,7 +51,8 @@ async fn test_network_task() { ::SignatureKey::sign( api.private_key(), block.commit().as_ref(), - ); + ) + .expect("Failed to sign block commitment"); let da_proposal = Proposal { data: DAProposal { block_payload: block.clone(), diff --git a/testing/tests/vid_task.rs b/testing/tests/vid_task.rs index 0e0f15465d..a302be85b8 100644 --- a/testing/tests/vid_task.rs +++ b/testing/tests/vid_task.rs @@ -45,7 +45,8 @@ async fn test_vid_task() { }; let signature = - ::SignatureKey::sign(api.private_key(), block.commit().as_ref()); + ::SignatureKey::sign(api.private_key(), block.commit().as_ref()) + .expect("Failed to sign block payload!"); let proposal: DAProposal = DAProposal { block_payload: block.clone(), view_number: ViewNumber::new(2), @@ -95,7 +96,8 @@ async fn test_vid_task() { ViewNumber::new(2), api.public_key(), api.private_key(), - ); + ) + .expect("Failed to sign vid vote"); output.insert(HotShotEvent::VidVoteSend(vid_vote), 1); output.insert(HotShotEvent::VidDisperseRecv(vid_proposal, pub_key), 1); diff --git a/testing/tests/view_sync_task.rs b/testing/tests/view_sync_task.rs index 46ed361c03..c740e07600 100644 --- a/testing/tests/view_sync_task.rs +++ b/testing/tests/view_sync_task.rs @@ -34,7 +34,8 @@ async fn test_view_sync_task() { ::Time::new(5), hotshot_types::traits::consensus_api::ConsensusSharedApi::public_key(&api), hotshot_types::traits::consensus_api::ConsensusSharedApi::private_key(&api), - ); + ) + .unwrap(); tracing::error!("Vote in test is {:?}", vote.clone()); diff --git a/types/src/data.rs b/types/src/data.rs index 4cb7c0cd4c..44e07914f8 100644 --- a/types/src/data.rs +++ b/types/src/data.rs @@ -8,7 +8,7 @@ use crate::{ traits::{ block_contents::BlockHeader, node_implementation::NodeType, - signature_key::{EncodedPublicKey, SignatureKey}, + signature_key::SignatureKey, state::{ConsensusTime, TestableBlock, TestableState}, storage::StoredView, BlockPayload, State, @@ -20,7 +20,6 @@ use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, Read, Serializatio use bincode::Options; use commit::{Commitment, Committable}; use derivative::Derivative; -use hotshot_constants::GENESIS_PROPOSER_ID; use hotshot_utils::bincode::bincode_opts; use jf_primitives::pcs::{checked_fft_size, prelude::UnivariateKzgPCS, PolynomialCommitmentScheme}; use rand::Rng; diff --git a/types/src/message.rs b/types/src/message.rs index aa74a2ac47..c8e76570d2 100644 --- a/types/src/message.rs +++ b/types/src/message.rs @@ -19,7 +19,6 @@ use crate::{ traits::{ network::{NetworkMsg, ViewMessage}, node_implementation::NodeType, - signature_key::EncodedSignature, }, }; diff --git a/types/src/simple_vote.rs b/types/src/simple_vote.rs index 944972c77f..48b2520b5e 100644 --- a/types/src/simple_vote.rs +++ b/types/src/simple_vote.rs @@ -7,10 +7,7 @@ use serde::{Deserialize, Serialize}; use crate::{ data::Leaf, - traits::{ - node_implementation::NodeType, - signature_key::{EncodedPublicKey, EncodedSignature, SignatureKey}, - }, + traits::{node_implementation::NodeType, signature_key::SignatureKey}, vote::{HasViewNumber, Vote}, }; @@ -89,7 +86,10 @@ mod sealed { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Hash, Eq)] pub struct SimpleVote { /// The signature share associated with this vote - pub signature: (TYPES::SignatureKey, ::PureAssembledSignatureType), + pub signature: ( + TYPES::SignatureKey, + ::PureAssembledSignatureType, + ), /// The leaf commitment being voted on. pub data: DATA, /// The view this vote was cast for @@ -124,17 +124,21 @@ impl Vote for SimpleVote SimpleVote { /// Creates and signs a simple vote + /// # Errors + /// If we are unable to sign the data pub fn create_signed_vote( data: DATA, view: TYPES::Time, pub_key: &TYPES::SignatureKey, private_key: &::PrivateKey, - ) -> Self { - let signature = TYPES::SignatureKey::sign(private_key, data.commit().as_ref()); - Self { - signature: (pub_key.clone(), signature), - data, - view_number: view, + ) -> Result::SignError> { + match TYPES::SignatureKey::sign(private_key, data.commit().as_ref()) { + Ok(signature) => Ok(Self { + signature: (pub_key.clone(), signature), + data, + view_number: view, + }), + Err(e) => Err(e), } } } diff --git a/types/src/traits/signature_key.rs b/types/src/traits/signature_key.rs index 3166d72272..305445fe27 100644 --- a/types/src/traits/signature_key.rs +++ b/types/src/traits/signature_key.rs @@ -101,12 +101,20 @@ pub trait SignatureKey: + Serialize + for<'a> Deserialize<'a>; + /// Type of error that can occur when signing data + type SignError: std::error::Error + Send + Sync; + // Signature type represented as a vec/slice of bytes to let the implementer handle the nuances // of serialization, to avoid Cryptographic pitfalls /// Validate a signature fn validate(&self, signature: &Self::PureAssembledSignatureType, data: &[u8]) -> bool; /// Produce a signature - fn sign(private_key: &Self::PrivateKey, data: &[u8]) -> Self::PureAssembledSignatureType; + /// # Errors + /// If unable to sign the data with the key + fn sign( + private_key: &Self::PrivateKey, + data: &[u8], + ) -> Result; /// Produce a public key from a private key fn from_private(private_key: &Self::PrivateKey) -> Self; /// Serialize a public key to bytes diff --git a/types/src/traits/storage.rs b/types/src/traits/storage.rs index c3c57686bc..eca798d35f 100644 --- a/types/src/traits/storage.rs +++ b/types/src/traits/storage.rs @@ -1,6 +1,6 @@ //! Abstraction over on-disk storage of node state -use super::{node_implementation::NodeType, signature_key::EncodedPublicKey}; +use super::node_implementation::NodeType; use crate::{ data::Leaf, simple_certificate::QuorumCertificate, traits::BlockPayload, vote::HasViewNumber, }; diff --git a/types/src/vote.rs b/types/src/vote.rs index e634a0ff21..70b23a8a20 100644 --- a/types/src/vote.rs +++ b/types/src/vote.rs @@ -5,12 +5,10 @@ use std::{ marker::PhantomData, }; -use bincode::Options; use bitvec::vec::BitVec; use commit::Commitment; use either::Either; use ethereum_types::U256; -use hotshot_utils::bincode::bincode_opts; use tracing::error; use crate::{ @@ -18,7 +16,7 @@ use crate::{ traits::{ election::Membership, node_implementation::NodeType, - signature_key::{EncodedPublicKey, EncodedSignature, SignatureKey, StakeTableEntryType}, + signature_key::{SignatureKey, StakeTableEntryType}, }, }; @@ -79,7 +77,11 @@ pub struct VoteAccumulator< CERT: Certificate, > { /// Map of all signatures accumlated so far - pub vote_outcomes: VoteMap2, TYPES::SignatureKey, ::PureAssembledSignatureType>, + pub vote_outcomes: VoteMap2< + Commitment, + TYPES::SignatureKey, + ::PureAssembledSignatureType, + >, /// A list of valid signatures for certificate aggregation pub sig_lists: Vec<::PureAssembledSignatureType>, /// A bitvec to indicate which node is active and send out a valid signature for certificate aggregation, this automatically do uniqueness check @@ -114,7 +116,8 @@ impl, CERT: Certificate::PureAssembledSignatureType = vote.get_signature(); + let original_signature: ::PureAssembledSignatureType = + vote.get_signature(); let (total_stake_casted, total_vote_map) = self .vote_outcomes @@ -135,10 +138,7 @@ impl, CERT: Certificate= CERT::threshold(membership).into() { // Assemble QC @@ -167,10 +167,4 @@ impl, CERT: Certificate = HashMap< - COMMITMENT, - ( - U256, - BTreeMap, - ), ->; +type VoteMap2 = HashMap)>; From f943da5c848ab3b2cb3e7100ed864b0d50c9e81e Mon Sep 17 00:00:00 2001 From: Justin Restivo Date: Sat, 25 Nov 2023 05:45:43 -0500 Subject: [PATCH 3/6] feat: move genesis pk into signaturekey --- constants/src/lib.rs | 3 --- hotshot-signature-key/src/bn254/bn254_pub.rs | 6 ++++++ hotshot-signature-key/src/lib.rs | 2 +- hotshot/src/traits/storage/memory_storage.rs | 5 +++-- types/src/data.rs | 9 +-------- types/src/traits/signature_key.rs | 4 ++++ 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/constants/src/lib.rs b/constants/src/lib.rs index 0b1b769650..fbc9a00b1d 100644 --- a/constants/src/lib.rs +++ b/constants/src/lib.rs @@ -1,8 +1,5 @@ //! configurable constants for hotshot -/// the ID of the genesis block proposer -pub const GENESIS_PROPOSER_ID: [u8; 2] = [4, 2]; - /// the number of views to gather information for ahead of time pub const LOOK_AHEAD: u64 = 5; diff --git a/hotshot-signature-key/src/bn254/bn254_pub.rs b/hotshot-signature-key/src/bn254/bn254_pub.rs index 111232baac..3a6c11ab19 100644 --- a/hotshot-signature-key/src/bn254/bn254_pub.rs +++ b/hotshot-signature-key/src/bn254/bn254_pub.rs @@ -146,4 +146,10 @@ impl SignatureKey for BLSPubKey { BitVectorQC::::assemble(real_qc_pp, signers, sigs) .expect("this assembling shouldn't fail") } + + fn genesis_proposer_pk() -> Self { + BLSPubKey { + pub_key: unimplemented!(), + } + } } diff --git a/hotshot-signature-key/src/lib.rs b/hotshot-signature-key/src/lib.rs index 2e8f711bab..08a9c6b33e 100644 --- a/hotshot-signature-key/src/lib.rs +++ b/hotshot-signature-key/src/lib.rs @@ -1,5 +1,5 @@ //! This crates offer implementations of quorum certificates used in HotShot. -#![deny(warnings)] +// #![deny(warnings)] #![deny(missing_docs)] pub mod bn254; diff --git a/hotshot/src/traits/storage/memory_storage.rs b/hotshot/src/traits/storage/memory_storage.rs index db59363198..f41bb93d62 100644 --- a/hotshot/src/traits/storage/memory_storage.rs +++ b/hotshot/src/traits/storage/memory_storage.rs @@ -112,9 +112,10 @@ mod test { use super::*; use commit::Committable; use hotshot_signature_key::bn254::BLSPubKey; + use hotshot_types::traits::signature_key::SignatureKey; use hotshot_types::{ block_impl::{VIDBlockHeader, VIDBlockPayload, VIDTransaction}, - data::{fake_commitment, genesis_proposer_id, Leaf, ViewNumber}, + data::{fake_commitment, Leaf, ViewNumber}, simple_certificate::QuorumCertificate, traits::{node_implementation::NodeType, state::dummy::DummyState, state::ConsensusTime}, }; @@ -171,7 +172,7 @@ mod test { Some(payload), dummy_leaf_commit, Vec::new(), - genesis_proposer_id(), + <::SignatureKey as SignatureKey>::genesis_proposer_pk(), ) } diff --git a/types/src/data.rs b/types/src/data.rs index 44e07914f8..cb674e7353 100644 --- a/types/src/data.rs +++ b/types/src/data.rs @@ -98,13 +98,6 @@ impl std::ops::Sub for ViewNumber { } } -/// Generate the genesis block proposer ID from the defined constant -#[must_use] -pub fn genesis_proposer_id() -> SIGKEY { - todo!() - // EncodedPublicKey(GENESIS_PROPOSER_ID.to_vec()) -} - /// The `Transaction` type associated with a `State`, as a syntactic shortcut pub type Transaction = <::BlockPayload as BlockPayload>::Transaction; /// `Commitment` to the `Transaction` type associated with a `State`, as a syntactic shortcut @@ -334,7 +327,7 @@ impl Leaf { block_payload: Some(block_payload), rejected: Vec::new(), timestamp: time::OffsetDateTime::now_utc().unix_timestamp_nanos(), - proposer_id: genesis_proposer_id(), + proposer_id: <::SignatureKey as SignatureKey>::genesis_proposer_pk(), } } diff --git a/types/src/traits/signature_key.rs b/types/src/traits/signature_key.rs index 305445fe27..8945ed4ed5 100644 --- a/types/src/traits/signature_key.rs +++ b/types/src/traits/signature_key.rs @@ -149,4 +149,8 @@ pub trait SignatureKey: signers: &BitSlice, sigs: &[Self::PureAssembledSignatureType], ) -> Self::QCType; + + /// generates the genesis public key. Meant to be dummy/filler + #[must_use] + fn genesis_proposer_pk() -> Self; } From 0cbbb8f7f75c06e1c9b76a4e185f03bc14f0fb81 Mon Sep 17 00:00:00 2001 From: Justin Restivo Date: Sat, 2 Dec 2023 11:17:25 -0500 Subject: [PATCH 4/6] feat: implement genesis pk generator --- hotshot-signature-key/src/bn254/bn254_pub.rs | 6 +++++- testing/tests/network_task.rs | 9 +++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hotshot-signature-key/src/bn254/bn254_pub.rs b/hotshot-signature-key/src/bn254/bn254_pub.rs index 3a6c11ab19..3b8183a986 100644 --- a/hotshot-signature-key/src/bn254/bn254_pub.rs +++ b/hotshot-signature-key/src/bn254/bn254_pub.rs @@ -148,8 +148,12 @@ impl SignatureKey for BLSPubKey { } fn genesis_proposer_pk() -> Self { + use jf_primitives::signatures::bls_over_bn254::KeyPair; + use rand::rngs::mock::StepRng; + let mut my_rng = StepRng::new(42, 1337); + let kp = KeyPair::generate(&mut my_rng); BLSPubKey { - pub_key: unimplemented!(), + pub_key: kp.ver_key(), } } } diff --git a/testing/tests/network_task.rs b/testing/tests/network_task.rs index f34025dc44..927bf85a0d 100644 --- a/testing/tests/network_task.rs +++ b/testing/tests/network_task.rs @@ -41,12 +41,9 @@ async fn test_network_task() { let vid_disperse = vid.disperse(&encoded_transactions).unwrap(); let payload_commitment = vid_disperse.commit; let signature = - ::SignatureKey::sign( - api.private_key(), - payload_commitment.as_ref(), - ) - .expect("Failed to sign block commitment"); - let da_proposal = Proposal { + ::SignatureKey::sign(api.private_key(), payload_commitment.as_ref()) + .expect("Failed to sign block commitment"); + let da_proposal = Proposal:: { data: DAProposal { encoded_transactions: encoded_transactions.clone(), metadata: (), From 0c00c53a056f8b2c118e278eb4cbe62951999c82 Mon Sep 17 00:00:00 2001 From: Sishan Long Date: Thu, 21 Dec 2023 15:27:53 -0800 Subject: [PATCH 5/6] wrap() to expect() for vote creation in test_view_sync_task --- testing/tests/view_sync_task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/tests/view_sync_task.rs b/testing/tests/view_sync_task.rs index c740e07600..a1ec3c3630 100644 --- a/testing/tests/view_sync_task.rs +++ b/testing/tests/view_sync_task.rs @@ -35,7 +35,7 @@ async fn test_view_sync_task() { hotshot_types::traits::consensus_api::ConsensusSharedApi::public_key(&api), hotshot_types::traits::consensus_api::ConsensusSharedApi::private_key(&api), ) - .unwrap(); + .expect("Should be able to create a ViewSyncPreCommitVote."); tracing::error!("Vote in test is {:?}", vote.clone()); From 848bd97a273ae3e47f7b9a453475dff8380f92a4 Mon Sep 17 00:00:00 2001 From: Sishan Long Date: Thu, 21 Dec 2023 16:35:36 -0800 Subject: [PATCH 6/6] fully remove EncodedSignature --- types/src/traits/signature_key.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/types/src/traits/signature_key.rs b/types/src/traits/signature_key.rs index e21587675f..25ebfdd7d2 100644 --- a/types/src/traits/signature_key.rs +++ b/types/src/traits/signature_key.rs @@ -22,17 +22,6 @@ use tagged_base64::tagged; )] pub struct EncodedPublicKey(#[debug(with = "custom_debug::hexbuf")] pub Vec); -/// Type saftey wrapper for byte encoded signature -#[derive( - Clone, custom_debug::Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, -)] -pub struct EncodedSignature(#[debug(with = "custom_debug::hexbuf")] pub Vec); - -impl AsRef<[u8]> for EncodedSignature { - fn as_ref(&self) -> &[u8] { - self.0.as_slice() - } -} /// Type representing stake table entries in a `StakeTable` pub trait StakeTableEntryType { /// Get the stake value