pub struct AnySignature {
pub variant: AnyPublicKeyVariant,
pub bytes: Vec<u8>,
}Expand description
A signature that can be any supported signature scheme.
Fields§
§variant: AnyPublicKeyVariantThe signature scheme variant.
bytes: Vec<u8>The raw signature bytes.
Implementations§
Source§impl AnySignature
impl AnySignature
Sourcepub fn new(variant: AnyPublicKeyVariant, bytes: Vec<u8>) -> Self
pub fn new(variant: AnyPublicKeyVariant, bytes: Vec<u8>) -> Self
Creates a new AnySignature.
Sourcepub fn ed25519(signature: &Ed25519Signature) -> Self
Available on crate feature ed25519 only.
pub fn ed25519(signature: &Ed25519Signature) -> Self
ed25519 only.Creates an Ed25519 signature.
Sourcepub fn secp256k1(signature: &Secp256k1Signature) -> Self
Available on crate feature secp256k1 only.
pub fn secp256k1(signature: &Secp256k1Signature) -> Self
secp256k1 only.Creates a Secp256k1 signature.
Sourcepub fn secp256r1(signature: &Secp256r1Signature) -> Self
Available on crate feature secp256r1 only.
pub fn secp256r1(signature: &Secp256r1Signature) -> Self
secp256r1 only.Creates a Secp256r1 signature.
Sourcepub fn to_bcs_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bcs_bytes(&self) -> Vec<u8> ⓘ
Serializes to BCS AnySignature bytes.
Most variants use variant_byte || ULEB128(len) || payload.
On Aptos, discriminant 2 is shared by bare Secp256r1Ecdsa signatures (64-byte
payload) and the WebAuthn variant, which embeds a PartialAuthenticatorAssertionResponse
struct without an outer ULEB128 length prefix after the enum tag. When this struct
is present, the first payload byte is 0x00 (AssertionSignature::Secp256r1Ecdsa).
For that shape we serialize as 0x02 || payload to match the chain and
crate::account::WebAuthnAccount.
Sourcepub fn from_bcs_bytes(bytes: &[u8]) -> AptosResult<Self>
pub fn from_bcs_bytes(bytes: &[u8]) -> AptosResult<Self>
Parses BCS AnySignature bytes from the wire.
For variants other than Secp256r1 (2), this expects
variant || ULEB128(len) || payload.
For discriminant 2, Aptos uses two layouts:
- Bare ECDSA:
0x02||ULEB128(64)|| 64-byte signature. The length prefix always begins with0x40when64is encoded as a single ULEB128 byte. - WebAuthn:
0x02|| BCS(PartialAuthenticatorAssertionResponse), which begins with0x00(AssertionSignature::Secp256r1Ecdsa) — no outerULEB128wrapping the struct.
§Errors
Returns AptosError::InvalidSignature if the slice is empty, the variant byte is
unknown, the length prefix is malformed, the payload is truncated, or trailing bytes
remain after the declared signature bytes.
Trait Implementations§
Source§impl Clone for AnySignature
impl Clone for AnySignature
Source§fn clone(&self) -> AnySignature
fn clone(&self) -> AnySignature
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AnySignature
impl Debug for AnySignature
Source§impl PartialEq for AnySignature
impl PartialEq for AnySignature
Source§fn eq(&self, other: &AnySignature) -> bool
fn eq(&self, other: &AnySignature) -> bool
self and other values to be equal, and is used by ==.impl Eq for AnySignature
impl StructuralPartialEq for AnySignature
Auto Trait Implementations§
impl Freeze for AnySignature
impl RefUnwindSafe for AnySignature
impl Send for AnySignature
impl Sync for AnySignature
impl Unpin for AnySignature
impl UnsafeUnpin for AnySignature
impl UnwindSafe for AnySignature
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
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
key and return true if they are equal.