Skip to content

Commit c0fd27f

Browse files
authored
Merge pull request #9 from encryption4all/fix/code-quality-housekeeping
chore: clippy fix, MSRV declaration, Signature PartialEq/Eq
2 parents 4f441b5 + 2db8c59 commit c0fd27f

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "ibs"
33
version = "0.4.0"
44
authors = ["Leon Botros <l.botros@cs.ru.nl>"]
55
edition = "2021"
6+
rust-version = "1.65"
67
categories = ["cryptography", "no-std", "elliptic-curve", "identity-based"]
78
description = "Identity-Based Signature schemes"
89
keywords = ["ibs", "signatures", "ecc", "no_std"]

src/gg.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub struct UserSecretKey {
8787
pub const SIG_BYTES: usize = 96;
8888

8989
/// Signature.
90-
#[derive(Debug, Clone)]
90+
#[derive(Debug, Clone, PartialEq, Eq)]
9191
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
9292
pub struct Signature {
9393
ga: RistrettoPoint,
@@ -228,7 +228,7 @@ fn h_helper(gr: &RistrettoPoint, id: &Identity) -> Scalar {
228228
let mut h = Sha3_512::new();
229229

230230
Digest::update(&mut h, gr.compress().as_bytes());
231-
Digest::update(&mut h, &id.0);
231+
Digest::update(&mut h, id.0);
232232

233233
Scalar::from_hash(h)
234234
}
@@ -447,6 +447,19 @@ mod tests {
447447
.verify(&pk_recovered, &sig_recovered, &id));
448448
}
449449

450+
#[test]
451+
fn test_signature_eq() {
452+
let (_, usk, _) = default_setup();
453+
let message = b"message under test";
454+
455+
let sig = Signer::new().chain(message).sign(&usk, &mut OsRng);
456+
let sig_clone = sig.clone();
457+
assert_eq!(sig, sig_clone);
458+
459+
let sig_other = Signer::new().chain(message).sign(&usk, &mut OsRng);
460+
assert_ne!(sig, sig_other);
461+
}
462+
450463
#[test]
451464
fn test_byte_roundtrip_public_key() {
452465
let (pk, _) = setup(&mut OsRng);

0 commit comments

Comments
 (0)