Skip to content

Commit

Permalink
Resolve #94 (#109)
Browse files Browse the repository at this point in the history
* semantically finished

* `fmt`

* Update Cargo.toml

version bump
  • Loading branch information
skaunov committed Apr 27, 2024
1 parent 7893200 commit bb24ab0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
9 changes: 7 additions & 2 deletions rust-k256/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plume_rustcrypto"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
license = "MIT"
description = "Implementation of PLUME: nullifier friendly signature scheme on ECDSA; using the k256 library"
Expand All @@ -17,7 +17,12 @@ num-bigint = "~0.4.3"
num-integer = "~0.1.45"
k256 = {version = "~0.13.3", features = ["arithmetic", "hash2curve", "expose-field", "sha2"]}
signature = "^2.2.0"
serde = { version = "^1.0.0", features = ["derive"], optional = true }

[dev-dependencies]
hex = "0.4.3"
hex-literal = "0.3.4"
hex-literal = "0.3.4"

[features]
default = ["serde"]
serde = ["dep:serde", "k256/serde"]
6 changes: 6 additions & 0 deletions rust-k256/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ pub use k256::{AffinePoint, NonZeroScalar, SecretKey};
/// Re-exports the [`CryptoRngCore`] trait from the [`rand_core`] crate.
/// This allows it to be used from the current module.
pub use rand_core::CryptoRngCore;
#[cfg(feature = "serde")]
/// Provides the ability to serialize and deserialize data using the Serde library.
/// The `Serialize` and `Deserialize` traits from the Serde library are re-exported for convenience.
pub use serde::{Deserialize, Serialize};

mod utils;
// not published due to use of `Projective...`; these utils can be found in other crates
Expand All @@ -59,6 +63,7 @@ pub const DST: &[u8] = b"QUUX-V01-CS02-with-secp256k1_XMD:SHA-256_SSWU_RO_"; //
/// Struct holding signature data for a PLUME signature.
///
/// `v1specific` field differintiate whether V1 or V2 protocol will be used.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlumeSignature {
/// The message that was signed.
pub message: Vec<u8>,
Expand All @@ -75,6 +80,7 @@ pub struct PlumeSignature {
}
/// Nested struct holding additional signature data used in variant 1 of the protocol.
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlumeSignatureV1Fields {
/// Part of the signature data, a curve point.
pub r_point: AffinePoint,
Expand Down
11 changes: 7 additions & 4 deletions rust-k256/src/randomizedsigner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ use k256::{
use signature::{Error, RandomizedSigner};

/// `PlumeSigner` is a `struct` that contains a reference to a secret key and a
/// boolean defining output [`PlumeSignature`] variant. It implements the
/// `RandomizedSigner` trait to generate signatures using the provided secret
/// key. The struct is generic over the lifetime of the secret key reference
/// so that the key can be borrowed immutably.
/// boolean defining output [`PlumeSignature`] variant.
///
/// It implements the `RandomizedSigner` trait to generate signatures using the provided secret
/// key. The struct is generic over the lifetime of the secret key reference so that the key can be borrowed immutably.
///
/// `serde` traits aren't added to this struct on purpose. It's a wrapper around [`SecretKey`] which provides variety of serialization formats (SEC1, bytes, ...).
/// Also it uses just a reference to the secret key itself, so the choices for handling the key is kept open here.
pub struct PlumeSigner<'signing> {
/// The secret key to use for signing. This is borrowed immutably.
secret_key: &'signing SecretKey,
Expand Down

0 comments on commit bb24ab0

Please sign in to comment.