Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Tx V6 support #7978

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a63c27b
Add draft transaction V6 support
dmidem Sep 29, 2023
ec01dd1
Return Box dyn Iterator instead of impls Iterator for orchard_... Tra…
dmidem Oct 4, 2023
bf63ee7
Implement initial support for V6 transactions with ZSA features
dmidem Nov 1, 2023
b90a93d
Remove PropTest trait from tx_version.rs and constrain in V:Encrypted…
dmidem Nov 2, 2023
8a2de1d
Fix unit tests to support orchard ShieldedData generic
dmidem Nov 7, 2023
f077fe9
Align tx-v6 feature flag usage across crates and fix related compilat…
dmidem Nov 8, 2023
dbc1d6c
Rename V5/V6 to TxV5/V6 in orcahrd, add BurnType to TxVersion and use…
dmidem Nov 9, 2023
7ca0f72
Fix test compilation error
dmidem Nov 9, 2023
528b95f
Add Clone to TxVersion::BurnType
dmidem Nov 10, 2023
dc28259
Remove patch.crates-io from the root Cargo.toml
dmidem Nov 10, 2023
34d3ac0
Fix datetime_full to limit nsecs with 1_000_000_000_u32 (as it is in …
dmidem Nov 11, 2023
e0d77ba
Remove 'default' for tx-v6 feature from zcash-chain's Cargo.toml
dmidem Nov 11, 2023
5425793
Use a special new empty struct type NoBurn isntead of () union type
dmidem Nov 14, 2023
b551585
Add missed derives for NoBurn
dmidem Nov 14, 2023
6ad9fbe
Add ci-test to .github/workflows
dmidem Nov 20, 2023
2dfe984
Disable (for now) new clippy warning (unnecessary_unwrap) in arbitrar…
dmidem Nov 20, 2023
4571355
Use 1.72.0 Rust toolchain in ci-test woirkflow action
dmidem Nov 20, 2023
7f02f7f
Move burn and issuance modules to orchard_zsa folder, rename TxVersio…
dmidem Nov 20, 2023
d95dc5f
Rename orchard_variant.rs to variant.rs, TxV5 tag to Orchard, TxV6 ta…
dmidem Nov 21, 2023
2c8e2e2
Fix comment
dmidem Nov 21, 2023
42469f1
Fix comment (2)
dmidem Nov 21, 2023
47a7d5a
Make fixes to resolve merge conflict with the latest version of zsa1
dmidem Nov 21, 2023
1187576
Merge branch 'zsa1' into tx_v6
dmidem Nov 21, 2023
1678e69
Add Cargo.lock
dmidem Nov 21, 2023
cced989
Update Cargo.lock
dmidem Nov 21, 2023
c9e3210
Add missed orchard_zsa
dmidem Nov 21, 2023
8eb2e76
Remove temp file
dmidem Nov 21, 2023
dfc127a
Add missed orchard_zsa
dmidem Nov 21, 2023
e43d151
Pin blake2b_simd/blake2s_simd to 1.0.1 in zebra-chain/zebra-consensus…
dmidem Nov 21, 2023
24cbbc1
Trigger Build
dmidem Nov 21, 2023
e1c0b1c
Trigger Build (2)
dmidem Nov 21, 2023
3c1f225
Trigger Build (3)
dmidem Nov 21, 2023
616d1ce
Trigger Build (4)
dmidem Nov 21, 2023
368cb54
Trigger Build (5)
dmidem Nov 21, 2023
09a3d53
Trigger Build (6)
dmidem Nov 21, 2023
469d5b1
renamed orchard_varient -> orchard_flavour
PaulLaux Nov 22, 2023
79b2df4
Merge branch 'main' into tx_v6_update
dmidem Dec 6, 2023
1027bb3
Remove unnecessary curly braces in ZcashDeserialize implementation fo…
dmidem Dec 4, 2023
04495ab
Add ref to spec in comment for burn field of ShieldedData struct
dmidem Dec 4, 2023
7ad4f34
Rename ActionRef to ActionCopy in orchard::ShieldedData, and define i…
dmidem Dec 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI checks

on: [push, pull_request]

jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.72.0
override: true
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose
112 changes: 92 additions & 20 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,9 @@ dependencies = [

[[package]]
name = "blake2b_simd"
version = "1.0.2"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780"
checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc"
dependencies = [
"arrayref",
"arrayvec",
Expand All @@ -510,9 +510,9 @@ dependencies = [

[[package]]
name = "blake2s_simd"
version = "1.0.2"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94230421e395b9920d23df13ea5d77a20e1725331f90fbbf6df6040b33f756ae"
checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f"
dependencies = [
"arrayref",
"arrayvec",
Expand Down Expand Up @@ -906,9 +906,9 @@ checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f"

[[package]]
name = "constant_time_eq"
version = "0.3.0"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2"
checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6"

[[package]]
name = "core-foundation"
Expand Down Expand Up @@ -1694,7 +1694,24 @@ dependencies = [
"bitvec",
"ff",
"group",
"halo2_proofs",
"halo2_proofs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static",
"pasta_curves",
"rand 0.8.5",
"subtle",
"uint",
]

[[package]]
name = "halo2_gadgets"
version = "0.3.0"
source = "git+https://github.com/QED-it/halo2?branch=zsa1#3c14fe44dd6c5b81b60bbc59ec0098dcb0b0081a"
dependencies = [
"arrayvec",
"bitvec",
"ff",
"group",
"halo2_proofs 0.3.0 (git+https://github.com/QED-it/halo2?branch=zsa1)",
"lazy_static",
"pasta_curves",
"rand 0.8.5",
Expand Down Expand Up @@ -1724,6 +1741,21 @@ dependencies = [
"tracing",
]

[[package]]
name = "halo2_proofs"
version = "0.3.0"
source = "git+https://github.com/QED-it/halo2?branch=zsa1#3c14fe44dd6c5b81b60bbc59ec0098dcb0b0081a"
dependencies = [
"blake2b_simd",
"ff",
"group",
"halo2_legacy_pdqsort",
"maybe-rayon",
"pasta_curves",
"rand_core 0.6.4",
"tracing",
]

[[package]]
name = "hashbrown"
version = "0.12.3"
Expand Down Expand Up @@ -2694,6 +2726,33 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"

[[package]]
name = "orchard"
version = "0.5.0"
source = "git+https://github.com/QED-it/orchard?branch=zsa1#f38d6b9e4cac7b56ec88c6aae91a9783ec977017"
dependencies = [
"aes",
"bitvec",
"blake2b_simd",
"ff",
"fpe",
"group",
"halo2_gadgets 0.3.0 (git+https://github.com/QED-it/halo2?branch=zsa1)",
"halo2_proofs 0.3.0 (git+https://github.com/QED-it/halo2?branch=zsa1)",
"hex",
"incrementalmerkletree",
"lazy_static",
"memuse",
"nonempty",
"pasta_curves",
"rand 0.8.5",
"reddsa",
"serde",
"subtle",
"tracing",
"zcash_note_encryption 0.4.0 (git+https://github.com/QED-it/librustzcash?branch=zsa1-zebra)",
]

[[package]]
name = "orchard"
version = "0.6.0"
Expand All @@ -2706,8 +2765,8 @@ dependencies = [
"ff",
"fpe",
"group",
"halo2_gadgets",
"halo2_proofs",
"halo2_gadgets 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"halo2_proofs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hex",
"incrementalmerkletree",
"lazy_static",
Expand All @@ -2719,7 +2778,7 @@ dependencies = [
"serde",
"subtle",
"tracing",
"zcash_note_encryption",
"zcash_note_encryption 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand Down Expand Up @@ -5447,6 +5506,18 @@ dependencies = [
"subtle",
]

[[package]]
name = "zcash_note_encryption"
version = "0.4.0"
source = "git+https://github.com/QED-it/librustzcash?branch=zsa1-zebra#d55ef03ea2fce9e9ed20f24e1de93a5d2c20dc35"
dependencies = [
"chacha20",
"chacha20poly1305",
"cipher",
"rand_core 0.6.4",
"subtle",
]

[[package]]
name = "zcash_primitives"
version = "0.13.0-rc.1"
Expand All @@ -5471,7 +5542,7 @@ dependencies = [
"lazy_static",
"memuse",
"nonempty",
"orchard",
"orchard 0.6.0",
"rand 0.8.5",
"rand_core 0.6.4",
"ripemd",
Expand All @@ -5480,7 +5551,7 @@ dependencies = [
"subtle",
"zcash_address",
"zcash_encoding",
"zcash_note_encryption",
"zcash_note_encryption 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand Down Expand Up @@ -5527,7 +5598,7 @@ dependencies = [
"libc",
"memuse",
"metrics",
"orchard",
"orchard 0.6.0",
"rand 0.8.5",
"rand_core 0.6.4",
"rayon",
Expand All @@ -5536,7 +5607,7 @@ dependencies = [
"tracing",
"zcash_address",
"zcash_encoding",
"zcash_note_encryption",
"zcash_note_encryption 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"zcash_primitives",
"zcash_proofs",
]
Expand All @@ -5561,15 +5632,16 @@ dependencies = [
"equihash",
"futures",
"group",
"halo2_proofs",
"halo2_proofs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hex",
"humantime",
"incrementalmerkletree",
"itertools 0.11.0",
"jubjub",
"lazy_static",
"num-integer",
"orchard",
"orchard 0.5.0",
"orchard 0.6.0",
"primitive-types",
"proptest",
"proptest-derive",
Expand Down Expand Up @@ -5597,7 +5669,7 @@ dependencies = [
"zcash_address",
"zcash_encoding",
"zcash_history",
"zcash_note_encryption",
"zcash_note_encryption 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"zcash_primitives",
"zebra-test",
]
Expand All @@ -5614,15 +5686,15 @@ dependencies = [
"displaydoc",
"futures",
"futures-util",
"halo2_proofs",
"halo2_proofs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hex",
"howudoin",
"jubjub",
"lazy_static",
"metrics",
"num-integer",
"once_cell",
"orchard",
"orchard 0.6.0",
"proptest",
"proptest-derive",
"rand 0.8.5",
Expand Down Expand Up @@ -5756,7 +5828,7 @@ dependencies = [
"dirs",
"elasticsearch",
"futures",
"halo2_proofs",
"halo2_proofs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hex",
"hex-literal",
"howudoin",
Expand Down
12 changes: 9 additions & 3 deletions zebra-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ keywords = ["zebra", "zcash"]
categories = ["asynchronous", "cryptography::cryptocurrencies", "encoding"]

[features]
default = []

# Production features that activate extra functionality

Expand Down Expand Up @@ -50,14 +49,17 @@ proptest-impl = [

bench = ["zebra-test"]

# Support for transaction version 6
tx-v6 = ["orchard_zsa"]

[dependencies]

# Cryptography
bitvec = "1.0.1"
bitflags = "2.4.1"
bitflags-serde-legacy = "0.1.1"
blake2b_simd = "1.0.2"
blake2s_simd = "1.0.2"
blake2b_simd = "=1.0.1" # Pinned to 1.0.1 for now to resolve cargo conflict with orchard_zsa
blake2s_simd = "=1.0.1" # Pinned to 1.0.1 for now to resolve cargo conflict with orchard_zsa
bridgetree = "0.4.0"
bs58 = { version = "0.5.0", features = ["check"] }
byteorder = "1.5.0"
Expand Down Expand Up @@ -128,6 +130,9 @@ rand_chacha = { version = "0.3.1", optional = true }

zebra-test = { path = "../zebra-test/", version = "1.0.0-beta.31", optional = true }

# ZSA deps
orchard_zsa = { package = "orchard", version = "0.5", git = "https://github.com/QED-it/orchard", branch = "zsa1", optional = true }

[dev-dependencies]
# Benchmarks
criterion = { version = "0.5.1", features = ["html_reports"] }
Expand Down Expand Up @@ -159,3 +164,4 @@ required-features = ["bench"]
[[bench]]
name = "redpallas"
harness = false

3 changes: 3 additions & 0 deletions zebra-chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pub mod transparent;
pub mod value_balance;
pub mod work;

#[cfg(feature = "tx-v6")]
pub mod orchard_zsa;

#[cfg(any(test, feature = "proptest-impl"))]
pub use block::LedgerState;

Expand Down
12 changes: 11 additions & 1 deletion zebra-chain/src/orchard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@ pub mod keys;
pub mod shielded_data;
pub mod tree;

mod orchard_flavour;

pub use action::Action;
pub use address::Address;
pub use commitment::{CommitmentRandomness, NoteCommitment, ValueCommitment};
pub use keys::Diversifier;
pub use note::{EncryptedNote, Note, Nullifier, WrappedNoteKey};
pub use shielded_data::{AuthorizedAction, Flags, ShieldedData};
pub use shielded_data::{ActionRef, AuthorizedAction, Flags, ShieldedData};

pub use orchard_flavour::{Orchard, OrchardFlavour};

#[cfg(feature = "tx-v6")]
pub use orchard_flavour::OrchardZSA;

#[cfg(any(test, feature = "proptest-impl"))]
pub use orchard_flavour::ENCRYPTED_NOTE_SIZE_V5;
11 changes: 6 additions & 5 deletions zebra-chain/src/orchard/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use super::{
commitment::{self, ValueCommitment},
keys,
note::{self, Nullifier},
OrchardFlavour,
};

/// An Action description, as described in the [Zcash specification §7.3][actiondesc].
Expand All @@ -21,7 +22,7 @@ use super::{
///
/// [actiondesc]: https://zips.z.cash/protocol/nu5.pdf#actiondesc
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Action {
pub struct Action<V: OrchardFlavour> {
/// A value commitment to net value of the input note minus the output note
pub cv: commitment::ValueCommitment,
/// The nullifier of the input note being spent.
Expand All @@ -35,14 +36,14 @@ pub struct Action {
/// encrypted private key in `out_ciphertext`.
pub ephemeral_key: keys::EphemeralPublicKey,
/// A ciphertext component for the encrypted output note.
pub enc_ciphertext: note::EncryptedNote,
pub enc_ciphertext: V::EncryptedNote,
/// A ciphertext component that allows the holder of a full viewing key to
/// recover the recipient diversified transmission key and the ephemeral
/// private key (and therefore the entire note plaintext).
pub out_ciphertext: note::WrappedNoteKey,
}

impl ZcashSerialize for Action {
impl<V: OrchardFlavour> ZcashSerialize for Action<V> {
fn zcash_serialize<W: io::Write>(&self, mut writer: W) -> Result<(), io::Error> {
self.cv.zcash_serialize(&mut writer)?;
writer.write_all(&<[u8; 32]>::from(self.nullifier)[..])?;
Expand All @@ -55,7 +56,7 @@ impl ZcashSerialize for Action {
}
}

impl ZcashDeserialize for Action {
impl<V: OrchardFlavour> ZcashDeserialize for Action<V> {
fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> {
// # Consensus
//
Expand Down Expand Up @@ -93,7 +94,7 @@ impl ZcashDeserialize for Action {
// https://zips.z.cash/protocol/protocol.pdf#concretesym but fixed to
// 580 bytes in https://zips.z.cash/protocol/protocol.pdf#outputencodingandconsensus
// See [`note::EncryptedNote::zcash_deserialize`].
enc_ciphertext: note::EncryptedNote::zcash_deserialize(&mut reader)?,
enc_ciphertext: V::EncryptedNote::zcash_deserialize(&mut reader)?,
// Type is `Sym.C`, i.e. `𝔹^Y^{\[N\]}`, i.e. arbitrary-sized byte arrays
// https://zips.z.cash/protocol/protocol.pdf#concretesym but fixed to
// 80 bytes in https://zips.z.cash/protocol/protocol.pdf#outputencodingandconsensus
Expand Down
Loading