Skip to content

Commit

Permalink
Merge pull request #142 from dusk-network/release-0.21.0
Browse files Browse the repository at this point in the history
Release 0.21.0
  • Loading branch information
CPerezz authored Jul 5, 2021
2 parents 91bab8c + dbffed1 commit e0db9ac
Show file tree
Hide file tree
Showing 28 changed files with 1,076 additions and 934 deletions.
54 changes: 2 additions & 52 deletions .github/workflows/dusk_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: install
Expand All @@ -29,8 +27,6 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: check
Expand All @@ -43,12 +39,11 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --release

test_nightly_no_std:
name: Nightly tests no_std
runs-on: ubuntu-latest
Expand All @@ -57,12 +52,11 @@ jobs:
- 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
Expand All @@ -71,8 +65,6 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: test
Expand All @@ -86,50 +78,10 @@ jobs:
- 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_no_std:
name: Nightly tests canon_host 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 --features canon_host
- uses: actions-rs/cargo@v1
with:
comand: test
args: --release --no-default-features --features canon_host

fmt:
name: Rustfmt
Expand All @@ -139,8 +91,6 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2020-10-25
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.21.0] - 2021-07-05
### Added

- Add integration tests with examples of custom walker iterators [#134](https://github.com/dusk-network/poseidon252/issues/134)
- Add `persistance` feature to the crate [#151](https://github.com/dusk-network/poseidon252/issues/151)
- Add `truncated` module in sponge to deal with scalar conversions [#153](https://github.com/dusk-network/poseidon252/issues/153)

### Changed

- Change the tree logic to be compatible with `microkelvin v0.9` [#151](https://github.com/dusk-network/poseidon252/issues/151)
- Changed toolchain-file version to nightly-2021-06-06 [#149](https://github.com/dusk-network/poseidon252/issues/149)
- Change featureset config for the crate [#138](https://github.com/dusk-network/poseidon252/issues/138)
- Update `error` module to be no_std compatible [#132](https://github.com/dusk-network/poseidon252/issues/132)
- Update to latest `dusk-poseidon`, `dusk-bls12_381` and `dusk-jubjub` [#126](https://github.com/dusk-network/poseidon252/issues/126)
- Update to latest `microkelvin v0.9`, `nstack v0.9` and `canonical v0.6` [#125](https://github.com/dusk-network/poseidon252/issues/125)
- Update randomness provider to `rand_core` [#127](https://github.com/dusk-network/poseidon252/issues/127)
- Change trait bound system for `PoseidonTree` [#125](https://github.com/dusk-network/poseidon252/issues/125)
- Update `PoseidonTreeAnnotation` to be an autotrait [#125](https://github.com/dusk-network/poseidon252/issues/125)
- Update feature system for the crate [#138](https://github.com/dusk-network/poseidon252/issues/138)
- Change `PoseidonLeaf` getter methods to return refs [#143](https://github.com/dusk-network/poseidon252/issues/143)

### Removed
- Remove `anyhow` and `thiserror` from deps [#132](https://github.com/dusk-network/poseidon252/issues/132)
- Remove `PoseidonWalkableIterator` and `PoseidonWalkableAnnotation` [#125](https://github.com/dusk-network/poseidon252/issues/125)
- Remove `canon_host` feature checks from CI [#136](https://github.com/dusk-network/poseidon252/issues/136)
- Remove `anyhow` and `thiserror` usage [#132](https://github.com/dusk-network/poseidon252/issues/132)
- Remove `microkelvin` requirements from Tree [#146](https://github.com/dusk-network/Poseidon252/issues/146)

### Fixed

- Fix Readme.md import from lib.rs [#148](https://github.com/dusk-network/poseidon252/issues/148)

## [0.20.0] - 2021-04-06

### Changed
Expand Down
37 changes: 14 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dusk-poseidon"
version = "0.20.0"
version = "0.21.0"
authors = [
"zer0 <[email protected]>", "vlopes11 <[email protected]>", "CPerezz <[email protected]>", "Kristoffer Ström <[email protected]>"
]
Expand All @@ -12,34 +12,28 @@ license = "MPL-2.0"
repository = "https://github.com/dusk-network/poseidon252"

[dependencies]
dusk-bls12_381 = {version = "0.6", default-features = false}
dusk-jubjub = {version = "0.8", default-features = false}
dusk-bls12_381 = {version = "0.8", default-features = false}
dusk-jubjub = {version = "0.10", default-features = false}
dusk-bytes = "0.1"
dusk-hades = { version = "0.15", default-features = false }
canonical = {version = "0.5", optional = true}
canonical_derive = {version = "0.5", optional = true}
microkelvin = {version = "0.6", optional = true}
nstack = {version = "0.7", optional = true}

dusk-plonk = {version="0.7", default-features = false, optional = true}
anyhow = { version = "1.0", optional = true }
thiserror = { version = "1.0", optional = true }
dusk-hades = "0.16"
canonical = {version = "0.6", optional = true}
canonical_derive = {version = "0.6", optional = true}
microkelvin = {version = "0.9", optional = true}
nstack = {version = "0.9", optional = true}
dusk-plonk = {version="0.8", default-features = false, features = ["alloc"]}

[dev-dependencies]
canonical_host = "0.5"
rand = "0.7"
rand_core = {version="0.6", default-features=false}
criterion = "0.3"

[features]
default = ["std"]
default = ["std", "canon"]
alloc = []
std = [
"dusk-hades/default",
"dusk-plonk/default",
"dusk-hades/plonk-std",
"dusk-bls12_381/default",
"dusk-jubjub/std",
"dusk-plonk",
"anyhow",
"thiserror"
]
canon = [
"dusk-bls12_381/canon",
Expand All @@ -50,10 +44,7 @@ canon = [
"nstack",
"alloc"
]
canon_host = [
"canon",
"canonical/host"
]
persistance = ["microkelvin/persistance"]

[profile.dev]
opt-level = 3
Expand Down
30 changes: 13 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,13 @@ majority of the configurations that the user may need:

### Zero Knowledge Merkle Opening Proof example:

```no_run
#[cfg(all(feature = "canon", feature = "std"))]
```rust
#[cfg(feature = "canon")]
{
use anyhow::Result;
use canonical::Canon;
use canonical_derive::Canon;
use canonical_host::MemStore;
use dusk_plonk::prelude::*;
use dusk_poseidon::tree::{PoseidonAnnotation, PoseidonLeaf, PoseidonTree, merkle_opening};
use rand_core::OsRng;

// Constant depth of the merkle tree
const DEPTH: usize = 17;
Expand All @@ -100,15 +97,15 @@ impl From<u64> for DataLeaf {
}

// Any leaf of the poseidon tree must implement `PoseidonLeaf`
impl PoseidonLeaf<MemStore> for DataLeaf {
impl PoseidonLeaf for DataLeaf {
// Cryptographic hash of the data leaf
fn poseidon_hash(&self) -> BlsScalar {
self.data
}

// Position on the tree
fn pos(&self) -> u64 {
self.pos
fn pos(&self) -> &u64 {
&self.pos
}

// Method used to set the position on the tree after the `PoseidonTree::push` call
Expand All @@ -117,13 +114,13 @@ impl PoseidonLeaf<MemStore> for DataLeaf {
}
}

fn main() -> Result<()> {
fn main() -> Result<(), Error> {
// Create the ZK keys
let pub_params = PublicParameters::setup(1 << 15, &mut rand::thread_rng())?;
let pub_params = PublicParameters::setup(1 << 15, &mut OsRng)?;
let (ck, ok) = pub_params.trim(1 << 15)?;

// Instantiate a new tree with the MemStore implementation
let mut tree: PoseidonTree<DataLeaf, PoseidonAnnotation, MemStore, DEPTH> =
// Instantiate a new tree
let mut tree: PoseidonTree<DataLeaf, PoseidonAnnotation, DEPTH> =
PoseidonTree::new();

// Append 1024 elements to the tree
Expand All @@ -135,9 +132,9 @@ fn main() -> Result<()> {
// Create a merkle opening tester gadget
let gadget_tester =
|composer: &mut StandardComposer,
tree: &PoseidonTree<DataLeaf, PoseidonAnnotation, MemStore, DEPTH>,
tree: &PoseidonTree<DataLeaf, PoseidonAnnotation, DEPTH>,
n: usize| {
let branch = tree.branch(n).unwrap().unwrap();
let branch = tree.branch(n as u64).unwrap().unwrap();
let root = tree.root().unwrap();

let root_p = merkle_opening::<DEPTH>(composer, &branch);
Expand Down Expand Up @@ -171,11 +168,10 @@ fn main() -> Result<()> {

The canonical implementations aim to make available a single representation of the Merkle tree to constrained (referred to as "hosted") and unconstrained (referred to as "host") environments.

For that, we rely on the features `canon` and `canon_host`.
For that, we rely on the feature `canon`.

`canon` feature will require all the crates needed for the Merkle tree to function.

`canon_host` feature will require `canon`, with the addition of the host environment implementations.

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly
nightly-2021-06-06
4 changes: 1 addition & 3 deletions src/cipher/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

use crate::Error;

#[cfg(feature = "canon")]
use canonical::Canon;
#[cfg(feature = "canon")]
use canonical_derive::Canon;

Expand Down Expand Up @@ -140,7 +138,7 @@ impl PoseidonCipher {
&self,
secret: &JubJubAffine,
nonce: &BlsScalar,
) -> Result<[BlsScalar; MESSAGE_CAPACITY], Error<()>> {
) -> Result<[BlsScalar; MESSAGE_CAPACITY], Error> {
let zero = BlsScalar::zero();
let mut strategy = ScalarStrategy::new();

Expand Down
9 changes: 3 additions & 6 deletions src/cipher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
//! use dusk_bls12_381::BlsScalar;
//! use dusk_jubjub::{dhke, JubJubExtended, JubJubScalar, GENERATOR};
//! use dusk_poseidon::cipher::PoseidonCipher;
//! use rand_core::OsRng;
//!
//! fn sender(
//! sender_secret: &JubJubScalar,
Expand All @@ -35,7 +36,7 @@
//! let shared_secret = dhke(sender_secret, receiver_public);
//!
//! // Generate a random nonce that will be public
//! let nonce = BlsScalar::random(&mut rand::thread_rng());
//! let nonce = BlsScalar::random(&mut OsRng);
//!
//! // Encrypt the message
//! let cipher = PoseidonCipher::encrypt(&message, &shared_secret, &nonce);
Expand All @@ -58,7 +59,7 @@
//! .expect("Failed to decrypt!")
//! }
//!
//! let mut rng = rand::thread_rng();
//! let mut rng = OsRng;
//!
//! // Generate a secret and a public key for Bob
//! let bob_secret = JubJubScalar::random(&mut rng);
Expand Down Expand Up @@ -89,10 +90,6 @@ mod cipher;
#[cfg(test)]
mod tests;

#[cfg(feature = "std")]
mod zk;

pub use cipher::PoseidonCipher;

#[cfg(feature = "std")]
pub use zk::{decrypt, encrypt};
Loading

0 comments on commit e0db9ac

Please sign in to comment.