pub struct PubKey { /* private fields */ }Expand description
| An encapsulated public key. | | Opaque data structure that holds a parsed | and valid public key. | | The exact representation of data inside | is implementation defined and not guaranteed | to be portable between different platforms | or versions. It is however guaranteed | to be 64 bytes in size, and can be safely | copied/moved. | | If you need to convert to a format suitable | for storage or transmission, use ec_pubkey_serialize | and ec_pubkey_parse. To compare keys, | use ec_pubkey_cmp. |
Implementations§
Source§impl PubKey
impl PubKey
Sourcepub fn get_len(ch_header: u8) -> u32
pub fn get_len(ch_header: u8) -> u32
| Compute the length of a pubkey with a | given first byte. |
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
| Set this key data to be invalid |
pub fn valid_size(vch: &Vec<u8>) -> bool
Sourcepub fn set<T>(&mut self, pbegin: T, pend: T)
pub fn set<T>(&mut self, pbegin: T, pend: T)
| Initialize a public key using begin/end | iterators to byte data. |
Sourcepub fn new_with_iter<T>(pbegin: T, pend: T) -> Self
pub fn new_with_iter<T>(pbegin: T, pend: T) -> Self
| Construct a public key using begin/end | iterators to byte data. |
Sourcepub fn new(slice: &[u8]) -> Self
pub fn new(slice: &[u8]) -> Self
| Construct a public key using begin/end | iterators to byte data. |
pub fn data(&self) -> *const u8
pub fn begin(&self) -> *const u8
pub fn end(&self) -> *const u8
Sourcepub fn serialize<Stream>(&self, s: &mut Stream)
pub fn serialize<Stream>(&self, s: &mut Stream)
| Implement serialization, as if this | was a byte vector. |
pub fn unserialize<Stream>(&mut self, s: &mut Stream)
Sourcepub fn getid(&self) -> KeyID
pub fn getid(&self) -> KeyID
| Get the KeyID of this public key (hash | of its serialization) |
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
| Check syntactic correctness. | | When setting a pubkey (Set()) or deserializing | fails (its header bytes don’t match | the length of the data), the size is set | to 0. Thus, by checking size, one can | observe whether Set() or deserialization | has failed. | | This does not check for more than that. | In particular, it does not verify that | the coordinates correspond to a point | on the curve (see IsFullyValid() for | that instead). | | ———– | @note | | this is consensus critical as | | CheckECDSASignature() calls it! |
Sourcepub fn is_compressed(&self) -> bool
pub fn is_compressed(&self) -> bool
| Check whether this is a compressed public | key. |
Sourcepub fn check_lows(&mut self, vch_sig: &Vec<u8>) -> bool
pub fn check_lows(&mut self, vch_sig: &Vec<u8>) -> bool
| Check whether a signature is normalized | (lower-S). |
Sourcepub fn verify(&self, hash: &u256, vch_sig: &Vec<u8>) -> bool
pub fn verify(&self, hash: &u256, vch_sig: &Vec<u8>) -> bool
| Verify a DER signature (~72 bytes). | | If this public key is not fully valid, | the return value will be false. |
Sourcepub fn recover_compact(&mut self, hash: &u256, vch_sig: &Vec<u8>) -> bool
pub fn recover_compact(&mut self, hash: &u256, vch_sig: &Vec<u8>) -> bool
| Recover a public key from a compact signature. |
Sourcepub fn is_fully_valid(&self) -> bool
pub fn is_fully_valid(&self) -> bool
| fully validate whether this is a valid | public key (more expensive than IsValid()) |
Sourcepub fn decompress(&mut self) -> bool
pub fn decompress(&mut self) -> bool
| Turn this public key into an uncompressed | public key. |
Trait Implementations§
Source§impl From<&PubKey> for XOnlyPubKey
impl From<&PubKey> for XOnlyPubKey
Source§impl Ord for PubKey
impl Ord for PubKey
Source§impl PartialOrd for PubKey
impl PartialOrd for PubKey
impl Eq for PubKey
Auto Trait Implementations§
impl Freeze for PubKey
impl RefUnwindSafe for PubKey
impl Send for PubKey
impl Sync for PubKey
impl Unpin for PubKey
impl UnwindSafe for PubKey
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<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.