Struct phoenix_core::note::Note
source · pub struct Note { /* private fields */ }Expand description
A note that does not encrypt its value
Implementations§
source§impl Note
impl Note
sourcepub fn new<R: RngCore + CryptoRng>(
rng: &mut R,
note_type: NoteType,
psk: &PublicSpendKey,
value: u64,
blinding_factor: JubJubScalar
) -> Self
pub fn new<R: RngCore + CryptoRng>( rng: &mut R, note_type: NoteType, psk: &PublicSpendKey, value: u64, blinding_factor: JubJubScalar ) -> Self
Creates a new phoenix output note
sourcepub fn transparent<R: RngCore + CryptoRng>(
rng: &mut R,
psk: &PublicSpendKey,
value: u64
) -> Self
pub fn transparent<R: RngCore + CryptoRng>( rng: &mut R, psk: &PublicSpendKey, value: u64 ) -> Self
Creates a new transparent note
The blinding factor will be constant zero since the value commitment exists only to shield the value. The value is not hidden for transparent notes, so this can be trivially treated as a constant.
sourcepub fn transparent_stealth(
stealth_address: StealthAddress,
value: u64,
nonce: BlsScalar
) -> Self
pub fn transparent_stealth( stealth_address: StealthAddress, value: u64, nonce: BlsScalar ) -> Self
Creates a new transparent note
This is equivalent to [transparent] but taking only a stealth address,
a value, and a nonce. This is done to be able to generate a note
directly for a stealth address, as opposed to a public spend key.
sourcepub fn obfuscated<R: RngCore + CryptoRng>(
rng: &mut R,
psk: &PublicSpendKey,
value: u64,
blinding_factor: JubJubScalar
) -> Self
pub fn obfuscated<R: RngCore + CryptoRng>( rng: &mut R, psk: &PublicSpendKey, value: u64, blinding_factor: JubJubScalar ) -> Self
Creates a new obfuscated note
The provided blinding factor will be used to calculate the value commitment of the note. The tuple (value, blinding_factor), known by the caller of this function, must be later used to prove the knowledge of the value commitment of this note.
sourcepub fn deterministic(
note_type: NoteType,
r: &JubJubScalar,
nonce: BlsScalar,
psk: &PublicSpendKey,
value: u64,
blinding_factor: JubJubScalar
) -> Self
pub fn deterministic( note_type: NoteType, r: &JubJubScalar, nonce: BlsScalar, psk: &PublicSpendKey, value: u64, blinding_factor: JubJubScalar ) -> Self
Create a new phoenix output note without inner randomness
sourcepub fn gen_nullifier(&self, sk: &SecretSpendKey) -> BlsScalar
pub fn gen_nullifier(&self, sk: &SecretSpendKey) -> BlsScalar
Create a unique nullifier for the note
This nullifier is represeted as H(sk_r · G', pos)
sourcepub fn hash_inputs(&self) -> [BlsScalar; 6]
pub fn hash_inputs(&self) -> [BlsScalar; 6]
Return the internal representation of scalars to be hashed
sourcepub fn hash(&self) -> BlsScalar
pub fn hash(&self) -> BlsScalar
Return a hash represented by `H(note_type, value_commitment, H(StealthAddress), pos, encrypted_data)
sourcepub fn set_pos(&mut self, pos: u64)
pub fn set_pos(&mut self, pos: u64)
Set the position of the note on the tree. This, naturally, won’t reflect immediatelly on the data storage
sourcepub const fn nonce(&self) -> &BlsScalar
pub const fn nonce(&self) -> &BlsScalar
Nonce used for the encrypt / decrypt of data for this note
sourcepub const fn value_commitment(&self) -> &JubJubExtended
pub const fn value_commitment(&self) -> &JubJubExtended
Return the value commitment H(value, blinding_factor)
sourcepub fn value(&self, vk: Option<&ViewKey>) -> Result<u64, Error>
pub fn value(&self, vk: Option<&ViewKey>) -> Result<u64, Error>
Attempt to decrypt the note value provided a ViewKey. Always
succeeds for transparent notes, might fails or return random values for
obfuscated notes if the provided view key is wrong.
sourcepub fn blinding_factor(
&self,
vk: Option<&ViewKey>
) -> Result<JubJubScalar, Error>
pub fn blinding_factor( &self, vk: Option<&ViewKey> ) -> Result<JubJubScalar, Error>
Decrypt the blinding factor with the provided ViewKey
If the decrypt fails, a random value is returned
Trait Implementations§
source§impl Ownable for Note
impl Ownable for Note
source§fn stealth_address(&self) -> &StealthAddress
fn stealth_address(&self) -> &StealthAddress
StealthAddress