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).
|
||||
|
||||
## [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
|
||||
### Added
|
||||
|
|
|
@ -552,7 +552,8 @@ impl DiversifierKey {
|
|||
pub struct Diversifier([u8; 11]);
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
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.
|
||||
#[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,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 esk = rseed.esk_inner(rho);
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -108,7 +111,8 @@ impl PartialEq for Note {
|
|||
impl Eq for Note {}
|
||||
|
||||
impl Note {
|
||||
pub(crate) fn from_parts(
|
||||
///Create a Note from its component parts.
|
||||
pub fn from_parts(
|
||||
recipient: Address,
|
||||
value: NoteValue,
|
||||
rho: Nullifier,
|
||||
|
|
Loading…
Reference in New Issue