-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves #5
- Loading branch information
Showing
7 changed files
with
81 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) DUSK NETWORK. All rights reserved. | ||
|
||
use bls12_381_bls::{PublicKey, SecretKey, Signature, APK}; | ||
use dusk_bls12_381::BlsScalar; | ||
use zeroize::Zeroize; | ||
|
||
#[test] | ||
fn secret_key() { | ||
let secret = BlsScalar::from(42); | ||
let mut sk = SecretKey::from(secret); | ||
|
||
sk.zeroize(); | ||
assert_eq!(sk, SecretKey::default()); | ||
} | ||
|
||
#[test] | ||
fn public_key() { | ||
let sk = BlsScalar::from(42).into(); | ||
let mut pk = PublicKey::from(&sk); | ||
|
||
pk.zeroize(); | ||
assert_eq!(pk, PublicKey::default()); | ||
} | ||
|
||
#[test] | ||
fn apk() { | ||
let sk = BlsScalar::from(42).into(); | ||
let pk = PublicKey::from(&sk); | ||
let mut apk = APK::from(&pk); | ||
|
||
let sk1 = BlsScalar::from(84).into(); | ||
let pk1 = PublicKey::from(&sk1); | ||
let sk2 = BlsScalar::from(21).into(); | ||
let pk2 = PublicKey::from(&sk2); | ||
|
||
apk.aggregate(&[pk1, pk2]); | ||
|
||
apk.zeroize(); | ||
assert_eq!(apk, APK::default()); | ||
} | ||
|
||
#[test] | ||
fn signature() { | ||
let sk: SecretKey = BlsScalar::from(42).into(); | ||
let mut sig = sk.sign(&PublicKey::from(&sk), &[1, 2, 3, 4]); | ||
|
||
sig.zeroize(); | ||
assert_eq!(sig, Signature::default()); | ||
} |