1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! Pluggable signature scheme for vote authentication.
//!
//! Each vote in the consensus protocol is authenticated by a signature over
//! its canonical encoding. The crate is agnostic to the cryptographic scheme:
//! embedders pick a concrete [`ConsensusSignatureScheme`] type that defines
//! how peers sign and how the service verifies.
//!
//! The wire layer ([`Vote::vote_owner`] and [`Vote::signature`] in the
//! protobuf) is byte-flexible; the scheme gives those bytes their meaning.
//!
//! [`ethereum::EthereumConsensusSigner`] provides a default ECDSA-secp256k1
//! implementation matching the historical behavior of the crate. It is the
//! scheme used by [`DefaultConsensusService`] but the core service is fully
//! generic — pick a different scheme to integrate Ed25519, an HSM, or any
//! other signing system.
//!
//! [`Vote::vote_owner`]: crate::protos::consensus::v1::Vote::vote_owner
//! [`Vote::signature`]: crate::protos::consensus::v1::Vote::signature
//! [`DefaultConsensusService`]: crate::service::DefaultConsensusService
use Future;
pub use EthereumConsensusSigner;
/// A signature scheme that the consensus service uses to sign and verify votes.
///
/// Implementors play two roles:
///
/// - **As a signer instance**: a value carrying private state (key material,
/// HSM handle, etc.) produces signatures via [`identity`](Self::identity)
/// and [`sign`](Self::sign). One such instance exists per peer that needs
/// to cast votes.
/// - **As a scheme type**: the type itself is used by the service to verify
/// incoming signatures via the static [`verify`](Self::verify) method.
/// Verification needs no instance — only the public bytes from the wire.
///
/// All peers on a network must agree on the scheme, since they all verify
/// each other's signatures using the same `verify` rule.
///
/// The trait inherits `Clone + Send + Sync + 'static` to mirror the
/// [`ConsensusStorage`](crate::storage::ConsensusStorage) and
/// [`ConsensusEventBus`](crate::events::ConsensusEventBus) traits — the
/// [`ConsensusService`](crate::service::ConsensusService) holds an instance
/// for the lifetime of the service and clones it when the service is cloned.
/// Error returned by [`ConsensusSignatureScheme`] operations.