Struct noah_api::xfr::structs::TracerMemo
source · pub struct TracerMemo {
pub enc_key: AssetTracerEncKeys,
pub lock_amount: Option<(RecordDataCiphertext, RecordDataCiphertext)>,
pub lock_asset_type: Option<RecordDataCiphertext>,
pub lock_attributes: Vec<AttributeCiphertext>,
pub lock_info: NoahHybridCiphertext,
}Expand description
Information directed to an asset tracer.
Fields§
§enc_key: AssetTracerEncKeysThe asset tracer encryption keys, used to identify the tracer.
lock_amount: Option<(RecordDataCiphertext, RecordDataCiphertext)>The ciphertexts of the amounts, each amount has one for higher 32 bits, and one for the lower 32 bits.
lock_asset_type: Option<RecordDataCiphertext>The ciphertexts of the asset types.
lock_attributes: Vec<AttributeCiphertext>The ciphertexts of the attributes.
lock_info: NoahHybridCiphertextA hybrid encryption of amount, asset type, and attributes encrypted above for faster access.
Implementations§
source§impl TracerMemo
impl TracerMemo
sourcepub fn new<R: CryptoRng + RngCore>(
prng: &mut R,
tracer_enc_key: &AssetTracerEncKeys,
amount_info: Option<(u32, u32, &RistrettoScalar, &RistrettoScalar)>,
asset_type_info: Option<(&AssetType, &RistrettoScalar)>,
attrs_info: &[(Attr, AttributeCiphertext)]
) -> Self
pub fn new<R: CryptoRng + RngCore>(
prng: &mut R,
tracer_enc_key: &AssetTracerEncKeys,
amount_info: Option<(u32, u32, &RistrettoScalar, &RistrettoScalar)>,
asset_type_info: Option<(&AssetType, &RistrettoScalar)>,
attrs_info: &[(Attr, AttributeCiphertext)]
) -> Self
Sample a new TracerMemo. amount_info is (amount_low, amount_high, amount_blind_low, amount_blind_high) tuple asset_type_info is (asset_type, asset_type_blind) tuple
sourcepub fn decrypt(
&self,
dec_key: &AssetTracerDecKeys
) -> Result<(Option<u64>, Option<AssetType>, Vec<Attr>)>
pub fn decrypt(
&self,
dec_key: &AssetTracerDecKeys
) -> Result<(Option<u64>, Option<AssetType>, Vec<Attr>)>
Decrypts the asset tracer memo: Returns NoahError:BogusAssetTracerMemo in case decrypted values are inconsistents
sourcepub fn verify_amount(
&self,
dec_key: &ElGamalDecKey<RistrettoScalar>,
expected: u64
) -> Result<()>
pub fn verify_amount(
&self,
dec_key: &ElGamalDecKey<RistrettoScalar>,
expected: u64
) -> Result<()>
Check if the amount encrypted in self.lock_amount is expected. If self.lock_amount is None, return Err(NoahError::ParameterError), Otherwise, if decrypted amount is not expected amount, return Err(NoahError::AssetTracingExtractionError), else Ok(()).
sourcepub fn verify_asset_type(
&self,
dec_key: &ElGamalDecKey<RistrettoScalar>,
expected: &AssetType
) -> Result<()>
pub fn verify_asset_type(
&self,
dec_key: &ElGamalDecKey<RistrettoScalar>,
expected: &AssetType
) -> Result<()>
Check if the asset type encrypted in self.lock_asset_type is expected. return Err if lock_asset_type is None or the decrypted is not as expected, else returns Ok.
sourcepub fn extract_asset_type(
&self,
dec_key: &ElGamalDecKey<RistrettoScalar>,
candidate_asset_types: &[AssetType]
) -> Result<AssetType>
pub fn extract_asset_type(
&self,
dec_key: &ElGamalDecKey<RistrettoScalar>,
candidate_asset_types: &[AssetType]
) -> Result<AssetType>
Decrypt asset_type in self.lock_asset_type via a linear scan over candidate_asset_types. If self.lock_asset_type is None, return Err(NoahError::ParameterError), Otherwise, if decrypted asset_type is not in the candidate list return Err(NoahError::AssetTracingExtractionError), else return the decrypted asset_type.
sourcepub fn verify_identity_attributes(
&self,
dec_key: &ElGamalDecKey<BLSScalar>,
expected_attributes: &[u32]
) -> Result<Vec<bool>>
pub fn verify_identity_attributes(
&self,
dec_key: &ElGamalDecKey<BLSScalar>,
expected_attributes: &[u32]
) -> Result<Vec<bool>>
Check is the attributes encrypted in self.lock_attrs are the same as in expected_attributes, If self.lock_attrs is None or if attribute length doesn’t match expected list, return Err(NoahError::ParameterError), Otherwise, it returns a boolean vector indicating true for every positive match and false otherwise.
Trait Implementations§
source§impl Clone for TracerMemo
impl Clone for TracerMemo
source§fn clone(&self) -> TracerMemo
fn clone(&self) -> TracerMemo
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for TracerMemo
impl Debug for TracerMemo
source§impl<'de> Deserialize<'de> for TracerMemo
impl<'de> Deserialize<'de> for TracerMemo
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>,
source§impl PartialEq<TracerMemo> for TracerMemo
impl PartialEq<TracerMemo> for TracerMemo
source§fn eq(&self, other: &TracerMemo) -> bool
fn eq(&self, other: &TracerMemo) -> bool
self and other values to be equal, and is used
by ==.