pub struct MultiKeyPublicKey { /* private fields */ }Expand description
A multi-key public key supporting mixed signature schemes.
This allows M-of-N threshold signing where each key can be a different type.
Implementations§
Source§impl MultiKeyPublicKey
impl MultiKeyPublicKey
Sourcepub fn new(public_keys: Vec<AnyPublicKey>, threshold: u8) -> AptosResult<Self>
pub fn new(public_keys: Vec<AnyPublicKey>, threshold: u8) -> AptosResult<Self>
Creates a new multi-key public key.
§Arguments
public_keys- The individual public keys (can be mixed types)threshold- The number of signatures required (M in M-of-N)
§Errors
Returns AptosError::InvalidPublicKey if:
- No public keys are provided
- More than 32 public keys are provided
- Threshold is 0
- Threshold exceeds the number of keys
Sourcepub fn public_keys(&self) -> &[AnyPublicKey]
pub fn public_keys(&self) -> &[AnyPublicKey]
Returns the individual public keys.
Sourcepub fn get(&self, index: usize) -> Option<&AnyPublicKey>
pub fn get(&self, index: usize) -> Option<&AnyPublicKey>
Returns the key at the given index.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serializes to bytes for authentication key derivation.
Format: num_keys || pk1_bcs || pk2_bcs || … || threshold
Sourcepub fn from_bytes(bytes: &[u8]) -> AptosResult<Self>
pub fn from_bytes(bytes: &[u8]) -> AptosResult<Self>
Creates from bytes.
§Errors
Returns AptosError::InvalidPublicKey if:
- The bytes are empty
- The number of keys is invalid (0 or > 32)
- The bytes are too short for the expected structure
- Any public key variant byte is invalid
- Any public key length or data is invalid
- The threshold is invalid
Sourcepub fn to_address(&self) -> AccountAddress
pub fn to_address(&self) -> AccountAddress
Derives the account address for this multi-key public key.
Sourcepub fn to_authentication_key(&self) -> [u8; 32]
pub fn to_authentication_key(&self) -> [u8; 32]
Derives the authentication key for this public key.
Sourcepub fn verify(
&self,
message: &[u8],
signature: &MultiKeySignature,
) -> AptosResult<()>
pub fn verify( &self, message: &[u8], signature: &MultiKeySignature, ) -> AptosResult<()>
Verifies a multi-key signature against a message.
§Errors
This function will return an error if:
- The number of signatures is less than the threshold
- Any individual signature verification fails
- A signer index is out of bounds
Trait Implementations§
Source§impl Clone for MultiKeyPublicKey
impl Clone for MultiKeyPublicKey
Source§fn clone(&self) -> MultiKeyPublicKey
fn clone(&self) -> MultiKeyPublicKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MultiKeyPublicKey
impl Debug for MultiKeyPublicKey
Source§impl Display for MultiKeyPublicKey
impl Display for MultiKeyPublicKey
Source§impl PartialEq for MultiKeyPublicKey
impl PartialEq for MultiKeyPublicKey
impl Eq for MultiKeyPublicKey
impl StructuralPartialEq for MultiKeyPublicKey
Auto Trait Implementations§
impl Freeze for MultiKeyPublicKey
impl RefUnwindSafe for MultiKeyPublicKey
impl Send for MultiKeyPublicKey
impl Sync for MultiKeyPublicKey
impl Unpin for MultiKeyPublicKey
impl UnwindSafe for MultiKeyPublicKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.