Enum noah_api::xfr::structs::XfrAssetType
source · pub enum XfrAssetType {
Confidential(CompressedRistretto),
NonConfidential(AssetType),
}Expand description
Asset type in BlindAsset record: if confidential, provide commitment.
Variants§
Confidential(CompressedRistretto)
Confidential asset type.
NonConfidential(AssetType)
Transparent asset type.
Implementations§
source§impl XfrAssetType
impl XfrAssetType
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::{AssetType, XfrAssetType};
use noah_algebra::ristretto::CompressedRistretto;
let xfr_asset_type = XfrAssetType::Confidential(CompressedRistretto::default());
assert!(xfr_asset_type.is_confidential());
let xfr_asset_type = XfrAssetType::NonConfidential(AssetType::from_identical_byte(0u8));
assert!(!xfr_asset_type.is_confidential());Runsourcepub fn get_asset_type(&self) -> Option<AssetType>
pub fn get_asset_type(&self) -> Option<AssetType>
Return Some(asset_type) if asset_type is non-confidential. Otherwise, return None
Example:
use noah_api::xfr::structs::{AssetType, XfrAssetType};
use noah_algebra::ristretto::CompressedRistretto;
let xfr_asset_type = XfrAssetType::NonConfidential(AssetType::from_identical_byte(0u8));
assert_eq!(xfr_asset_type.get_asset_type().unwrap(), AssetType::from_identical_byte(0u8));
let xfr_asset_type = XfrAssetType::Confidential(CompressedRistretto::default());
assert!(xfr_asset_type.get_asset_type().is_none());Runsourcepub fn get_commitment(&self) -> Option<CompressedRistretto>
pub fn get_commitment(&self) -> Option<CompressedRistretto>
Return Some(c), where c is a commitment to the asset_type if asset_type is confidential. Otherwise, return None.
Example:
use noah_api::xfr::structs::{AssetType, XfrAssetType};
use noah_algebra::ristretto::CompressedRistretto;
let xfr_asset_type = XfrAssetType::NonConfidential(AssetType::from_identical_byte(0u8));
assert!(xfr_asset_type.get_commitment().is_none());
let xfr_amount = XfrAssetType::Confidential(CompressedRistretto::default());
assert_eq!(xfr_amount.get_commitment().unwrap(), CompressedRistretto::default());Runsourcepub fn from_blind(
pc_gens: &PedersenCommitmentRistretto,
asset_type: &AssetType,
blind: &RistrettoScalar
) -> Self
pub fn from_blind(
pc_gens: &PedersenCommitmentRistretto,
asset_type: &AssetType,
blind: &RistrettoScalar
) -> Self
Construct a confidential asset type with an asset type and asset type blind.
Trait Implementations§
source§impl Clone for XfrAssetType
impl Clone for XfrAssetType
source§fn clone(&self) -> XfrAssetType
fn clone(&self) -> XfrAssetType
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 Debug for XfrAssetType
impl Debug for XfrAssetType
source§impl<'de> Deserialize<'de> for XfrAssetType
impl<'de> Deserialize<'de> for XfrAssetType
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<XfrAssetType> for XfrAssetType
impl PartialEq<XfrAssetType> for XfrAssetType
source§fn eq(&self, other: &XfrAssetType) -> bool
fn eq(&self, other: &XfrAssetType) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl Serialize for XfrAssetType
impl Serialize for XfrAssetType
impl Eq for XfrAssetType
impl StructuralEq for XfrAssetType
impl StructuralPartialEq for XfrAssetType
Auto Trait Implementations§
impl RefUnwindSafe for XfrAssetType
impl Send for XfrAssetType
impl Sync for XfrAssetType
impl Unpin for XfrAssetType
impl UnwindSafe for XfrAssetType
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