Skip to content

Commit

Permalink
Merge pull request #24 from datachainlab/audit-202411-s-1
Browse files Browse the repository at this point in the history
S-1: fix typo

Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele authored Dec 23, 2024
2 parents a9a27ae + a9202d1 commit 86510d8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions crates/consensus/src/bls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl TryFrom<Signature> for BLSSignature {
}
}

pub fn aggreate_public_key(keys: &[BLSPublicKey]) -> Result<BLSAggregatePublicKey, Error> {
pub fn aggregate_public_key(keys: &[BLSPublicKey]) -> Result<BLSAggregatePublicKey, Error> {
Ok(BLSAggregatePublicKey::into_aggregate(keys)?)
}

Expand All @@ -204,21 +204,21 @@ pub fn fast_aggregate_verify(
msg: H256,
signature: BLSSignature,
) -> Result<bool, Error> {
let aggregate_pubkey = aggreate_public_key(&pubkeys)?;
let aggregate_pubkey = aggregate_public_key(&pubkeys)?;
let aggregate_signature = BLSAggregateSignature::from_signature(&signature);

Ok(aggregate_signature.fast_aggregate_verify_pre_aggregated(msg.as_bytes(), &aggregate_pubkey))
}

pub fn is_equal_pubkeys_and_aggreate_pub_key<const SYNC_COMMITTEE_SIZE: usize>(
pub fn is_equal_pubkeys_and_aggregate_pub_key<const SYNC_COMMITTEE_SIZE: usize>(
pubkeys: &Vector<PublicKey, SYNC_COMMITTEE_SIZE>,
aggregate_pubkey: &PublicKey,
) -> Result<(), Error> {
let pubkeys: Vec<BLSPublicKey> = pubkeys
.iter()
.map(|k| k.clone().try_into().unwrap())
.collect();
let agg_pubkey: PublicKey = aggreate_public_key(&pubkeys)?.into();
let agg_pubkey: PublicKey = aggregate_public_key(&pubkeys)?.into();
if aggregate_pubkey == &agg_pubkey {
Ok(())
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum Error {
InvalidBLSSignatureLenght(usize, usize),
/// invalid bls public key length: `expected={0} actual={1}`
InvalidBLSPublicKeyLength(usize, usize),
/// bls aggreate public key mismatch: `{0:?} != {1:?}`
/// bls aggregate public key mismatch: `{0:?} != {1:?}`
BLSAggregatePublicKeyMismatch(PublicKey, PublicKey),
/// invalid address length: `expected={0} actual={1}`
InvalidAddressLength(usize, usize),
Expand Down
4 changes: 2 additions & 2 deletions crates/consensus/src/sync_protocol.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
bls::{is_equal_pubkeys_and_aggreate_pub_key, PublicKey, Signature},
bls::{is_equal_pubkeys_and_aggregate_pub_key, PublicKey, Signature},
errors::Error,
internal_prelude::*,
types::U64,
Expand All @@ -21,7 +21,7 @@ pub struct SyncCommittee<const SYNC_COMMITTEE_SIZE: usize> {

impl<const SYNC_COMMITTEE_SIZE: usize> SyncCommittee<SYNC_COMMITTEE_SIZE> {
pub fn validate(&self) -> Result<(), Error> {
is_equal_pubkeys_and_aggreate_pub_key(&self.pubkeys, &self.aggregate_pubkey)
is_equal_pubkeys_and_aggregate_pub_key(&self.pubkeys, &self.aggregate_pubkey)
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/light-client-verifier/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ pub mod test_utils {
use ethereum_consensus::ssz_rs::Vector;
use ethereum_consensus::{
beacon::{BlockNumber, Checkpoint, Epoch, Slot},
bls::{aggreate_public_key, PublicKey, Signature},
bls::{aggregate_public_key, PublicKey, Signature},
fork::deneb,
merkle::MerkleTree,
preset::minimal::DenebBeaconBlock,
Expand Down Expand Up @@ -441,7 +441,7 @@ pub mod test_utils {
for v in self.committee.iter() {
pubkeys.push(v.public_key());
}
let aggregate_pubkey = aggreate_public_key(&pubkeys.to_vec()).unwrap();
let aggregate_pubkey = aggregate_public_key(&pubkeys.to_vec()).unwrap();
SyncCommittee {
pubkeys: Vector::from_iter(pubkeys.into_iter().map(PublicKey::from)),
aggregate_pubkey: PublicKey::from(aggregate_pubkey),
Expand Down Expand Up @@ -855,7 +855,7 @@ mod tests {
};
use ethereum_consensus::{
beacon::Version,
bls::aggreate_public_key,
bls::aggregate_public_key,
config::{minimal, Config},
fork::{
altair::ALTAIR_FORK_SPEC, bellatrix::BELLATRIX_FORK_SPEC, ForkParameter,
Expand Down Expand Up @@ -897,7 +897,7 @@ mod tests {
.iter()
.map(|k| k.clone().try_into().unwrap())
.collect();
let aggregated_key = aggreate_public_key(&pubkeys).unwrap();
let aggregated_key = aggregate_public_key(&pubkeys).unwrap();
let pubkey = BLSPublicKey {
point: aggregated_key.point,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/light-client-verifier/src/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub trait ConsensusUpdate<const SYNC_COMMITTEE_SIZE: usize>:

/// validate the basic properties of the update
fn validate_basic<C: ConsensusVerificationContext>(&self, ctx: &C) -> Result<(), Error> {
// ensure that sync committee's aggreated key matches pubkeys
// ensure that sync committee's aggregated key matches pubkeys
if let Some(next_sync_committee) = self.next_sync_committee() {
next_sync_committee.validate()?;
}
Expand Down

0 comments on commit 86510d8

Please sign in to comment.