Struct ed25519_consensus::VerificationKey
source · [−]pub struct VerificationKey { /* private fields */ }
Expand description
A valid Ed25519 verification key.
This is also called a public key by other implementations.
This type holds decompressed state used in signature verification; if the
verification key may not be used immediately, it is probably better to use
VerificationKeyBytes
, which is a refinement type for [u8; 32]
.
Consensus properties
Ed25519 checks are described in §5.4.5 of the Zcash protocol specification and in
[ZIP 215]. The verification criteria for an (encoded) verification key A_bytes
are:
A_bytes
MUST be an encoding of a pointA
on the twisted Edwards form of Curve25519, and non-canonical encodings MUST be accepted;
Implementations
sourceimpl VerificationKey
impl VerificationKey
sourcepub fn to_bytes(&self) -> [u8; 32]
pub fn to_bytes(&self) -> [u8; 32]
Returns the byte encoding of the verification key.
This is the same as .into()
, but does not require type inference.
sourcepub fn verify(&self, signature: &Signature, msg: &[u8]) -> Result<(), Error>
pub fn verify(&self, signature: &Signature, msg: &[u8]) -> Result<(), Error>
Verify a purported signature
on the given msg
.
Consensus properties
Ed25519 checks are described in §5.4.5 of the Zcash protocol specification and in
ZIP215. The verification criteria for an (encoded) signature (R_bytes, s_bytes)
with
(encoded) verification key A_bytes
are:
-
A_bytes
andR_bytes
MUST be encodings of pointsA
andR
respectively on the twisted Edwards form of Curve25519, and non-canonical encodings MUST be accepted; -
s_bytes
MUST represent an integers
less thanl
, the order of the prime-order subgroup of Curve25519; -
the verification equation
[8][s]B = [8]R + [8][k]A
MUST be satisfied; -
the alternate verification equation
[s]B = R + [k]A
, allowed by RFC 8032, MUST NOT be used.
Trait Implementations
sourceimpl Clone for VerificationKey
impl Clone for VerificationKey
sourcefn clone(&self) -> VerificationKey
fn clone(&self) -> VerificationKey
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for VerificationKey
impl Debug for VerificationKey
sourceimpl<'de> Deserialize<'de> for VerificationKey
impl<'de> Deserialize<'de> for VerificationKey
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'a> From<&'a SigningKey> for VerificationKey
impl<'a> From<&'a SigningKey> for VerificationKey
sourcefn from(sk: &'a SigningKey) -> VerificationKey
fn from(sk: &'a SigningKey) -> VerificationKey
Converts to this type from the input type.
sourceimpl From<VerificationKey> for VerificationKeyBytes
impl From<VerificationKey> for VerificationKeyBytes
sourcefn from(vk: VerificationKey) -> VerificationKeyBytes
fn from(vk: VerificationKey) -> VerificationKeyBytes
Converts to this type from the input type.
sourceimpl PartialEq<VerificationKey> for VerificationKey
impl PartialEq<VerificationKey> for VerificationKey
sourcefn eq(&self, other: &VerificationKey) -> bool
fn eq(&self, other: &VerificationKey) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &VerificationKey) -> bool
fn ne(&self, other: &VerificationKey) -> bool
This method tests for !=
.
sourceimpl Serialize for VerificationKey
impl Serialize for VerificationKey
sourceimpl TryFrom<VerificationKeyBytes> for VerificationKey
impl TryFrom<VerificationKeyBytes> for VerificationKey
impl Copy for VerificationKey
impl Eq for VerificationKey
impl StructuralEq for VerificationKey
impl StructuralPartialEq for VerificationKey
Auto Trait Implementations
impl RefUnwindSafe for VerificationKey
impl Send for VerificationKey
impl Sync for VerificationKey
impl Unpin for VerificationKey
impl UnwindSafe for VerificationKey
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToHex for T where
T: AsRef<[u8]>,
impl<T> ToHex for T where
T: AsRef<[u8]>,
sourcefn encode_hex<U>(&self) -> U where
U: FromIterator<char>,
fn encode_hex<U>(&self) -> U where
U: FromIterator<char>,
Encode the hex strict representing self
into the result. Lower case
letters are used (e.g. f9b4ca
) Read more
sourcefn encode_hex_upper<U>(&self) -> U where
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> U where
U: FromIterator<char>,
Encode the hex strict representing self
into the result. Upper case
letters are used (e.g. F9B4CA
) Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more