diff --git a/Cargo.lock b/Cargo.lock index 7074cd5a9..e7a81fe34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -771,7 +771,7 @@ dependencies = [ [[package]] name = "halo2_gadgets" version = "0.3.0" -source = "git+https://github.com/QED-it/halo2?branch=orchardzsa-backward-compatability#4cc147385e7cf106b9fab6d6951d66a343899e38" +source = "git+https://github.com/QED-it/halo2?rev=7f5c0babd61f8ca46c9165a1adfac298d3fd3a11#7f5c0babd61f8ca46c9165a1adfac298d3fd3a11" dependencies = [ "arrayvec", "bitvec", @@ -794,7 +794,7 @@ checksum = "47716fe1ae67969c5e0b2ef826f32db8c3be72be325e1aa3c1951d06b5575ec5" [[package]] name = "halo2_proofs" version = "0.3.0" -source = "git+https://github.com/QED-it/halo2?branch=orchardzsa-backward-compatability#4cc147385e7cf106b9fab6d6951d66a343899e38" +source = "git+https://github.com/QED-it/halo2?rev=7f5c0babd61f8ca46c9165a1adfac298d3fd3a11#7f5c0babd61f8ca46c9165a1adfac298d3fd3a11" dependencies = [ "blake2b_simd", "ff", @@ -1229,7 +1229,7 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "orchard" version = "0.8.0" -source = "git+https://github.com/QED-it/orchard?branch=orchardzsa-backward-compatability-0.8.0-ak#984276d113f6ef2563a26feb8c634ffbda0d31c6" +source = "git+https://github.com/QED-it/orchard?branch=zsa1#39b479ea81045e5c5ac719821fe2feb2bfce5f36" dependencies = [ "aes", "bitvec", @@ -1253,7 +1253,7 @@ dependencies = [ "serde", "subtle", "tracing", - "zcash_note_encryption", + "zcash_note_encryption 0.4.0 (git+https://github.com/QED-it/zcash_note_encryption?branch=zsa1)", "zcash_spec", "zip32", ] @@ -1776,7 +1776,7 @@ dependencies = [ "redjubjub", "subtle", "tracing", - "zcash_note_encryption", + "zcash_note_encryption 0.4.0 (git+https://github.com/QED-it/zcash_note_encryption?branch=fix-sapling-constants)", "zcash_spec", "zip32", ] @@ -2496,6 +2496,18 @@ dependencies = [ "subtle", ] +[[package]] +name = "zcash_note_encryption" +version = "0.4.0" +source = "git+https://github.com/QED-it/zcash_note_encryption?branch=zsa1#b8bd2a186fc04ec4f55b2db44df7374f03ab5725" +dependencies = [ + "chacha20", + "chacha20poly1305", + "cipher", + "rand_core", + "subtle", +] + [[package]] name = "zcash_primitives" version = "0.15.0" @@ -2533,7 +2545,7 @@ dependencies = [ "tracing", "zcash_address", "zcash_encoding", - "zcash_note_encryption", + "zcash_note_encryption 0.4.0 (git+https://github.com/QED-it/zcash_note_encryption?branch=fix-sapling-constants)", "zcash_protocol", "zcash_spec", "zip32", diff --git a/Cargo.toml b/Cargo.toml index 9a57a38b5..58c05b2ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ sapling = { package = "sapling-crypto", version = "0.1.3" } # - Orchard nonempty = "0.7" -orchard = { version = "0.8.0", default-features = false, git = "https://github.com/QED-it/orchard", branch = "orchardzsa-backward-compatability-0.8.0-ak" } +orchard = { version = "0.8.0", default-features = false, git = "https://github.com/QED-it/orchard", branch = "zsa1" } pasta_curves = "0.5" # - Transparent @@ -125,4 +125,4 @@ codegen-units = 1 [patch.crates-io] zcash_note_encryption = { version = "0.4", git = "https://github.com/QED-it/zcash_note_encryption", branch = "fix-sapling-constants" } -sapling = { package = "sapling-crypto", version = "0.1.3", git = "https://github.com/QED-it/sapling-crypto", branch = "orchard-backward-compatibility" } \ No newline at end of file +sapling = { package = "sapling-crypto", version = "0.1.3", git = "https://github.com/QED-it/sapling-crypto", branch = "orchard-backward-compatibility" } diff --git a/zcash_primitives/src/transaction/builder.rs b/zcash_primitives/src/transaction/builder.rs index dc8d85a63..e97c6d22f 100644 --- a/zcash_primitives/src/transaction/builder.rs +++ b/zcash_primitives/src/transaction/builder.rs @@ -53,8 +53,8 @@ use crate::{ #[cfg(zcash_unstable = "nu6")] /* TODO nu7 */ use crate::transaction::builder::Error::{IssuanceBuilder, IssuanceBundle}; use orchard::note::AssetBase; -use orchard::orchard_flavors::OrchardVanilla; -#[cfg(zcash_unstable = "nu6")] /* TODO nu7 */ use orchard::orchard_flavors::OrchardZSA; +use orchard::orchard_flavor::OrchardVanilla; +#[cfg(zcash_unstable = "nu6")] /* TODO nu7 */ use orchard::orchard_flavor::OrchardZSA; #[cfg(zcash_unstable = "nu6")] /* TODO nu7 */ use orchard::{ issuance::{IssueBundle, IssueInfo}, diff --git a/zcash_primitives/src/transaction/components/orchard.rs b/zcash_primitives/src/transaction/components/orchard.rs index 5b9b05f4f..bc59747ea 100644 --- a/zcash_primitives/src/transaction/components/orchard.rs +++ b/zcash_primitives/src/transaction/components/orchard.rs @@ -6,13 +6,13 @@ use crate::transaction::components::issuance::read_asset; use byteorder::{ReadBytesExt, WriteBytesExt}; use nonempty::NonEmpty; use orchard::note::AssetBase; -use orchard::note_encryption::OrchardDomain; -use orchard::orchard_flavors::{OrchardVanilla, OrchardZSA}; +use orchard::note_encryption::OrchardDomainCommon; +use orchard::orchard_flavor::{OrchardVanilla, OrchardZSA}; use orchard::{ bundle::{Authorization, Authorized, Flags}, note::{ExtractedNoteCommitment, Nullifier, TransmittedNoteCiphertext}, primitives::redpallas::{self, SigType, Signature, SpendAuth, VerificationKey}, - value::ValueCommitment, + value::{NoteValue, ValueCommitment}, Action, Anchor, }; use zcash_encoding::{Array, CompactSize, Vector}; @@ -125,8 +125,8 @@ pub fn read_v6_bundle( } } -fn read_burn(reader: &mut R) -> io::Result<(AssetBase, Amount)> { - Ok((read_asset(reader)?, Transaction::read_amount(reader)?)) +fn read_burn(reader: &mut R) -> io::Result<(AssetBase, NoteValue)> { + Ok((read_asset(reader)?, Transaction::read_note_value(reader)?)) } pub fn read_value_commitment(mut reader: R) -> io::Result { @@ -186,7 +186,7 @@ pub fn read_note_ciphertext( ) -> io::Result> { let mut tnc = TransmittedNoteCiphertext:: { epk_bytes: [0u8; 32], - enc_ciphertext: ::NoteCiphertextBytes::from( + enc_ciphertext: ::NoteCiphertextBytes::from( [0u8; OrchardVanilla::ENC_CIPHERTEXT_SIZE].as_ref(), ), out_ciphertext: [0u8; 80], @@ -204,7 +204,7 @@ pub fn read_zsa_note_ciphertext( ) -> io::Result> { let mut tnc = TransmittedNoteCiphertext:: { epk_bytes: [0u8; 32], - enc_ciphertext: ::NoteCiphertextBytes::from( + enc_ciphertext: ::NoteCiphertextBytes::from( [0u8; OrchardZSA::ENC_CIPHERTEXT_SIZE].as_ref(), ), out_ciphertext: [0u8; 80], @@ -338,7 +338,7 @@ pub fn write_v6_bundle( Vector::write(&mut writer, bundle.burn(), |w, (asset, amount)| { w.write_all(&asset.to_bytes())?; - w.write_all(&amount.to_i64_le_bytes())?; + w.write_all(&amount.to_bytes())?; Ok(()) })?; @@ -371,7 +371,7 @@ pub fn write_cmx(mut writer: W, cmx: &ExtractedNoteCommitment) -> io:: writer.write_all(&cmx.to_bytes()) } -pub fn write_note_ciphertext( +pub fn write_note_ciphertext( mut writer: W, nc: &TransmittedNoteCiphertext, ) -> io::Result<()> { @@ -380,7 +380,7 @@ pub fn write_note_ciphertext( writer.write_all(&nc.out_ciphertext) } -pub fn write_action_without_auth( +pub fn write_action_without_auth( mut writer: W, act: &Action<::SpendAuth, D>, ) -> io::Result<()> { @@ -403,7 +403,7 @@ pub mod testing { testing::{self as t_orch}, Authorized, Bundle, }; - use orchard::orchard_flavors::{OrchardVanilla, OrchardZSA}; + use orchard::orchard_flavor::{OrchardVanilla, OrchardZSA}; prop_compose! { pub fn arb_bundle(n_actions: usize)( diff --git a/zcash_primitives/src/transaction/mod.rs b/zcash_primitives/src/transaction/mod.rs index fd0cd42dd..7683cd02f 100644 --- a/zcash_primitives/src/transaction/mod.rs +++ b/zcash_primitives/src/transaction/mod.rs @@ -15,8 +15,7 @@ mod tests; use blake2b_simd::Hash as Blake2bHash; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use memuse::DynamicUsage; -use orchard::builder::Unproven; -use orchard::orchard_flavors::OrchardVanilla; +use orchard::{builder::Unproven, orchard_flavor::OrchardVanilla, value::NoteValue}; use std::convert::TryFrom; use std::fmt; use std::fmt::Debug; @@ -31,7 +30,7 @@ use crate::{ #[cfg(zcash_unstable = "nu6")] /* TODO nu7 */ use crate::transaction::components::issuance; #[cfg(zcash_unstable = "nu6")] /* TODO nu7 */ -use orchard::{issuance::IssueBundle, orchard_flavors::OrchardZSA}; +use orchard::{issuance::IssueBundle, orchard_flavor::OrchardZSA}; use self::{ components::{ @@ -864,6 +863,12 @@ impl Transaction { .map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "valueBalance out of range")) } + fn read_note_value(mut reader: R) -> io::Result { + let mut tmp = [0; 8]; + reader.read_exact(&mut tmp)?; + Ok(NoteValue::from_bytes(tmp)) + } + fn read_v5(mut reader: R, version: TxVersion) -> io::Result { let (consensus_branch_id, lock_time, expiry_height) = Self::read_v5_header_fragment(&mut reader)?; diff --git a/zcash_primitives/src/transaction/txid.rs b/zcash_primitives/src/transaction/txid.rs index f90efd617..670e36d97 100644 --- a/zcash_primitives/src/transaction/txid.rs +++ b/zcash_primitives/src/transaction/txid.rs @@ -6,11 +6,11 @@ use blake2b_simd::{Hash as Blake2bHash, Params, State}; use byteorder::{LittleEndian, WriteBytesExt}; use ff::PrimeField; use orchard::bundle; -use orchard::orchard_flavors::OrchardVanilla; +use orchard::orchard_flavor::OrchardVanilla; #[cfg(zcash_unstable = "nu6")] /* TODO nu7 */ use orchard::{ issuance::{IssueBundle, Signed}, - orchard_flavors::OrchardZSA, + orchard_flavor::OrchardZSA, }; use crate::{