mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-19 10:14:14 +00:00
33 lines
1.0 KiB
Rust
33 lines
1.0 KiB
Rust
use std::fmt::Display;
|
|
use types::{Keypair, PublicKey, Signature};
|
|
|
|
/// Signs message using an internally-maintained private key.
|
|
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))
|
|
}
|
|
*/
|
|
}
|