#[non_exhaustive]pub enum DerivedPublicKey {
Secp256k1Compressed([u8; 33]),
Secp256k1Uncompressed([u8; 65]),
Ed25519([u8; 32]),
Secp256k1XOnly([u8; 32]),
}Expand description
Strongly typed public key emitted by an HD derivation.
Each variant fixes its length and cryptographic algorithm at the type
level, so consumers can branch on kind (or pattern
match) instead of inspecting a raw byte slice.
§Chain mapping
| Chain(s) | Variant | Length |
|---|---|---|
kobe-btc, kobe-cosmos, kobe-spark, kobe-xrpl | Secp256k1Compressed | 33 B |
kobe-evm, kobe-fil, kobe-tron | Secp256k1Uncompressed | 65 B |
kobe-svm, kobe-sui, kobe-aptos, kobe-ton | Ed25519 | 32 B |
kobe-nostr | Secp256k1XOnly | 32 B |
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Secp256k1Compressed([u8; 33])
secp256k1 compressed SEC1 encoding (0x02/0x03 prefix + 32-byte x).
Secp256k1Uncompressed([u8; 65])
secp256k1 uncompressed SEC1 encoding (0x04 prefix + 32-byte x + 32-byte y).
Ed25519([u8; 32])
Ed25519 32-byte public key (RFC 8032 §5.1.5).
Secp256k1XOnly([u8; 32])
BIP-340 x-only secp256k1 public key (32-byte x, parity dropped).
Implementations§
Source§impl DerivedPublicKey
impl DerivedPublicKey
Sourcepub const fn byte_len(&self) -> usize
pub const fn byte_len(&self) -> usize
Length of the key in bytes.
The method is named byte_len rather than len because a key is
not a collection: the “length” is a constant per variant and has no
emptiness invariant to pair with.
Sourcepub const fn kind(&self) -> PublicKeyKind
pub const fn kind(&self) -> PublicKeyKind
Cryptographic algorithm / encoding tag.
Sourcepub fn compressed(bytes: &[u8]) -> Result<DerivedPublicKey, DeriveError>
pub fn compressed(bytes: &[u8]) -> Result<DerivedPublicKey, DeriveError>
Try to build Secp256k1Compressed from a byte slice.
§Errors
Returns DeriveError::Crypto if the slice is not exactly 33 bytes long.
Sourcepub fn uncompressed(bytes: &[u8]) -> Result<DerivedPublicKey, DeriveError>
pub fn uncompressed(bytes: &[u8]) -> Result<DerivedPublicKey, DeriveError>
Try to build Secp256k1Uncompressed from a byte slice.
§Errors
Returns DeriveError::Crypto if the slice is not exactly 65 bytes long.
Trait Implementations§
Source§impl AsRef<[u8]> for DerivedPublicKey
impl AsRef<[u8]> for DerivedPublicKey
Source§impl Clone for DerivedPublicKey
impl Clone for DerivedPublicKey
Source§fn clone(&self) -> DerivedPublicKey
fn clone(&self) -> DerivedPublicKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DerivedPublicKey
impl Debug for DerivedPublicKey
Source§impl Hash for DerivedPublicKey
impl Hash for DerivedPublicKey
Source§impl PartialEq for DerivedPublicKey
impl PartialEq for DerivedPublicKey
impl Eq for DerivedPublicKey
impl StructuralPartialEq for DerivedPublicKey
Auto Trait Implementations§
impl Freeze for DerivedPublicKey
impl RefUnwindSafe for DerivedPublicKey
impl Send for DerivedPublicKey
impl Sync for DerivedPublicKey
impl Unpin for DerivedPublicKey
impl UnsafeUnpin for DerivedPublicKey
impl UnwindSafe for DerivedPublicKey
Blanket Implementations§
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
use ToHexExt instead
self into the result.
Lower case letters are used (e.g. f9b4ca).Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
use ToHexExt instead
self into the result.
Upper case letters are used (e.g. F9B4CA).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<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Upper case
letters are used (e.g. F9B4CA)Source§impl<T> ToHexExt for T
impl<T> ToHexExt for T
Source§fn encode_hex(&self) -> String
fn encode_hex(&self) -> String
self into the result.
Lower case letters are used (e.g. f9b4ca).Source§fn encode_hex_upper(&self) -> String
fn encode_hex_upper(&self) -> String
self into the result.
Upper case letters are used (e.g. F9B4CA).Source§fn encode_hex_with_prefix(&self) -> String
fn encode_hex_with_prefix(&self) -> String
self into the result with prefix 0x.
Lower case letters are used (e.g. 0xf9b4ca).Source§fn encode_hex_upper_with_prefix(&self) -> String
fn encode_hex_upper_with_prefix(&self) -> String
self into the result with prefix 0X.
Upper case letters are used (e.g. 0xF9B4CA).