Struct massa_signature::PublicKeyV0
source · pub struct PublicKeyV0(VerifyingKey);
Expand description
Public key used to check if a message was encoded
by the corresponding PublicKey
.
Generated from the KeyPair
using SignatureEngine
Tuple Fields§
§0: VerifyingKey
Implementations§
source§impl PublicKeyV0
impl PublicKeyV0
sourcepub const PUBLIC_KEY_SIZE_BYTES: usize = 32usize
pub const PUBLIC_KEY_SIZE_BYTES: usize = 32usize
Size of a public key
sourcepub fn get_ser_len(&self) -> usize
pub fn get_ser_len(&self) -> usize
Return the total length after serialization
sourcepub fn verify_signature(
&self,
hash: &Hash,
signature: &SignatureV0,
) -> Result<(), MassaSignatureError>
pub fn verify_signature( &self, hash: &Hash, signature: &SignatureV0, ) -> Result<(), MassaSignatureError>
Checks if the Signature
associated with data bytes
was produced with the KeyPair
associated to given PublicKey
sourcepub fn to_bytes(&self) -> Vec<u8>
pub fn to_bytes(&self) -> Vec<u8>
Return the bytes representing the keypair (should be a reference in the future)
§Example
let keypair = KeyPair::generate(0).unwrap();
let bytes = keypair.to_bytes();
sourcepub fn from_bytes(data: &[u8]) -> Result<PublicKeyV0, MassaSignatureError>
pub fn from_bytes(data: &[u8]) -> Result<PublicKeyV0, MassaSignatureError>
Deserialize a PublicKey
from bytes.
IMPORTANT: providing more bytes than needed does not result in an error.
§Example
let keypair = KeyPair::generate(0).unwrap();
let serialized = keypair.get_public_key().to_bytes();
let deserialized: PublicKey = PublicKey::from_bytes(&serialized).unwrap();
Trait Implementations§
source§impl Clone for PublicKeyV0
impl Clone for PublicKeyV0
source§fn clone(&self) -> PublicKeyV0
fn clone(&self) -> PublicKeyV0
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PublicKeyV0
impl Debug for PublicKeyV0
source§impl Display for PublicKeyV0
impl Display for PublicKeyV0
source§impl Hash for PublicKeyV0
impl Hash for PublicKeyV0
source§impl Ord for PublicKeyV0
impl Ord for PublicKeyV0
source§fn cmp(&self, other: &PublicKeyV0) -> Ordering
fn cmp(&self, other: &PublicKeyV0) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for PublicKeyV0
impl PartialEq for PublicKeyV0
source§fn eq(&self, other: &PublicKeyV0) -> bool
fn eq(&self, other: &PublicKeyV0) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for PublicKeyV0
impl PartialOrd for PublicKeyV0
source§fn partial_cmp(&self, other: &PublicKeyV0) -> Option<Ordering>
fn partial_cmp(&self, other: &PublicKeyV0) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Versioned for PublicKeyV0
impl Versioned for PublicKeyV0
impl Copy for PublicKeyV0
impl Eq for PublicKeyV0
impl StructuralPartialEq for PublicKeyV0
Auto Trait Implementations§
impl Freeze for PublicKeyV0
impl RefUnwindSafe for PublicKeyV0
impl Send for PublicKeyV0
impl Sync for PublicKeyV0
impl Unpin for PublicKeyV0
impl UnwindSafe for PublicKeyV0
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> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)