pub struct AnyPublicKey {
pub variant: AnyPublicKeyVariant,
pub bytes: Vec<u8>,
}Expand description
A public key that can be any supported signature scheme.
Fields§
§variant: AnyPublicKeyVariantThe signature scheme variant.
bytes: Vec<u8>The raw public key bytes.
Implementations§
Source§impl AnyPublicKey
impl AnyPublicKey
Sourcepub fn new(variant: AnyPublicKeyVariant, bytes: Vec<u8>) -> Self
pub fn new(variant: AnyPublicKeyVariant, bytes: Vec<u8>) -> Self
Creates a new AnyPublicKey.
Sourcepub fn ed25519(public_key: &Ed25519PublicKey) -> Self
Available on crate feature ed25519 only.
pub fn ed25519(public_key: &Ed25519PublicKey) -> Self
ed25519 only.Creates an Ed25519 public key.
Sourcepub fn secp256k1(public_key: &Secp256k1PublicKey) -> Self
Available on crate feature secp256k1 only.
pub fn secp256k1(public_key: &Secp256k1PublicKey) -> Self
secp256k1 only.Creates a Secp256k1 public key. Uses uncompressed format (65 bytes) as required by the Aptos protocol.
Sourcepub fn secp256r1(public_key: &Secp256r1PublicKey) -> Self
Available on crate feature secp256r1 only.
pub fn secp256r1(public_key: &Secp256r1PublicKey) -> Self
secp256r1 only.Creates a Secp256r1 public key. Uses uncompressed format (65 bytes) as required by the Aptos protocol.
Sourcepub fn to_bcs_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bcs_bytes(&self) -> Vec<u8> ⓘ
Serializes to BCS format: variant_byte || ULEB128(length) || bytes
This is the correct BCS serialization format for AnyPublicKey used
in authentication key derivation: SHA3-256(BCS(AnyPublicKey) || scheme_id)
Sourcepub fn verify(
&self,
message: &[u8],
signature: &AnySignature,
) -> AptosResult<()>
pub fn verify( &self, message: &[u8], signature: &AnySignature, ) -> AptosResult<()>
Verifies a signature against a message.
§Errors
This function will return an error if:
- The signature variant doesn’t match the public key variant
- The public key bytes are invalid for the variant
- The signature bytes are invalid for the variant
- Signature verification fails
- Verification is not supported for the variant
Trait Implementations§
Source§impl Clone for AnyPublicKey
impl Clone for AnyPublicKey
Source§fn clone(&self) -> AnyPublicKey
fn clone(&self) -> AnyPublicKey
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 AnyPublicKey
impl Debug for AnyPublicKey
Source§impl Display for AnyPublicKey
impl Display for AnyPublicKey
Source§impl PartialEq for AnyPublicKey
impl PartialEq for AnyPublicKey
impl Eq for AnyPublicKey
impl StructuralPartialEq for AnyPublicKey
Auto Trait Implementations§
impl Freeze for AnyPublicKey
impl RefUnwindSafe for AnyPublicKey
impl Send for AnyPublicKey
impl Sync for AnyPublicKey
impl Unpin for AnyPublicKey
impl UnwindSafe for AnyPublicKey
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.