pub struct Keypair { /* private fields */ }Expand description
A native keypair or a versioned hashed account backed by workspace crypto.
Implementations§
Source§impl Keypair
impl Keypair
Sourcepub fn from_hashed_descriptor(
encoded: &[u8],
ss58_format: u16,
) -> Result<Self, CoreError>
pub fn from_hashed_descriptor( encoded: &[u8], ss58_format: u16, ) -> Result<Self, CoreError>
Restore public account metadata without retaining any signing material.
Sourcepub fn public_only(&self) -> Result<Self, CoreError>
pub fn public_only(&self) -> Result<Self, CoreError>
Clone public metadata only, including the hashed genesis descriptor.
Sourcepub fn at_generation(&self, generation: u64) -> Result<Self, CoreError>
pub fn at_generation(&self, generation: u64) -> Result<Self, CoreError>
A new view of the same stable account at the generation read from chain. Neither this operation nor signing mutates any persisted wallet state.
pub fn hashed_descriptor(&self) -> Result<Vec<u8>, CoreError>
pub fn hashed_generation(&self) -> Result<u64, CoreError>
pub fn hashed_public_key(&self) -> Result<[u8; 32], CoreError>
pub fn hashed_commitment(&self, generation: u64) -> Result<[u8; 32], CoreError>
pub fn hashed_current_commitment(&self) -> Result<[u8; 32], CoreError>
pub fn hashed_next_commitment(&self) -> Result<[u8; 32], CoreError>
Sourcepub fn sign_hashed(&self, payload: &[u8]) -> Result<Vec<u8>, CoreError>
pub fn sign_hashed(&self, payload: &[u8]) -> Result<Vec<u8>, CoreError>
Sign a direct call’s complete, unshortened Substrate payload. Bind the versioned raw signer address (account, scheme, generation, current key and next commitment) under the transaction domain before signing.
pub fn hashed_signing_public_key(&self) -> Result<Vec<u8>, CoreError>
Source§impl Keypair
impl Keypair
pub fn from_mldsa_descriptor( encoded: &[u8], ss58_format: u16, ) -> Result<Self, CoreError>
pub fn mldsa_descriptor(&self) -> Result<Vec<u8>, CoreError>
pub fn mldsa_profile(&self) -> Result<u8, CoreError>
pub fn mldsa_generation(&self) -> Result<u64, CoreError>
pub fn mldsa_public_key(&self) -> Result<PublicKeyBytes, CoreError>
pub fn mldsa_commitment(&self, generation: u64) -> Result<[u8; 64], CoreError>
pub fn mldsa_current_commitment(&self) -> Result<[u8; 64], CoreError>
pub fn mldsa_next_commitment(&self) -> Result<[u8; 64], CoreError>
Sourcepub fn sign_mldsa(&self, payload: &[u8]) -> Result<Vec<u8>, CoreError>
pub fn sign_mldsa(&self, payload: &[u8]) -> Result<Vec<u8>, CoreError>
Returns the entire canonical MlDsaSignerAddress, not a MultiSignature payload.
payload is the full unshortened native call + extra + implicit data.
Sourcepub fn sign_mldsa_with_randomness(
&self,
payload: &[u8],
random: &[u8; 32],
) -> Result<Vec<u8>, CoreError>
pub fn sign_mldsa_with_randomness( &self, payload: &[u8], random: &[u8; 32], ) -> Result<Vec<u8>, CoreError>
Explicit deterministic input supports offline devices and golden vectors.
Variable-width authorization APIs support classical and post-quantum profiles without changing the historical fixed-width Rust v1 APIs.
Source§impl Keypair
impl Keypair
Sourcepub fn hashed_receiving_address(&self) -> Result<String, CoreError>
pub fn hashed_receiving_address(&self) -> Result<String, CoreError>
Return the ordinary SS58 address for fixed ML-DSA, or the receiving descriptor for a registered account, without exposing a signing key.
Source§impl Keypair
impl Keypair
pub fn account_type(&self) -> &'static str
pub fn signing_scheme(&self) -> &'static str
Sourcepub fn new(
ss58_address: Option<&str>,
public_key: Option<&[u8]>,
crypto_type: u8,
ss58_format: u16,
) -> Result<Self, CoreError>
pub fn new( ss58_address: Option<&str>, public_key: Option<&[u8]>, crypto_type: u8, ss58_format: u16, ) -> Result<Self, CoreError>
Public-only or full keypair from SS58 address and/or raw public key bytes.
Sourcepub fn from_mnemonic(
mnemonic: &str,
crypto_type: u8,
password: Option<&str>,
) -> Result<Self, CoreError>
pub fn from_mnemonic( mnemonic: &str, crypto_type: u8, password: Option<&str>, ) -> Result<Self, CoreError>
Derive a keypair from a BIP39 mnemonic (with optional password).
Sourcepub fn from_seed(seed: &[u8], crypto_type: u8) -> Result<Self, CoreError>
pub fn from_seed(seed: &[u8], crypto_type: u8) -> Result<Self, CoreError>
Derive a keypair from a 32-byte seed.
Sourcepub fn from_uri(uri: &str, crypto_type: u8) -> Result<Self, CoreError>
pub fn from_uri(uri: &str, crypto_type: u8) -> Result<Self, CoreError>
Derive a keypair from a secret URI (e.g. “//Alice” or “
Sourcepub fn from_private_key(
private_key: &str,
crypto_type: u8,
) -> Result<Self, CoreError>
pub fn from_private_key( private_key: &str, crypto_type: u8, ) -> Result<Self, CoreError>
Derive a keypair from a hex-encoded private key or seed bytes.
Sourcepub fn generate_mnemonic(n_words: usize) -> Result<String, CoreError>
pub fn generate_mnemonic(n_words: usize) -> Result<String, CoreError>
Generate a fresh mnemonic with n_words (12/15/18/21/24).
Sourcepub fn from_encrypted_json(
json_data: &str,
passphrase: &str,
) -> Result<Self, CoreError>
pub fn from_encrypted_json( json_data: &str, passphrase: &str, ) -> Result<Self, CoreError>
Import a keypair from a PolkadotJS encrypted JSON keystore (v3).
pub fn crypto_type(&self) -> u8
Sourcepub fn public_key_bytes(&self) -> [u8; 32]
pub fn public_key_bytes(&self) -> [u8; 32]
Stable account identity. For hashed wallets, obtain the active signer
separately with hashed_public_key, only when constructing its proof.
pub fn ss58_address(&self) -> String
pub fn ss58_format(&self) -> u16
pub fn private_key_bytes(&self) -> Option<Vec<u8>>
Sourcepub fn mnemonic(&self) -> Option<&str>
pub fn mnemonic(&self) -> Option<&str>
The BIP39 phrase this keypair was derived from, when retained.
Sourcepub fn seed_bytes(&self) -> Option<&[u8]>
pub fn seed_bytes(&self) -> Option<&[u8]>
The raw seed this keypair was derived from, when retained.
Sourcepub fn sign(&self, message: &[u8]) -> Result<Vec<u8>, CoreError>
pub fn sign(&self, message: &[u8]) -> Result<Vec<u8>, CoreError>
Sign a message; returns the raw 64-byte signature.
Sourcepub fn verify(
&self,
message: &[u8],
signature: &[u8],
) -> Result<bool, CoreError>
pub fn verify( &self, message: &[u8], signature: &[u8], ) -> Result<bool, CoreError>
Verify a signature. Matches btwallet’s <Bytes> wrapping fallback.
Sourcepub fn encrypt(&self, message: &[u8]) -> Result<Vec<u8>, CoreError>
pub fn encrypt(&self, message: &[u8]) -> Result<Vec<u8>, CoreError>
Encrypt a message to this keypair’s ed25519 public key (sealed box).
Auto Trait Implementations§
impl Forget for Keypair
impl Freeze for Keypair
impl Move for Keypair
impl RefUnwindSafe for Keypair
impl Send for Keypair
impl Sync for Keypair
impl Unpin for Keypair
impl UnsafeUnpin for Keypair
impl UnwindSafe for Keypair
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> JsonSchemaMaybe for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.