Struct schnorr_fun::Signature[][src]

pub struct Signature<S = Public> {
    pub R: XOnly,
    pub s: Scalar<S, Zero>,
}
Expand description

A Schnorr signature.

Fields

R: XOnly

The x-coordinate of the signature’s public nonce. When verifying it is interpreted as the Point.

s: Scalar<S, Zero>

The challenge response part of the signature.

Implementations

Serializes the signature as 64 bytes – First the 32-byte nonce x-coordinate and then the 32-byte challenge response scalar.

Examples

let bytes = signature.to_bytes();
assert_eq!(signature.R.as_bytes(), &bytes[..32]);
assert_eq!(signature.s.to_bytes().as_ref(), &bytes[32..]);

Gets a reference to the signature components as a tuple.

Examples

let (R, s) = signature.as_tuple();

Marks the signature with a Secrecy. If it is marked as Secret the operations (e.g. verification) on the signature should be done in constant time.

Examples

use schnorr_fun::{fun::marker::*, Signature};
let signature = Signature::random(&mut rand::thread_rng());
let secret_sig = signature.mark::<Secret>();

Generates a uniformly distributed signature. It will be valid for an infinite number of messages on every key but computationally you will never be able to find one! Useful for testing.

Examples

use schnorr_fun::Signature;
let random_signature = Signature::random(&mut rand::thread_rng());

Deserializes a signature from the byte representation produced by to_bytes.

This returns None if the first 32 bytes were not a valid XOnly or the last 32 bytes were not a valid scalar.

Examples

match Signature::from_bytes(bytes) {
    Some(signature) => println!("the bytes were a valid encoding of a signature!"),
    None => eprintln!("the bytes did *not* encode a valid signature"),
}

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the type as hex and any markers on the type.

Deserialize this value from the given Serde deserializer. Read more

Displays as hex.

Parses the string as hex and interprets tries to convert the resulting byte array into the desired value.

The associated error which can be returned from parsing.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Returns a new instance of the invocant that will be marked with M. Read more

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.