[−][src]Struct schnorr_fun::Signature
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
impl<S> Signature<S>
[src]
pub fn to_bytes(&self) -> [u8; 64]
[src]
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..]);
pub fn as_tuple(&self) -> (&XOnly, &Scalar<S, Zero>)
[src]
Gets a reference to the signature components as a tuple.
Examples
let (R, s) = signature.as_tuple();
#[must_use]pub fn mark<M: Secrecy>(self) -> Signature<M>
[src]
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>();
impl Signature<Public>
[src]
pub fn random<R: RngCore + CryptoRng>(rng: &mut R) -> Self
[src]
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());
pub fn from_bytes(bytes: [u8; 64]) -> Option<Self>
[src]
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
impl<S: Clone> Clone for Signature<S>
[src]
impl<S> Debug for Signature<S>
[src]
fn fmt(&self, f: &mut Formatter<'_>) -> Result
[src]
Formats the type as hex and any markers on the type.
impl<'de, S: Secrecy> Deserialize<'de> for Signature<S>
[src]
fn deserialize<Deser: Deserializer<'de>>(
deserializer: Deser
) -> Result<Signature<S>, Deser::Error>
[src]
deserializer: Deser
) -> Result<Signature<S>, Deser::Error>
impl<S> Display for Signature<S>
[src]
impl<S: Secrecy> FromStr for Signature<S>
[src]
type Err = HexError
The associated error which can be returned from parsing.
fn from_str(hex: &str) -> Result<Signature<S>, HexError>
[src]
Parses the string as hex and interprets tries to convert the resulting byte array into the desired value.
impl<S1, S2> PartialEq<Signature<S2>> for Signature<S1>
[src]
fn eq(&self, rhs: &Signature<S2>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<S> Serialize for Signature<S>
[src]
Auto Trait Implementations
impl<S> RefUnwindSafe for Signature<S> where
S: RefUnwindSafe,
S: RefUnwindSafe,
impl<S> Send for Signature<S> where
S: Send,
S: Send,
impl<S> Sync for Signature<S> where
S: Sync,
S: Sync,
impl<S> Unpin for Signature<S> where
S: Unpin,
S: Unpin,
impl<S> UnwindSafe for Signature<S> where
S: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Mark for T
[src]
#[must_use]fn mark<M>(self) -> <M as ChangeMark<T>>::Out where
M: ChangeMark<T>,
[src]
M: ChangeMark<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,