pub enum XfrAmount {
Confidential((CompressedRistretto, CompressedRistretto)),
NonConfidential(u64),
}Expand description
Amount in blind asset record: if confidential, provide commitments for lower and hight 32 bits
Variants§
Confidential((CompressedRistretto, CompressedRistretto))
Confidential amount.
NonConfidential(u64)
Transparent amount.
Implementations§
source§impl XfrAmount
impl XfrAmount
sourcepub fn is_confidential(&self) -> bool
pub fn is_confidential(&self) -> bool
Return true only if amount is confidential.
Example:
use noah_api::xfr::structs::XfrAmount;
use noah_algebra::ristretto::CompressedRistretto;
let xfr_amount = XfrAmount::Confidential((CompressedRistretto::default(), CompressedRistretto::default()));
assert!(xfr_amount.is_confidential());
let xfr_amount = XfrAmount::NonConfidential(100u64);
assert!(!xfr_amount.is_confidential());Runsourcepub fn get_amount(&self) -> Option<u64>
pub fn get_amount(&self) -> Option<u64>
Return Some(amount) if amount is non-confidential. Otherwise, return None
Example:
use noah_api::xfr::structs::XfrAmount;
use noah_algebra::ristretto::CompressedRistretto;
let xfr_amount = XfrAmount::NonConfidential(100u64);
assert_eq!(xfr_amount.get_amount().unwrap(), 100u64);
let xfr_amount = XfrAmount::Confidential((CompressedRistretto::default(), CompressedRistretto::default()));
assert!(xfr_amount.get_amount().is_none());Runsourcepub fn get_commitments(
&self
) -> Option<(CompressedRistretto, CompressedRistretto)>
pub fn get_commitments(
&self
) -> Option<(CompressedRistretto, CompressedRistretto)>
Return Some((c1,c2)), where (c1,c2) is a commitment to the amount if amount is confidential. Otherwise, return None
Example:
use noah_api::xfr::structs::XfrAmount;
use noah_algebra::ristretto::CompressedRistretto;
let xfr_amount = XfrAmount::NonConfidential(100u64);
assert!(xfr_amount.get_commitments().is_none());
let xfr_amount = XfrAmount::Confidential((CompressedRistretto::default(), CompressedRistretto::default()));
assert_eq!(xfr_amount.get_commitments().unwrap(), (CompressedRistretto::default(), CompressedRistretto::default()));Runsourcepub fn from_blinds(
pc_gens: &PedersenCommitmentRistretto,
amount: u64,
blind_lo: &RistrettoScalar,
blind_hi: &RistrettoScalar
) -> Self
pub fn from_blinds(
pc_gens: &PedersenCommitmentRistretto,
amount: u64,
blind_lo: &RistrettoScalar,
blind_hi: &RistrettoScalar
) -> Self
Construct a confidential amount with an amount and an amount blind.
Trait Implementations§
source§impl<'de> Deserialize<'de> for XfrAmount
impl<'de> Deserialize<'de> for XfrAmount
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq<XfrAmount> for XfrAmount
impl PartialEq<XfrAmount> for XfrAmount
impl Eq for XfrAmount
impl StructuralEq for XfrAmount
impl StructuralPartialEq for XfrAmount
Auto Trait Implementations§
impl RefUnwindSafe for XfrAmount
impl Send for XfrAmount
impl Sync for XfrAmount
impl Unpin for XfrAmount
impl UnwindSafe for XfrAmount
Blanket Implementations§
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more