Skip to content

Commit

Permalink
vendor: add code of ark-sponge fork to poseidon377
Browse files Browse the repository at this point in the history
This is the `r1cs` branch from our git fork of `ark-sponge`:

https://github.com/penumbra-zone/sponge

It is unmodified in this commit, changes will be made in the
subsequent commits for clarity of the git history.

The upstream `ark-sponge` repository is archived because they moved
the poseidon implementation to a different repository. In addition,
we need to make a lot of changes to get on the upstream impl. This
was attempted back in November and at that time we decided to continue
using our fork only for the R1CS feature.

However, in light of the upcoming migration to Poseidon2, any work
resolving the divergence between our fork and the upstream repo would
be wasted, as we'll be soon removing Poseidon 1 from `poseidon377`.

As such, for stability, we are vendoring our fork of `ark-sponge`
on a temporary basis such that we can release `poseidon377` unchanged
to crates, then pin all penumbra repositories to that release.

Afterwards, we will proceed with migrating to Arkworks 0.4.x release
series [0] and migrating to Poseidon2 [1].

[0] penumbra-zone/penumbra#2004
[1] #40
  • Loading branch information
redshiftzero committed Apr 25, 2023
1 parent f7e82ae commit 5dd59ec
Show file tree
Hide file tree
Showing 12 changed files with 3,369 additions and 8 deletions.
4 changes: 0 additions & 4 deletions poseidon377/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ ark-snark = { version = "0.3", default-features = false, optional=true }
decaf377 = { version="0.3", default-features = false, features = ["r1cs"] }
num-bigint = { version = "0.4.3", default-features = false }
once_cell = { version = "1.8", default-features = false }

ark-sponge = { git = "https://github.com/penumbra-zone/sponge", default-features = false, branch = "r1cs" }

poseidon-parameters = { path = "../poseidon-parameters", default-features = false }
poseidon-permutation = { path = "../poseidon-permutation", default-features = false }

Expand All @@ -44,7 +41,6 @@ r1cs = [
"ark-relations",
"ark-snark",
"ark-r1cs-std",
"ark-sponge/r1cs",
"decaf377/r1cs",
]
parallel = [
Expand Down
11 changes: 7 additions & 4 deletions poseidon377/src/r1cs.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError};
use ark_sponge::{
constraints::CryptographicSpongeVar,
poseidon::{constraints::PoseidonSpongeVar, PoseidonParameters as ArkPoseidonParameters},
};
use decaf377::r1cs::FqVar;
use poseidon_parameters::{Alpha, PoseidonParameters};

use crate::Fq;

mod vendor;

use vendor::sponge::{
constraints::CryptographicSpongeVar,
poseidon::{constraints::PoseidonSpongeVar, PoseidonParameters as ArkPoseidonParameters},
};

fn convert_to_ark_sponge_parameters(params: PoseidonParameters<Fq>) -> ArkPoseidonParameters<Fq> {
let alpha = match params.alpha {
Alpha::Exponent(exp) => exp as u64,
Expand Down
3 changes: 3 additions & 0 deletions poseidon377/src/r1cs/vendor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This is the vendored repository from: https://github.com/penumbra-zone/sponge
// TODO: Replace this
pub mod sponge;
Loading

0 comments on commit 5dd59ec

Please sign in to comment.