Enum near_crypto::Signature
source · pub enum Signature {
ED25519(Signature),
SECP256K1(Secp256K1Signature),
}
Expand description
Signature container supporting different curves.
Variants§
ED25519(Signature)
SECP256K1(Secp256K1Signature)
Implementations§
source§impl Signature
impl Signature
sourcepub fn from_parts(
signature_type: KeyType,
signature_data: &[u8]
) -> Result<Self, ParseSignatureError>
pub fn from_parts( signature_type: KeyType, signature_data: &[u8] ) -> Result<Self, ParseSignatureError>
Construct Signature from key type and raw signature blob
sourcepub fn verify(&self, data: &[u8], public_key: &PublicKey) -> bool
pub fn verify(&self, data: &[u8], public_key: &PublicKey) -> bool
Verifies that this signature is indeed signs the data with given public key.
Also if public key doesn’t match on the curve returns false
.
pub fn key_type(&self) -> KeyType
Trait Implementations§
source§impl BorshDeserialize for Signature
impl BorshDeserialize for Signature
fn deserialize_reader<R: Read>(rd: &mut R) -> Result<Self>
source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
source§impl BorshSerialize for Signature
impl BorshSerialize for Signature
source§impl<'de> Deserialize<'de> for Signature
impl<'de> Deserialize<'de> for Signature
source§fn deserialize<D>(
deserializer: D
) -> Result<Self, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Self, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq for Signature
impl PartialEq for Signature
source§impl Serialize for Signature
impl Serialize for Signature
source§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for Signature
impl StructuralPartialEq for Signature
Auto Trait Implementations§
impl Freeze for Signature
impl RefUnwindSafe for Signature
impl Send for Signature
impl Sync for Signature
impl Unpin for Signature
impl UnwindSafe for Signature
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