pub struct PrivateKey(/* private fields */);Expand description
A Schnorr private key over the ECgFp5 scalar field.
The wrapped Scalar is canonical (< n). Intentionally non-Copy so the
type cannot be silently duplicated past a future Drop/zeroize owner; the
Debug impl is redacted so accidental logging cannot leak the secret limbs.
Memory zeroization of secret material is deferred to the live signing
wire-up (Phase G), where the long-lived key store will own the
PrivateKey and apply zeroize on drop.
Implementations§
Source§impl PrivateKey
impl PrivateKey
Sourcepub fn from_scalar(s: Scalar) -> Self
pub fn from_scalar(s: Scalar) -> Self
Wrap a canonical scalar as a private key. The caller is responsible for
ensuring s is canonical and uniformly random in 1..n.
Sourcepub fn from_le_bytes_reduce(bytes: [u8; 40]) -> Self
pub fn from_le_bytes_reduce(bytes: [u8; 40]) -> Self
Decode a private key from 40 little-endian bytes, reducing modulo the group order if necessary (matching the Go reference’s scalar decoder).
Sourcepub fn to_le_bytes(&self) -> [u8; 40]
pub fn to_le_bytes(&self) -> [u8; 40]
Canonical 40-byte little-endian encoding of the private scalar.
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Derive the matching public key as pk = (sk * G).encode().
Routes through the constant-time scalar mul so the secret scalar’s limbs do not leak via timing.
Sourcepub fn sign(&self, hashed_msg: Fp5, k: Scalar) -> Signature
pub fn sign(&self, hashed_msg: Fp5, k: Scalar) -> Signature
Sign a pre-hashed message under the supplied per-signature nonce k.
hashed_msg is the Fp5 digest produced by the caller (typically via
crate::signing::hash::hash_to_quintic_extension over the message
field elements, or via crate::signing::tx::sign_tx which folds
the body and attribute hashes). k MUST be drawn uniformly at random
from a cryptographic RNG, MUST NOT be zero (a zero nonce trivially
reveals sk from the resulting signature), and MUST NOT repeat across
distinct signatures under the same key (a repeated nonce reveals sk
from any two signatures sharing it). Matching the Go reference
SchnorrSignHashedMessage2, the caller-contract is enforced by the
caller — no runtime k != 0 check is performed inside sign.
Trait Implementations§
Source§impl Clone for PrivateKey
impl Clone for PrivateKey
Source§fn clone(&self) -> PrivateKey
fn clone(&self) -> PrivateKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PrivateKey
impl RefUnwindSafe for PrivateKey
impl Send for PrivateKey
impl Sync for PrivateKey
impl Unpin for PrivateKey
impl UnsafeUnpin for PrivateKey
impl UnwindSafe for PrivateKey
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more