zcash_note_encryption: Place pre-ZIP 212 APIs behind a feature flag

This commit is contained in:
Jack Grigg 2021-12-17 01:32:50 +00:00
parent 69c3b4b5e1
commit 01c768dbeb
3 changed files with 16 additions and 2 deletions

View File

@ -28,6 +28,7 @@ jubjub = "0.8"
[features]
default = ["std"]
alloc = []
pre-zip-212 = []
std = ["alloc", "blake2b_simd/std"]
[lib]

View File

@ -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>,

View File

@ -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"