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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
use crate::;
/// A trait for types capable of creating digital signatures.
///
/// The `Signer` trait provides methods for signing messages with various
/// cryptographic signature schemes. Implementations of this trait can sign
/// messages using different algorithms according to the specific signer type.
///
/// This trait is implemented by `SigningPrivateKey` for all supported signature
/// schemes.
///
/// # Examples
///
/// ```
/// use bc_components::{SignatureScheme, Signer, Verifier};
///
/// // Create a key pair using the default signature scheme (Schnorr)
/// let (private_key, public_key) = SignatureScheme::default().keypair();
///
/// // Sign a message
/// let message = b"Hello, world!";
/// let signature = private_key.sign(&message).unwrap();
///
/// // Verify the signature
/// assert!(public_key.verify(&signature, &message));
/// ```
/// A trait for types capable of verifying digital signatures.
///
/// The `Verifier` trait provides a method to verify that a signature was
/// created by a corresponding signer for a specific message. This trait is
/// implemented by `SigningPublicKey` for all supported signature schemes.
///
/// # Examples
///
/// ```ignore
/// # // Requires secp256k1 feature (enabled by default)
/// use bc_components::{SignatureScheme, Signer, Verifier};
///
/// // Create a key pair using the ECDSA signature scheme
/// let (private_key, public_key) = SignatureScheme::Ecdsa.keypair();
///
/// // Sign a message
/// let message = b"Hello, world!";
/// let signature = private_key.sign(&message).unwrap();
///
/// // Verify the signature
/// assert!(public_key.verify(&signature, &message));
///
/// // Verification should fail for a different message
/// assert!(!public_key.verify(&signature, &b"Different message"));
/// ```