Skip to main content

Keypair

Struct Keypair 

Source
pub struct Keypair { /* private fields */ }
Expand description

A native keypair or a versioned hashed account backed by workspace crypto.

Implementations§

Source§

impl Keypair

Source

pub fn from_hashed_descriptor( encoded: &[u8], ss58_format: u16, ) -> Result<Self, CoreError>

Restore public account metadata without retaining any signing material.

Source

pub fn public_only(&self) -> Result<Self, CoreError>

Clone public metadata only, including the hashed genesis descriptor.

Source

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.

Source

pub fn hashed_descriptor(&self) -> Result<Vec<u8>, CoreError>

Source

pub fn hashed_generation(&self) -> Result<u64, CoreError>

Source

pub fn hashed_public_key(&self) -> Result<[u8; 32], CoreError>

Source

pub fn hashed_commitment(&self, generation: u64) -> Result<[u8; 32], CoreError>

Source

pub fn hashed_current_commitment(&self) -> Result<[u8; 32], CoreError>

Source

pub fn hashed_next_commitment(&self) -> Result<[u8; 32], CoreError>

Source

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.

Source

pub fn hashed_signing_public_key(&self) -> Result<Vec<u8>, CoreError>

Source§

impl Keypair

Source

pub fn pq_public_key(&self) -> Result<Vec<u8>, CoreError>

Active transaction public key, with the width selected by the wallet profile.

Source§

impl Keypair

Source

pub fn from_mldsa_descriptor( encoded: &[u8], ss58_format: u16, ) -> Result<Self, CoreError>

Source

pub fn mldsa_descriptor(&self) -> Result<Vec<u8>, CoreError>

Source

pub fn mldsa_profile(&self) -> Result<u8, CoreError>

Source

pub fn mldsa_generation(&self) -> Result<u64, CoreError>

Source

pub fn mldsa_public_key(&self) -> Result<PublicKeyBytes, CoreError>

Source

pub fn mldsa_commitment(&self, generation: u64) -> Result<[u8; 64], CoreError>

Source

pub fn mldsa_current_commitment(&self) -> Result<[u8; 64], CoreError>

Source

pub fn mldsa_next_commitment(&self) -> Result<[u8; 64], CoreError>

Source

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.

Source

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.

Source

pub fn authorization_descriptor(&self) -> Result<Vec<u8>, CoreError>

Variable-width authorization APIs support classical and post-quantum profiles without changing the historical fixed-width Rust v1 APIs.

Source

pub fn authorization_generation(&self) -> Result<u64, CoreError>

Source

pub fn authorization_public_key(&self) -> Result<Vec<u8>, CoreError>

Source

pub fn authorization_commitment( &self, generation: u64, ) -> Result<Vec<u8>, CoreError>

Source

pub fn authorization_current_commitment(&self) -> Result<Vec<u8>, CoreError>

Source

pub fn authorization_next_commitment(&self) -> Result<Vec<u8>, CoreError>

Source

pub fn sign_authorization(&self, payload: &[u8]) -> Result<Vec<u8>, CoreError>

Source§

impl Keypair

Source

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

Source

pub fn account_type(&self) -> &'static str

Source

pub fn signing_scheme(&self) -> &'static str

Source

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.

Source

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).

Source

pub fn from_seed(seed: &[u8], crypto_type: u8) -> Result<Self, CoreError>

Derive a keypair from a 32-byte seed.

Source

pub fn from_uri(uri: &str, crypto_type: u8) -> Result<Self, CoreError>

Derive a keypair from a secret URI (e.g. “//Alice” or “//hard/soft”).

Source

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.

Source

pub fn generate_mnemonic(n_words: usize) -> Result<String, CoreError>

Generate a fresh mnemonic with n_words (12/15/18/21/24).

Source

pub fn from_encrypted_json( json_data: &str, passphrase: &str, ) -> Result<Self, CoreError>

Import a keypair from a PolkadotJS encrypted JSON keystore (v3).

Source

pub fn crypto_type(&self) -> u8

Source

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.

Source

pub fn ss58_address(&self) -> String

Source

pub fn ss58_format(&self) -> u16

Source

pub fn private_key_bytes(&self) -> Option<Vec<u8>>

Source

pub fn mnemonic(&self) -> Option<&str>

The BIP39 phrase this keypair was derived from, when retained.

Source

pub fn seed_bytes(&self) -> Option<&[u8]>

The raw seed this keypair was derived from, when retained.

Source

pub fn sign(&self, message: &[u8]) -> Result<Vec<u8>, CoreError>

Sign a message; returns the raw 64-byte signature.

Source

pub fn verify( &self, message: &[u8], signature: &[u8], ) -> Result<bool, CoreError>

Verify a signature. Matches btwallet’s <Bytes> wrapping fallback.

Source

pub fn encrypt(&self, message: &[u8]) -> Result<Vec<u8>, CoreError>

Encrypt a message to this keypair’s ed25519 public key (sealed box).

Source

pub fn decrypt(&self, ciphertext: &[u8]) -> Result<Vec<u8>, CoreError>

Decrypt a sealed-box ciphertext with this ed25519 keypair’s private key.

Source

pub fn encrypt_for( ss58_address: &str, message: &[u8], crypto_type: u8, ) -> Result<Vec<u8>, CoreError>

Encrypt a message for a recipient SS58 address (ed25519 sealed box).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> JsonSchemaMaybe for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

Source§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more