mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 21:08:32 +00:00
Implements Signer generic for validator client and epoch duties
This commit is contained in:
@@ -1,7 +1,32 @@
|
||||
use types::Signature;
|
||||
use std::fmt::Display;
|
||||
use types::{Keypair, PublicKey, Signature};
|
||||
|
||||
/// Signs message using an internally-maintained private key.
|
||||
pub trait Signer {
|
||||
pub trait Signer: Display + Send + Sync {
|
||||
fn sign_block_proposal(&self, message: &[u8], domain: u64) -> Option<Signature>;
|
||||
fn sign_randao_reveal(&self, message: &[u8], domain: u64) -> Option<Signature>;
|
||||
/// Returns a public key for the signer object.
|
||||
fn to_public(&self) -> PublicKey;
|
||||
}
|
||||
|
||||
/* Implements Display and Signer for Keypair */
|
||||
|
||||
impl Signer for Keypair {
|
||||
fn to_public(&self) -> PublicKey {
|
||||
self.pk.clone()
|
||||
}
|
||||
|
||||
fn sign_block_proposal(&self, message: &[u8], domain: u64) -> Option<Signature> {
|
||||
Some(Signature::new(message, domain, &self.sk))
|
||||
}
|
||||
|
||||
fn sign_randao_reveal(&self, message: &[u8], domain: u64) -> Option<Signature> {
|
||||
Some(Signature::new(message, domain, &self.sk))
|
||||
}
|
||||
|
||||
/*
|
||||
fn sign_attestation_message(&self, message: &[u8], domain: u64) -> Option<Signature> {
|
||||
Some(Signature::new(message, domain, &self.sk))
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user