pub struct Nonce { /* private fields */ }Expand description
A verifier-chosen nonce for an ownership proof (Operation D).
32 opaque bytes the verifier sends to the prover so the resulting
OwnershipProof is bound to a fresh, single-use challenge and cannot
be replayed. Generate one with crate::generate_nonce.
Unlike the key types, a nonce has no validity constraint — any 32
bytes are a valid nonce — so Nonce::from_bytes is infallible. The
prefixed form (nonce_<hex>_<checksum>) is, exactly like the other
types, a pure transport wrapper: the bytes that get hashed into a proof
are the raw Nonce::as_bytes, never the prefixed string. Both prover
and verifier must use the same nonce.
Implementations§
Source§impl Nonce
impl Nonce
Sourcepub fn from_bytes(bytes: [u8; 32]) -> Self
pub fn from_bytes(bytes: [u8; 32]) -> Self
Wrap 32 raw bytes as a nonce. Infallible — any value is valid.
Sourcepub fn to_bytes(&self) -> [u8; 32]
pub fn to_bytes(&self) -> [u8; 32]
The raw 32 bytes. These are what an ownership proof binds to (pass
them as the context argument of crate::prove_ownership /
crate::verify_ownership).
Sourcepub fn to_prefixed(&self) -> String
pub fn to_prefixed(&self) -> String
Encode in the human-friendly prefixed format: nonce_<hex>_<checksum>.
Sourcepub fn from_prefixed(s: &str) -> Result<Self>
pub fn from_prefixed(s: &str) -> Result<Self>
Decode a nonce_<hex>_<checksum> string produced by
Nonce::to_prefixed, verifying the tag and the checksum.