Merge pull request #797 from zcash/note_encryption_remove_recipient
zcash_note_encryption: remove `recipient` parameter from `Domain::note_plaintext_bytes`
This commit is contained in:
commit
169782c672
|
@ -20,7 +20,6 @@ codegen-units = 1
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
zcash_encoding = { path = "components/zcash_encoding" }
|
zcash_encoding = { path = "components/zcash_encoding" }
|
||||||
zcash_note_encryption = { path = "components/zcash_note_encryption" }
|
|
||||||
orchard = { git = "https://github.com/zcash/orchard.git", rev = "6cbde279e90974201bedbd9b5ddf155e8f8b1e8e" }
|
orchard = { git = "https://github.com/zcash/orchard.git", rev = "6cbde279e90974201bedbd9b5ddf155e8f8b1e8e" }
|
||||||
halo2_gadgets = { git = "https://github.com/zcash/halo2.git", rev = "642924d614305d882cc122739c59144109f4bd3f" }
|
halo2_gadgets = { git = "https://github.com/zcash/halo2.git", rev = "642924d614305d882cc122739c59144109f4bd3f" }
|
||||||
halo2_proofs = { git = "https://github.com/zcash/halo2.git", rev = "642924d614305d882cc122739c59144109f4bd3f" }
|
halo2_proofs = { git = "https://github.com/zcash/halo2.git", rev = "642924d614305d882cc122739c59144109f4bd3f" }
|
||||||
|
|
|
@ -7,6 +7,13 @@ and this library adheres to Rust's notion of
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- The `recipient` parameter has been removed from `Domain::note_plaintext_bytes`.
|
||||||
|
- The `recipient` parameter has been removed from `NoteEncryption::new`. Since
|
||||||
|
the `Domain::Note` type is now expected to contain information about the
|
||||||
|
recipient of the note, there is no longer any need to pass this information
|
||||||
|
in via the encryption context.
|
||||||
|
|
||||||
## [0.2.0] - 2022-10-13
|
## [0.2.0] - 2022-10-13
|
||||||
### Added
|
### Added
|
||||||
- `zcash_note_encryption::Domain`:
|
- `zcash_note_encryption::Domain`:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "zcash_note_encryption"
|
name = "zcash_note_encryption"
|
||||||
description = "Note encryption for Zcash transactions"
|
description = "Note encryption for Zcash transactions"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
authors = [
|
authors = [
|
||||||
"Jack Grigg <jack@electriccoin.co>",
|
"Jack Grigg <jack@electriccoin.co>",
|
||||||
"Kris Nuttycombe <kris@electriccoin.co>"
|
"Kris Nuttycombe <kris@electriccoin.co>"
|
||||||
|
|
|
@ -180,11 +180,7 @@ pub trait Domain {
|
||||||
/// future crate release, once [`zcash_primitives` has been refactored].
|
/// future crate release, once [`zcash_primitives` has been refactored].
|
||||||
///
|
///
|
||||||
/// [`zcash_primitives` has been refactored]: https://github.com/zcash/librustzcash/issues/454
|
/// [`zcash_primitives` has been refactored]: https://github.com/zcash/librustzcash/issues/454
|
||||||
fn note_plaintext_bytes(
|
fn note_plaintext_bytes(note: &Self::Note, memo: &Self::Memo) -> NotePlaintextBytes;
|
||||||
note: &Self::Note,
|
|
||||||
recipient: &Self::Recipient,
|
|
||||||
memo: &Self::Memo,
|
|
||||||
) -> NotePlaintextBytes;
|
|
||||||
|
|
||||||
/// Derives the [`OutgoingCipherKey`] for an encrypted note, given the note-specific
|
/// Derives the [`OutgoingCipherKey`] for an encrypted note, given the note-specific
|
||||||
/// public data and an `OutgoingViewingKey`.
|
/// public data and an `OutgoingViewingKey`.
|
||||||
|
@ -349,7 +345,6 @@ pub struct NoteEncryption<D: Domain> {
|
||||||
epk: D::EphemeralPublicKey,
|
epk: D::EphemeralPublicKey,
|
||||||
esk: D::EphemeralSecretKey,
|
esk: D::EphemeralSecretKey,
|
||||||
note: D::Note,
|
note: D::Note,
|
||||||
to: D::Recipient,
|
|
||||||
memo: D::Memo,
|
memo: D::Memo,
|
||||||
/// `None` represents the `ovk = ⊥` case.
|
/// `None` represents the `ovk = ⊥` case.
|
||||||
ovk: Option<D::OutgoingViewingKey>,
|
ovk: Option<D::OutgoingViewingKey>,
|
||||||
|
@ -358,18 +353,12 @@ pub struct NoteEncryption<D: Domain> {
|
||||||
impl<D: Domain> NoteEncryption<D> {
|
impl<D: Domain> NoteEncryption<D> {
|
||||||
/// Construct a new note encryption context for the specified note,
|
/// Construct a new note encryption context for the specified note,
|
||||||
/// recipient, and memo.
|
/// recipient, and memo.
|
||||||
pub fn new(
|
pub fn new(ovk: Option<D::OutgoingViewingKey>, note: D::Note, memo: D::Memo) -> Self {
|
||||||
ovk: Option<D::OutgoingViewingKey>,
|
|
||||||
note: D::Note,
|
|
||||||
to: D::Recipient,
|
|
||||||
memo: D::Memo,
|
|
||||||
) -> Self {
|
|
||||||
let esk = D::derive_esk(¬e).expect("ZIP 212 is active.");
|
let esk = D::derive_esk(¬e).expect("ZIP 212 is active.");
|
||||||
NoteEncryption {
|
NoteEncryption {
|
||||||
epk: D::ka_derive_public(¬e, &esk),
|
epk: D::ka_derive_public(¬e, &esk),
|
||||||
esk,
|
esk,
|
||||||
note,
|
note,
|
||||||
to,
|
|
||||||
memo,
|
memo,
|
||||||
ovk,
|
ovk,
|
||||||
}
|
}
|
||||||
|
@ -384,14 +373,12 @@ impl<D: Domain> NoteEncryption<D> {
|
||||||
esk: D::EphemeralSecretKey,
|
esk: D::EphemeralSecretKey,
|
||||||
ovk: Option<D::OutgoingViewingKey>,
|
ovk: Option<D::OutgoingViewingKey>,
|
||||||
note: D::Note,
|
note: D::Note,
|
||||||
to: D::Recipient,
|
|
||||||
memo: D::Memo,
|
memo: D::Memo,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
NoteEncryption {
|
NoteEncryption {
|
||||||
epk: D::ka_derive_public(¬e, &esk),
|
epk: D::ka_derive_public(¬e, &esk),
|
||||||
esk,
|
esk,
|
||||||
note,
|
note,
|
||||||
to,
|
|
||||||
memo,
|
memo,
|
||||||
ovk,
|
ovk,
|
||||||
}
|
}
|
||||||
|
@ -412,7 +399,7 @@ impl<D: Domain> NoteEncryption<D> {
|
||||||
let pk_d = D::get_pk_d(&self.note);
|
let pk_d = D::get_pk_d(&self.note);
|
||||||
let shared_secret = D::ka_agree_enc(&self.esk, &pk_d);
|
let shared_secret = D::ka_agree_enc(&self.esk, &pk_d);
|
||||||
let key = D::kdf(shared_secret, &D::epk_bytes(&self.epk));
|
let key = D::kdf(shared_secret, &D::epk_bytes(&self.epk));
|
||||||
let input = D::note_plaintext_bytes(&self.note, &self.to, &self.memo);
|
let input = D::note_plaintext_bytes(&self.note, &self.memo);
|
||||||
|
|
||||||
let mut output = [0u8; ENC_CIPHERTEXT_SIZE];
|
let mut output = [0u8; ENC_CIPHERTEXT_SIZE];
|
||||||
output[..NOTE_PLAINTEXT_SIZE].copy_from_slice(&input.0);
|
output[..NOTE_PLAINTEXT_SIZE].copy_from_slice(&input.0);
|
||||||
|
|
|
@ -22,7 +22,7 @@ development = ["zcash_proofs"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
zcash_address = { version = "0.2", path = "../components/zcash_address" }
|
zcash_address = { version = "0.2", path = "../components/zcash_address" }
|
||||||
zcash_encoding = { version = "0.2", path = "../components/zcash_encoding" }
|
zcash_encoding = { version = "0.2", path = "../components/zcash_encoding" }
|
||||||
zcash_note_encryption = { version = "0.2", path = "../components/zcash_note_encryption" }
|
zcash_note_encryption = "0.2"
|
||||||
zcash_primitives = { version = "0.10", path = "../zcash_primitives", default-features = false }
|
zcash_primitives = { version = "0.10", path = "../zcash_primitives", default-features = false }
|
||||||
|
|
||||||
# Dependencies exposed in a public API:
|
# Dependencies exposed in a public API:
|
||||||
|
|
|
@ -50,7 +50,7 @@ proptest = "1.0.0"
|
||||||
rand_core = "0.6"
|
rand_core = "0.6"
|
||||||
regex = "1.4"
|
regex = "1.4"
|
||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
zcash_note_encryption = { version = "0.2", path = "../components/zcash_note_encryption" }
|
zcash_note_encryption = "0.2"
|
||||||
zcash_proofs = { version = "0.10", path = "../zcash_proofs" }
|
zcash_proofs = { version = "0.10", path = "../zcash_proofs" }
|
||||||
zcash_primitives = { version = "0.10", path = "../zcash_primitives", features = ["test-dependencies"] }
|
zcash_primitives = { version = "0.10", path = "../zcash_primitives", features = ["test-dependencies"] }
|
||||||
zcash_address = { version = "0.2", path = "../components/zcash_address", features = ["test-dependencies"] }
|
zcash_address = { version = "0.2", path = "../components/zcash_address", features = ["test-dependencies"] }
|
||||||
|
|
|
@ -81,7 +81,6 @@ fpe = "0.5"
|
||||||
|
|
||||||
[dependencies.zcash_note_encryption]
|
[dependencies.zcash_note_encryption]
|
||||||
version = "0.2"
|
version = "0.2"
|
||||||
path = "../components/zcash_note_encryption"
|
|
||||||
features = ["pre-zip-212"]
|
features = ["pre-zip-212"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
Loading…
Reference in New Issue