@@ -148,17 +148,17 @@ impl Routing {
148
148
self . stage . state . lock ( ) . await . node ( ) . age
149
149
}
150
150
151
- /// Returns the `PublicKey` of this node.
151
+ /// Returns the ed25519 public key of this node.
152
152
pub async fn public_key ( & self ) -> PublicKey {
153
153
self . stage . state . lock ( ) . await . node ( ) . keypair . public
154
154
}
155
155
156
- /// Sign any data with the key of this node.
156
+ /// Signs any data with the ed25519 key of this node.
157
157
pub async fn sign ( & self , data : & [ u8 ] ) -> Signature {
158
158
self . stage . state . lock ( ) . await . node ( ) . keypair . sign ( data)
159
159
}
160
160
161
- /// Verify any signed data with the key of this node.
161
+ /// Verifies `signature` on ` data` with the ed25519 public key of this node.
162
162
pub async fn verify ( & self , data : & [ u8 ] , signature : & Signature ) -> bool {
163
163
self . stage
164
164
. state
@@ -291,45 +291,45 @@ impl Routing {
291
291
self . stage . clone ( ) . handle_commands ( command) . await
292
292
}
293
293
294
- /// Returns the current BLS public key set or `Error::InvalidState` if we are not joined
295
- /// yet .
294
+ /// Returns the current BLS public key set if this node has one, or
295
+ /// `Error::MissingSecretKeyShare` otherwise .
296
296
pub async fn public_key_set ( & self ) -> Result < bls:: PublicKeySet > {
297
297
self . stage
298
298
. state
299
299
. lock ( )
300
300
. await
301
301
. section_key_share ( )
302
302
. map ( |share| share. public_key_set . clone ( ) )
303
- . ok_or ( Error :: InvalidState )
303
+ . ok_or ( Error :: MissingSecretKeyShare )
304
304
}
305
305
306
- /// Returns the current BLS secret key share or `Error::InvalidState` if we are not
307
- /// elder .
308
- pub async fn secret_key_share ( & self ) -> Result < bls:: SecretKeyShare > {
306
+ /// Signs `data` with the BLS secret key share of this node, if it has any. Returns
307
+ // `Error::MissingSecretKeyShare` otherwise .
308
+ pub async fn sign_with_secret_key_share ( & self , data : & [ u8 ] ) -> Result < bls:: SignatureShare > {
309
309
self . stage
310
310
. state
311
311
. lock ( )
312
312
. await
313
313
. section_key_share ( )
314
- . map ( |share| share. secret_key_share . clone ( ) )
315
- . ok_or ( Error :: InvalidState )
314
+ . map ( |share| share. secret_key_share . sign ( data ) )
315
+ . ok_or ( Error :: MissingSecretKeyShare )
316
316
}
317
317
318
- /// Returns our section proof chain, or `None` if we are not joined yet .
318
+ /// Returns our section proof chain.
319
319
pub async fn our_history ( & self ) -> SectionProofChain {
320
320
self . stage . state . lock ( ) . await . section ( ) . chain ( ) . clone ( )
321
321
}
322
322
323
- /// Returns our index in the current BLS group or `Error::InvalidState` if section key was
324
- /// not generated yet .
323
+ /// Returns our index in the current BLS group if this node is a member of one, or
324
+ /// `Error::MissingSecretKeyShare` otherwise .
325
325
pub async fn our_index ( & self ) -> Result < usize > {
326
326
self . stage
327
327
. state
328
328
. lock ( )
329
329
. await
330
330
. section_key_share ( )
331
331
. map ( |share| share. index )
332
- . ok_or ( Error :: InvalidState )
332
+ . ok_or ( Error :: MissingSecretKeyShare )
333
333
}
334
334
}
335
335
0 commit comments