mirror of https://github.com/zcash/orchard.git
Allow creating notes from serialized parts
This commit is contained in:
parent
3faab98e9e
commit
a29a468280
11
src/note.rs
11
src/note.rs
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue