Struct PubKey

Source
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

Source

pub fn get_len(ch_header: u8) -> u32

| Compute the length of a pubkey with a | given first byte. |

Source

pub fn invalidate(&mut self)

| Set this key data to be invalid |

Source

pub fn valid_size(vch: &Vec<u8>) -> bool

Source

pub fn set<T>(&mut self, pbegin: T, pend: T)

| Initialize a public key using begin/end | iterators to byte data. |

Source

pub fn new_with_iter<T>(pbegin: T, pend: T) -> Self

| Construct a public key using begin/end | iterators to byte data. |

Source

pub fn new(slice: &[u8]) -> Self

| Construct a public key using begin/end | iterators to byte data. |

Source

pub fn size(&self) -> u32

| Simple read-only vector-like interface | to the pubkey data. |

Source

pub fn data(&self) -> *const u8

Source

pub fn begin(&self) -> *const u8

Source

pub fn end(&self) -> *const u8

Source

pub fn serialize<Stream>(&self, s: &mut Stream)

| Implement serialization, as if this | was a byte vector. |

Source

pub fn unserialize<Stream>(&mut self, s: &mut Stream)

Source

pub fn getid(&self) -> KeyID

| Get the KeyID of this public key (hash | of its serialization) |

Source

pub fn get_hash(&self) -> u256

| Get the 256-bit hash of this public key. |

Source

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! |

Source

pub fn is_compressed(&self) -> bool

| Check whether this is a compressed public | key. |

Source

pub fn check_lows(&mut self, vch_sig: &Vec<u8>) -> bool

| Check whether a signature is normalized | (lower-S). |

Source

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

Source

pub fn recover_compact(&mut self, hash: &u256, vch_sig: &Vec<u8>) -> bool

| Recover a public key from a compact signature. |

Source

pub fn is_fully_valid(&self) -> bool

| fully validate whether this is a valid | public key (more expensive than IsValid()) |

Source

pub fn decompress(&mut self) -> bool

| Turn this public key into an uncompressed | public key. |

Source

pub fn derive( &self, pubkey_child: &mut PubKey, cc_child: &mut ChainCode, n_child: u32, cc: &ChainCode, ) -> bool

| Derive BIP32 child pubkey. |

Trait Implementations§

Source§

impl Clone for PubKey

Source§

fn clone(&self) -> PubKey

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for PubKey

Source§

fn default() -> Self

| Construct an invalid public key. |

Source§

impl From<&[u8]> for PubKey

Source§

fn from(vch: &[u8]) -> Self

| Construct a public key from a byte vector. |

Source§

impl From<&PubKey> for XOnlyPubKey

Source§

fn from(pubkey: &PubKey) -> Self

| Construct an x-only pubkey from a normal | pubkey. |

Source§

impl Hash for PubKey

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Index<u32> for PubKey

Source§

type Output = u8

The returned type after indexing.
Source§

fn index(&self, pos: u32) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Ord for PubKey

Source§

fn cmp(&self, other: &PubKey) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for PubKey

Source§

fn eq(&self, other: &PubKey) -> bool

Comparator implementation.

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for PubKey

Source§

fn partial_cmp(&self, other: &PubKey) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

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> 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<T> CallHasher for T
where T: Hash + ?Sized,

Source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

Source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

Source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> StaticUpcast<T> for T

Source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V