Struct snarkvm_console_program::Signature
source · pub struct Signature<N>where
N: Network,{ /* private fields */ }
Implementations§
source§impl<N> Signature<N>where
N: Network,
impl<N> Signature<N>where
N: Network,
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> Signature<N>where
N: Network,
impl<N> Signature<N>where
N: Network,
sourcepub fn sign<R>(
private_key: &PrivateKey<N>,
message: &[Field<N>],
rng: &mut R
) -> Result<Signature<N>, Error>
pub fn sign<R>( private_key: &PrivateKey<N>, message: &[Field<N>], rng: &mut R ) -> Result<Signature<N>, Error>
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>(
private_key: &PrivateKey<N>,
message: &[u8],
rng: &mut R
) -> Result<Signature<N>, Error>
pub fn sign_bytes<R>( private_key: &PrivateKey<N>, message: &[u8], rng: &mut R ) -> Result<Signature<N>, Error>
Returns a signature for the given message (as bytes) using the private key.
source§impl<N> Signature<N>where
N: Network,
impl<N> Signature<N>where
N: Network,
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> Deserialize<'de> for Signature<N>where
N: Network,
impl<'de, N> Deserialize<'de> for Signature<N>where
N: Network,
source§fn deserialize<D>(
deserializer: D
) -> Result<Signature<N>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Signature<N>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserializes the signature from a string or bytes.
source§impl<N> PartialEq for Signature<N>
impl<N> PartialEq for Signature<N>
source§impl<N> Serialize for Signature<N>where
N: Network,
impl<N> Serialize for Signature<N>where
N: Network,
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,
Serializes the signature into string or bytes.
source§impl<N> SizeInBits for Signature<N>where
N: Network,
impl<N> SizeInBits for Signature<N>where
N: Network,
source§fn size_in_bits() -> usize
fn size_in_bits() -> usize
Returns the signature size in bits.
source§impl<N> SizeInBytes for Signature<N>where
N: Network,
impl<N> SizeInBytes for Signature<N>where
N: Network,
source§fn size_in_bytes() -> usize
fn size_in_bytes() -> usize
Returns the signature size in bytes.
source§impl<N> ToBits for Signature<N>where
N: Network,
impl<N> ToBits for Signature<N>where
N: Network,
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 for Signature<N>
impl<N> Eq for Signature<N>
impl<N> StructuralPartialEq for Signature<N>where
N: Network,
Auto Trait Implementations§
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<'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 Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.