Allow creating notes from serialized parts

This commit is contained in:
Aditya Kulkarni 2022-07-29 10:58:11 -05:00
parent 3faab98e9e
commit a29a468280
1 changed files with 7 additions and 4 deletions

View File

@ -21,7 +21,7 @@ pub use self::nullifier::Nullifier;
/// The ZIP 212 seed randomness for a note.
#[derive(Copy, Clone, Debug)]
pub(crate) struct RandomSeed([u8; 32]);
pub struct RandomSeed([u8; 32]);
impl RandomSeed {
pub(crate) fn random(rng: &mut impl RngCore, rho: &Nullifier) -> Self {
@ -35,13 +35,15 @@ impl RandomSeed {
}
}
pub(crate) fn from_bytes(rseed: [u8; 32], rho: &Nullifier) -> CtOption<Self> {
/// Create RandomSeed from previously serialized bytes
pub fn from_bytes(rseed: [u8; 32], rho: &Nullifier) -> CtOption<Self> {
let rseed = RandomSeed(rseed);
let esk = rseed.esk_inner(rho);
CtOption::new(rseed, esk.is_some())
}
pub(crate) fn as_bytes(&self) -> &[u8; 32] {
/// Serialize randomness into bytes
pub fn as_bytes(&self) -> &[u8; 32] {
&self.0
}
@ -108,7 +110,8 @@ impl PartialEq for Note {
impl Eq for Note {}
impl Note {
pub(crate) fn from_parts(
/// Construct note from its component parts
pub fn from_parts(
recipient: Address,
value: NoteValue,
rho: Nullifier,