pub struct SecpPair { /* private fields */ }Expand description
A secp256k1 key pair.
Implementations§
Source§impl SecpPair
impl SecpPair
pub fn generate() -> (Self, [u8; 32])
Sourcepub fn generate_with_phrase(
password: Option<&str>,
) -> (SecpPair, String, [u8; 32])
pub fn generate_with_phrase( password: Option<&str>, ) -> (SecpPair, String, [u8; 32])
Generate new secure (random) key pair and provide the recovery phrase.
You can recover the same key later with from_phrase.
Sourcepub fn from_phrase(
phrase: &str,
password: Option<&str>,
) -> Result<(SecpPair, [u8; 32])>
pub fn from_phrase( phrase: &str, password: Option<&str>, ) -> Result<(SecpPair, [u8; 32])>
Generate key pair from given recovery phrase and password.
Sourcepub fn from_seed(seed: &[u8; 32]) -> SecpPair
pub fn from_seed(seed: &[u8; 32]) -> SecpPair
Make a new key pair from secret seed material.
You should never need to use this; generate(), generate_with_phrase
Sourcepub fn from_seed_slice(seed_slice: &[u8]) -> Result<SecpPair>
pub fn from_seed_slice(seed_slice: &[u8]) -> Result<SecpPair>
Make a new key pair from secret seed material. The slice must be 32 bytes long or it
will return None.
You should never need to use this; generate(), generate_with_phrase
Sourcepub fn sign_prehashed(&self, message: &[u8; 32]) -> Signature
pub fn sign_prehashed(&self, message: &[u8; 32]) -> Signature
Sign a pre-hashed message
Sourcepub fn verify<M: AsRef<[u8]>>(
sig: &Signature,
message: M,
pubkey: &Public,
) -> bool
pub fn verify<M: AsRef<[u8]>>( sig: &Signature, message: M, pubkey: &Public, ) -> bool
Verify a signature on a message. Returns true if the signature is good.
Sourcepub fn to_raw_vec(self) -> Vec<u8> ⓘ
pub fn to_raw_vec(self) -> Vec<u8> ⓘ
Return a vec filled with raw data.
Trait Implementations§
impl Copy for SecpPair
impl Eq for SecpPair
impl StructuralPartialEq for SecpPair
Auto Trait Implementations§
impl Freeze for SecpPair
impl RefUnwindSafe for SecpPair
impl Send for SecpPair
impl Sync for SecpPair
impl Unpin for SecpPair
impl UnwindSafe for SecpPair
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