pub enum PublicKeyHandle {
ED25519(ED25519PublicKey),
SECP256K1(Secp256K1PublicKey),
MlDsa65(MlDsa65PublicKeyHandle),
}Expand description
How an access-key entry is referred to in the trie.
The trie stores ed25519 and secp256k1 access keys as their full
public keys, but ML-DSA-65 access keys as a SHA3-256 hash of the
pubkey (storage-efficiency optimization - see
docs/architecture/how/post_quantum_signatures.md).
PublicKeyHandle is the type the trie-key layer reads and writes, and the
type used by view-API responses that list an account’s keys. It is
NOT a public key - the MlDsa65 variant cannot verify a
signature. To verify, the caller needs the full pubkey, which is
carried separately on the wire (in the transaction or action).
The variant set mirrors PublicKey for schemes that store the
full key in the trie (ed25519, secp256k1), and replaces ML-DSA-65’s
full-key variant with the SHA3-256 hash actually stored. This makes
“a full ML-DSA-65 key in the trie” unrepresentable in the type
system - the encoding/decoding round-trip becomes lossless and
invalid combinations cannot be constructed.
Variants§
ED25519(ED25519PublicKey)
Full ed25519 public key, as stored in the trie.
SECP256K1(Secp256K1PublicKey)
Full secp256k1 public key, as stored in the trie.
MlDsa65(MlDsa65PublicKeyHandle)
SHA3-256 hash of an ML-DSA-65 public key. The full pubkey is not stored on-chain; only this hash appears in the trie.
Implementations§
Source§impl PublicKeyHandle
impl PublicKeyHandle
Sourcepub fn trie_id_len(&self) -> usize
pub fn trie_id_len(&self) -> usize
Length, in bytes, of this handle’s on-trie borsh encoding: the raw
handle bytes plus a 1-byte borsh discriminant tag (the leading
+ 1 in each arm). For ML-DSA-65 the handle is the 32-byte
SHA3-256 digest, not the full 1952-byte pubkey.
Sourcepub fn key_type(&self) -> KeyType
pub fn key_type(&self) -> KeyType
Key-type tag for this handle. All ML-DSA-65 entries report
KeyType::MLDSA65; the underlying storage is the hash but the
scheme is the same.
Sourcepub fn full_pubkey(&self) -> Option<PublicKey>
pub fn full_pubkey(&self) -> Option<PublicKey>
Returns the underlying full public key, if this handle carries
one (ed25519 / secp256k1). For ML-DSA-65 entries the trie stores
only a hash, so the full pubkey is not recoverable - returns
None in that case.
TODO(post-quantum): every current caller treats the None case as “skip
this entry” (fork-network and mirror tools), which means
ML-DSA-65 access keys are silently dropped during network
forking and mirroring. Grep for TODO(post-quantum) to find the call
sites that need to be taught to recover the full pubkey (e.g.
via a side index of pubkey-hash → pubkey, or via RPC lookup).
Trait Implementations§
Source§impl BorshDeserialize for PublicKeyHandle
impl BorshDeserialize for PublicKeyHandle
fn deserialize_reader<R: Read>(rd: &mut R) -> Result<Self>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for PublicKeyHandle
impl BorshSerialize for PublicKeyHandle
Source§impl Clone for PublicKeyHandle
impl Clone for PublicKeyHandle
Source§fn clone(&self) -> PublicKeyHandle
fn clone(&self) -> PublicKeyHandle
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 PublicKeyHandle
impl Debug for PublicKeyHandle
Source§impl<'de> Deserialize<'de> for PublicKeyHandle
impl<'de> Deserialize<'de> for PublicKeyHandle
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Source§impl Display for PublicKeyHandle
impl Display for PublicKeyHandle
impl Eq for PublicKeyHandle
Source§impl From<&PublicKey> for PublicKeyHandle
impl From<&PublicKey> for PublicKeyHandle
Source§impl From<MlDsa65PublicKeyHandle> for PublicKeyHandle
impl From<MlDsa65PublicKeyHandle> for PublicKeyHandle
Source§fn from(h: MlDsa65PublicKeyHandle) -> Self
fn from(h: MlDsa65PublicKeyHandle) -> Self
Source§impl From<PublicKey> for PublicKeyHandle
impl From<PublicKey> for PublicKeyHandle
Source§impl FromStr for PublicKeyHandle
impl FromStr for PublicKeyHandle
Source§impl Hash for PublicKeyHandle
impl Hash for PublicKeyHandle
Source§impl Ord for PublicKeyHandle
impl Ord for PublicKeyHandle
Source§fn cmp(&self, other: &PublicKeyHandle) -> Ordering
fn cmp(&self, other: &PublicKeyHandle) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PublicKeyHandle
impl PartialEq for PublicKeyHandle
Source§fn eq(&self, other: &PublicKeyHandle) -> bool
fn eq(&self, other: &PublicKeyHandle) -> bool
self and other values to be equal, and is used by ==.