Enum elements::confidential::Value
source · pub enum Value {
Null,
Explicit(u64),
Confidential(PedersenCommitment),
}
Expand description
A CT commitment to an amount
Variants§
Null
No value
Explicit(u64)
Value is explicitly encoded
Confidential(PedersenCommitment)
Value is committed
Implementations§
source§impl Value
impl Value
sourcepub fn new_confidential<C: Signing>(
secp: &Secp256k1<C>,
value: u64,
asset: Generator,
bf: ValueBlindingFactor
) -> Self
pub fn new_confidential<C: Signing>( secp: &Secp256k1<C>, value: u64, asset: Generator, bf: ValueBlindingFactor ) -> Self
Create value commitment.
sourcepub fn new_confidential_from_assetid<C: Signing>(
secp: &Secp256k1<C>,
value: u64,
asset: AssetId,
v_bf: ValueBlindingFactor,
a_bf: AssetBlindingFactor
) -> Self
pub fn new_confidential_from_assetid<C: Signing>( secp: &Secp256k1<C>, value: u64, asset: AssetId, v_bf: ValueBlindingFactor, a_bf: AssetBlindingFactor ) -> Self
Create value commitment from assetID, asset blinding factor, value and value blinding factor
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<u64>
pub fn explicit(&self) -> Option<u64>
Returns the explicit inner value. Returns None if Value::is_explicit returns false.
sourcepub fn commitment(&self) -> Option<PedersenCommitment>
pub fn commitment(&self) -> Option<PedersenCommitment>
Returns the confidential commitment in case of a confidential value. Returns None if Value::is_confidential returns false.
source§impl Value
impl Value
sourcepub fn blind<C: Signing>(
self,
secp: &Secp256k1<C>,
vbf: ValueBlindingFactor,
receiver_blinding_pk: PublicKey,
ephemeral_sk: SecretKey,
spk: &Script,
msg: &RangeProofMessage
) -> Result<(Self, Nonce, RangeProof), ConfidentialTxOutError>
pub fn blind<C: Signing>( self, secp: &Secp256k1<C>, vbf: ValueBlindingFactor, receiver_blinding_pk: PublicKey, ephemeral_sk: SecretKey, spk: &Script, msg: &RangeProofMessage ) -> Result<(Self, Nonce, RangeProof), ConfidentialTxOutError>
Blinds the values and outputs the blinded value along with RangeProof
.
This computes the nonce by doing an ECDH with receiver_blinding_pk
and ephemeral_sk
§Returns:
A pair of blinded value, nonce and corresponding proof as (Value
, Nonce
, RangeProof
)
The nonce here refers to public key corresponding to the input ephemeral_sk
Blinds with the given shared_secret(instead of computing it via ECDH) This is useful while blinding assets as there is no counter party to provide the blinding key.
Trait Implementations§
source§impl Deserialize for Value
impl Deserialize for Value
source§impl From<PedersenCommitment> for Value
impl From<PedersenCommitment> for Value
source§fn from(from: PedersenCommitment) -> Self
fn from(from: PedersenCommitment) -> Self
source§impl Ord for Value
impl Ord for Value
source§impl PartialEq for Value
impl PartialEq for Value
source§impl PartialOrd for Value
impl PartialOrd for Value
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