-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
signature: add
Keypair
trait (#1080)
Adds a trait for types which represent a combination of both a signing key and verifying key as is common in many digital signature systems. The `Keypair` name follows Rust standard capitalization rules for the closed compound word "keypair" as commonly used in cryptography.
- Loading branch information
Showing
2 changed files
with
19 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//! Signing keypairs. | ||
use crate::{Signature, Signer, Verifier}; | ||
|
||
/// Signing keypair with an associated verifying key. | ||
/// | ||
/// This represents a type which holds both a signing key and a verifying key. | ||
pub trait Keypair<S: Signature>: AsRef<Self::VerifyingKey> + Signer<S> { | ||
/// Verifying key type for this keypair. | ||
type VerifyingKey: Verifier<S>; | ||
|
||
/// Get the verifying key which can verify signatures produced by the | ||
/// signing key portion of this keypair. | ||
fn verifying_key(&self) -> &Self::VerifyingKey { | ||
self.as_ref() | ||
} | ||
} |
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