Skip to content

Commit

Permalink
Merge pull request #100 from dusk-network/vlopes11/min_host
Browse files Browse the repository at this point in the history
Poseidon252 no-std
  • Loading branch information
vlopes11 authored Nov 17, 2020
2 parents c4fabe1 + 3635c3c commit 8cf82a8
Show file tree
Hide file tree
Showing 20 changed files with 822 additions and 556 deletions.
65 changes: 58 additions & 7 deletions .github/workflows/dusk_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
with:
command: check

test_nightly:
name: Nightly tests
test_nightly_std:
name: Nightly tests std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -49,9 +49,22 @@ jobs:
with:
command: test
args: --release

test_nightly_canon:
name: Nightly tests
test_nightly_no_std:
name: Nightly tests no_std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --release --no-default-features
test_nightly_canon_std:
name: Nightly tests canon std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -64,9 +77,43 @@ jobs:
with:
command: test
args: --release --features canon

test_nightly_canon_no_std:
name: Nightly tests canon no_std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --release --no-default-features --features canon

test_nightly_canon_host_std:
name: Nightly tests canon_host std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --release --features canon_host
- uses: actions-rs/cargo@v1
with:
comand: test
args: --release --features canon_host

test_nightly_canon_host:
name: Nightly tests
test_nightly_canon_host_no_std:
name: Nightly tests canon_host no_std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -79,6 +126,10 @@ jobs:
with:
command: test
args: --release --features canon_host
- uses: actions-rs/cargo@v1
with:
comand: test
args: --release --no-default-features --features canon_host

fmt:
name: Rustfmt
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.14.0] - 17-11-20
### Changed
- No-Std compatibility.

## [0.13.1] - 06-11-20
### Changed
- Feature split between `canon` and `canon_host` for constrained and unconstrained environments.
Expand Down
38 changes: 29 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,51 @@
[package]
name = "poseidon252"
version = "0.13.2"
version = "0.14.0"
authors = [
"zer0 <[email protected]>", "vlopes11 <[email protected]>", "CPerezz <[email protected]>", "Kristoffer Ström <[email protected]>"
]
edition = "2018"

[dependencies]
lazy_static = "1.3.0"
hades252 = { git = "https://github.com/dusk-network/hades252", tag = "v0.10.1" }
dusk-plonk = {version = "0.3.4", features = ["trace-print"]}
anyhow = "1.0"
thiserror = "1.0"
dusk-bls12_381 = {version = "0.3", default-features = false}
dusk-jubjub = {version = "0.5", default-features = false}
hades252 = { git = "https://github.com/dusk-network/hades252", tag = "v0.10.1", default-features = false }
canonical = {version = "0.4", optional = true}
canonical_derive = {version = "0.4", optional = true}
microkelvin = {version = "0.5", optional = true}
nstack = {version = "0.6", optional = true}

dusk-plonk = {version = "0.3", default-features = false, optional = true}
anyhow = { version = "1.0", optional = true }
thiserror = { version = "1.0", optional = true }

[dev-dependencies]
canonical_host = "0.4"
rand = "0.7"
rand_core = "0.5"
criterion = "0.3"

[features]
canon = ["canonical", "canonical_derive", "nstack", "microkelvin", "dusk-plonk/canon"]
canon_host = ["canon", "canonical/host"]
default = ["std"]
std = [
"hades252/default",
"dusk-bls12_381/default",
"dusk-jubjub/std",
"dusk-plonk",
"anyhow",
"thiserror"
]
canon = [
"dusk-bls12_381/canon",
"dusk-jubjub/canon",
"canonical",
"canonical_derive",
"microkelvin",
"nstack"
]
canon_host = [
"canon",
"canonical/host"
]

[profile.dev]
opt-level = 3
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The sponge hash techniqe requires a padding to be applied before the data can
be hashed.

This is done to avoid hash collitions as stated in the paper of the Poseidon Hash
algorithm. See: (https://eprint.iacr.org/2019/458.pdf)[https://eprint.iacr.org/2019/458.pdf].
algorithm. See: <https://eprint.iacr.org/2019/458.pdf>.
The inputs of the `sponge_hash` are always `Scalar` or need to be capable of being represented
as it.

Expand Down Expand Up @@ -68,16 +68,15 @@ computed and placed in the first Level position.
### Zero Knowledge Merkle Opening Proof example:

```no_run
#[cfg(feature = "canon")]
#[cfg(all(feature = "canon", feature = "std"))]
{
use anyhow::Result;
use canonical::Canon;
use canonical_derive::Canon;
use canonical_host::MemStore;
use dusk_plonk::prelude::*;
use poseidon252::tree::zk::merkle_opening;
use poseidon252::tree::{PoseidonAnnotation, PoseidonLeaf, PoseidonTree};
use poseidon252::tree::{PoseidonAnnotation, PoseidonLeaf, PoseidonTree, merkle_opening};
// Constant depth of the merkle tree
const DEPTH: usize = 17;
Expand Down Expand Up @@ -129,7 +128,7 @@ fn main() -> Result<()> {
// Append 1024 elements to the tree
for i in 0..1024 {
let l = DataLeaf::from(i as u64);
tree.push(l)?;
tree.push(l).unwrap();
}
// Create a merkle opening tester gadget
Expand Down
Loading

0 comments on commit 8cf82a8

Please sign in to comment.