pub struct Keypair(/* private fields */);
Expand description
A vanilla Ed25519 key pair
Implementations§
source§impl Keypair
impl Keypair
sourcepub const SECRET_KEY_LENGTH: usize = 32usize
pub const SECRET_KEY_LENGTH: usize = 32usize
Can be used for generating a Keypair without a dependency on rand
types
sourcepub fn generate<R>(csprng: &mut R) -> Self
pub fn generate<R>(csprng: &mut R) -> Self
Constructs a new, random Keypair
using a caller-provided RNG
sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, SignatureError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, SignatureError>
Recovers a Keypair
from a byte array
sourcepub fn from_base58_string(s: &str) -> Self
pub fn from_base58_string(s: &str) -> Self
Recovers a Keypair
from a base58-encoded string
sourcepub fn to_base58_string(&self) -> String
pub fn to_base58_string(&self) -> String
Returns this Keypair
as a base58-encoded string
sourcepub fn insecure_clone(&self) -> Self
pub fn insecure_clone(&self) -> Self
Allows Keypair cloning
Note that the Clone
trait is intentionally unimplemented because making a
second copy of sensitive secret keys in memory is usually a bad idea.
Only use this in tests or when strictly required. Consider using std::sync::Arc<Keypair>
instead.
Trait Implementations§
source§impl EncodableKey for Keypair
impl EncodableKey for Keypair
fn read<R: Read>(reader: &mut R) -> Result<Self, Box<dyn Error>>
fn write<W: Write>(&self, writer: &mut W) -> Result<String, Box<dyn Error>>
fn read_from_file<F: AsRef<Path>>(path: F) -> Result<Self, Box<dyn Error>>
fn write_to_file<F: AsRef<Path>>( &self, outfile: F, ) -> Result<String, Box<dyn Error>>
source§impl EncodableKeypair for Keypair
impl EncodableKeypair for Keypair
source§impl FromWasmAbi for Keypair
impl FromWasmAbi for Keypair
source§impl IntoWasmAbi for Keypair
impl IntoWasmAbi for Keypair
source§impl LongRefFromWasmAbi for Keypair
impl LongRefFromWasmAbi for Keypair
source§impl OptionFromWasmAbi for Keypair
impl OptionFromWasmAbi for Keypair
source§impl OptionIntoWasmAbi for Keypair
impl OptionIntoWasmAbi for Keypair
source§impl RefFromWasmAbi for Keypair
impl RefFromWasmAbi for Keypair
source§impl RefMutFromWasmAbi for Keypair
impl RefMutFromWasmAbi for Keypair
source§impl SeedDerivable for Keypair
impl SeedDerivable for Keypair
fn from_seed(seed: &[u8]) -> Result<Self, Box<dyn Error>>
fn from_seed_and_derivation_path( seed: &[u8], derivation_path: Option<DerivationPath>, ) -> Result<Self, Box<dyn Error>>
fn from_seed_phrase_and_passphrase( seed_phrase: &str, passphrase: &str, ) -> Result<Self, Box<dyn Error>>
source§impl Signer for Keypair
impl Signer for Keypair
source§fn pubkey(&self) -> Pubkey
fn pubkey(&self) -> Pubkey
Infallibly gets the implementor’s public key. Returns the all-zeros
Pubkey
if the implementor has none.source§fn try_pubkey(&self) -> Result<Pubkey, SignerError>
fn try_pubkey(&self) -> Result<Pubkey, SignerError>
Fallibly gets the implementor’s public key
source§fn sign_message(&self, message: &[u8]) -> Signature
fn sign_message(&self, message: &[u8]) -> Signature
Infallibly produces an Ed25519 signature over the provided
message
bytes. Returns the all-zeros Signature
if signing is not possible.source§fn try_sign_message(&self, message: &[u8]) -> Result<Signature, SignerError>
fn try_sign_message(&self, message: &[u8]) -> Result<Signature, SignerError>
Fallibly produces an Ed25519 signature over the provided
message
bytes.source§fn is_interactive(&self) -> bool
fn is_interactive(&self) -> bool
Whether the implementation requires user interaction to sign
source§impl TryFromJsValue for Keypair
impl TryFromJsValue for Keypair
source§impl VectorFromWasmAbi for Keypair
impl VectorFromWasmAbi for Keypair
source§impl VectorIntoWasmAbi for Keypair
impl VectorIntoWasmAbi for Keypair
Auto Trait Implementations§
impl Freeze for Keypair
impl RefUnwindSafe for Keypair
impl Send for Keypair
impl Sync for Keypair
impl Unpin 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
Mutably borrows from an owned value. Read more
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>
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 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>
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 moresource§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::Abi
source§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
.