mirror of https://github.com/zcash/orchard.git
Publicize necessary functionality for reading diversifiers and notes from data
This commit is contained in:
parent
3faab98e9e
commit
45bcc16f80
|
@ -6,6 +6,11 @@ and this project adheres to Rust's notion of
|
||||||
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Changed
|
||||||
|
- `note`:
|
||||||
|
- `RandomSeed` and its functions `from_bytes` and `as_bytes` now public
|
||||||
|
- `Note::from_parts` now public
|
||||||
|
- `keys::Diversifier::from_bytes` now public
|
||||||
|
|
||||||
## [0.2.0] - 2022-06-24
|
## [0.2.0] - 2022-06-24
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -552,7 +552,8 @@ impl DiversifierKey {
|
||||||
pub struct Diversifier([u8; 11]);
|
pub struct Diversifier([u8; 11]);
|
||||||
|
|
||||||
impl Diversifier {
|
impl Diversifier {
|
||||||
pub(crate) fn from_bytes(d: [u8; 11]) -> Self {
|
///Read a diversifier from a byte array.
|
||||||
|
pub fn from_bytes(d: [u8; 11]) -> Self {
|
||||||
Diversifier(d)
|
Diversifier(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
src/note.rs
12
src/note.rs
|
@ -21,7 +21,7 @@ pub use self::nullifier::Nullifier;
|
||||||
|
|
||||||
/// The ZIP 212 seed randomness for a note.
|
/// The ZIP 212 seed randomness for a note.
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub(crate) struct RandomSeed([u8; 32]);
|
pub struct RandomSeed([u8; 32]);
|
||||||
|
|
||||||
impl RandomSeed {
|
impl RandomSeed {
|
||||||
pub(crate) fn random(rng: &mut impl RngCore, rho: &Nullifier) -> Self {
|
pub(crate) fn random(rng: &mut impl RngCore, rho: &Nullifier) -> Self {
|
||||||
|
@ -35,13 +35,16 @@ impl RandomSeed {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn from_bytes(rseed: [u8; 32], rho: &Nullifier) -> CtOption<Self> {
|
///Read a note's random seed from bytes, given the note's nullifier.
|
||||||
|
///Returns None if the nullifier is not for the same note as the seed.
|
||||||
|
pub fn from_bytes(rseed: [u8; 32], rho: &Nullifier) -> CtOption<Self> {
|
||||||
let rseed = RandomSeed(rseed);
|
let rseed = RandomSeed(rseed);
|
||||||
let esk = rseed.esk_inner(rho);
|
let esk = rseed.esk_inner(rho);
|
||||||
CtOption::new(rseed, esk.is_some())
|
CtOption::new(rseed, esk.is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn as_bytes(&self) -> &[u8; 32] {
|
/// Returns the byte array corresponding to this seed.
|
||||||
|
pub fn as_bytes(&self) -> &[u8; 32] {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +111,8 @@ impl PartialEq for Note {
|
||||||
impl Eq for Note {}
|
impl Eq for Note {}
|
||||||
|
|
||||||
impl Note {
|
impl Note {
|
||||||
pub(crate) fn from_parts(
|
///Create a Note from its component parts.
|
||||||
|
pub fn from_parts(
|
||||||
recipient: Address,
|
recipient: Address,
|
||||||
value: NoteValue,
|
value: NoteValue,
|
||||||
rho: Nullifier,
|
rho: Nullifier,
|
||||||
|
|
Loading…
Reference in New Issue