mirror of https://github.com/zcash/orchard.git
Merge pull request #293 from zcash/merge-non-consensus-changes-2
Merge non-consensus changes again
This commit is contained in:
commit
3ddf6c49f7
|
@ -16,7 +16,7 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.54.0
|
||||
toolchain: 1.56.1
|
||||
override: true
|
||||
- name: Run benchmark
|
||||
run: cargo bench -- --output-format bencher | tee output.txt
|
||||
|
|
|
@ -14,7 +14,7 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.54.0
|
||||
toolchain: 1.56.1
|
||||
override: true
|
||||
- name: Run tests
|
||||
uses: actions-rs/cargo@v1
|
||||
|
@ -30,7 +30,7 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.54.0
|
||||
toolchain: 1.56.1
|
||||
override: true
|
||||
# Build benchmarks to prevent bitrot
|
||||
- name: Build benchmarks
|
||||
|
@ -46,7 +46,7 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.54.0
|
||||
toolchain: 1.56.1
|
||||
override: true
|
||||
- name: Setup mdBook
|
||||
uses: peaceiris/actions-mdbook@v1
|
||||
|
@ -89,7 +89,7 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.54.0
|
||||
toolchain: 1.56.1
|
||||
override: true
|
||||
- name: cargo fetch
|
||||
uses: actions-rs/cargo@v1
|
||||
|
@ -112,7 +112,7 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.54.0
|
||||
toolchain: 1.56.1
|
||||
override: true
|
||||
- run: rustup component add rustfmt
|
||||
- uses: actions-rs/cargo@v1
|
||||
|
|
|
@ -5,19 +5,19 @@ on: pull_request
|
|||
|
||||
jobs:
|
||||
clippy:
|
||||
name: Clippy (1.54.0)
|
||||
name: Clippy (1.56.1)
|
||||
timeout-minutes: 30
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.54.0
|
||||
toolchain: 1.56.1
|
||||
components: clippy
|
||||
override: true
|
||||
- name: Run Clippy
|
||||
uses: actions-rs/clippy-check@v1
|
||||
with:
|
||||
name: Clippy (1.54.0)
|
||||
name: Clippy (1.56.1)
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: --all-features --all-targets -- -D warnings
|
||||
|
|
17
CHANGELOG.md
17
CHANGELOG.md
|
@ -9,13 +9,18 @@ and this project adheres to Rust's notion of
|
|||
### Added
|
||||
- `orchard::keys`:
|
||||
- `DiversifierIndex::to_bytes`
|
||||
- `FullViewingKey::derive_internal`
|
||||
- `IncomingViewingKey::diversifier_index`
|
||||
- `orchard::note`:
|
||||
- `impl PartialEq, Eq, PartialOrd, Ord for Nullifier`
|
||||
- `orchard::primitives::redpallas::VerificationKey::verify`
|
||||
- `orchard::tree::MerklePath::from_parts`
|
||||
- `orchard::tree`:
|
||||
- `MerklePath::from_parts`
|
||||
- `impl PartialEq, Eq, PartialOrd, Ord for MerkleHashOrchard`
|
||||
- `impl From<orchard::bundle::BundleCommitment> for [u8; 32]`
|
||||
|
||||
### Changed
|
||||
- MSRV is now 1.54.0.
|
||||
- MSRV is now 1.56.1.
|
||||
- Bumped dependencies to `pasta_curves 0.3`.
|
||||
- The following methods now have an additional `rng: impl RngCore` argument:
|
||||
- `orchard::builder::Bundle::create_proof`
|
||||
|
@ -25,6 +30,8 @@ and this project adheres to Rust's notion of
|
|||
instead of `i64: From<&'a V>`.
|
||||
- `orchard::Bundle::binding_validating_key` now requires the bound
|
||||
`V: Into<i64>` instead of `V: Into<ValueSum>`.
|
||||
- `orchard::builder::InProgressSignatures` and `orchard::bundle::Authorization`
|
||||
now have `Debug` bounds on themselves and their associated types.
|
||||
|
||||
### Removed
|
||||
- `orchard::bundle`:
|
||||
|
@ -34,8 +41,10 @@ and this project adheres to Rust's notion of
|
|||
- `orchard::keys`:
|
||||
- `FullViewingKey::default_address`
|
||||
- `IncomingViewingKey::default_address`
|
||||
- `DiversifierKey` (use the APIs on `FullViewingKey` and `IncomingViewingKey`
|
||||
instead).
|
||||
- `DiversifierKey` (use the APIs on `FullViewingKey` and `IncomingViewingKey`
|
||||
instead).
|
||||
- `impl std::hash::Hash for orchard::tree::MerkleHashOrchard` (use `BTreeMap`
|
||||
instead of `HashMap`).
|
||||
- `orchard::value::ValueSum::from_raw`
|
||||
|
||||
## [0.1.0-beta.1] - 2021-12-17
|
||||
|
|
|
@ -47,6 +47,9 @@ incrementalmerkletree = "0.2"
|
|||
# Developer tooling dependencies
|
||||
plotters = { version = "0.3.0", optional = true }
|
||||
|
||||
[patch.crates-io]
|
||||
incrementalmerkletree = { git = "https://github.com/zcash/incrementalmerkletree.git", rev = "dd57b430dee7c0b163f4035fef2280cd1935036c" }
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
halo2_gadgets = { version = "=0.1.0-beta.1", features = ["test-dependencies"] }
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.54.0
|
||||
1.56.1
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! Logic for building Orchard components of transactions.
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
use std::iter;
|
||||
|
||||
use ff::Field;
|
||||
|
@ -363,9 +364,9 @@ impl Builder {
|
|||
}
|
||||
|
||||
/// Marker trait representing bundle signatures in the process of being created.
|
||||
pub trait InProgressSignatures {
|
||||
pub trait InProgressSignatures: fmt::Debug {
|
||||
/// The authorization type of an Orchard action in the process of being authorized.
|
||||
type SpendAuth;
|
||||
type SpendAuth: fmt::Debug;
|
||||
}
|
||||
|
||||
/// Marker for a bundle in the process of being built.
|
||||
|
@ -375,7 +376,7 @@ pub struct InProgress<P, S: InProgressSignatures> {
|
|||
sigs: S,
|
||||
}
|
||||
|
||||
impl<P, S: InProgressSignatures> Authorization for InProgress<P, S> {
|
||||
impl<P: fmt::Debug, S: InProgressSignatures> Authorization for InProgress<P, S> {
|
||||
type SpendAuth = S::SpendAuth;
|
||||
}
|
||||
|
||||
|
@ -488,7 +489,7 @@ impl MaybeSigned {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P, V> Bundle<InProgress<P, Unauthorized>, V> {
|
||||
impl<P: fmt::Debug, V> Bundle<InProgress<P, Unauthorized>, V> {
|
||||
/// Loads the sighash into this bundle, preparing it for signing.
|
||||
///
|
||||
/// This API ensures that all signatures are created over the same sighash.
|
||||
|
@ -534,7 +535,7 @@ impl<V> Bundle<InProgress<Proof, Unauthorized>, V> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P, V> Bundle<InProgress<P, PartiallyAuthorized>, V> {
|
||||
impl<P: fmt::Debug, V> Bundle<InProgress<P, PartiallyAuthorized>, V> {
|
||||
/// Signs this bundle with the given [`SpendAuthorizingKey`].
|
||||
///
|
||||
/// This will apply signatures for all notes controlled by this spending key.
|
||||
|
@ -679,9 +680,9 @@ pub mod testing {
|
|||
for note in notes.iter() {
|
||||
let leaf = MerkleHashOrchard::from_cmx(¬e.commitment().into());
|
||||
tree.append(&leaf);
|
||||
tree.witness();
|
||||
let (position, leaf) = tree.witness().expect("tree is not empty");
|
||||
|
||||
let path = tree.authentication_path(&leaf).unwrap().into();
|
||||
let path = MerklePath::from((position, tree.authentication_path(position, &leaf).expect("we just witnessed the path")));
|
||||
notes_and_auth_paths.push((*note, path));
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
pub mod commitments;
|
||||
|
||||
use std::convert::TryInto;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
|
||||
use blake2b_simd::Hash as Blake2bHash;
|
||||
|
@ -230,9 +231,9 @@ impl Flags {
|
|||
}
|
||||
|
||||
/// Defines the authorization type of an Orchard bundle.
|
||||
pub trait Authorization {
|
||||
pub trait Authorization: fmt::Debug {
|
||||
/// The authorization type of an Orchard action.
|
||||
type SpendAuth;
|
||||
type SpendAuth: fmt::Debug;
|
||||
}
|
||||
|
||||
/// A bundle of actions to be applied to the ledger.
|
||||
|
|
|
@ -407,12 +407,12 @@ impl FullViewingKey {
|
|||
/// Derives an internal full viewing key from a full viewing key, as specified in [ZIP32][orchardinternalfullviewingkey]
|
||||
///
|
||||
/// [orchardinternalfullviewingkey]: https://zips.z.cash/zip-0032#orchard-internal-key-derivation
|
||||
pub fn derive_internal(&self) -> Option<Self> {
|
||||
Some(FullViewingKey {
|
||||
pub fn derive_internal(&self) -> Self {
|
||||
FullViewingKey {
|
||||
ak: self.ak.clone(),
|
||||
nk: self.nk,
|
||||
rivk: self.rivk_internal(),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -981,7 +981,7 @@ mod tests {
|
|||
let internal_rivk = fvk.rivk_internal();
|
||||
assert_eq!(internal_rivk.0.to_repr(), tv.internal_rivk);
|
||||
|
||||
let internal_fvk = fvk.derive_internal().unwrap();
|
||||
let internal_fvk = fvk.derive_internal();
|
||||
assert_eq!(internal_rivk, *internal_fvk.rivk());
|
||||
|
||||
let internal_ivk: KeyAgreementPrivateKey = (&internal_fvk).into();
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// Temporary until we have more of the crate implemented.
|
||||
#![allow(dead_code)]
|
||||
// Catch documentation errors caused by code changes.
|
||||
#![deny(broken_intra_doc_links)]
|
||||
#![deny(rustdoc::broken_intra_doc_links)]
|
||||
#![deny(missing_debug_implementations)]
|
||||
#![deny(missing_docs)]
|
||||
#![deny(unsafe_code)]
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::{
|
|||
};
|
||||
|
||||
/// A unique nullifier for a note.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct Nullifier(pub(crate) pallas::Base);
|
||||
|
||||
impl Nullifier {
|
||||
|
|
32
src/tree.rs
32
src/tree.rs
|
@ -19,7 +19,7 @@ use serde::de::{Deserializer, Error};
|
|||
use serde::ser::Serializer;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::iter;
|
||||
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
|
||||
use subtle::{Choice, ConditionallySelectable, CtOption};
|
||||
|
||||
// The uncommitted leaf is defined as pallas::Base(2).
|
||||
// <https://zips.z.cash/protocol/protocol.pdf#thmuncommittedorchard>
|
||||
|
@ -160,7 +160,7 @@ impl MerklePath {
|
|||
|
||||
/// A newtype wrapper for leaves and internal nodes in the Orchard
|
||||
/// incremental note commitment tree.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct MerkleHashOrchard(pallas::Base);
|
||||
|
||||
impl MerkleHashOrchard {
|
||||
|
@ -190,25 +190,6 @@ impl MerkleHashOrchard {
|
|||
}
|
||||
}
|
||||
|
||||
/// This instance should only be used for hash table key comparisons.
|
||||
impl std::cmp::PartialEq for MerkleHashOrchard {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0.ct_eq(&other.0).into()
|
||||
}
|
||||
}
|
||||
|
||||
/// This instance should only be used for hash table key comparisons.
|
||||
impl std::cmp::Eq for MerkleHashOrchard {}
|
||||
|
||||
/// This instance should only be used for hash table key hashing.
|
||||
impl std::hash::Hash for MerkleHashOrchard {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
<Option<pallas::Base>>::from(self.0)
|
||||
.map(|b| b.to_repr())
|
||||
.hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
impl ConditionallySelectable for MerkleHashOrchard {
|
||||
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
|
||||
MerkleHashOrchard(pallas::Base::conditional_select(&a.0, &b.0, choice))
|
||||
|
@ -302,7 +283,7 @@ pub mod testing {
|
|||
{
|
||||
let cmx = MerkleHashOrchard::from_bytes(&tv.leaves[i]).unwrap();
|
||||
tree.append(&cmx);
|
||||
tree.witness();
|
||||
tree.witness().expect("tree is not empty");
|
||||
|
||||
assert_eq!(tree.root().0, pallas::Base::from_repr(tv.root).unwrap());
|
||||
|
||||
|
@ -312,14 +293,13 @@ pub mod testing {
|
|||
for j in 0..=i {
|
||||
let leaf = MerkleHashOrchard::from_bytes(&tv.leaves[j]).unwrap();
|
||||
assert_eq!(
|
||||
tree.authentication_path(&leaf),
|
||||
Some((
|
||||
j.try_into().unwrap(),
|
||||
tree.authentication_path(j.try_into().unwrap(), &leaf),
|
||||
Some(
|
||||
tv.paths[j]
|
||||
.iter()
|
||||
.map(|v| MerkleHashOrchard::from_bytes(v).unwrap())
|
||||
.collect()
|
||||
))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,8 +74,8 @@ fn bundle_chain() {
|
|||
let leaf = MerkleHashOrchard::from_cmx(&cmx);
|
||||
let mut tree = BridgeTree::<MerkleHashOrchard, 32>::new(0);
|
||||
tree.append(&leaf);
|
||||
tree.witness();
|
||||
let (position, auth_path) = tree.authentication_path(&leaf).unwrap();
|
||||
let (position, leaf) = tree.witness().unwrap();
|
||||
let auth_path = tree.authentication_path(position, &leaf).unwrap();
|
||||
let merkle_path = MerklePath::from_parts(
|
||||
u64::from(position).try_into().unwrap(),
|
||||
auth_path[..].try_into().unwrap(),
|
||||
|
|
Loading…
Reference in New Issue