Migrate to 2021 edition

This commit is contained in:
Jack Grigg 2022-04-28 17:13:07 +00:00
parent 6339fca4cb
commit 4574d4793a
18 changed files with 8 additions and 38 deletions

View File

@ -8,7 +8,7 @@ authors = [
"Ying Tong Lai <yingtong@electriccoin.co>", "Ying Tong Lai <yingtong@electriccoin.co>",
"Kris Nuttycombe <kris@electriccoin.co>", "Kris Nuttycombe <kris@electriccoin.co>",
] ]
edition = "2018" edition = "2021"
rust-version = "1.56.1" rust-version = "1.56.1"
description = "[BETA] The Orchard shielded transaction protocol" description = "[BETA] The Orchard shielded transaction protocol"
license-file = "LICENSE-BOSL" license-file = "LICENSE-BOSL"

View File

@ -1,5 +1,3 @@
use std::array;
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use orchard::{ use orchard::{
builder::Builder, builder::Builder,
@ -116,7 +114,7 @@ fn bench_note_decryption(c: &mut Criterion) {
let mut group = c.benchmark_group("batch-note-decryption"); let mut group = c.benchmark_group("batch-note-decryption");
for size in array::IntoIter::new([10, 50, 100]) { for size in [10, 50, 100] {
group.throughput(Throughput::Elements((ivks * size) as u64)); group.throughput(Throughput::Elements((ivks * size) as u64));
group.bench_function(BenchmarkId::new("valid", size), |b| { group.bench_function(BenchmarkId::new("valid", size), |b| {

View File

@ -1,5 +1,3 @@
use std::convert::TryInto;
use subtle::CtOption; use subtle::CtOption;
use crate::{ use crate::{

View File

@ -1,6 +1,5 @@
//! Logic for building Orchard components of transactions. //! Logic for building Orchard components of transactions.
use std::convert::TryFrom;
use std::fmt; use std::fmt;
use std::iter; use std::iter;

View File

@ -2,7 +2,6 @@
pub mod commitments; pub mod commitments;
use std::convert::TryInto;
use std::fmt; use std::fmt;
use std::io; use std::io;

View File

@ -52,8 +52,6 @@ use halo2_gadgets::{
utilities::{lookup_range_check::LookupRangeCheckConfig, UtilitiesInstructions}, utilities::{lookup_range_check::LookupRangeCheckConfig, UtilitiesInstructions},
}; };
use std::convert::TryInto;
mod commit_ivk; mod commit_ivk;
pub mod gadget; pub mod gadget;
mod note_commit; mod note_commit;
@ -163,7 +161,7 @@ impl plonk::Circuit<pallas::Base> for Circuit {
let not_enable_spends = one.clone() - meta.query_advice(advices[6], Rotation::cur()); let not_enable_spends = one.clone() - meta.query_advice(advices[6], Rotation::cur());
let not_enable_outputs = one - meta.query_advice(advices[7], Rotation::cur()); let not_enable_outputs = one - meta.query_advice(advices[7], Rotation::cur());
std::array::IntoIter::new([ [
( (
"v_old - v_new = magnitude * sign", "v_old - v_new = magnitude * sign",
v_old.clone() - v_new.clone() - magnitude * sign, v_old.clone() - v_new.clone() - magnitude * sign,
@ -177,7 +175,7 @@ impl plonk::Circuit<pallas::Base> for Circuit {
"v_new = 0 or enable_outputs = 1", "v_new = 0 or enable_outputs = 1",
v_new * not_enable_outputs, v_new * not_enable_outputs,
), ),
]) ]
.map(move |(name, poly)| (name, q_orchard.clone() * poly)) .map(move |(name, poly)| (name, q_orchard.clone() * poly))
}); });
@ -1029,7 +1027,6 @@ mod tests {
#[test] #[test]
fn serialized_proof_test_case() { fn serialized_proof_test_case() {
use std::convert::TryInto;
use std::io::{Read, Write}; use std::io::{Read, Write};
let vk = VerifyingKey::build(); let vk = VerifyingKey::build();

View File

@ -652,8 +652,6 @@ mod tests {
use pasta_curves::{arithmetic::FieldExt, pallas}; use pasta_curves::{arithmetic::FieldExt, pallas};
use rand::rngs::OsRng; use rand::rngs::OsRng;
use std::convert::TryInto;
#[test] #[test]
fn commit_ivk() { fn commit_ivk() {
#[derive(Default)] #[derive(Default)]

View File

@ -1480,7 +1480,6 @@ mod tests {
}; };
use rand::{rngs::OsRng, RngCore}; use rand::{rngs::OsRng, RngCore};
use std::convert::TryInto;
#[test] #[test]
fn note_commit() { fn note_commit() {

View File

@ -1,5 +1,3 @@
use std::convert::TryInto;
use crate::constants::{self, compute_lagrange_coeffs, H, NUM_WINDOWS, NUM_WINDOWS_SHORT}; use crate::constants::{self, compute_lagrange_coeffs, H, NUM_WINDOWS, NUM_WINDOWS_SHORT};
use group::ff::PrimeField; use group::ff::PrimeField;
use pasta_curves::pallas; use pasta_curves::pallas;

View File

@ -1,7 +1,5 @@
//! Key structures for Orchard. //! Key structures for Orchard.
use std::array;
use std::convert::{TryFrom, TryInto};
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
use std::mem; use std::mem;
@ -389,7 +387,8 @@ impl FullViewingKey {
/// Returns the scope of the given address, or `None` if the address is not derived /// Returns the scope of the given address, or `None` if the address is not derived
/// from this full viewing key. /// from this full viewing key.
pub fn scope_for_address(&self, address: &Address) -> Option<Scope> { pub fn scope_for_address(&self, address: &Address) -> Option<Scope> {
array::IntoIter::new([Scope::External, Scope::Internal]) [Scope::External, Scope::Internal]
.into_iter()
.find(|scope| self.to_ivk(*scope).diversifier_index(address).is_some()) .find(|scope| self.to_ivk(*scope).diversifier_index(address).is_some())
} }

View File

@ -66,7 +66,6 @@ pub mod testing {
use pasta_curves::{arithmetic::FieldExt, pallas}; use pasta_curves::{arithmetic::FieldExt, pallas};
use proptest::collection::vec; use proptest::collection::vec;
use proptest::prelude::*; use proptest::prelude::*;
use std::convert::TryFrom;
use super::Nullifier; use super::Nullifier;
use crate::spec::extract_p; use crate::spec::extract_p;

View File

@ -1,6 +1,6 @@
//! In-band secret distribution for Orchard bundles. //! In-band secret distribution for Orchard bundles.
use std::{convert::TryInto, fmt}; use std::fmt;
use blake2b_simd::{Hash, Params}; use blake2b_simd::{Hash, Params};
use group::ff::PrimeField; use group::ff::PrimeField;

View File

@ -1,7 +1,6 @@
//! A minimal RedPallas implementation for use in Zcash. //! A minimal RedPallas implementation for use in Zcash.
use std::cmp::{Ord, Ordering, PartialOrd}; use std::cmp::{Ord, Ordering, PartialOrd};
use std::convert::{TryFrom, TryInto};
use pasta_curves::pallas; use pasta_curves::pallas;
use rand::{CryptoRng, RngCore}; use rand::{CryptoRng, RngCore};
@ -184,8 +183,6 @@ pub(crate) mod private {
#[cfg(any(test, feature = "test-dependencies"))] #[cfg(any(test, feature = "test-dependencies"))]
#[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))] #[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))]
pub mod testing { pub mod testing {
use std::convert::TryFrom;
use proptest::prelude::*; use proptest::prelude::*;
use super::{Binding, SigningKey, SpendAuth, VerificationKey}; use super::{Binding, SigningKey, SpendAuth, VerificationKey};

View File

@ -276,7 +276,6 @@ mod tests {
use halo2_proofs::arithmetic::CurveExt; use halo2_proofs::arithmetic::CurveExt;
use pasta_curves::pallas; use pasta_curves::pallas;
use rand::{rngs::OsRng, RngCore}; use rand::{rngs::OsRng, RngCore};
use std::convert::TryInto;
#[test] #[test]
fn diversify_hash_substitution() { fn diversify_hash_substitution() {

View File

@ -86,8 +86,6 @@ pub struct MerklePath {
#[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))] #[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))]
impl From<(incrementalmerkletree::Position, Vec<MerkleHashOrchard>)> for MerklePath { impl From<(incrementalmerkletree::Position, Vec<MerkleHashOrchard>)> for MerklePath {
fn from(path: (incrementalmerkletree::Position, Vec<MerkleHashOrchard>)) -> Self { fn from(path: (incrementalmerkletree::Position, Vec<MerkleHashOrchard>)) -> Self {
use std::convert::TryInto;
let position: u64 = path.0.into(); let position: u64 = path.0.into();
Self { Self {
position: position as u32, position: position as u32,
@ -266,8 +264,6 @@ pub mod testing {
use group::ff::PrimeField; use group::ff::PrimeField;
#[cfg(test)] #[cfg(test)]
use pasta_curves::pallas; use pasta_curves::pallas;
#[cfg(test)]
use std::convert::TryInto;
#[test] #[test]
fn test_vectors() { fn test_vectors() {

View File

@ -35,7 +35,6 @@
//! [`Builder::add_recipient`]: crate::builder::Builder::add_recipient //! [`Builder::add_recipient`]: crate::builder::Builder::add_recipient
//! [Rust documentation]: https://doc.rust-lang.org/stable/std/primitive.i64.html //! [Rust documentation]: https://doc.rust-lang.org/stable/std/primitive.i64.html
use std::convert::{TryFrom, TryInto};
use std::fmt::{self, Debug}; use std::fmt::{self, Debug};
use std::iter::Sum; use std::iter::Sum;
use std::ops::{Add, Sub}; use std::ops::{Add, Sub};

View File

@ -1,9 +1,6 @@
//! Key structures for Orchard. //! Key structures for Orchard.
use std::{ use std::fmt;
convert::{TryFrom, TryInto},
fmt,
};
use blake2b_simd::Params as Blake2bParams; use blake2b_simd::Params as Blake2bParams;
use subtle::{Choice, ConstantTimeEq}; use subtle::{Choice, ConstantTimeEq};

View File

@ -1,5 +1,3 @@
use std::convert::TryInto;
use incrementalmerkletree::{bridgetree::BridgeTree, Frontier, Hashable, Tree}; use incrementalmerkletree::{bridgetree::BridgeTree, Frontier, Hashable, Tree};
use orchard::{ use orchard::{
builder::Builder, builder::Builder,