Skip to content

Commit

Permalink
Aggregate and verify changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vusirikala committed Oct 8, 2024
1 parent 04d3589 commit 971d119
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 173 deletions.
16 changes: 9 additions & 7 deletions consensus/consensus-types/src/proof_of_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use anyhow::{bail, ensure, Context};
use aptos_crypto::{bls12381, CryptoMaterialError, HashValue};
use aptos_crypto_derive::{BCSCryptoHash, CryptoHasher};
use aptos_types::{
aggregate_signature::AggregateSignature, validator_signer::ValidatorSigner,
validator_verifier::ValidatorVerifier, PeerId,
aggregate_signature::AggregateSignature, ledger_info::SignatureWithStatus, validator_signer::ValidatorSigner, validator_verifier::ValidatorVerifier, PeerId
};
use mini_moka::sync::Cache;
use rand::{seq::SliceRandom, thread_rng};
Expand Down Expand Up @@ -217,7 +216,7 @@ impl SignedBatchInfoMsg {
pub struct SignedBatchInfo {
info: BatchInfo,
signer: PeerId,
signature: bls12381::Signature,
signature: SignatureWithStatus,
}

impl SignedBatchInfo {
Expand All @@ -230,7 +229,7 @@ impl SignedBatchInfo {
Ok(Self {
info: batch_info,
signer: validator_signer.author(),
signature,
signature: SignatureWithStatus::from(signature),
})
}

Expand All @@ -239,7 +238,7 @@ impl SignedBatchInfo {
Self {
info: batch_info,
signer,
signature: bls12381::Signature::dummy_signature(),
signature: SignatureWithStatus::from(bls12381::Signature::dummy_signature()),
}
}

Expand Down Expand Up @@ -269,10 +268,14 @@ impl SignedBatchInfo {
);
}

Ok(validator.verify(self.signer, &self.info, &self.signature)?)
Ok(validator.optimistic_verify(self.signer, &self.info, &self.signature)?)
}

pub fn signature(&self) -> &bls12381::Signature {
self.signature.signature()
}

pub fn signature_with_status(&self) -> &SignatureWithStatus {
&self.signature
}

Expand Down Expand Up @@ -300,7 +303,6 @@ pub enum SignedBatchInfoError {
NoTimeStamps,
UnableToAggregate,
LowVotingPower,
InvalidAggregatedSignature,
}

#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq)]
Expand Down
Loading

0 comments on commit 971d119

Please sign in to comment.