Skip to content

Commit

Permalink
zcash_note_encryption: Place pre-ZIP 212 APIs behind a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Dec 17, 2021
1 parent 69c3b4b commit 01c768d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions components/zcash_note_encryption/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jubjub = "0.8"
[features]
default = ["std"]
alloc = []
pre-zip-212 = []
std = ["alloc", "blake2b_simd/std"]

[lib]
Expand Down
11 changes: 10 additions & 1 deletion components/zcash_note_encryption/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,21 @@ impl<D: Domain> NoteEncryption<D> {
memo: D::Memo,
) -> Self {
let esk = D::derive_esk(&note).expect("ZIP 212 is active.");
Self::new_with_esk(esk, ovk, note, to, memo)
NoteEncryption {
epk: D::ka_derive_public(&note, &esk),
esk,
note,
to,
memo,
ovk,
}
}

/// For use only with Sapling. This method is preserved in order that test code
/// be able to generate pre-ZIP-212 ciphertexts so that tests can continue to
/// cover pre-ZIP-212 transaction decryption.
#[cfg(feature = "pre-zip-212")]
#[cfg_attr(docsrs, doc(cfg(feature = "pre-zip-212")))]
pub fn new_with_esk(
esk: D::EphemeralSecretKey,
ovk: Option<D::OutgoingViewingKey>,
Expand Down
6 changes: 5 additions & 1 deletion zcash_primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ secp256k1 = { version = "0.20", optional = true }
sha2 = "0.9"
subtle = "2.2.3"
zcash_encoding = { version = "0.0", path = "../components/zcash_encoding" }
zcash_note_encryption = { version = "0.0", path = "../components/zcash_note_encryption" }

[dependencies.zcash_note_encryption]
version = "0.0"
path = "../components/zcash_note_encryption"
features = ["pre-zip-212"]

[dev-dependencies]
criterion = "0.3"
Expand Down

0 comments on commit 01c768d

Please sign in to comment.