pub struct SigningKey<T: LamportDigest> { /* private fields */ }
Expand description
A one-time signing private key.
Implementations§
Source§impl<T: LamportDigest> SigningKey<T>
impl<T: LamportDigest> SigningKey<T>
Sourcepub fn random(rng: impl RngCore + CryptoRng) -> SigningKey<T>
pub fn random(rng: impl RngCore + CryptoRng) -> SigningKey<T>
Constructs a SigningKey
with Digest algorithm type and the specified RNG.
Sourcepub fn sign<B: AsRef<[u8]>>(&mut self, data: B) -> LamportResult<Signature<T>>
pub fn sign<B: AsRef<[u8]>>(&mut self, data: B) -> LamportResult<Signature<T>>
Signs the data.
§Example
use sha2::Sha256;
use rand::SeedableRng;
use rand_chacha::ChaCha12Rng;
use lamport_signature_plus::{LamportFixedDigest, SigningKey};
const SEED: [u8; 32] = [0; 32];
let rng = ChaCha12Rng::from_seed(SEED);
let mut private_key = SigningKey::<LamportFixedDigest<Sha256>>::random(rng);
const MESSAGE: &[u8] = b"hello, world!";
assert!(private_key.sign(MESSAGE).is_ok());
Sourcepub fn from_bytes<B: AsRef<[u8]>>(input: B) -> LamportResult<Self>
pub fn from_bytes<B: AsRef<[u8]>>(input: B) -> LamportResult<Self>
Constructs a SigningKey
from canonical bytes.
Sourcepub fn split(
&self,
threshold: usize,
shares: usize,
rng: impl RngCore + CryptoRng,
) -> LamportResult<Vec<SigningKeyShare<T>>>
pub fn split( &self, threshold: usize, shares: usize, rng: impl RngCore + CryptoRng, ) -> LamportResult<Vec<SigningKeyShare<T>>>
Create secret shares of the signing key where threshold
are required
to combine back into this secret.
Sourcepub fn combine(shares: &[SigningKeyShare<T>]) -> LamportResult<Self>
pub fn combine(shares: &[SigningKeyShare<T>]) -> LamportResult<Self>
Reconstruct the signing key from the secret shares created by split
Trait Implementations§
Source§impl<T: Clone + LamportDigest> Clone for SigningKey<T>
impl<T: Clone + LamportDigest> Clone for SigningKey<T>
Source§fn clone(&self) -> SigningKey<T>
fn clone(&self) -> SigningKey<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug + LamportDigest> Debug for SigningKey<T>
impl<T: Debug + LamportDigest> Debug for SigningKey<T>
Source§impl<'de, T: LamportDigest> Deserialize<'de> for SigningKey<T>
impl<'de, T: LamportDigest> Deserialize<'de> for SigningKey<T>
Source§fn deserialize<D>(d: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: LamportDigest> From<&SigningKey<T>> for Vec<u8>
impl<T: LamportDigest> From<&SigningKey<T>> for Vec<u8>
Source§impl<T: LamportDigest> From<&SigningKey<T>> for VerifyingKey<T>
impl<T: LamportDigest> From<&SigningKey<T>> for VerifyingKey<T>
Source§fn from(value: &SigningKey<T>) -> Self
fn from(value: &SigningKey<T>) -> Self
Converts to this type from the input type.
Source§impl<T: LamportDigest> From<SigningKey<T>> for Vec<u8>
impl<T: LamportDigest> From<SigningKey<T>> for Vec<u8>
Source§impl<T: Hash + LamportDigest> Hash for SigningKey<T>
impl<T: Hash + LamportDigest> Hash for SigningKey<T>
Source§impl<T: Ord + LamportDigest> Ord for SigningKey<T>
impl<T: Ord + LamportDigest> Ord for SigningKey<T>
Source§fn cmp(&self, other: &SigningKey<T>) -> Ordering
fn cmp(&self, other: &SigningKey<T>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialEq + LamportDigest> PartialEq for SigningKey<T>
impl<T: PartialEq + LamportDigest> PartialEq for SigningKey<T>
Source§impl<T: PartialOrd + LamportDigest> PartialOrd for SigningKey<T>
impl<T: PartialOrd + LamportDigest> PartialOrd for SigningKey<T>
Source§impl<T: LamportDigest> Serialize for SigningKey<T>
impl<T: LamportDigest> Serialize for SigningKey<T>
Source§impl<T: LamportDigest> TryFrom<&[u8]> for SigningKey<T>
impl<T: LamportDigest> TryFrom<&[u8]> for SigningKey<T>
Source§type Error = LamportError
type Error = LamportError
The type returned in the event of a conversion error.
Source§fn try_from(value: &[u8]) -> LamportResult<Self>
fn try_from(value: &[u8]) -> LamportResult<Self>
Performs the conversion.
Source§impl<T: LamportDigest> TryFrom<&Vec<u8>> for SigningKey<T>
impl<T: LamportDigest> TryFrom<&Vec<u8>> for SigningKey<T>
Source§type Error = LamportError
type Error = LamportError
The type returned in the event of a conversion error.
Source§impl<T: LamportDigest> TryFrom<Box<[u8]>> for SigningKey<T>
impl<T: LamportDigest> TryFrom<Box<[u8]>> for SigningKey<T>
Source§type Error = LamportError
type Error = LamportError
The type returned in the event of a conversion error.
Source§impl<T: LamportDigest> TryFrom<Vec<u8>> for SigningKey<T>
impl<T: LamportDigest> TryFrom<Vec<u8>> for SigningKey<T>
Source§type Error = LamportError
type Error = LamportError
The type returned in the event of a conversion error.
Source§impl<T: LamportDigest> Zeroize for SigningKey<T>
impl<T: LamportDigest> Zeroize for SigningKey<T>
impl<T: Eq + LamportDigest> Eq for SigningKey<T>
impl<T: LamportDigest> StructuralPartialEq for SigningKey<T>
Auto Trait Implementations§
impl<T> Freeze for SigningKey<T>
impl<T> RefUnwindSafe for SigningKey<T>where
T: RefUnwindSafe,
impl<T> Send for SigningKey<T>where
T: Send,
impl<T> Sync for SigningKey<T>where
T: Sync,
impl<T> Unpin for SigningKey<T>where
T: Unpin,
impl<T> UnwindSafe for SigningKey<T>where
T: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more