mirror of https://github.com/zcash/halo2.git
Use gen_const_array_with_default where possible.
This commit is contained in:
parent
291400ec33
commit
2c551db32b
|
@ -16,6 +16,7 @@ use pasta_curves::{
|
|||
use crate::{
|
||||
constants::{
|
||||
load::{NullifierK, OrchardFixedBasesFull, ValueCommitV},
|
||||
util::gen_const_array_with_default,
|
||||
MERKLE_DEPTH_ORCHARD,
|
||||
},
|
||||
keys::{
|
||||
|
@ -54,6 +55,7 @@ use gadget::{
|
|||
},
|
||||
utilities::{copy, CellValue, UtilitiesInstructions, Var},
|
||||
};
|
||||
use incrementalmerkletree::Hashable;
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
|
@ -399,11 +401,9 @@ impl plonk::Circuit<pallas::Base> for Circuit {
|
|||
let anchor = {
|
||||
let path = self.path.map(|typed_path| {
|
||||
// TODO: Replace with array::map once MSRV is 1.55.0.
|
||||
let mut inner_path = [pallas::Base::zero(); MERKLE_DEPTH_ORCHARD];
|
||||
for (a, b) in inner_path.iter_mut().zip(typed_path.iter()) {
|
||||
*a = b.inner();
|
||||
}
|
||||
inner_path
|
||||
gen_const_array_with_default(MerkleHashOrchard::empty_leaf().inner(), |i| {
|
||||
typed_path[i].inner()
|
||||
})
|
||||
});
|
||||
let merkle_inputs = MerklePath {
|
||||
chip_1: config.merkle_chip_1(),
|
||||
|
|
10
src/tree.rs
10
src/tree.rs
|
@ -17,7 +17,6 @@ use rand::RngCore;
|
|||
use serde::de::{Deserializer, Error};
|
||||
use serde::ser::Serializer;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::convert::TryInto;
|
||||
use std::iter;
|
||||
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
|
||||
|
||||
|
@ -96,12 +95,9 @@ impl MerklePath {
|
|||
pub(crate) fn new(position: u32, auth_path: [pallas::Base; MERKLE_DEPTH_ORCHARD]) -> Self {
|
||||
Self {
|
||||
position,
|
||||
auth_path: auth_path
|
||||
.iter()
|
||||
.map(|node| MerkleHashOrchard(*node))
|
||||
.collect::<Vec<_>>()
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
auth_path: gen_const_array_with_default(MerkleHashOrchard::empty_leaf(), |i| {
|
||||
MerkleHashOrchard(auth_path[i])
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue