From d8d586205cec59ae78920cefc188f7057790afe6 Mon Sep 17 00:00:00 2001 From: Boyuan Feng Date: Thu, 28 Jul 2022 14:27:08 -0400 Subject: [PATCH] feat: recover compat poseidon (#186) * feat: recover compat poseidon * feat: fix lint * chore: pin `syn` version in `manta-pay` * chore: re-order dependencies correctly * chore: disable hakari * feat: disable hakari on the CI on the main branch * chore: enable hakari * chore: fix typo in CI * chore: sort dependencies in manta-pay Signed-off-by: Brandon H. Gomes Co-authored-by: Brandon H. Gomes --- .github/workflows/ci.yml | 1 + CHANGELOG.md | 1 - manta-accounting/Cargo.toml | 2 +- manta-benchmark/Cargo.toml | 2 +- manta-crypto/Cargo.toml | 2 +- manta-parameters/Cargo.toml | 2 +- manta-pay/Cargo.toml | 5 +- manta-pay/src/config.rs | 26 +- manta-pay/src/crypto/poseidon/README.md | 1 + manta-pay/src/crypto/poseidon/compat.rs | 455 +++++++++++++++++++++ manta-pay/src/crypto/poseidon/constants.rs | 5 +- manta-pay/src/crypto/poseidon/hash.rs | 2 + manta-pay/src/crypto/poseidon/mod.rs | 1 + manta-pay/src/test/mod.rs | 5 +- manta-trusted-setup/Cargo.toml | 2 +- manta-util/Cargo.toml | 2 +- workspace-hack/Cargo.toml | 7 +- 17 files changed, 490 insertions(+), 31 deletions(-) create mode 100644 manta-pay/src/crypto/poseidon/compat.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4d73e885..34aeeb8a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ env: jobs: workspace-hack-check: name: Workspace Hack Check + if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index d133bbc0f..204e1ba25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Deprecated ### Removed -- [\#168](https://github.com/Manta-Network/manta-rs/pull/168) Remove old Poseidon hash ### Fixed diff --git a/manta-accounting/Cargo.toml b/manta-accounting/Cargo.toml index 8eab33ddd..6f4561dc6 100644 --- a/manta-accounting/Cargo.toml +++ b/manta-accounting/Cargo.toml @@ -64,7 +64,7 @@ manta-util = { path = "../manta-util", default-features = false, features = ["al parking_lot = { version = "0.12.0", optional = true, default-features = false } rand_chacha = { version = "0.3.1", optional = true, default-features = false } statrs = { version = "0.15.0", optional = true, default-features = false } -workspace-hack = { version = "0.1.0", path = "../workspace-hack" } +workspace-hack = { version = "0.1", path = "../workspace-hack" } [dev-dependencies] manta-crypto = { path = "../manta-crypto", default-features = false, features = ["getrandom"] } diff --git a/manta-benchmark/Cargo.toml b/manta-benchmark/Cargo.toml index cd95a8c27..1b814cad9 100644 --- a/manta-benchmark/Cargo.toml +++ b/manta-benchmark/Cargo.toml @@ -55,7 +55,7 @@ manta-pay = { path = "../manta-pay", default-features = false, features = ["grot wasm-bindgen = { version = "0.2.82", default-features = false } wasm-bindgen-test = { version = "0.3.30", default-features = false } web-sys = { version = "0.3.59", default-features = false, features = ["console"] } -workspace-hack = { version = "0.1.0", path = "../workspace-hack" } +workspace-hack = { version = "0.1", path = "../workspace-hack" } [dev-dependencies] criterion = { version = "0.3.4", default-features = false } diff --git a/manta-crypto/Cargo.toml b/manta-crypto/Cargo.toml index 52ba1ece1..455647d0d 100644 --- a/manta-crypto/Cargo.toml +++ b/manta-crypto/Cargo.toml @@ -42,7 +42,7 @@ derivative = { version = "2.2.0", default-features = false, features = ["use_cor manta-util = { path = "../manta-util", default-features = false, features = ["alloc"] } rand = { version = "0.8.4", optional = true, default-features = false, features = ["alloc"] } rand_core = { version = "0.6.3", default-features = false } -workspace-hack = { version = "0.1.0", path = "../workspace-hack" } +workspace-hack = { version = "0.1", path = "../workspace-hack" } [dev-dependencies] rand = "0.8.4" diff --git a/manta-parameters/Cargo.toml b/manta-parameters/Cargo.toml index ec4b183e6..f40d3b2e4 100644 --- a/manta-parameters/Cargo.toml +++ b/manta-parameters/Cargo.toml @@ -35,7 +35,7 @@ std = ["anyhow?/std"] anyhow = { version = "1.0.57", optional = true, default-features = false } attohttpc = { version = "0.19.1", optional = true } blake3 = { version = "1.3.1", default-features = false } -workspace-hack = { version = "0.1.0", path = "../workspace-hack" } +workspace-hack = { version = "0.1", path = "../workspace-hack" } [dev-dependencies] git2 = { version = "0.14.4", default-features = false } diff --git a/manta-pay/Cargo.toml b/manta-pay/Cargo.toml index e3148cef1..5a66d5c86 100644 --- a/manta-pay/Cargo.toml +++ b/manta-pay/Cargo.toml @@ -59,7 +59,7 @@ groth16 = ["ark-groth16", "ark-snark", "arkworks"] http = ["reqwest", "serde"] # SCALE Codec and Type Info -scale = ["scale-codec", "scale-info"] +scale = ["scale-codec", "scale-info", "syn"] # SCALE Codec and Type Info with the Standard Library Enabled scale-std = ["scale", "scale-codec/std", "scale-info/std", "std"] @@ -132,11 +132,12 @@ reqwest = { version = "0.11.9", optional = true, default-features = false, featu scale-codec = { package = "parity-scale-codec", version = "3.1.2", optional = true, default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.1.2", optional = true, default-features = false, features = ["derive"] } serde_json = { version = "1.0.82", optional = true, default-features = false, features = ["alloc"] } +syn = { version = "=1.0.96", optional = true, default-features = false } # FIXME: Workaround until polkadot-v0.9.24 for https://github.com/paritytech/substrate/issues/11706 tempfile = { version = "3.3.0", optional = true, default-features = false } tide = { version = "0.16.0", optional = true, default-features = false, features = ["h1-server"] } tokio = { version = "1.20.1", optional = true, default-features = false } tokio-tungstenite = { version = "0.17.2", optional = true, default-features = false, features = ["native-tls"] } -workspace-hack = { version = "0.1.0", path = "../workspace-hack" } +workspace-hack = { version = "0.1", path = "../workspace-hack" } ws_stream_wasm = { version = "0.7.3", optional = true, default-features = false } [dev-dependencies] diff --git a/manta-pay/src/config.rs b/manta-pay/src/config.rs index af59e3d3d..658250021 100644 --- a/manta-pay/src/config.rs +++ b/manta-pay/src/config.rs @@ -21,7 +21,7 @@ use crate::crypto::{ ecc, encryption::aes::{self, FixedNonceAesGcm}, key::Blake2sKdf, - poseidon::{self, arkworks::TwoPowerMinusOneDomainTag, hash::Hasher}, + poseidon::compat as poseidon, }; use alloc::vec::Vec; use ark_ff::ToConstraintField; @@ -118,36 +118,28 @@ impl Constant for PoseidonSpec { } /// Poseidon-2 Hash Parameters -pub type Poseidon2 = Hasher, TwoPowerMinusOneDomainTag, 2>; +pub type Poseidon2 = poseidon::Hasher, 2>; /// Poseidon-2 Hash Parameters Variable -pub type Poseidon2Var = Hasher, TwoPowerMinusOneDomainTag, 2, Compiler>; - -impl poseidon::Constants for PoseidonSpec<2> { - const WIDTH: usize = 3; - const FULL_ROUNDS: usize = 8; - const PARTIAL_ROUNDS: usize = 55; -} +pub type Poseidon2Var = poseidon::Hasher, 2, Compiler>; impl poseidon::arkworks::Specification for PoseidonSpec<2> { type Field = ConstraintField; + const FULL_ROUNDS: usize = 8; + const PARTIAL_ROUNDS: usize = 57; const SBOX_EXPONENT: u64 = 5; } /// Poseidon-4 Hash Parameters -pub type Poseidon4 = Hasher, TwoPowerMinusOneDomainTag, 4>; +pub type Poseidon4 = poseidon::Hasher, 4>; /// Poseidon-4 Hash Parameters Variable -pub type Poseidon4Var = Hasher, TwoPowerMinusOneDomainTag, 4, Compiler>; - -impl poseidon::Constants for PoseidonSpec<4> { - const WIDTH: usize = 5; - const FULL_ROUNDS: usize = 8; - const PARTIAL_ROUNDS: usize = 56; -} +pub type Poseidon4Var = poseidon::Hasher, 4, Compiler>; impl poseidon::arkworks::Specification for PoseidonSpec<4> { type Field = ConstraintField; + const FULL_ROUNDS: usize = 8; + const PARTIAL_ROUNDS: usize = 60; const SBOX_EXPONENT: u64 = 5; } diff --git a/manta-pay/src/crypto/poseidon/README.md b/manta-pay/src/crypto/poseidon/README.md index 529bfd487..314237cf7 100644 --- a/manta-pay/src/crypto/poseidon/README.md +++ b/manta-pay/src/crypto/poseidon/README.md @@ -2,6 +2,7 @@ ## Code Structure +* `compat.rs`: Contains legacy implementation for Poseidon hash that is kept for compatibility. * `constants.rs`: Generates poseidon permutation round numbers. * `lfsr.rs`: Implements linear feedback shift register as a random number generator. * `matrix.rs`: Implements basic linear algebra. diff --git a/manta-pay/src/crypto/poseidon/compat.rs b/manta-pay/src/crypto/poseidon/compat.rs new file mode 100644 index 000000000..1d4e46c66 --- /dev/null +++ b/manta-pay/src/crypto/poseidon/compat.rs @@ -0,0 +1,455 @@ +// Copyright 2019-2022 Manta Network. +// This file is part of manta-rs. +// +// manta-rs is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// manta-rs is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with manta-rs. If not, see . + +//! Compatibility for Poseidon Hash Implementation + +use alloc::vec::Vec; +use core::{fmt::Debug, hash::Hash, iter, mem}; +use manta_crypto::hash::ArrayHashFunction; +use manta_util::codec::{Decode, DecodeError, Encode, Read, Write}; + +#[cfg(feature = "serde")] +use manta_util::serde::{Deserialize, Serialize}; + +#[cfg(any(feature = "test", test))] +use { + core::iter::repeat, + manta_crypto::rand::{Rand, RngCore, Sample}, +}; + +/// Poseidon Permutation Specification +pub trait Specification { + /// Field Type + type Field; + + /// Number of Full Rounds + /// + /// This is counted twice for the first set of full rounds and then the second set after the + /// partial rounds. + const FULL_ROUNDS: usize; + + /// Number of Partial Rounds + const PARTIAL_ROUNDS: usize; + + /// Returns the additive identity of the field. + fn zero(compiler: &mut COM) -> Self::Field; + + /// Adds two field elements together. + fn add(lhs: &Self::Field, rhs: &Self::Field, compiler: &mut COM) -> Self::Field; + + /// Multiplies two field elements together. + fn mul(lhs: &Self::Field, rhs: &Self::Field, compiler: &mut COM) -> Self::Field; + + /// Adds the `rhs` field element to `self`, storing the value in `self`. + fn add_assign(lhs: &mut Self::Field, rhs: &Self::Field, compiler: &mut COM); + + /// Applies the S-BOX to `point`. + fn apply_sbox(point: &mut Self::Field, compiler: &mut COM); +} + +/// Poseidon State Vector +type State = Vec<>::Field>; + +/// Returns the total number of rounds in a Poseidon permutation. +#[inline] +pub fn rounds() -> usize +where + S: Specification, +{ + 2 * S::FULL_ROUNDS + S::PARTIAL_ROUNDS +} + +/// Poseidon Hash +#[cfg_attr( + feature = "serde", + derive(Deserialize, Serialize), + serde( + bound( + deserialize = "S::Field: Deserialize<'de>", + serialize = "S::Field: Serialize" + ), + crate = "manta_util::serde", + deny_unknown_fields + ) +)] +#[derive(derivative::Derivative)] +#[derivative( + Clone(bound = "S::Field: Clone"), + Debug(bound = "S::Field: Debug"), + Eq(bound = "S::Field: Eq"), + Hash(bound = "S::Field: Hash"), + PartialEq(bound = "S::Field: PartialEq") +)] +pub struct Hasher +where + S: Specification, +{ + /// Additive Round Keys + additive_round_keys: Vec, + + /// MDS Matrix + mds_matrix: Vec, +} + +impl Hasher +where + S: Specification, +{ + /// Width of the State Buffer + pub const WIDTH: usize = ARITY + 1; + + /// Total Number of Rounds + pub const ROUNDS: usize = 2 * S::FULL_ROUNDS + S::PARTIAL_ROUNDS; + + /// Number of Entries in the MDS Matrix + pub const MDS_MATRIX_SIZE: usize = Self::WIDTH * Self::WIDTH; + + /// Total Number of Additive Rounds Keys + pub const ADDITIVE_ROUND_KEYS_COUNT: usize = Self::ROUNDS * Self::WIDTH; + + /// Builds a new [`Hasher`] from `additive_round_keys` and `mds_matrix`. + /// + /// # Panics + /// + /// This method panics if the input vectors are not the correct size for the specified + /// [`Specification`]. + #[inline] + pub fn new(additive_round_keys: Vec, mds_matrix: Vec) -> Self { + assert_eq!( + additive_round_keys.len(), + Self::ADDITIVE_ROUND_KEYS_COUNT, + "Additive Rounds Keys are not the correct size." + ); + assert_eq!( + mds_matrix.len(), + Self::MDS_MATRIX_SIZE, + "MDS Matrix is not the correct size." + ); + Self::new_unchecked(additive_round_keys, mds_matrix) + } + + /// Builds a new [`Hasher`] from `additive_round_keys` and `mds_matrix` without + /// checking their sizes. + #[inline] + fn new_unchecked(additive_round_keys: Vec, mds_matrix: Vec) -> Self { + Self { + additive_round_keys, + mds_matrix, + } + } + + /// Returns the additive keys for the given `round`. + #[inline] + fn additive_keys(&self, round: usize) -> &[S::Field] { + let width = Self::WIDTH; + let start = round * width; + &self.additive_round_keys[start..start + width] + } + + /// Computes the MDS matrix multiplication against the `state`. + #[inline] + fn mds_matrix_multiply(&self, state: &mut State, compiler: &mut COM) { + let width = Self::WIDTH; + let mut next = Vec::with_capacity(width); + for i in 0..width { + #[allow(clippy::needless_collect)] + // NOTE: Clippy is wrong here, we need `&mut` access. + let linear_combination = state + .iter() + .enumerate() + .map(|(j, elem)| S::mul(elem, &self.mds_matrix[width * i + j], compiler)) + .collect::>(); + next.push( + linear_combination + .into_iter() + .reduce(|acc, next| S::add(&acc, &next, compiler)) + .unwrap(), + ); + } + mem::swap(&mut next, state); + } + + /// Computes the first round of the Poseidon permutation from `trapdoor` and `input`. + #[inline] + fn first_round(&self, input: [&S::Field; ARITY], compiler: &mut COM) -> State { + let mut state = Vec::with_capacity(Self::WIDTH); + for (i, point) in iter::once(&S::zero(compiler)).chain(input).enumerate() { + let mut elem = S::add(point, &self.additive_round_keys[i], compiler); + S::apply_sbox(&mut elem, compiler); + state.push(elem); + } + self.mds_matrix_multiply(&mut state, compiler); + state + } + + /// Computes a full round at the given `round` index on the internal permutation `state`. + #[inline] + fn full_round(&self, round: usize, state: &mut State, compiler: &mut COM) { + let keys = self.additive_keys(round); + for (i, elem) in state.iter_mut().enumerate() { + S::add_assign(elem, &keys[i], compiler); + S::apply_sbox(elem, compiler); + } + self.mds_matrix_multiply(state, compiler); + } + + /// Computes a partial round at the given `round` index on the internal permutation `state`. + #[inline] + fn partial_round(&self, round: usize, state: &mut State, compiler: &mut COM) { + let keys = self.additive_keys(round); + for (i, elem) in state.iter_mut().enumerate() { + S::add_assign(elem, &keys[i], compiler); + } + S::apply_sbox(&mut state[0], compiler); + self.mds_matrix_multiply(state, compiler); + } +} + +impl ArrayHashFunction for Hasher +where + S: Specification, +{ + type Input = S::Field; + type Output = S::Field; + + #[inline] + fn hash(&self, input: [&Self::Input; ARITY], compiler: &mut COM) -> Self::Output { + let mut state = self.first_round(input, compiler); + for round in 1..S::FULL_ROUNDS { + self.full_round(round, &mut state, compiler); + } + for round in S::FULL_ROUNDS..(S::FULL_ROUNDS + S::PARTIAL_ROUNDS) { + self.partial_round(round, &mut state, compiler); + } + for round in (S::FULL_ROUNDS + S::PARTIAL_ROUNDS)..(2 * S::FULL_ROUNDS + S::PARTIAL_ROUNDS) + { + self.full_round(round, &mut state, compiler); + } + state.truncate(1); + state.remove(0) + } +} + +#[cfg(any(feature = "test", test))] // NOTE: This is only safe to use in a test. +impl Sample for Hasher +where + D: Clone, + S: Specification, + S::Field: Sample, +{ + /// Samples random Poseidon parameters. + /// + /// # Warning + /// + /// This method samples the individual field elements of the parameters set, instead of + /// producing an actually correct/safe set of additive round keys and MDS matrix. + #[inline] + fn sample(distribution: D, rng: &mut R) -> Self + where + R: RngCore + ?Sized, + { + Self { + additive_round_keys: rng + .sample_iter(repeat(distribution.clone()).take(Self::ADDITIVE_ROUND_KEYS_COUNT)) + .collect(), + mds_matrix: rng + .sample_iter(repeat(distribution).take(Self::MDS_MATRIX_SIZE)) + .collect(), + } + } +} + +impl Decode for Hasher +where + S: Specification, + S::Field: Decode, +{ + type Error = ::Error; + + #[inline] + fn decode(mut reader: R) -> Result> + where + R: Read, + { + Ok(Self::new_unchecked( + (0..Self::ADDITIVE_ROUND_KEYS_COUNT) + .map(|_| S::Field::decode(&mut reader)) + .collect::, _>>()?, + (0..Self::MDS_MATRIX_SIZE) + .map(|_| S::Field::decode(&mut reader)) + .collect::, _>>()?, + )) + } +} + +impl Encode for Hasher +where + S: Specification, + S::Field: Encode, +{ + #[inline] + fn encode(&self, mut writer: W) -> Result<(), W::Error> + where + W: Write, + { + for key in &self.additive_round_keys { + key.encode(&mut writer)?; + } + for entry in &self.mds_matrix { + entry.encode(&mut writer)?; + } + Ok(()) + } +} + +/// Poseidon Hash Input Type +pub type Input = + as ArrayHashFunction>::Input; + +/// Poseidon Commitment Output Type +pub type Output = + as ArrayHashFunction>::Output; + +/// Arkworks Backend +#[cfg(feature = "arkworks")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "arkworks")))] +pub mod arkworks { + use crate::crypto::constraint::arkworks::{Fp, FpVar, R1CS}; + use ark_ff::{Field, PrimeField}; + use ark_r1cs_std::fields::FieldVar; + use manta_crypto::constraint::{Allocate, Constant}; + + /// Compiler Type + type Compiler = R1CS<::Field>; + + /// Poseidon Permutation Specification + pub trait Specification { + /// Field Type + type Field: PrimeField; + + /// Number of Full Rounds + /// + /// This is counted twice for the first set of full rounds and then the second set after the + /// partial rounds. + const FULL_ROUNDS: usize; + + /// Number of Partial Rounds + const PARTIAL_ROUNDS: usize; + + /// S-BOX Exponenet + const SBOX_EXPONENT: u64; + } + + impl super::Specification for S + where + S: Specification, + { + type Field = Fp; + + const FULL_ROUNDS: usize = S::FULL_ROUNDS; + const PARTIAL_ROUNDS: usize = S::PARTIAL_ROUNDS; + + #[inline] + fn zero(_: &mut ()) -> Self::Field { + Default::default() + } + + #[inline] + fn add(lhs: &Self::Field, rhs: &Self::Field, _: &mut ()) -> Self::Field { + Fp(lhs.0 + rhs.0) + } + + #[inline] + fn mul(lhs: &Self::Field, rhs: &Self::Field, _: &mut ()) -> Self::Field { + Fp(lhs.0 * rhs.0) + } + + #[inline] + fn add_assign(lhs: &mut Self::Field, rhs: &Self::Field, _: &mut ()) { + lhs.0 += rhs.0; + } + + #[inline] + fn apply_sbox(point: &mut Self::Field, _: &mut ()) { + point.0 = point.0.pow(&[Self::SBOX_EXPONENT, 0, 0, 0]); + } + } + + impl super::Specification> for S + where + S: Specification, + { + type Field = FpVar; + + const FULL_ROUNDS: usize = S::FULL_ROUNDS; + const PARTIAL_ROUNDS: usize = S::PARTIAL_ROUNDS; + + #[inline] + fn zero(compiler: &mut Compiler) -> Self::Field { + let _ = compiler; + Self::Field::zero() + } + + #[inline] + fn add(lhs: &Self::Field, rhs: &Self::Field, compiler: &mut Compiler) -> Self::Field { + let _ = compiler; + lhs + rhs + } + + #[inline] + fn mul(lhs: &Self::Field, rhs: &Self::Field, compiler: &mut Compiler) -> Self::Field { + let _ = compiler; + lhs * rhs + } + + #[inline] + fn add_assign(lhs: &mut Self::Field, rhs: &Self::Field, compiler: &mut Compiler) { + let _ = compiler; + *lhs += rhs; + } + + #[inline] + fn apply_sbox(point: &mut Self::Field, compiler: &mut Compiler) { + let _ = compiler; + *point = point + .pow_by_constant(&[Self::SBOX_EXPONENT]) + .expect("Exponentiation is not allowed to fail."); + } + } + + impl Constant> for super::Hasher> + where + S: Specification, + { + type Type = super::Hasher; + + #[inline] + fn new_constant(this: &Self::Type, compiler: &mut Compiler) -> Self { + Self { + additive_round_keys: this + .additive_round_keys + .iter() + .map(|k| k.as_constant(compiler)) + .collect(), + mds_matrix: this + .mds_matrix + .iter() + .map(|k| k.as_constant(compiler)) + .collect(), + } + } + } +} diff --git a/manta-pay/src/crypto/poseidon/constants.rs b/manta-pay/src/crypto/poseidon/constants.rs index cd8ece63e..42befc21b 100644 --- a/manta-pay/src/crypto/poseidon/constants.rs +++ b/manta-pay/src/crypto/poseidon/constants.rs @@ -276,7 +276,6 @@ pub mod security { #[cfg(test)] mod test { use super::*; - use crate::config::PoseidonSpec; /// Tests if the constants match the known constant values. #[test] @@ -320,6 +319,9 @@ mod test { } } + /* After upgrading to new Poseidon, we have to enable these tests. + // TODO: After upgrading to new Poseidon, we have to enable these tests. + // use crate::config::PoseidonSpec; /// Tests if the specifications match the known constant values. #[test] fn specifications_match_known_values() { @@ -332,4 +334,5 @@ mod test { Constants::from_specification::>() ); } + */ } diff --git a/manta-pay/src/crypto/poseidon/hash.rs b/manta-pay/src/crypto/poseidon/hash.rs index 31bea2af3..968f9f88a 100644 --- a/manta-pay/src/crypto/poseidon/hash.rs +++ b/manta-pay/src/crypto/poseidon/hash.rs @@ -206,6 +206,7 @@ where } } +/* TODO: After upgrading to new Poseidon, we have to enable these tests. /// Testing Suite #[cfg(test)] mod test { @@ -225,3 +226,4 @@ mod test { ); } } +*/ diff --git a/manta-pay/src/crypto/poseidon/mod.rs b/manta-pay/src/crypto/poseidon/mod.rs index ade5dafca..564c2a72b 100644 --- a/manta-pay/src/crypto/poseidon/mod.rs +++ b/manta-pay/src/crypto/poseidon/mod.rs @@ -31,6 +31,7 @@ use manta_util::codec::{Decode, DecodeError, Encode, Read, Write}; #[cfg(feature = "serde")] use manta_util::serde::{Deserialize, Serialize}; +pub mod compat; pub mod constants; pub mod encryption; pub mod hash; diff --git a/manta-pay/src/test/mod.rs b/manta-pay/src/test/mod.rs index ce8117736..054fecde5 100644 --- a/manta-pay/src/test/mod.rs +++ b/manta-pay/src/test/mod.rs @@ -23,9 +23,8 @@ // #[cfg_attr(doc_cfg, doc(cfg(feature = "simulation")))] // pub mod simulation; -// TODO: Recover this tests when finishing v0.6.0 -// #[cfg(test)] -// pub mod compatibility; +#[cfg(test)] +pub mod compatibility; #[cfg(test)] pub mod transfer; diff --git a/manta-trusted-setup/Cargo.toml b/manta-trusted-setup/Cargo.toml index b8cea473b..dad4589ad 100644 --- a/manta-trusted-setup/Cargo.toml +++ b/manta-trusted-setup/Cargo.toml @@ -44,4 +44,4 @@ derivative = { version = "2.2.0", default-features = false, features = ["use_cor manta-crypto = { path = "../manta-crypto", default-features = false, features = ["getrandom"] } manta-util = { path = "../manta-util", default-features = false, features = ["alloc"] } rayon = { version = "1.5.3", optional = true, default-features = false } -workspace-hack = { version = "0.1.0", path = "../workspace-hack" } +workspace-hack = { version = "0.1", path = "../workspace-hack" } diff --git a/manta-util/Cargo.toml b/manta-util/Cargo.toml index 970fecdbc..cc1f1027b 100644 --- a/manta-util/Cargo.toml +++ b/manta-util/Cargo.toml @@ -42,4 +42,4 @@ crossbeam-channel = { version = "0.5.6", optional = true, default-features = fal rayon = { version = "1.5.3", optional = true, default-features = false } serde = { version = "1.0.140", optional = true, default-features = false, features = ["derive"] } serde_with = { version = "1.14.0", optional = true, default-features = false, features = ["macros"] } -workspace-hack = { version = "0.1.0", path = "../workspace-hack" } +workspace-hack = { version = "0.1", path = "../workspace-hack" } diff --git a/workspace-hack/Cargo.toml b/workspace-hack/Cargo.toml index c8aaef181..426f5dab3 100644 --- a/workspace-hack/Cargo.toml +++ b/workspace-hack/Cargo.toml @@ -35,6 +35,8 @@ log = { version = "0.4.17", default-features = false, features = ["kv_unstable", memchr = { version = "2.5.0", features = ["std"] } num-traits = { version = "0.2.15", features = ["i128", "libm", "std"] } ppv-lite86 = { version = "0.2.16", default-features = false, features = ["simd", "std"] } +proc-macro2 = { version = "1.0.42", features = ["proc-macro"] } +quote = { version = "1.0.20", features = ["proc-macro"] } rand = { version = "0.8.5", features = ["alloc", "getrandom", "libc", "rand_chacha", "std", "std_rng"] } rand_chacha = { version = "0.3.1", default-features = false, features = ["std"] } rand_core = { version = "0.6.3", default-features = false, features = ["alloc", "getrandom", "std"] } @@ -43,6 +45,7 @@ serde_json = { version = "1.0.82", features = ["alloc", "std"] } sha2 = { version = "0.9.9", features = ["std"] } standback = { version = "0.2.17", default-features = false, features = ["std"] } subtle = { version = "2.4.1", default-features = false, features = ["i128"] } +syn = { version = "1.0.96", features = ["clone-impls", "derive", "extra-traits", "fold", "full", "parsing", "printing", "proc-macro", "quote", "visit", "visit-mut"] } url = { version = "2.2.2", default-features = false, features = ["serde"] } web-sys = { version = "0.3.59", default-features = false, features = ["BinaryType", "Blob", "CloseEvent", "DomException", "Event", "EventTarget", "MessageEvent", "WebSocket", "console"] } zeroize = { version = "1.5.7", default-features = false, features = ["alloc", "zeroize_derive"] } @@ -56,9 +59,11 @@ digest-93f6ce9d446188ac = { package = "digest", version = "0.10.3", features = [ generic-array = { version = "0.14.5", default-features = false, features = ["more_lengths"] } log = { version = "0.4.17", default-features = false, features = ["kv_unstable", "kv_unstable_std", "std", "value-bag"] } num-traits = { version = "0.2.15", features = ["i128", "libm", "std"] } +proc-macro2 = { version = "1.0.42", features = ["proc-macro"] } +quote = { version = "1.0.20", features = ["proc-macro"] } serde = { version = "1.0.140", features = ["alloc", "derive", "serde_derive", "std"] } standback = { version = "0.2.17", default-features = false, features = ["std"] } subtle = { version = "2.4.1", default-features = false, features = ["i128"] } -syn = { version = "1.0.98", features = ["clone-impls", "derive", "extra-traits", "fold", "full", "parsing", "printing", "proc-macro", "quote", "visit", "visit-mut"] } +syn = { version = "1.0.96", features = ["clone-impls", "derive", "extra-traits", "fold", "full", "parsing", "printing", "proc-macro", "quote", "visit", "visit-mut"] } ### END HAKARI SECTION