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 #17 from dusk-network/update_poseidon
Browse files Browse the repository at this point in the history
Add gate-featured Canon usage/derivation.
  • Loading branch information
CPerezz authored Nov 4, 2020
2 parents 3d52f76 + bde33c4 commit cfe35a1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dusk_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: test
args: --release
args: --release --features canon

fmt:
name: Rustfmt
Expand Down
11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
[package]
name = "dusk-pki"
version = "0.2.0"
version = "0.3.0"
authors = ["zer0 <[email protected]>", "Victor Lopez <[email protected]"]
edition = "2018"

[dependencies]
poseidon252 = { git = "https://github.com/dusk-network/Poseidon252", tag = "v0.8.0"}
dusk-jubjub = "0.3.8"
poseidon252 = { git = "https://github.com/dusk-network/Poseidon252", tag = "v0.12.0"}
dusk-jubjub = "0.4"
canonical = {version = "0.4", optional = true}
canonical_derive = {version = "0.4", optional = true}
hex = "^0.4"
rand = "^0.7"
sha2 = "0.8"
Expand All @@ -16,3 +18,6 @@ thiserror = "1.0"
[dependencies.subtle]
version = "^2.2.1"
default-features = false

[features]
canon = ["canonical", "canonical_derive", "dusk-jubjub/canon", "poseidon252/canon"]
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
stable
nightly
5 changes: 5 additions & 0 deletions src/spend/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ use crate::{
decode::decode, Error, JubJubAffine, JubJubExtended, JubJubScalar,
};

#[cfg(feature = "canon")]
use canonical::Canon;
#[cfg(feature = "canon")]
use canonical_derive::Canon;
use dusk_jubjub::GENERATOR_EXTENDED;
use std::convert::TryFrom;
use std::fmt;
use subtle::{Choice, ConstantTimeEq};

/// Public pair of `a·G` and `b·G`
#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "canon", derive(Canon))]
pub struct PublicKey {
A: JubJubExtended,
B: JubJubExtended,
Expand Down
5 changes: 5 additions & 0 deletions src/spend/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ use dusk_jubjub::GENERATOR_EXTENDED;

use std::fmt;

#[cfg(feature = "canon")]
use canonical::Canon;
#[cfg(feature = "canon")]
use canonical_derive::Canon;
use rand::rngs::StdRng;
use rand::SeedableRng;
use rand::{CryptoRng, RngCore};
use sha2::{Digest, Sha256};

/// Secret pair of `a` and `b`
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "canon", derive(Canon))]
pub struct SecretKey {
a: JubJubScalar,
b: JubJubScalar,
Expand Down
5 changes: 5 additions & 0 deletions src/spend/stealth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

use crate::{decode::decode, Error, JubJubAffine, JubJubExtended};

#[cfg(feature = "canon")]
use canonical::Canon;
#[cfg(feature = "canon")]
use canonical_derive::Canon;
use std::convert::{TryFrom, TryInto};
use std::fmt;
use subtle::{Choice, ConstantTimeEq};
Expand All @@ -22,6 +26,7 @@ pub trait Ownable {
/// A `StealthAddress` is composed by a one-time public key (`pk_r`, the actual
// address) and a random point `R`.
#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "canon", derive(Canon))]
pub struct StealthAddress {
pub(crate) R: JubJubExtended,
pub(crate) pk_r: JubJubExtended,
Expand Down

0 comments on commit cfe35a1

Please sign in to comment.