Skip to main content

WinternitzSignature

Struct WinternitzSignature 

Source
pub struct WinternitzSignature<const N: usize> { /* private fields */ }
Expand description

Winternitz one-time signature: N message scalars and 2 checksum scalars, each 32 bytes. Total size is (N + 2) * 32 bytes.

Verify with Self::verify against a WinternitzRoot and the original message. Verification reconstructs the corresponding pubkey by completing each chain, merklizes, and compares to the supplied root.

Implementations§

Source§

impl<const N: usize> WinternitzSignature<N>

Source

pub fn new(scalars: [[u8; 32]; N], checksum: [[u8; 32]; 2]) -> Self

Create a signature from N * [u8;32] scalars + 2 checksum scalars.

Source

pub fn as_bytes(&self) -> &[u8]

Return the signature’s (N + 2) * 32 raw bytes (message scalars then checksum scalars), with no copy.

Source

pub fn verify(&self, message: &[&[u8]], root: &WinternitzRoot) -> bool

Verify this signature against a message and a stored root. Returns true if the signature is valid. The message is supplied as a slice of byte slices (matching solana_sha256_hasher::hashv), so callers can mix domain-separation tags or context bytes with the payload without an intermediate allocation.

Source

pub fn verify_prehashed(&self, hash: &[u8; N], root: &WinternitzRoot) -> bool

Verify against a pre-hashed message digest. See Self::hash for the expected digest construction.

Source

pub fn recover_pubkey(&self, message: &[&[u8]]) -> WinternitzPubkey<N>

Recover the WinternitzPubkey implied by this signature over the given message. No verification is performed — pair with WinternitzPubkey::merklize (or rely on the Into<WinternitzRoot> impl) and compare against a trusted root to verify.

The message is supplied as a slice of byte slices so callers can include domain-separation tags or context bytes alongside the payload (matching solana_sha256_hasher::hashv).

Source

pub fn recover_pubkey_prehashed(&self, hash: &[u8; N]) -> WinternitzPubkey<N>

Recover the WinternitzPubkey from a pre-hashed message digest. See Self::hash for the expected digest construction.

Source

pub fn hash(message: &[&[u8]]) -> [u8; N]

Hash a message into the N-byte Winternitz digest used by verification. Equivalent to truncating SHA-256 of the concatenated message slices to N bytes.

Trait Implementations§

Source§

impl<const N: usize> Debug for WinternitzSignature<N>

Source§

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

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

impl<const N: usize> Display for WinternitzSignature<N>

Source§

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

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

impl<'a, const N: usize> TryFrom<&'a [u8]> for &'a WinternitzSignature<N>

Source§

type Error = WinternitzError

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

fn try_from(value: &'a [u8]) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<const N: usize> Freeze for WinternitzSignature<N>

§

impl<const N: usize> RefUnwindSafe for WinternitzSignature<N>

§

impl<const N: usize> Send for WinternitzSignature<N>

§

impl<const N: usize> Sync for WinternitzSignature<N>

§

impl<const N: usize> Unpin for WinternitzSignature<N>

§

impl<const N: usize> UnsafeUnpin for WinternitzSignature<N>

§

impl<const N: usize> UnwindSafe for WinternitzSignature<N>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.