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
StealthAddresssource§impl PartialEq for Note
impl PartialEq for Note
source§impl Serializable<{ 137 + PoseidonCipher::SIZE }> for Note
impl Serializable<{ 137 + PoseidonCipher::SIZE }> for Note
impl Copy for Note
impl Eq for Note
Auto Trait Implementations§
impl RefUnwindSafe for Note
impl Send for Note
impl Sync for Note
impl Unpin for Note
impl UnwindSafe for Note
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
source§impl<T, const N: usize> DeserializableSlice<N> for Twhere
T: Serializable<N>,
impl<T, const N: usize> DeserializableSlice<N> for Twhere T: Serializable<N>,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,
source§impl<T, const N: usize> ParseHexStr<N> for Twhere
T: Serializable<N>,
impl<T, const N: usize> ParseHexStr<N> for Twhere T: Serializable<N>,
source§fn from_hex_str(s: &str) -> Result<Self, Self::Error>where
Self: Sized,
Self::Error: BadLength + InvalidChar,
fn from_hex_str(s: &str) -> Result<Self, Self::Error>where Self: Sized, Self::Error: BadLength + InvalidChar,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self, then passes self.as_mut() into the pipe
function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut() only in debug builds, and is erased in release
builds.