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

chore(deps): Updates ECC dependencies #9300

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
301 changes: 217 additions & 84 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ resolver = "2"
# `cargo release` settings

[workspace.dependencies]
incrementalmerkletree = { version = "0.7.1", features = ["legacy-api"] }
orchard = "0.10.0"
sapling-crypto = "0.3.0"
zcash_address = "0.6.0"
zcash_client_backend = "0.14.0"
zcash_encoding = "0.2.2"
incrementalmerkletree = { version = "0.8.2", features = ["legacy-api"] }
orchard = "0.11.0"
sapling-crypto = "0.5.0"
zcash_address = "0.7.0"
zcash_client_backend = "0.17.0"
zcash_encoding = "0.3.0"
zcash_history = "0.4.0"
zcash_keys = "0.4.0"
zcash_primitives = "0.19.0"
zcash_proofs = "0.19.0"
zcash_protocol = "0.4.0"
zcash_keys = "0.7.0"
zcash_primitives = "0.22.0"
zcash_proofs = "0.22.0"
zcash_transparent = { version = "0.2.0", features = ["test-dependencies"] }
zcash_protocol = "0.5.0"
abscissa_core = "0.7.0"
atty = "0.2.14"
base64 = "0.22.1"
Expand All @@ -41,10 +42,9 @@ bincode = "1.3.3"
bitflags = "2.8.0"
bitflags-serde-legacy = "0.1.1"
bitvec = "1.0.1"
blake2b_simd = "1.0.2"
blake2s_simd = "1.0.2"
blake2b_simd = "1.0.3"
blake2s_simd = "1.0.3"
bls12_381 = "0.8.0"
bridgetree = "0.6.0"
bs58 = "0.5.1"
byteorder = "1.5.0"
bytes = "1.9.0"
Expand Down
7 changes: 5 additions & 2 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ skip-tree = [
# Remove after release candicate period is over and the ECC crates are not patched anymore
{ name = "equihash", version = "=0.2.0" },

# wait for zcash_client_backend to update bech32
{ name = "bech32", version = "=0.9.1" },
# wait for all librustzcash crates to update sha2, secp256k1, and ripemd
{ name = "sha2", version = "=0.10.8" },
{ name = "secp256k1", version = "=0.27.0" },
{ name = "redjubjub", version = "=0.7.0" },
{ name = "ripemd", version = "=0.1.3" },

# wait for zcash_script to update itertools
{ name = "itertools", version = "=0.13.0" },
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ bitflags = { workspace = true }
bitflags-serde-legacy = { workspace = true }
blake2b_simd = { workspace = true }
blake2s_simd = { workspace = true }
bridgetree = { workspace = true }
bs58 = { workspace = true, features = ["check"] }
byteorder = { workspace = true }

Expand Down Expand Up @@ -103,6 +102,7 @@ zcash_primitives = { workspace = true, features = ["transparent-inputs"] }
sapling-crypto.workspace = true
zcash_protocol.workspace = true
zcash_address.workspace = true
zcash_transparent.workspace = true

# Time
chrono = { workspace = true, features = ["clock", "std", "serde"] }
Expand Down
11 changes: 5 additions & 6 deletions zebra-chain/src/orchard/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ use std::{
};

use bitvec::prelude::*;
use bridgetree::NonEmptyFrontier;
use halo2::pasta::{group::ff::PrimeField, pallas};
use hex::ToHex;
use incrementalmerkletree::Hashable;
use incrementalmerkletree::{frontier::NonEmptyFrontier, Hashable};
use lazy_static::lazy_static;
use thiserror::Error;
use zcash_primitives::merkle_tree::HashSer;
Expand Down Expand Up @@ -248,7 +247,7 @@ impl ToHex for Node {
/// [`z_gettreestate`][2] RPC requires [`CommitmentTree`][3]s. Implementing
/// [`HashSer`] for [`Node`]s allows the conversion.
///
/// [1]: bridgetree::Frontier
/// [1]: incrementalmerkletree::frontier::Frontier
/// [2]: https://zcash.github.io/rpc/z_gettreestate.html
/// [3]: incrementalmerkletree::frontier::CommitmentTree
impl HashSer for Node {
Expand Down Expand Up @@ -348,7 +347,7 @@ pub struct NoteCommitmentTree {
/// <https://zips.z.cash/protocol/protocol.pdf#merkletree>
///
/// Note: MerkleDepth^Orchard = MERKLE_DEPTH = 32.
inner: bridgetree::Frontier<Node, MERKLE_DEPTH>,
inner: incrementalmerkletree::frontier::Frontier<Node, MERKLE_DEPTH>,

/// A cached root of the tree.
///
Expand Down Expand Up @@ -637,7 +636,7 @@ impl NoteCommitmentTree {

/// Serializes [`Self`] to a format compatible with `zcashd`'s RPCs.
pub fn to_rpc_bytes(&self) -> Vec<u8> {
// Convert the tree from [`Frontier`](bridgetree::Frontier) to
// Convert the tree from [`Frontier`](incrementalmerkletree::frontier::Frontier) to
// [`CommitmentTree`](merkle_tree::CommitmentTree).
let tree = incrementalmerkletree::frontier::CommitmentTree::from_frontier(&self.inner);

Expand Down Expand Up @@ -665,7 +664,7 @@ impl Clone for NoteCommitmentTree {
impl Default for NoteCommitmentTree {
fn default() -> Self {
Self {
inner: bridgetree::Frontier::empty(),
inner: incrementalmerkletree::frontier::Frontier::empty(),
cached_root: Default::default(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/parameters/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl FromStr for Network {
pub struct InvalidNetworkError(String);

impl zcash_protocol::consensus::Parameters for Network {
fn network_type(&self) -> zcash_address::Network {
fn network_type(&self) -> zcash_protocol::consensus::NetworkType {
self.kind().into()
}

Expand Down
3 changes: 1 addition & 2 deletions zebra-chain/src/parameters/network/tests/vectors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Fixed test vectors for the network consensus parameters.

use zcash_primitives::consensus::{self as zp_consensus, Parameters};
use zcash_protocol::consensus::NetworkConstants as _;
use zcash_protocol::consensus::{self as zp_consensus, NetworkConstants as _, Parameters};

use crate::{
block::Height,
Expand Down
29 changes: 15 additions & 14 deletions zebra-chain/src/primitives/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! Usage: <https://docs.rs/zcash_address/0.2.0/zcash_address/trait.TryFromAddress.html#examples>

use zcash_address::unified::{self, Container};
use zcash_protocol::consensus::NetworkType;

use crate::{parameters::NetworkKind, transparent, BoxError};

Expand Down Expand Up @@ -44,7 +45,7 @@ impl zcash_address::TryFromAddress for Address {
type Error = BoxError;

fn try_from_transparent_p2pkh(
network: zcash_address::Network,
network: NetworkType,
data: [u8; 20],
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
Ok(Self::Transparent(transparent::Address::from_pub_key_hash(
Expand All @@ -54,7 +55,7 @@ impl zcash_address::TryFromAddress for Address {
}

fn try_from_transparent_p2sh(
network: zcash_address::Network,
network: NetworkType,
data: [u8; 20],
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
Ok(Self::Transparent(transparent::Address::from_script_hash(
Expand All @@ -64,7 +65,7 @@ impl zcash_address::TryFromAddress for Address {
}

fn try_from_sapling(
network: zcash_address::Network,
network: NetworkType,
data: [u8; 43],
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
let network = network.into();
Expand All @@ -74,7 +75,7 @@ impl zcash_address::TryFromAddress for Address {
}

fn try_from_unified(
network: zcash_address::Network,
network: NetworkType,
unified_address: zcash_address::unified::Address,
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
let network = network.into();
Expand Down Expand Up @@ -170,27 +171,27 @@ impl Address {
}
}

impl From<zcash_address::Network> for NetworkKind {
fn from(network: zcash_address::Network) -> Self {
impl From<NetworkType> for NetworkKind {
fn from(network: NetworkType) -> Self {
match network {
zcash_address::Network::Main => NetworkKind::Mainnet,
zcash_address::Network::Test => NetworkKind::Testnet,
zcash_address::Network::Regtest => NetworkKind::Regtest,
NetworkType::Main => NetworkKind::Mainnet,
NetworkType::Test => NetworkKind::Testnet,
NetworkType::Regtest => NetworkKind::Regtest,
}
}
}

impl From<NetworkKind> for zcash_address::Network {
impl From<NetworkKind> for NetworkType {
fn from(network: NetworkKind) -> Self {
match network {
NetworkKind::Mainnet => zcash_address::Network::Main,
NetworkKind::Testnet => zcash_address::Network::Test,
NetworkKind::Regtest => zcash_address::Network::Regtest,
NetworkKind::Mainnet => NetworkType::Main,
NetworkKind::Testnet => NetworkType::Test,
NetworkKind::Regtest => NetworkType::Regtest,
}
}
}

impl From<&NetworkKind> for zcash_address::Network {
impl From<&NetworkKind> for NetworkType {
fn from(network: &NetworkKind) -> Self {
(*network).into()
}
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/primitives/viewing_key/sapling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use zcash_client_backend::{
encoding::decode_extended_full_viewing_key,
keys::sapling::DiversifiableFullViewingKey as SaplingDfvk,
};
use zcash_primitives::constants::*;
use zcash_protocol::constants::*;

use crate::parameters::Network;

Expand Down
38 changes: 20 additions & 18 deletions zebra-chain/src/primitives/zcash_primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ impl zp_tx::components::transparent::Authorization for TransparentAuth<'_> {

// In this block we convert our Output to a librustzcash to TxOut.
// (We could do the serialize/deserialize route but it's simple enough to convert manually)
impl zp_tx::sighash::TransparentAuthorizingContext for TransparentAuth<'_> {
fn input_amounts(&self) -> Vec<zp_tx::components::amount::NonNegativeAmount> {
impl zcash_transparent::sighash::TransparentAuthorizingContext for TransparentAuth<'_> {
fn input_amounts(&self) -> Vec<zcash_protocol::value::Zatoshis> {
self.all_prev_outputs
.iter()
.map(|prevout| {
Expand Down Expand Up @@ -151,7 +151,7 @@ impl<'a> zp_tx::Authorization for PrecomputedAuth<'a> {
// End of (mostly) copied code

/// Convert a Zebra transparent::Output into a librustzcash one.
impl TryFrom<&transparent::Output> for zp_tx::components::TxOut {
impl TryFrom<&transparent::Output> for zcash_transparent::bundle::TxOut {
type Error = io::Error;

#[allow(clippy::unwrap_in_result)]
Expand All @@ -160,12 +160,12 @@ impl TryFrom<&transparent::Output> for zp_tx::components::TxOut {
.zcash_serialize_to_vec()
.expect("zcash_primitives and Zebra transparent output formats must be compatible");

zp_tx::components::TxOut::read(&mut serialized_output_bytes.as_slice())
zcash_transparent::bundle::TxOut::read(&mut serialized_output_bytes.as_slice())
}
}

/// Convert a Zebra transparent::Output into a librustzcash one.
impl TryFrom<transparent::Output> for zp_tx::components::TxOut {
impl TryFrom<transparent::Output> for zcash_transparent::bundle::TxOut {
type Error = io::Error;

// The borrow is actually needed to use TryFrom<&transparent::Output>
Expand All @@ -176,11 +176,11 @@ impl TryFrom<transparent::Output> for zp_tx::components::TxOut {
}

/// Convert a Zebra non-negative Amount into a librustzcash one.
impl TryFrom<Amount<NonNegative>> for zp_tx::components::amount::NonNegativeAmount {
impl TryFrom<Amount<NonNegative>> for zcash_protocol::value::Zatoshis {
type Error = BalanceError;

fn try_from(amount: Amount<NonNegative>) -> Result<Self, Self::Error> {
zp_tx::components::amount::NonNegativeAmount::from_nonnegative_i64(amount.into())
zcash_protocol::value::Zatoshis::from_nonnegative_i64(amount.into())
}
}

Expand Down Expand Up @@ -293,16 +293,18 @@ pub(crate) fn sighash(
let output = &precomputed_tx_data.all_previous_outputs[input_index];
lock_script = output.lock_script.clone().into();
unlock_script = zcash_primitives::legacy::Script(script_code);
zp_tx::sighash::SignableInput::Transparent {
hash_type: hash_type.bits() as _,
index: input_index,
script_code: &unlock_script,
script_pubkey: &lock_script,
value: output
.value
.try_into()
.expect("amount was previously validated"),
}
zp_tx::sighash::SignableInput::Transparent(
zcash_transparent::sighash::SignableInput::from_parts(
hash_type.try_into().expect("hash type should be ALL"),
input_index,
&unlock_script,
&lock_script,
output
.value
.try_into()
.expect("amount was previously validated"),
),
)
}
None => zp_tx::sighash::SignableInput::Shielded,
};
Expand Down Expand Up @@ -344,7 +346,7 @@ pub(crate) fn transparent_output_address(
output: &transparent::Output,
network: &Network,
) -> Option<transparent::Address> {
let tx_out = zp_tx::components::TxOut::try_from(output)
let tx_out = zcash_transparent::bundle::TxOut::try_from(output)
.expect("zcash_primitives and Zebra transparent output formats must be compatible");

let alt_addr = tx_out.recipient_address();
Expand Down
10 changes: 6 additions & 4 deletions zebra-chain/src/sapling/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ use std::{
};

use bitvec::prelude::*;
use bridgetree::NonEmptyFrontier;
use hex::ToHex;
use incrementalmerkletree::{frontier::Frontier, Hashable};
use incrementalmerkletree::{
frontier::{Frontier, NonEmptyFrontier},
Hashable,
};

use lazy_static::lazy_static;
use thiserror::Error;
Expand Down Expand Up @@ -637,7 +639,7 @@ impl NoteCommitmentTree {

/// Serializes [`Self`] to a format matching `zcashd`'s RPCs.
pub fn to_rpc_bytes(&self) -> Vec<u8> {
// Convert the tree from [`Frontier`](bridgetree::Frontier) to
// Convert the tree from [`Frontier`](incrementalmerkletree::frontier::Frontier) to
// [`CommitmentTree`](merkle_tree::CommitmentTree).
let tree = incrementalmerkletree::frontier::CommitmentTree::from_frontier(&self.inner);

Expand Down Expand Up @@ -666,7 +668,7 @@ impl Clone for NoteCommitmentTree {
impl Default for NoteCommitmentTree {
fn default() -> Self {
Self {
inner: bridgetree::Frontier::empty(),
inner: incrementalmerkletree::frontier::Frontier::empty(),
cached_root: Default::default(),
}
}
Expand Down
6 changes: 3 additions & 3 deletions zebra-chain/src/sprout/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub enum NoteCommitmentTreeError {
/// job of this tree to protect against double-spending, as it is append-only; double-spending
/// is prevented by maintaining the [nullifier set] for each shielded pool.
///
/// Internally this wraps [`bridgetree::Frontier`], so that we can maintain and increment
/// Internally this wraps [`incrementalmerkletree::frontier::Frontier`], so that we can maintain and increment
/// the full tree with only the minimal amount of non-empty nodes/leaves required.
///
/// Note that the default value of the [`Root`] type is `[0, 0, 0, 0]`. However, this value differs
Expand All @@ -210,9 +210,9 @@ pub enum NoteCommitmentTreeError {
#[serde(into = "LegacyNoteCommitmentTree")]
#[serde(from = "LegacyNoteCommitmentTree")]
pub struct NoteCommitmentTree {
/// The tree represented as a [`bridgetree::Frontier`].
/// The tree represented as a [`incrementalmerkletree::frontier::Frontier`].
///
/// A [`bridgetree::Frontier`] is a subset of the tree that allows to fully specify it. It
/// A [`incrementalmerkletree::frontier::Frontier`] is a subset of the tree that allows to fully specify it. It
/// consists of nodes along the rightmost (newer) branch of the tree that
/// has non-empty nodes. Upper (near root) empty nodes of the branch are not
/// stored.
Expand Down
Loading
Loading