mirror of https://github.com/zcash/orchard.git
Adopt Orchard ZSA for Zebra (introduce zcash_note_encryption_zsa alias, minor enhancements) (#89)
This Pull Request introduces the `zcash_note_encryption_zsa` alias, ensuring compatibility with the Zebra project. This alias is used to prevent conflicts with the original `zcash_note_encryption` crate, which is also used in Zebra through the original `orchard` crate that is used in parallel with our `orchard` (Orchard ZSA) crate. Additionally, this PR includes minor enhancements to ensure compatibility with the Zebra project. --------- Co-authored-by: Dmitry Demin <dmitry@qed-it.com>
This commit is contained in:
parent
a680f410a4
commit
7b943e197e
|
@ -41,7 +41,7 @@ reddsa = "0.5"
|
|||
nonempty = "0.7"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
subtle = "2.3"
|
||||
zcash_note_encryption = "0.4"
|
||||
zcash_note_encryption_zsa = { package = "zcash_note_encryption", version = "0.4", git = "https://github.com/QED-it/librustzcash", branch = "zsa1-zebra" }
|
||||
incrementalmerkletree = "0.5"
|
||||
|
||||
# Logging
|
||||
|
@ -57,7 +57,7 @@ criterion = "0.4" # 0.5 depends on clap 4 which has MSRV 1.70
|
|||
halo2_gadgets = { git = "https://github.com/QED-it/halo2", branch = "zsa1", features = ["test-dependencies"] }
|
||||
hex = "0.4"
|
||||
proptest = "1.0.0"
|
||||
zcash_note_encryption = { version = "0.4", features = ["pre-zip-212"] }
|
||||
zcash_note_encryption_zsa = { package = "zcash_note_encryption", version = "0.4", git = "https://github.com/QED-it/librustzcash", branch = "zsa1-zebra", features = ["pre-zip-212"] }
|
||||
incrementalmerkletree = { version = "0.5", features = ["test-dependencies"] }
|
||||
|
||||
[target.'cfg(unix)'.dev-dependencies]
|
||||
|
@ -91,6 +91,3 @@ debug = true
|
|||
|
||||
[profile.bench]
|
||||
debug = true
|
||||
|
||||
[patch.crates-io]
|
||||
zcash_note_encryption = { version = "0.4", git = "https://github.com/QED-it/librustzcash.git", branch = "zsa1-zebra" }
|
||||
|
|
|
@ -10,7 +10,7 @@ use orchard::{
|
|||
Anchor, Bundle,
|
||||
};
|
||||
use rand::rngs::OsRng;
|
||||
use zcash_note_encryption::{batch, try_compact_note_decryption, try_note_decryption};
|
||||
use zcash_note_encryption_zsa::{batch, try_compact_note_decryption, try_note_decryption};
|
||||
|
||||
#[cfg(unix)]
|
||||
use pprof::criterion::{Output, PProfProfiler};
|
||||
|
|
|
@ -337,7 +337,7 @@ impl Builder {
|
|||
/// Adds a note to be spent in this transaction.
|
||||
///
|
||||
/// - `note` is a spendable note, obtained by trial-decrypting an [`Action`] using the
|
||||
/// [`zcash_note_encryption`] crate instantiated with [`OrchardDomain`].
|
||||
/// [`zcash_note_encryption_zsa`] crate instantiated with [`OrchardDomain`].
|
||||
/// - `merkle_path` can be obtained using the [`incrementalmerkletree`] crate
|
||||
/// instantiated with [`MerkleHashOrchard`].
|
||||
///
|
||||
|
|
|
@ -11,7 +11,7 @@ use core::fmt;
|
|||
use blake2b_simd::Hash as Blake2bHash;
|
||||
use memuse::DynamicUsage;
|
||||
use nonempty::NonEmpty;
|
||||
use zcash_note_encryption::{try_note_decryption, try_output_recovery_with_ovk};
|
||||
use zcash_note_encryption_zsa::{try_note_decryption, try_output_recovery_with_ovk};
|
||||
|
||||
use crate::note::AssetBase;
|
||||
use crate::{
|
||||
|
|
|
@ -26,7 +26,7 @@ use crate::{
|
|||
use crate::supply_info::{AssetSupply, SupplyInfo};
|
||||
|
||||
/// A bundle of actions to be applied to the ledger.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct IssueBundle<T: IssueAuth> {
|
||||
/// The issuer key for the note being created.
|
||||
ik: IssuanceValidatingKey,
|
||||
|
@ -39,7 +39,7 @@ pub struct IssueBundle<T: IssueAuth> {
|
|||
/// An issue action applied to the global ledger.
|
||||
///
|
||||
/// Externally, this creates new zsa notes (adding a commitment to the global ledger).
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct IssueAction {
|
||||
/// Asset description for verification.
|
||||
asset_desc: String,
|
||||
|
@ -181,7 +181,7 @@ pub struct Prepared {
|
|||
}
|
||||
|
||||
/// Marker for an authorized bundle.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Signed {
|
||||
signature: redpallas::Signature<SpendAuth>,
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use group::{
|
|||
use pasta_curves::{pallas, pallas::Scalar};
|
||||
use rand::{CryptoRng, RngCore};
|
||||
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
|
||||
use zcash_note_encryption::EphemeralKeyBytes;
|
||||
use zcash_note_encryption_zsa::EphemeralKeyBytes;
|
||||
|
||||
use crate::{
|
||||
address::Address,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use blake2b_simd::{Hash, Params};
|
||||
use group::ff::PrimeField;
|
||||
use std::fmt;
|
||||
use zcash_note_encryption::{
|
||||
use zcash_note_encryption_zsa::{
|
||||
BatchDomain, Domain, EphemeralKeyBytes, OutPlaintextBytes, OutgoingCipherKey, ShieldedOutput,
|
||||
AEAD_TAG_SIZE, MEMO_SIZE, OUT_PLAINTEXT_SIZE,
|
||||
};
|
||||
|
@ -350,7 +350,7 @@ impl BatchDomain for OrchardDomainV2 {
|
|||
}
|
||||
|
||||
/// Implementation of in-band secret distribution for Orchard bundles.
|
||||
pub type OrchardNoteEncryption = zcash_note_encryption::NoteEncryption<OrchardDomainV2>;
|
||||
pub type OrchardNoteEncryption = zcash_note_encryption_zsa::NoteEncryption<OrchardDomainV2>;
|
||||
|
||||
impl<T> ShieldedOutput<OrchardDomainV2> for Action<T> {
|
||||
fn ephemeral_key(&self) -> EphemeralKeyBytes {
|
||||
|
@ -450,7 +450,7 @@ impl CompactAction {
|
|||
mod tests {
|
||||
use proptest::proptest;
|
||||
use rand::rngs::OsRng;
|
||||
use zcash_note_encryption::{
|
||||
use zcash_note_encryption_zsa::{
|
||||
try_compact_note_decryption, try_note_decryption, try_output_recovery_with_ovk, Domain,
|
||||
EphemeralKeyBytes,
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use blake2b_simd::{Hash, Params};
|
||||
use core::fmt;
|
||||
use group::ff::PrimeField;
|
||||
use zcash_note_encryption::{
|
||||
use zcash_note_encryption_zsa::{
|
||||
BatchDomain, Domain, EphemeralKeyBytes, OutPlaintextBytes, OutgoingCipherKey, ShieldedOutput,
|
||||
AEAD_TAG_SIZE, MEMO_SIZE, OUT_PLAINTEXT_SIZE,
|
||||
};
|
||||
|
@ -440,9 +440,8 @@ impl BatchDomain for OrchardDomain {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Implementation of in-band secret distribution for Orchard bundles.
|
||||
pub type OrchardNoteEncryption = zcash_note_encryption::NoteEncryption<OrchardDomain>;
|
||||
pub type OrchardNoteEncryption = zcash_note_encryption_zsa::NoteEncryption<OrchardDomain>;
|
||||
|
||||
impl<T> ShieldedOutput<OrchardDomain> for Action<T> {
|
||||
fn ephemeral_key(&self) -> EphemeralKeyBytes {
|
||||
|
@ -548,7 +547,7 @@ impl CompactAction {
|
|||
mod tests {
|
||||
use proptest::prelude::*;
|
||||
use rand::rngs::OsRng;
|
||||
use zcash_note_encryption::{
|
||||
use zcash_note_encryption_zsa::{
|
||||
try_compact_note_decryption, try_note_decryption, try_output_recovery_with_ovk, Domain,
|
||||
EphemeralKeyBytes,
|
||||
};
|
||||
|
@ -571,7 +570,7 @@ mod tests {
|
|||
Address, Note,
|
||||
};
|
||||
|
||||
use super::{version, orchard_parse_note_plaintext_without_memo};
|
||||
use super::{orchard_parse_note_plaintext_without_memo, version};
|
||||
|
||||
proptest! {
|
||||
#[test]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use blake2b_simd::{Hash, Params};
|
||||
use core::fmt;
|
||||
use group::ff::PrimeField;
|
||||
use zcash_note_encryption::{
|
||||
use zcash_note_encryption_zsa::{
|
||||
BatchDomain, Domain, EphemeralKeyBytes, OutPlaintextBytes, OutgoingCipherKey, ShieldedOutput,
|
||||
AEAD_TAG_SIZE, MEMO_SIZE, OUT_PLAINTEXT_SIZE,
|
||||
};
|
||||
|
@ -349,7 +349,7 @@ impl BatchDomain for OrchardDomainV3 {
|
|||
}
|
||||
|
||||
/// Implementation of in-band secret distribution for Orchard bundles.
|
||||
pub type OrchardNoteEncryption = zcash_note_encryption::NoteEncryption<OrchardDomainV3>;
|
||||
pub type OrchardNoteEncryption = zcash_note_encryption_zsa::NoteEncryption<OrchardDomainV3>;
|
||||
|
||||
impl<T> ShieldedOutput<OrchardDomainV3> for Action<T> {
|
||||
fn ephemeral_key(&self) -> EphemeralKeyBytes {
|
||||
|
@ -449,7 +449,7 @@ impl CompactAction {
|
|||
mod tests {
|
||||
use proptest::prelude::*;
|
||||
use rand::rngs::OsRng;
|
||||
use zcash_note_encryption::{
|
||||
use zcash_note_encryption_zsa::{
|
||||
try_compact_note_decryption, try_note_decryption, try_output_recovery_with_ovk, Domain,
|
||||
EphemeralKeyBytes,
|
||||
};
|
||||
|
|
|
@ -154,7 +154,7 @@ impl<T: SigType> VerificationKey<T> {
|
|||
}
|
||||
|
||||
/// A RedPallas signature.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Signature<T: SigType>(reddsa::Signature<T>);
|
||||
|
||||
impl<T: SigType> From<[u8; 64]> for Signature<T> {
|
||||
|
|
|
@ -12,7 +12,7 @@ use orchard::{
|
|||
Anchor, Bundle, Note,
|
||||
};
|
||||
use rand::rngs::OsRng;
|
||||
use zcash_note_encryption::try_note_decryption;
|
||||
use zcash_note_encryption_zsa::try_note_decryption;
|
||||
|
||||
pub fn verify_bundle(bundle: &Bundle<Authorized, i64>, vk: &VerifyingKey, verify_proof: bool) {
|
||||
if verify_proof {
|
||||
|
|
|
@ -22,7 +22,7 @@ use orchard::{
|
|||
};
|
||||
use rand::rngs::OsRng;
|
||||
use std::collections::HashSet;
|
||||
use zcash_note_encryption::try_note_decryption;
|
||||
use zcash_note_encryption_zsa::try_note_decryption;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Keychain {
|
||||
|
|
Loading…
Reference in New Issue