From d39ef7e0c63ade4dedfe07e3c29caad1278372bd Mon Sep 17 00:00:00 2001 From: "zhoujun.ma" Date: Sun, 4 Feb 2024 00:08:58 -0800 Subject: [PATCH] update QuorumCertifiedUpdate struct --- aptos-move/aptos-vm/src/validator_txns/jwk.rs | 16 ++-------------- types/src/jwks/mod.rs | 15 +++++++-------- types/src/validator_txn.rs | 2 +- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/aptos-move/aptos-vm/src/validator_txns/jwk.rs b/aptos-move/aptos-vm/src/validator_txns/jwk.rs index b469779761d96..f302e3ee7e2fa 100644 --- a/aptos-move/aptos-vm/src/validator_txns/jwk.rs +++ b/aptos-move/aptos-vm/src/validator_txns/jwk.rs @@ -14,9 +14,7 @@ use crate::{ }, AptosVM, }; -use aptos_bitvec::BitVec; use aptos_types::{ - aggregate_signature::AggregateSignature, fee_statement::FeeStatement, jwks, jwks::{Issuer, ObservedJWKs, ProviderJWKs, QuorumCertifiedUpdate}, @@ -94,7 +92,6 @@ impl AptosVM { let verifier = ValidatorVerifier::from(&validator_set); let QuorumCertifiedUpdate { - authors, update: observed, multi_sig, } = update; @@ -104,13 +101,7 @@ impl AptosVM { return Err(Expected(IncorrectVersion)); } - let signer_bit_vec = BitVec::from( - verifier - .get_ordered_account_addresses() - .into_iter() - .map(|addr| authors.contains(&addr)) - .collect::>(), - ); + let authors = multi_sig.get_signers_addresses(&verifier.get_ordered_account_addresses()); // Check voting power. verifier @@ -119,10 +110,7 @@ impl AptosVM { // Verify multi-sig. verifier - .verify_multi_signatures( - &observed, - &AggregateSignature::new(signer_bit_vec, Some(multi_sig)), - ) + .verify_multi_signatures(&observed, &multi_sig) .map_err(|_| Expected(MultiSigVerificationFailed))?; // All verification passed. Apply the `observed`. diff --git a/types/src/jwks/mod.rs b/types/src/jwks/mod.rs index f688fda472d61..98fdc5c16f2d6 100644 --- a/types/src/jwks/mod.rs +++ b/types/src/jwks/mod.rs @@ -1,13 +1,14 @@ // Copyright © Aptos Foundation use self::jwk::JWK; -use crate::{move_utils::as_move_value::AsMoveValue, on_chain_config::OnChainConfig}; +use crate::{ + aggregate_signature::AggregateSignature, move_utils::as_move_value::AsMoveValue, + on_chain_config::OnChainConfig, +}; use anyhow::{bail, Context}; -use aptos_crypto::bls12381; use aptos_crypto_derive::{BCSCryptoHash, CryptoHasher}; use jwk::JWKMoveStruct; use move_core_types::{ - account_address::AccountAddress, ident_str, identifier::IdentStr, move_resource::MoveStructType, @@ -15,7 +16,7 @@ use move_core_types::{ }; use serde::{Deserialize, Serialize}; use std::{ - collections::{BTreeSet, HashMap}, + collections::HashMap, fmt::{Debug, Formatter}, }; @@ -190,18 +191,16 @@ impl MoveStructType for PatchedJWKs { /// A JWK update in format of `ProviderJWKs` and a multi-signature of it as a quorum certificate. #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, CryptoHasher, BCSCryptoHash)] pub struct QuorumCertifiedUpdate { - pub authors: BTreeSet, pub update: ProviderJWKs, - pub multi_sig: bls12381::Signature, + pub multi_sig: AggregateSignature, } impl QuorumCertifiedUpdate { #[cfg(any(test, feature = "fuzzing"))] pub fn dummy() -> Self { Self { - authors: Default::default(), update: ProviderJWKs::new(dummy_issuer()), - multi_sig: bls12381::Signature::dummy_signature(), + multi_sig: AggregateSignature::empty(), } } } diff --git a/types/src/validator_txn.rs b/types/src/validator_txn.rs index 0eb6dba67adcd..d99b43a96a1d2 100644 --- a/types/src/validator_txn.rs +++ b/types/src/validator_txn.rs @@ -3,7 +3,7 @@ #[cfg(any(test, feature = "fuzzing"))] use crate::dkg::DKGTranscriptMetadata; -use crate::{DKGTranscript, jwks}; +use crate::{dkg::DKGTranscript, jwks}; use aptos_crypto_derive::{BCSCryptoHash, CryptoHasher}; #[cfg(any(test, feature = "fuzzing"))] use move_core_types::account_address::AccountAddress;