Skip to main content

fresh_k

Function fresh_k 

Source
pub fn fresh_k() -> Result<Scalar>
Expand description

Draws a fresh nonzero canonical Scalar from the operating system’s cryptographic random number source for the per-signature k nonce.

The Schnorr binding requires k to be drawn from a cryptographic RNG and used at most once per signature; see PrivateKey::sign for the full contract. Rejection sampling gives a uniform scalar in [1, n), where n is the curve order. Direct OS randomness avoids duplicating a userspace RNG’s state across a process fork.

§Errors

Returns an error if the operating system’s random number source fails.