pub struct Signature<N: Network> { /* private fields */ }
Implementations§
Source§impl<N: Network> Signature<N>
impl<N: Network> Signature<N>
Sourcepub fn verify(&self, address: &Address<N>, message: &[Field<N>]) -> bool
pub fn verify(&self, address: &Address<N>, message: &[Field<N>]) -> bool
Verifies (challenge == challenge’) && (address == address’) where: challenge’ := HashToScalar(G^response pk_sig^challenge, pk_sig, pr_sig, address, message)
Sourcepub fn verify_bytes(&self, address: &Address<N>, message: &[u8]) -> bool
pub fn verify_bytes(&self, address: &Address<N>, message: &[u8]) -> bool
Verifies a signature for the given address and message (as bytes).
Sourcepub fn verify_bits(&self, address: &Address<N>, message: &[bool]) -> bool
pub fn verify_bits(&self, address: &Address<N>, message: &[bool]) -> bool
Verifies a signature for the given address and message (as bits).
Source§impl<N: Network> Signature<N>
impl<N: Network> Signature<N>
Sourcepub fn sign<R: Rng + CryptoRng>(
private_key: &PrivateKey<N>,
message: &[Field<N>],
rng: &mut R,
) -> Result<Self>
pub fn sign<R: Rng + CryptoRng>( private_key: &PrivateKey<N>, message: &[Field<N>], rng: &mut R, ) -> Result<Self>
Returns a signature (challenge, response, compute_key)
for a given message and RNG, where:
challenge := HashToScalar(nonce * G, pk_sig, pr_sig, address, message)
response := nonce - challenge * private_key.sk_sig()
Sourcepub fn sign_bytes<R: Rng + CryptoRng>(
private_key: &PrivateKey<N>,
message: &[u8],
rng: &mut R,
) -> Result<Signature<N>>
pub fn sign_bytes<R: Rng + CryptoRng>( private_key: &PrivateKey<N>, message: &[u8], rng: &mut R, ) -> Result<Signature<N>>
Returns a signature for the given message (as bytes) using the private key.
Source§impl<N: Network> Signature<N>
impl<N: Network> Signature<N>
Sourcepub const fn compute_key(&self) -> ComputeKey<N>
pub const fn compute_key(&self) -> ComputeKey<N>
Returns the signer compute key.
Sourcepub fn to_address(&self) -> Address<N>
pub fn to_address(&self) -> Address<N>
Returns the signer address.
Trait Implementations§
Source§impl<'de, N: Network> Deserialize<'de> for Signature<N>
impl<'de, N: Network> Deserialize<'de> for Signature<N>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserializes the signature from a string or bytes.
Source§impl<N: Network> FromBits for Signature<N>
impl<N: Network> FromBits for Signature<N>
Source§fn from_bits_le(bits_le: &[bool]) -> Result<Self>
fn from_bits_le(bits_le: &[bool]) -> Result<Self>
Initializes a new signature from a list of little-endian bits.
Source§fn from_bits_be(bits_be: &[bool]) -> Result<Self>
fn from_bits_be(bits_be: &[bool]) -> Result<Self>
Initializes a new signature from a list of big-endian bits.
Source§impl<N: Network> Parser for Signature<N>
impl<N: Network> Parser for Signature<N>
Source§fn parse(string: &str) -> ParserResult<'_, Self>
fn parse(string: &str) -> ParserResult<'_, Self>
Parses a string into an signature.
Source§impl<N: Network> SizeInBits for Signature<N>
impl<N: Network> SizeInBits for Signature<N>
Source§fn size_in_bits() -> usize
fn size_in_bits() -> usize
Returns the signature size in bits.
Source§impl<N: Network> SizeInBytes for Signature<N>
impl<N: Network> SizeInBytes for Signature<N>
Source§fn size_in_bytes() -> usize
fn size_in_bytes() -> usize
Returns the signature size in bytes.
Source§impl<N: Network> ToBits for Signature<N>
impl<N: Network> ToBits for Signature<N>
Source§fn write_bits_le(&self, vec: &mut Vec<bool>)
fn write_bits_le(&self, vec: &mut Vec<bool>)
Returns the little-endian bits of the signature.
Source§fn write_bits_be(&self, vec: &mut Vec<bool>)
fn write_bits_be(&self, vec: &mut Vec<bool>)
Returns the big-endian bits of the signature.
Source§fn to_bits_le(&self) -> Vec<bool>
fn to_bits_le(&self) -> Vec<bool>
self
as a boolean array in little-endian order.Source§fn to_bits_be(&self) -> Vec<bool>
fn to_bits_be(&self) -> Vec<bool>
self
as a boolean array in big-endian order.impl<N: Copy + Network> Copy for Signature<N>
impl<N: Eq + Network> Eq for Signature<N>
impl<N: Network> StructuralPartialEq for Signature<N>
Auto Trait Implementations§
impl<N> Freeze for Signature<N>
impl<N> RefUnwindSafe for Signature<N>
impl<N> Send for Signature<N>
impl<N> Sync for Signature<N>
impl<N> Unpin for Signature<N>
impl<N> UnwindSafe for Signature<N>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
fn take_from_value<D>(
value: &mut Value,
field: &str,
) -> Result<T, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more