Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signature: add Keypair trait #1080

Merged
merged 1 commit into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions signature/src/keypair.rs
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()
}
}
3 changes: 2 additions & 1 deletion signature/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ pub use digest;
pub use rand_core;

mod error;
mod keypair;
mod signature;
mod signer;
mod verifier;

pub use crate::{error::*, signature::*, signer::*, verifier::*};
pub use crate::{error::*, keypair::*, signature::*, signer::*, verifier::*};