Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

Commit

Permalink
Merge pull request #47 from dusk-network/release-0.7
Browse files Browse the repository at this point in the history
Release 0.7
  • Loading branch information
CPerezz authored Jul 5, 2021
2 parents 157305a + 9396d87 commit f5cfb20
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 45 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.7.0] - 2021-07-05

### Changed

- Update `canonical` from v0.5.0 to v0.6.0 [#44](https://github.com/dusk-network/dusk-pki/issues/44)
- Update `rand_core` from v0.5.0 to v0.6.0 [#44](https://github.com/dusk-network/dusk-pki/issues/44)
- Update `dusk-jubjub` from v0.8.0 to v0.10.0 [#44](https://github.com/dusk-network/dusk-pki/issues/44)
- Update `dusk-poseidon` from v0.20.0 to v0.21 [#44](https://github.com/dusk-network/dusk-pki/issues/44)
- Update `rand_core` to not use default features [#48](https://github.com/dusk-network/dusk-pki/issues/48)
- Change `permutation::hash` to use poseidon's `truncated::hash` [#50](https://github.com/dusk-network/dusk-pki/issues/50)

### Removed

- Remove `rand` from dev-dependencies [#44](https://github.com/dusk-network/dusk-pki/issues/44)

## [0.6.2] - 2021-04-06

### Changed
Expand Down
13 changes: 6 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dusk-pki"
version = "0.6.2"
version = "0.7.0"
authors = ["zer0 <[email protected]>", "Victor Lopez <[email protected]>"]
edition = "2018"

Expand All @@ -12,16 +12,15 @@ license = "MPL-2.0"
exclude = [".github/workflows/ci.yml", ".gitignore"]

[dependencies]
rand_core = "0.5"
rand_core = { version = "0.6", default-features = false }
dusk-bytes = "0.1"
subtle = {version="^2.2.1", default-features=false}
dusk-jubjub = {version="0.8", default-features=false}
dusk-poseidon = {version="0.20", default-features = false}
canonical = {version = "0.5", optional = true}
canonical_derive = {version = "0.5", optional = true}
dusk-jubjub = {version="0.10", default-features=false}
dusk-poseidon = {version="0.21", default-features = false}
canonical = {version = "0.6", optional = true}
canonical_derive = {version = "0.6", optional = true}

[dev-dependencies]
rand ="0.7"
sha2 = "0.8"

[features]
Expand Down
2 changes: 0 additions & 2 deletions src/keys/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use crate::{JubJubAffine, JubJubExtended};
use dusk_bytes::{Error, HexDebug, Serializable};
use dusk_jubjub::GENERATOR_EXTENDED;

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

Expand Down
2 changes: 0 additions & 2 deletions src/keys/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use crate::JubJubScalar;
use dusk_bytes::{Error, HexDebug, Serializable};
use rand_core::{CryptoRng, RngCore};

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

Expand Down
2 changes: 0 additions & 2 deletions src/keys/spend/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use crate::{

use super::secret::SecretSpendKey;

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

Expand Down
2 changes: 0 additions & 2 deletions src/keys/spend/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use crate::{permutation, JubJubScalar, SecretKey, ViewKey};
use super::public::PublicSpendKey;
use super::stealth::StealthAddress;

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

Expand Down
3 changes: 1 addition & 2 deletions src/keys/spend/stealth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

use crate::{JubJubAffine, JubJubExtended, PublicKey};
#[cfg(feature = "canon")]
use canonical::Canon;

#[cfg(feature = "canon")]
use canonical_derive::Canon;
use dusk_bytes::{DeserializableSlice, Error, HexDebug, Serializable};
Expand Down
7 changes: 2 additions & 5 deletions src/permutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

use crate::{JubJubExtended, JubJubScalar};

use dusk_poseidon::sponge;
use dusk_poseidon::sponge::truncated;

/// Hashes a JubJub's ExtendedPoint into a JubJub's Scalar
pub fn hash(p: &JubJubExtended) -> JubJubScalar {
let h = sponge::hash(&p.to_hash_inputs());

JubJubScalar::from_raw(h.reduce().0)
truncated::hash(&p.to_hash_inputs())
}
32 changes: 9 additions & 23 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,22 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

mod std_tests {
use dusk_bytes::ParseHexStr;
use dusk_bytes::{DeserializableSlice, ParseHexStr, Serializable};
use dusk_pki::{PublicSpendKey, SecretSpendKey, ViewKey};
use rand::SeedableRng;
fn ssk_from_str(s: &str) -> SecretSpendKey {
use rand::rngs::StdRng;
use sha2::{Digest, Sha256};

let bytes = s.as_bytes();

let mut hasher = Sha256::default();
hasher.input(bytes);
let bytes = hasher.result();

let mut seed = [0u8; 32];
seed.copy_from_slice(&bytes[..32]);

SecretSpendKey::random(&mut StdRng::from_seed(seed))
}
use rand_core::OsRng;

#[test]
fn ssk_from_bytes() {
let ssk_a = ssk_from_str("some bytes");
let ssk_b = ssk_from_str("some bytes");
let ssk_a = SecretSpendKey::random(&mut OsRng);
let bytes = ssk_a.to_bytes();
let ssk_b = SecretSpendKey::from_slice(&bytes).expect("Serde error");

assert_eq!(ssk_a, ssk_b);
}

#[test]
fn keys_encoding() {
let ssk = ssk_from_str("some bytes");
let ssk = SecretSpendKey::random(&mut OsRng);
let vk = ssk.view_key();
let psk = ssk.public_spend_key();

Expand All @@ -53,15 +39,15 @@ mod std_tests {
fn keys_consistency() {
use dusk_jubjub::{JubJubScalar, GENERATOR_EXTENDED};

let r = JubJubScalar::random(&mut rand::thread_rng());
let ssk = SecretSpendKey::random(&mut rand::thread_rng());
let r = JubJubScalar::random(&mut OsRng);
let ssk = SecretSpendKey::random(&mut OsRng);
let psk = ssk.public_spend_key();
let vk = ssk.view_key();
let sa = psk.gen_stealth_address(&r);

assert!(vk.owns(&sa));

let wrong_ssk = SecretSpendKey::random(&mut rand::thread_rng());
let wrong_ssk = SecretSpendKey::random(&mut OsRng);
let wrong_vk = wrong_ssk.view_key();

assert_ne!(ssk, wrong_ssk);
Expand Down

0 comments on commit f5cfb20

Please sign in to comment.