pub struct Signature<N>where
    N: Network,{ /* private fields */ }

Implementations§

source§

impl<N> Signature<N>where N: Network,

source

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)

source

pub fn verify_bytes(&self, address: &Address<N>, message: &[u8]) -> bool

Verifies a signature for the given address and message (as bytes).

source

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,

source

pub fn sign<R>( private_key: &PrivateKey<N>, message: &[Field<N>], rng: &mut R ) -> Result<Signature<N>, Error>where R: Rng + CryptoRng,

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()

source

pub fn sign_bytes<R>( private_key: &PrivateKey<N>, message: &[u8], rng: &mut R ) -> Result<Signature<N>, Error>where R: Rng + CryptoRng,

Returns a signature for the given message (as bytes) using the private key.

source

pub fn sign_bits<R>( private_key: &PrivateKey<N>, message: &[bool], rng: &mut R ) -> Result<Signature<N>, Error>where R: Rng + CryptoRng,

Returns a signature for the given message (as bits) using the private key.

source§

impl<N> Signature<N>where N: Network,

source

pub const fn challenge(&self) -> Scalar<N>

Returns the verifier challenge.

source

pub const fn response(&self) -> Scalar<N>

Returns the prover response.

source

pub const fn compute_key(&self) -> ComputeKey<N>

Returns the signer compute key.

source

pub fn to_address(&self) -> Address<N>

Returns the signer address.

Trait Implementations§

source§

impl<N> Clone for Signature<N>where N: Clone + Network,

source§

fn clone(&self) -> Signature<N>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<N> Debug for Signature<N>where N: Network,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

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>,

Deserializes the signature from a string or bytes.

source§

impl<N> Display for Signature<N>where N: Network,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Writes the signature as a bech32m string.

source§

impl<N> Equal for Signature<N>where N: Network,

source§

fn is_equal(&self, other: &Signature<N>) -> <Signature<N> as Equal>::Output

Returns true if self and other are equal.

source§

fn is_not_equal(&self, other: &Signature<N>) -> <Signature<N> as Equal>::Output

Returns true if self and other are not equal.

§

type Output = Boolean<N>

source§

impl<N> From<&(Scalar<N>, Scalar<N>, ComputeKey<N>)> for Signature<N>where N: Network,

source§

fn from(_: &(Scalar<N>, Scalar<N>, ComputeKey<N>)) -> Signature<N>

Derives the account signature from a tuple (challenge, response, compute_key).

source§

impl<N> From<(Scalar<N>, Scalar<N>, ComputeKey<N>)> for Signature<N>where N: Network,

source§

fn from(_: (Scalar<N>, Scalar<N>, ComputeKey<N>)) -> Signature<N>

Derives the account signature from a tuple (challenge, response, compute_key).

source§

impl<N> FromBits for Signature<N>where N: Network,

source§

fn from_bits_le(bits_le: &[bool]) -> Result<Signature<N>, Error>

Initializes a new signature from a list of little-endian bits.

source§

fn from_bits_be(bits_be: &[bool]) -> Result<Signature<N>, Error>

Initializes a new signature from a list of big-endian bits.

source§

impl<N> FromBytes for Signature<N>where N: Network,

source§

fn read_le<R>(reader: R) -> Result<Signature<N>, Error>where R: Read,

Reads an account signature from a buffer.

source§

fn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>where Self: Sized,

Returns Self from a byte array in little-endian order.
source§

impl<N> FromStr for Signature<N>where N: Network,

source§

fn from_str( signature: &str ) -> Result<Signature<N>, <Signature<N> as FromStr>::Err>

Reads in the signature string.

§

type Err = Error

The associated error which can be returned from parsing.
source§

impl<N> Hash for Signature<N>where N: Hash + Network,

source§

fn hash<__H>(&self, state: &mut __H)where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<N> Parser for Signature<N>where N: Network,

source§

fn parse(string: &str) -> Result<(&str, Signature<N>), Err<VerboseError<&str>>>

Parses a string into an signature.

source§

impl<N> PartialEq for Signature<N>where N: PartialEq + Network,

source§

fn eq(&self, other: &Signature<N>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

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,

Serializes the signature into string or bytes.

source§

impl<N> SizeInBits for Signature<N>where N: Network,

source§

fn size_in_bits() -> usize

Returns the signature size in bits.

source§

impl<N> Ternary for Box<Signature<N>>where N: Network,

source§

fn ternary( condition: &<Box<Signature<N>> as Ternary>::Boolean, first: &Box<Signature<N>>, second: &Box<Signature<N>> ) -> <Box<Signature<N>> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

§

type Boolean = Boolean<N>

§

type Output = Box<Signature<N>>

source§

impl<N> Ternary for Signature<N>where N: Network,

source§

fn ternary( condition: &<Signature<N> as Ternary>::Boolean, first: &Signature<N>, second: &Signature<N> ) -> <Signature<N> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

§

type Boolean = Boolean<N>

§

type Output = Signature<N>

source§

impl<N> ToBits for Signature<N>where N: Network,

source§

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>)

Returns the big-endian bits of the signature.

source§

fn to_bits_le(&self) -> Vec<bool>

Returns self as a boolean array in little-endian order.
source§

fn to_bits_be(&self) -> Vec<bool>

Returns self as a boolean array in big-endian order.
source§

fn num_bits() -> Option<usize>

An optional indication of how many bits an object can be represented with.
source§

impl<N> ToBytes for Signature<N>where N: Network,

source§

fn write_le<W>(&self, writer: W) -> Result<(), Error>where W: Write,

Writes an account signature to a buffer.

source§

fn to_bytes_le(&self) -> Result<Vec<u8>, Error>where Self: Sized,

Returns self as a byte array in little-endian order.
source§

impl<N> ToFields for Signature<N>where N: Network,

source§

fn to_fields(&self) -> Result<Vec<<Signature<N> as ToFields>::Field>, Error>

Casts a signature into a list of base fields.

§

type Field = Field<N>

source§

impl<N> TypeName for Signature<N>where N: Network,

source§

fn type_name() -> &'static str

Returns the type name as a string.

source§

impl<N> Copy for Signature<N>where N: Copy + Network,

source§

impl<N> Eq for Signature<N>where N: Eq + Network,

source§

impl<N> StructuralEq for Signature<N>where N: Network,

source§

impl<N> StructuralPartialEq for Signature<N>where N: Network,

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<'de, T> DeserializeExt<'de> for Twhere T: DeserializeOwned,

source§

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,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,