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

feat: add poseidon encryption implementation #149

Merged
merged 18 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [\#141](https://github.com/Manta-Network/manta-rs/pull/141) Add `U128` type and range assertion trait to ECLAIR
- [\#144](https://github.com/Manta-Network/manta-rs/pull/144) Add new release PR template for future releases
- [\#145](https://github.com/Manta-Network/manta-rs/pull/145) Add `cargo-hakari` and `cargo-nextest` to speed up CI pipeline
- [\#149](https://github.com/Manta-Network/manta-rs/pull/149) Add poseidon encryption implementation
- [\#147](https://github.com/Manta-Network/manta-rs/pull/147) Add benchmarks for Arkworks elliptic curve operations
- [\#163](https://github.com/Manta-Network/manta-rs/pull/163) Add `cargo-sort` to the CI pipeline for formatting `Cargo.toml` files

Expand Down
24 changes: 21 additions & 3 deletions manta-crypto/src/permutation/sponge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,27 @@ where
Self { permutation, state }
}

/// Writes `input` into `self`.
#[inline]
pub fn write<W>(&mut self, input: &W, compiler: &mut COM) -> W::Output
where
W: Write<P, COM>,
{
input.write(self.state, compiler)
}

/// Updates `self` by absorbing writes into the state with `input`.
#[inline]
pub fn absorb<W>(&mut self, input: &W, compiler: &mut COM) -> W::Output
where
W: Write<P, COM>,
{
let out = input.write(self.state, compiler);
let out = self.write(input, compiler);
self.permutation.permute(self.state, compiler);
out
}

/// Absorbs all the items in the `input` iterator, collecting all output items from writes into
/// Absorbs all items in the `input` iterator, collecting all output items from writes into
/// the state. See [`Write::write`] for more.
#[inline]
pub fn absorb_all<'w, W, I, C>(&mut self, input: I, compiler: &mut COM) -> C
Expand All @@ -95,13 +104,22 @@ where
.collect()
}

/// Reads values from `self`.
#[inline]
pub fn read<R>(&self, compiler: &mut COM) -> R
where
R: Read<P, COM>,
{
R::read(self.state, compiler)
}

/// Returns the next values from `self` by squeezing reads of the values from the state.
#[inline]
pub fn squeeze<R>(&mut self, compiler: &mut COM) -> R
where
R: Read<P, COM>,
{
let out = R::read(self.state, compiler);
let out = self.read(compiler);
self.permutation.permute(self.state, compiler);
out
}
Expand Down
2 changes: 1 addition & 1 deletion manta-pay/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use crate::crypto::{
constraint::arkworks::{field_element_as_bytes, groth16, Boolean, Fp, FpVar, R1CS},
ecc,
encryption::aes::{self, FixedNonceAesGcm},
hash::poseidon::compat as poseidon,
key::Blake2sKdf,
poseidon::compat as poseidon,
};
use alloc::vec::Vec;
use ark_ff::ToConstraintField;
Expand Down
19 changes: 0 additions & 19 deletions manta-pay/src/crypto/hash/mod.rs

This file was deleted.

Loading