Struct snarkvm_console_account::signature::Signature
source · 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: PartialEq + Network> PartialEq for Signature<N>
impl<N: PartialEq + Network> PartialEq for Signature<N>
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> 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.
§fn to_bits_le(&self) -> Vec<bool>
fn to_bits_le(&self) -> Vec<bool>
self
as a boolean array in little-endian order.§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> StructuralEq for Signature<N>
impl<N: Network> StructuralPartialEq for Signature<N>
Auto Trait Implementations§
impl<N> RefUnwindSafe for Signature<N>where <N as Environment>::Projective: RefUnwindSafe, <N as Environment>::Scalar: RefUnwindSafe,
impl<N> Send for Signature<N>
impl<N> Sync for Signature<N>
impl<N> Unpin for Signature<N>where <N as Environment>::Projective: Unpin, <N as Environment>::Scalar: Unpin,
impl<N> UnwindSafe for Signature<N>where <N as Environment>::Projective: UnwindSafe, <N as Environment>::Scalar: UnwindSafe,
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
§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>,
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.