-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: (temporary commit) make each hasher generic over a field
- Loading branch information
1 parent
7cd0c6e
commit 1cbb33f
Showing
11 changed files
with
2,115 additions
and
502 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#[cfg(feature = "blake2s")] | ||
pub mod blake2s; | ||
#[cfg(feature = "poseidon")] | ||
pub mod poseidon; | ||
#[cfg(feature = "sha256")] | ||
pub mod sha256; | ||
|
||
#[cfg(feature = "blake2s")] | ||
pub use blake2s::{Blake2sDomain, Blake2sFunction, Blake2sHasher}; | ||
#[cfg(feature = "poseidon")] | ||
pub use poseidon::{PoseidonDomain, PoseidonFunction, PoseidonHasher}; | ||
#[cfg(feature = "sha256")] | ||
pub use sha256::{Sha256Domain, Sha256Function, Sha256Hasher}; | ||
|
||
// Rexport each hasher over the field `Fr` which is compatible with Groth16. | ||
pub mod groth { | ||
#[cfg(any(feature = "blake2s", feature = "poseidon", feature = "sha256"))] | ||
use blstrs::Scalar as Fr; | ||
|
||
// BLS12-381 | ||
#[cfg(feature = "blake2s")] | ||
pub type Blake2sDomain = super::Blake2sDomain<Fr>; | ||
#[cfg(feature = "blake2s")] | ||
pub type Blake2sFunction = super::Blake2sFunction<Fr>; | ||
#[cfg(feature = "blake2s")] | ||
pub type Blake2sHasher = super::Blake2sHasher<Fr>; | ||
|
||
#[cfg(feature = "poseidon")] | ||
pub type PoseidonDomain = super::PoseidonDomain<Fr>; | ||
#[cfg(feature = "poseidon")] | ||
pub type PoseidonFunction = super::PoseidonFunction<Fr>; | ||
#[cfg(feature = "poseidon")] | ||
pub type PoseidonHasher = super::PoseidonHasher<Fr>; | ||
|
||
#[cfg(feature = "sha256")] | ||
pub type Sha256Domain = super::Sha256Domain<Fr>; | ||
#[cfg(feature = "sha256")] | ||
pub type Sha256Function = super::Sha256Function<Fr>; | ||
#[cfg(feature = "sha256")] | ||
pub type Sha256Hasher = super::Sha256Hasher<Fr>; | ||
} | ||
|
||
// Rexport each hasher over the fields `Fp` and `Fq` which are compatible with Halo2. | ||
pub mod halo { | ||
#[cfg(any(feature = "blake2s", feature = "poseidon", feature = "sha256"))] | ||
use pasta_curves::{Fp, Fq}; | ||
|
||
// Pallas | ||
#[cfg(feature = "blake2s")] | ||
pub type Blake2sDomainPallas = super::Blake2sDomain<Fp>; | ||
#[cfg(feature = "blake2s")] | ||
pub type Blake2sFunctionPallas = super::Blake2sFunction<Fp>; | ||
#[cfg(feature = "blake2s")] | ||
pub type Blake2sHasherPallas = super::Blake2sHasher<Fp>; | ||
|
||
#[cfg(feature = "poseidon")] | ||
pub type PoseidonDomainPallas = super::PoseidonDomain<Fp>; | ||
#[cfg(feature = "poseidon")] | ||
pub type PoseidonFunctionPallas = super::PoseidonFunction<Fp>; | ||
#[cfg(feature = "poseidon")] | ||
pub type PoseidonHasherPallas = super::PoseidonHasher<Fp>; | ||
|
||
#[cfg(feature = "sha256")] | ||
pub type Sha256DomainPallas = super::Sha256Domain<Fp>; | ||
#[cfg(feature = "sha256")] | ||
pub type Sha256FunctionPallas = super::Sha256Function<Fp>; | ||
#[cfg(feature = "sha256")] | ||
pub type Sha256HasherPallas = super::Sha256Hasher<Fp>; | ||
|
||
// Vesta | ||
#[cfg(feature = "blake2s")] | ||
pub type Blake2sDomainVesta = super::Blake2sDomain<Fq>; | ||
#[cfg(feature = "blake2s")] | ||
pub type Blake2sFunctionVesta = super::Blake2sFunction<Fq>; | ||
#[cfg(feature = "blake2s")] | ||
pub type Blake2sHasherVesta = super::Blake2sHasher<Fq>; | ||
|
||
#[cfg(feature = "poseidon")] | ||
pub type PoseidonDomainVesta = super::PoseidonDomain<Fq>; | ||
#[cfg(feature = "poseidon")] | ||
pub type PoseidonFunctionVesta = super::PoseidonFunction<Fq>; | ||
#[cfg(feature = "poseidon")] | ||
pub type PoseidonHasherVesta = super::PoseidonHasher<Fq>; | ||
|
||
#[cfg(feature = "sha256")] | ||
pub type Sha256DomainVesta = super::Sha256Domain<Fq>; | ||
#[cfg(feature = "sha256")] | ||
pub type Sha256FunctionVesta = super::Sha256Function<Fq>; | ||
#[cfg(feature = "sha256")] | ||
pub type Sha256HasherVesta = super::Sha256Hasher<Fq>; | ||
} |
Oops, something went wrong.