pub struct Key { /* private fields */ }Expand description
| An encapsulated private key. |
Implementations§
Source§impl Key
impl Key
Sourcepub fn set<T>(&mut self, pbegin: T, pend: T, compressed_in: bool)
pub fn set<T>(&mut self, pbegin: T, pend: T, compressed_in: bool)
| Initialize using begin and end iterators | to byte data. |
pub fn begin(&self) -> *const u8
pub fn end(&self) -> *const u8
Sourcepub fn is_compressed(&self) -> bool
pub fn is_compressed(&self) -> bool
| Check whether the public key corresponding | to this private key is (to be) compressed. |
Sourcepub fn check(&mut self, vch: *const u8) -> bool
pub fn check(&mut self, vch: *const u8) -> bool
| Check whether the 32-byte array pointed | to by vch is valid keydata. |
Sourcepub fn make_new_key(&mut self, compressed_in: bool)
pub fn make_new_key(&mut self, compressed_in: bool)
| Generate a new private key using a cryptographic | PRNG. |
Sourcepub fn get_priv_key(&self) -> PrivKey
pub fn get_priv_key(&self) -> PrivKey
| Convert the private key to a CPrivKey | (serialized OpenSSL private key data). | | This is expensive. |
Sourcepub fn get_pub_key(&self) -> PubKey
pub fn get_pub_key(&self) -> PubKey
| Compute the public key from a private | key. | | This is expensive. |
Sourcepub fn sign(
&self,
hash: &u256,
vch_sig: &mut Vec<u8>,
grind: Option<bool>,
test_case: Option<u32>,
) -> bool
pub fn sign( &self, hash: &u256, vch_sig: &mut Vec<u8>, grind: Option<bool>, test_case: Option<u32>, ) -> bool
| Create a DER-serialized signature. | | The test_case parameter tweaks the | deterministic nonce. |
Sourcepub fn verify_pub_key(&self, pubkey: &PubKey) -> bool
pub fn verify_pub_key(&self, pubkey: &PubKey) -> bool
| Verify thoroughly whether a private | key and a public key match. | | This is done using a different mechanism | than just regenerating it. |
Sourcepub fn sign_compact(&self, hash: &u256, vch_sig: &mut Vec<u8>) -> bool
pub fn sign_compact(&self, hash: &u256, vch_sig: &mut Vec<u8>) -> bool
| Create a compact signature (65 bytes), | which allows reconstructing the used | public key. | | The format is one header byte, followed | by two times 32 bytes for the serialized | r and s values. | | The header byte: 0x1B = first key with | even y, 0x1C = first key with odd y, 0x1D | = second key with even y, 0x1E = second | key with odd y, add 0x04 for compressed | keys. |
Sourcepub fn sign_schnorr(
&self,
hash: &u256,
sig: &[u8],
merkle_root: *const u256,
aux: *const u256,
) -> bool
pub fn sign_schnorr( &self, hash: &u256, sig: &[u8], merkle_root: *const u256, aux: *const u256, ) -> bool
| Create a BIP-340 Schnorr signature, | for the xonly-pubkey corresponding | to *this, optionally tweaked by *merkle_root. | Additional nonce entropy can be provided | through aux. merkle_root is used to | optionally perform tweaking of the | private key, as specified in BIP341: | | - If merkle_root == nullptr: no tweaking | is done, sign with key directly (this | is used for signatures in BIP342 script). | | - If merkle_root->IsNull(): sign with | key + H_TapTweak(pubkey) (this is used | for key path spending when no scripts | are present). | | - Otherwise: sign with key + H_TapTweak(pubkey | || *merkle_root) (this is used for key | path spending, with specific | | Merkle root of the script tree). |
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Key
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnwindSafe for Key
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
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.