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 #84 from dusk-network/mocello/update-dep
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
moCello authored Oct 12, 2023
2 parents c3497cd + 2f76524 commit 81bb680
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 48 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/dusk_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ jobs:
command: test
args: --release

test_nightly_canon:
name: Nightly tests canon
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
- uses: actions-rs/cargo@v1
with:
command: test
args: --release --features canon

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

## [Unreleased]

### Changed

- Update `dusk-poseidon` from `0.30` to `0.31`
- Update `dusk-jubjub` from `0.12` to `0.13`

### Removed

- Remove `canonical` dependencies and features

## [0.12.0] - 2023-06-28

### Changed

- Update `dusk-poseidon` from `0.28` to `0.30`
- Update `rust-toolchain` from `nightly-2022-08-08` to `nightly-2023-05-22`

Expand Down
11 changes: 2 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ exclude = [".github/workflows/ci.yml", ".gitignore"]
rand_core = { version = "0.6", default-features = false }
dusk-bytes = "0.1"
subtle = { version = "^2.2.1", default-features = false }
dusk-jubjub = { version = "0.12", default-features = false }
dusk-poseidon = { version = "0.30", default-features = false }
canonical = { version = "0.7", optional = true }
canonical_derive = { version = "0.7", optional = true }
dusk-jubjub = { version = "0.13", default-features = false }
dusk-poseidon = { version = "0.31", default-features = false }
rkyv = { version = "0.7", optional = true, default-features = false }
bytecheck = { version = "0.6", optional = true, default-features = false }

Expand All @@ -27,9 +25,4 @@ rand_core = { version = "0.6", default-features = false, features = ["getrandom"
sha2 = "0.8"

[features]
canon = [
"canonical",
"canonical_derive",
"dusk-jubjub/canon"
]
rkyv-impl = ["dusk-jubjub/rkyv-impl", "rkyv", "bytecheck"]
17 changes: 9 additions & 8 deletions src/keys/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ use crate::{JubJubAffine, JubJubExtended};
use dusk_bytes::{Error, HexDebug, Serializable};
use dusk_jubjub::GENERATOR_EXTENDED;

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

#[cfg(feature = "rkyv-impl")]
use rkyv::{Archive, Deserialize, Serialize};

/// Structure repesenting a [`PublicKey`]
#[derive(Default, Copy, Clone, HexDebug)]
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(
feature = "rkyv-impl",
derive(Archive, Serialize, Deserialize),
Expand All @@ -35,9 +31,9 @@ impl From<&SecretKey> for PublicKey {

impl PartialEq for PublicKey {
fn eq(&self, other: &Self) -> bool {
self.0.get_x() * other.0.get_z() == other.0.get_x() * self.0.get_z()
&& self.0.get_y() * other.0.get_z()
== other.0.get_y() * self.0.get_z()
self.0.get_u() * other.0.get_z() == other.0.get_u() * self.0.get_z()
&& self.0.get_v() * other.0.get_z()
== other.0.get_v() * self.0.get_z()
}
}

Expand Down Expand Up @@ -69,7 +65,12 @@ impl Serializable<32> for PublicKey {
}

fn from_bytes(bytes: &[u8; 32]) -> Result<Self, Error> {
Ok(Self(JubJubAffine::from_bytes(bytes)?.into()))
let public_key: JubJubAffine =
match JubJubAffine::from_bytes(*bytes).into() {
Some(pk) => pk,
None => return Err(Error::InvalidData),
};
Ok(Self(public_key.into()))
}
}

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

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

#[cfg(feature = "rkyv-impl")]
use rkyv::{Archive, Deserialize, Serialize};

/// Structure repesenting a secret key
#[allow(non_snake_case)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, HexDebug)]
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(
feature = "rkyv-impl",
derive(Archive, Serialize, Deserialize),
Expand Down Expand Up @@ -64,6 +60,10 @@ impl Serializable<32> for SecretKey {
}

fn from_bytes(bytes: &[u8; 32]) -> Result<Self, Error> {
Ok(Self(JubJubScalar::from_bytes(bytes)?))
let secret_key = match JubJubScalar::from_bytes(bytes).into() {
Some(sk) => sk,
None => return Err(Error::InvalidData),
};
Ok(Self(secret_key))
}
}
4 changes: 0 additions & 4 deletions src/keys/spend/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ use crate::{

use super::secret::SecretSpendKey;

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

#[cfg(feature = "rkyv-impl")]
use rkyv::{Archive, Deserialize, Serialize};

Expand All @@ -23,7 +20,6 @@ use subtle::{Choice, ConstantTimeEq};

/// Public pair of `a·G` and `b·G` defining a [`PublicSpendKey`]
#[derive(HexDebug, Clone, Copy)]
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(
feature = "rkyv-impl",
derive(Archive, Serialize, Deserialize),
Expand Down
4 changes: 0 additions & 4 deletions src/keys/spend/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ use crate::{permutation, JubJubScalar, SecretKey, ViewKey};
use super::public::PublicSpendKey;
use super::stealth::StealthAddress;

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

#[cfg(feature = "rkyv-impl")]
use rkyv::{Archive, Deserialize, Serialize};

Expand All @@ -22,7 +19,6 @@ use subtle::{Choice, ConstantTimeEq};

/// Secret pair of `a` and `b` defining a [`SecretSpendKey`]
#[derive(Clone, Copy, Eq, HexDebug)]
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(
feature = "rkyv-impl",
derive(Archive, Serialize, Deserialize),
Expand Down
3 changes: 0 additions & 3 deletions src/keys/spend/stealth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

use crate::{JubJubAffine, JubJubExtended, PublicKey};

#[cfg(feature = "canon")]
use canonical_derive::Canon;
use dusk_bytes::{DeserializableSlice, Error, HexDebug, Serializable};

use subtle::{Choice, ConstantTimeEq};
Expand All @@ -20,7 +18,6 @@ use rkyv::{Archive, Deserialize, Serialize};
/// A `StealthAddress` is composed by a one-time public key (`pk_r`, the actual
// address) and a random point `R`.
#[derive(Default, HexDebug, Clone, Copy)]
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(
feature = "rkyv-impl",
derive(Archive, Serialize, Deserialize),
Expand Down
4 changes: 2 additions & 2 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ fn partial_eq_pk() {
+ dusk_jubjub::GENERATOR_EXTENDED * s.4;

// Assert none of the points coordinates actually matches
assert_ne!(left.get_x(), right.get_x());
assert_ne!(left.get_y(), right.get_y());
assert_ne!(left.get_u(), right.get_u());
assert_ne!(left.get_v(), right.get_v());
assert_ne!(left.get_z(), right.get_z());

assert_eq!(JubJubAffine::from(right), JubJubAffine::from(left));
Expand Down

0 comments on commit 81bb680

Please sign in to comment.