Enum elements::confidential::Nonce
source · pub enum Nonce {
Null,
Explicit([u8; 32]),
Confidential(PublicKey),
}Expand description
A CT commitment to an output nonce (i.e. a public key)
Variants§
Null
No value
Explicit([u8; 32])
There should be no such thing as an “explicit nonce”, but Elements will deserialize such a thing (and insists that its size be 32 bytes). So we stick a 32-byte type here that implements all the traits we need.
Confidential(PublicKey)
Nonce is committed
Implementations§
source§impl Nonce
impl Nonce
sourcepub fn new_confidential<R: RngCore + CryptoRng, C: Signing>(
rng: &mut R,
secp: &Secp256k1<C>,
receiver_blinding_pk: &PublicKey
) -> (Self, SecretKey)
pub fn new_confidential<R: RngCore + CryptoRng, C: Signing>( rng: &mut R, secp: &Secp256k1<C>, receiver_blinding_pk: &PublicKey ) -> (Self, SecretKey)
Create nonce commitment.
sourcepub fn with_ephemeral_sk<C: Signing>(
secp: &Secp256k1<C>,
ephemeral_sk: SecretKey,
receiver_blinding_pk: &PublicKey
) -> (Self, SecretKey)
pub fn with_ephemeral_sk<C: Signing>( secp: &Secp256k1<C>, ephemeral_sk: SecretKey, receiver_blinding_pk: &PublicKey ) -> (Self, SecretKey)
Similar to Nonce::new_confidential, but with a given ephemeral_sk
instead of sampling it from rng.
Calculate the shared secret.
sourcepub fn encoded_length(&self) -> usize
pub fn encoded_length(&self) -> usize
Serialized length, in bytes
sourcepub fn from_commitment(bytes: &[u8]) -> Result<Self, Error>
pub fn from_commitment(bytes: &[u8]) -> Result<Self, Error>
Create from commitment.
sourcepub fn is_explicit(&self) -> bool
pub fn is_explicit(&self) -> bool
Check if the object is explicit.
sourcepub fn is_confidential(&self) -> bool
pub fn is_confidential(&self) -> bool
Check if the object is confidential.
sourcepub fn explicit(&self) -> Option<[u8; 32]>
pub fn explicit(&self) -> Option<[u8; 32]>
Returns the explicit inner value. Returns None if Nonce::is_explicit returns false.
sourcepub fn commitment(&self) -> Option<PublicKey>
pub fn commitment(&self) -> Option<PublicKey>
Returns the confidential commitment in case of a confidential value. Returns None if Nonce::is_confidential returns false.
Trait Implementations§
source§impl Ord for Nonce
impl Ord for Nonce
source§impl PartialEq for Nonce
impl PartialEq for Nonce
source§impl PartialOrd for Nonce
impl PartialOrd for Nonce
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more