@@ -170,6 +170,30 @@ pub trait IDkgProtocol {
170
170
///
171
171
/// For resharing or multiplication, the relevant previous dealings
172
172
/// must have been loaded via prior calls to `load_transcript`.
173
+ ///
174
+ /// # Errors
175
+ /// * [`IDkgCreateDealingError::NotADealer`] if the current node is not specified as a dealer
176
+ /// in `params`.
177
+ /// * [`IDkgCreateDealingError::MalformedPublicKey`] if the public key in the registry of any
178
+ /// of the receivers specified in `params` is malformed.
179
+ /// * [`IDkgCreateDealingError::PublicKeyNotFound`] if the public key of any of the receivers
180
+ /// specified in `params` is not found in the registry.
181
+ /// * [`IDkgCreateDealingError::UnsupportedAlgorithm`] if the public key in the registry of any
182
+ /// of the receivers specified in `params` has an unsupported algorithm.
183
+ /// * [`IDkgCreateDealingError::RegistryError`] if there was an error retrieving the public key
184
+ /// of any of the receivers specified in `params` from the registry.
185
+ /// * [`IDkgCreateDealingError::SerializationError`] if there was an error deserializing the
186
+ /// internal iDKG transcript in `params.operation_type`, or an error serializing the created
187
+ /// dealing.
188
+ /// * [`IDkgCreateDealingError::SignatureError`] if there was an error signing the created
189
+ /// dealing.
190
+ /// * [`IDkgCreateDealingError::InternalError`] if there was an internal error creating the
191
+ /// dealing, likely due to invalid input.
192
+ /// * [`IDkgCreateDealingError::SecretSharesNotFound`] if the secret shares necessary for
193
+ /// creating the dealing could not be found in the canister secret key store. Calling
194
+ /// [`IDkgProtocol::load_transcript`] may be necessary.
195
+ /// * [`IDkgCreateDealingError::TransientInternalError`] if there was a transient internal
196
+ /// error, e.g., when communicating with the remote CSP vault.
173
197
fn create_dealing (
174
198
& self ,
175
199
params : & IDkgTranscriptParams ,
@@ -181,10 +205,10 @@ pub trait IDkgProtocol {
181
205
/// and it verifies the optional contextual proof.
182
206
///
183
207
/// # Errors
184
- /// * `IDkgVerifyDealingPublicError::TranscriptIdMismatch` if the transcript ID in the `params`
208
+ /// * [ `IDkgVerifyDealingPublicError::TranscriptIdMismatch`] if the transcript ID in the `params`
185
209
/// is different from the one included in the dealing.
186
- /// * `IDkgVerifyDealingPublicError::InvalidDealing` if the internal dealing is invalid.
187
- /// * `IDkgVerifyDealingPublicError::InvalidSignature` if the signature on the dealing is invalid.
210
+ /// * [ `IDkgVerifyDealingPublicError::InvalidDealing`] if the internal dealing is invalid.
211
+ /// * [ `IDkgVerifyDealingPublicError::InvalidSignature`] if the signature on the dealing is invalid.
188
212
fn verify_dealing_public (
189
213
& self ,
190
214
params : & IDkgTranscriptParams ,
@@ -204,21 +228,21 @@ pub trait IDkgProtocol {
204
228
/// Otherwise, calling this method may result in a security vulnerability!
205
229
///
206
230
/// # Errors
207
- /// * `IDkgVerifyDealingPrivateError::NotAReceiver` if the caller isn't in the
231
+ /// * [ `IDkgVerifyDealingPrivateError::NotAReceiver`] if the caller isn't in the
208
232
/// dealing's receivers. Only receivers can perform private verification of dealings.
209
- /// * `IDkgVerifyDealingPrivateError::InvalidDealing` if the decrypted shares are not consistent
233
+ /// * [ `IDkgVerifyDealingPrivateError::InvalidDealing`] if the decrypted shares are not consistent
210
234
/// with polynomial commitment.
211
- /// * `IDkgVerifyDealingPrivateError::InvalidArgument` if some argument cannot be parsed correctly.
212
- /// * `IDkgVerifyDealingPrivateError::PrivateKeyNotFound` if the secret key store of the node
235
+ /// * [ `IDkgVerifyDealingPrivateError::InvalidArgument`] if some argument cannot be parsed correctly.
236
+ /// * [ `IDkgVerifyDealingPrivateError::PrivateKeyNotFound`] if the secret key store of the node
213
237
/// does not contain the secret key necessary to decrypt the ciphertext.
214
- /// * `IDkgVerifyDealingPrivateError::RegistryError` if the registry client returned an error.
215
- /// * `IDkgVerifyDealingPrivateError::PublicKeyNotInRegistry` if the encryption key of the
238
+ /// * [ `IDkgVerifyDealingPrivateError::RegistryError`] if the registry client returned an error.
239
+ /// * [ `IDkgVerifyDealingPrivateError::PublicKeyNotInRegistry`] if the encryption key of the
216
240
/// receiver is not in the registry.
217
- /// * `IDkgVerifyDealingPrivateError::MalformedPublicKey` if the public key of one of the receivers
241
+ /// * [ `IDkgVerifyDealingPrivateError::MalformedPublicKey`] if the public key of one of the receivers
218
242
/// is not well formed.
219
- /// * `IDkgVerifyDealingPrivateError::UnsupportedAlgorithm` if the `params.algorithm_id` is not supported
220
- /// * `IDkgVerifyDealingPrivateError::InternalError` if the an internal error occurs.
221
- /// * `IDkgVerifyDealingPrivateError::CspVaultRpcError` if there is an RPC error reported when
243
+ /// * [ `IDkgVerifyDealingPrivateError::UnsupportedAlgorithm`] if the `params.algorithm_id` is not supported
244
+ /// * [ `IDkgVerifyDealingPrivateError::InternalError`] if the an internal error occurs.
245
+ /// * [ `IDkgVerifyDealingPrivateError::CspVaultRpcError`] if there is an RPC error reported when
222
246
/// connecting with the vault.
223
247
fn verify_dealing_private (
224
248
& self ,
@@ -233,9 +257,9 @@ pub trait IDkgProtocol {
233
257
/// * public dealing verification is successful for all dealings in `initial_dealings`
234
258
///
235
259
/// # Errors
236
- /// * `IDkgVerifyInitialDealingsError::MismatchingTranscriptParams` if the
260
+ /// * [ `IDkgVerifyInitialDealingsError::MismatchingTranscriptParams`] if the
237
261
/// `params` are equal to the params of `initial_dealings`.
238
- /// * `IDkgVerifyInitialDealingsError::PublicVerificationFailure` if public
262
+ /// * [ `IDkgVerifyInitialDealingsError::PublicVerificationFailure`] if public
239
263
/// dealing verification fails for some dealing in `initial_dealings`.
240
264
fn verify_initial_dealings (
241
265
& self ,
@@ -250,6 +274,25 @@ pub trait IDkgProtocol {
250
274
/// * Checks that the multisignature was computed by at least
251
275
/// `IDkgTranscriptParams::verification_threshold` receivers
252
276
/// * Verifies the (combined) multisignature
277
+ ///
278
+ /// # Errors
279
+ /// * [`IDkgCreateTranscriptError::SerializationError`] if there was an error deserializing the
280
+ /// internal iDKG transcript in `params.operation_type`; if there was an error deserializing
281
+ /// the internal dealings from the signed `dealings`; or if there was an error serializing
282
+ /// the created transcript.
283
+ /// * [`IDkgCreateTranscriptError::InternalError`] if there was an internal error creating the
284
+ /// transcript, likely due to invalid input.
285
+ /// * [`IDkgCreateTranscriptError::DealerNotAllowed`] if a `NodeId` of a dealer in `dealings`
286
+ /// is not included in the list of allowed dealers in `params`.
287
+ /// * [`IDkgCreateTranscriptError::SignerNotAllowed`] if a `NodeId` of a signer in `dealings`
288
+ /// is not included in the list of allowed receivers in `params`.
289
+ /// * [`IDkgCreateTranscriptError::UnsatisfiedCollectionThreshold`] if the number of `dealings`
290
+ /// is less than the collection threshold specified in `params`.
291
+ /// * [`IDkgCreateTranscriptError::UnsatisfiedVerificationThreshold`] if the number of signers
292
+ /// in any dealing in `dealings` is less than the verification threshold specified in
293
+ /// `params`.
294
+ /// * [`IDkgCreateTranscriptError::InvalidSignatureBatch`] if there was an error verifying any
295
+ /// of the signatures in any of the dealings in `dealings`.
253
296
fn create_transcript (
254
297
& self ,
255
298
params : & IDkgTranscriptParams ,
@@ -260,6 +303,18 @@ pub trait IDkgProtocol {
260
303
///
261
304
/// Also checks that each multisignature was computed by at least
262
305
/// `IDkgTranscriptParams::verification_threshold` receivers.
306
+ ///
307
+ /// # Errors
308
+ /// * [`IDkgVerifyTranscriptError::InvalidArgument`] if there was an error verifying the
309
+ /// transcript due to invalid arguments, e.g., an invalid algorithm, insufficient number of
310
+ /// dealings, an unexpected commitment type wrt. the dealing type, etc.
311
+ /// * [`IDkgVerifyTranscriptError::InvalidDealingSignatureBatch`] if there was an error
312
+ /// verifying any of the signatures in any of the dealings in `dealings`.
313
+ /// * [`IDkgVerifyTranscriptError::SerializationError`] if there was an error deserializing the
314
+ /// internal transcript in `transcript`, or if there was an error deserializing any of the
315
+ /// internal dealings in the verified dealings in `transcript`.
316
+ /// * [`IDkgVerifyTranscriptError::InvalidTranscript`] if the re-creation of an internal
317
+ /// transcript does not match the internal transcript in `transcript`.
263
318
fn verify_transcript (
264
319
& self ,
265
320
params : & IDkgTranscriptParams ,
@@ -277,9 +332,33 @@ pub trait IDkgProtocol {
277
332
/// * Stores the recombined secret in the local canister secret key store
278
333
///
279
334
/// # Returns
280
- /// * `Ok([])` if decryption succeeded
335
+ /// * `Ok([])` if decryption succeeded, if the secret share had already been stored in the
336
+ /// canister secret keystore, or if this node is not a receiver of the `transcript`.
281
337
/// * `Ok(Vec<IDkgComplaints>)` if some dealings require Openings
282
- /// * `Err` if a fatal error occurred
338
+ ///
339
+ /// # Errors
340
+ /// * [`IDkgLoadTranscriptError::InvalidArguments`] if there was an error decrypting
341
+ /// ciphertexts, or an error combining openings.
342
+ /// * [`IDkgLoadTranscriptError::PublicKeyNotFound`] if the public key of this receiver was not
343
+ /// found in the registry.
344
+ /// * [`IDkgLoadTranscriptError::SerializationError`] if there was an error deserializing a
345
+ /// dealing from the signed and verified dealings in `transcript`; if there was an error
346
+ /// deserializing the internal transcript in `transcript`; if there was an error
347
+ /// serializing any of the generated internal complaints; if there was an error deserializing
348
+ /// the `MEGaPublicKeySet` from the secret keystore, or if the key with the computed `KeyId`
349
+ /// was not of the expected type.
350
+ /// * [`IDkgLoadTranscriptError::PrivateKeyNotFound`] if the private key corresponding to this
351
+ /// receiver's public key was not found in the canister secret keystore.
352
+ /// * [`IDkgLoadTranscriptError::InternalError`] if there was an internal error while loading
353
+ /// the transcript, e.g., an error writing to the canister secret keystore.
354
+ /// * [`IDkgLoadTranscriptError::MalformedPublicKey`] if this receiver's public key in the
355
+ /// registry is malformed.
356
+ /// * [`IDkgLoadTranscriptError::UnsupportedAlgorithm`] if this receiver's public key in the
357
+ /// registry has an unsupported algorithm.
358
+ /// * [`IDkgLoadTranscriptError::RegistryError`] if there was an error retrieving this
359
+ /// receiver's public key from the registry.
360
+ /// * [`IDkgLoadTranscriptError::TransientInternalError`] if there was a transient internal
361
+ /// error, e.g., when communicating with the remote CSP vault.
283
362
fn load_transcript (
284
363
& self ,
285
364
transcript : & IDkgTranscript ,
@@ -296,31 +375,31 @@ pub trait IDkgProtocol {
296
375
/// polynomial commitment.
297
376
///
298
377
/// # Errors
299
- /// * `IDkgVerifyComplaintError::InvalidComplaint` if the complaint is invalid.
300
- /// * `IDkgVerifyComplaintError::InvalidArguments` if one or more arguments
378
+ /// * [ `IDkgVerifyComplaintError::InvalidComplaint`] if the complaint is invalid.
379
+ /// * [ `IDkgVerifyComplaintError::InvalidArguments`] if one or more arguments
301
380
/// are invalid.
302
- /// * `IDkgVerifyComplaintError::InvalidArgumentsMismatchingTranscriptIDs` if
381
+ /// * [ `IDkgVerifyComplaintError::InvalidArgumentsMismatchingTranscriptIDs`] if
303
382
/// the transcript IDs in the transcript and the complaint do not match (i.e.,
304
383
/// are not equal).
305
- /// * `IDkgVerifyComplaintError::InvalidArgumentsMissingDealingInTranscript`
384
+ /// * [ `IDkgVerifyComplaintError::InvalidArgumentsMissingDealingInTranscript`]
306
385
/// if the (verified) dealings in the transcript do not contain a dealing
307
386
/// whose dealer ID matches the complaint's dealer ID.
308
- /// * `IDkgVerifyComplaintError::InvalidArgumentsMissingComplainerInTranscript`
387
+ /// * [ `IDkgVerifyComplaintError::InvalidArgumentsMissingComplainerInTranscript`]
309
388
/// if the transcript's receivers do not contain a receiver whose ID matches
310
389
/// the complaint's complainer ID.
311
- /// * `IDkgVerifyComplaintError::ComplainerPublicKeyNotInRegistry` if the
390
+ /// * [ `IDkgVerifyComplaintError::ComplainerPublicKeyNotInRegistry`] if the
312
391
/// complainer's (MEGa) public key cannot be found in the registry.
313
- /// * `IDkgVerifyComplaintError::MalformedComplainerPublicKey` if the
392
+ /// * [ `IDkgVerifyComplaintError::MalformedComplainerPublicKey`] if the
314
393
/// complainer's (MEGa) public key fetched from the registry is malformed.
315
- /// * `IDkgVerifyComplaintError::UnsupportedComplainerPublicKeyAlgorithm` if
394
+ /// * [ `IDkgVerifyComplaintError::UnsupportedComplainerPublicKeyAlgorithm`] if
316
395
/// the algorithm of the complainer's (MEGa) public key in the registry is
317
396
/// not supported.
318
- /// * `IDkgVerifyComplaintError::SerializationError` if the (internal raw)
397
+ /// * [ `IDkgVerifyComplaintError::SerializationError`] if the (internal raw)
319
398
/// complaint cannot be deserialized, or if the dealing corresponding to the
320
399
/// complaint's dealer ID cannot be deserialized from the transcript.
321
- /// * `IDkgVerifyComplaintError::Registry` if the registry client returns an
400
+ /// * [ `IDkgVerifyComplaintError::Registry`] if the registry client returns an
322
401
/// error, e.g., because the transcript's `registry_version` is not available.
323
- /// * `IDkgVerifyComplaintError::InternalError` if an internal error occurred
402
+ /// * [ `IDkgVerifyComplaintError::InternalError`] if an internal error occurred
324
403
/// during the verification.
325
404
fn verify_complaint (
326
405
& self ,
@@ -331,6 +410,23 @@ pub trait IDkgProtocol {
331
410
332
411
/// Generate an opening for the dealing given in `complaint`,
333
412
/// reported by `complainer_id`.
413
+ ///
414
+ /// # Errors
415
+ /// * [`IDkgOpenTranscriptError::PrivateKeyNotFound`] if the private key corresponding to this
416
+ /// receiver's public key was not found in the canister secret keystore.
417
+ /// * [`IDkgOpenTranscriptError::PublicKeyNotFound`] if the public key of this receiver was not
418
+ /// found in the registry.
419
+ /// * [`IDkgOpenTranscriptError::MissingDealingInTranscript`] if the `transcript` does not
420
+ /// contain a dealing with the `NodeId` of the dealer accused in the `complaint`.
421
+ /// * [`IDkgOpenTranscriptError::RegistryError`] if there was an error retrieving this
422
+ /// receiver's public key from the registry.
423
+ /// * [`IDkgOpenTranscriptError::InternalError`] if there was an internal error while verifying
424
+ /// the complaint; if there was an error serializing the internal opening; if this node is
425
+ /// not a receiver in the `transcript`; if there was an error deserializing a signed dealing;
426
+ /// or if this receiver's public key in the registry is malformed, or has an unsupported
427
+ /// algorithm.
428
+ /// * [`IDkgOpenTranscriptError::TransientInternalError`] if there was a transient internal
429
+ /// error, e.g., when communicating with the remote CSP vault.
334
430
fn open_transcript (
335
431
& self ,
336
432
transcript : & IDkgTranscript ,
@@ -340,6 +436,19 @@ pub trait IDkgProtocol {
340
436
341
437
/// Verify that an opening corresponds to the complaint,
342
438
/// and matches the commitment in the transcript.
439
+ ///
440
+ /// # Errors
441
+ /// * [`IDkgVerifyOpeningError::TranscriptIdMismatch`] if the transcript ID in the `transcript`
442
+ /// does not match the one in the `opening` and/or the `complaint`.
443
+ /// * [`IDkgVerifyOpeningError::DealerIdMismatch`] if the dealer ID in the `opening` does not
444
+ /// match the one in the `complaint`.
445
+ /// * [`IDkgVerifyOpeningError::MissingDealingInTranscript`] if the `transcript` does not
446
+ /// contain a dealing with the `NodeId` of the dealer accused in the `complaint`.
447
+ /// * [`IDkgVerifyOpeningError::MissingOpenerInReceivers`] if the ID of the `opener` does not
448
+ /// exist as a receiver in the `transcript`.
449
+ /// * [`IDkgVerifyOpeningError::InternalError`] if there was an internal error verifying the
450
+ /// `opening`; if there was an error deserializing the internal `opening`; or if there was an
451
+ /// error deserializing a signed dealing.
343
452
fn verify_opening (
344
453
& self ,
345
454
transcript : & IDkgTranscript ,
@@ -354,6 +463,30 @@ pub trait IDkgProtocol {
354
463
/// # Preconditions
355
464
/// * For each (complaint, (opener, opening)) tuple, it holds that
356
465
/// `verify_opening(transcript, opener, opening, complaint).is_ok()`
466
+ ///
467
+ /// # Errors
468
+ /// * [`IDkgLoadTranscriptError::InsufficientOpenings`] if, in any of the complaints, there are
469
+ /// less openings than the reconstruction threshold specified in the `transcript`.
470
+ /// * [`IDkgLoadTranscriptError::InvalidArguments`] if there was an error decrypting
471
+ /// ciphertexts, or an error combining openings.
472
+ /// * [`IDkgLoadTranscriptError::PublicKeyNotFound`] if the public key of this receiver was not
473
+ /// found in the registry.
474
+ /// * [`IDkgLoadTranscriptError::SerializationError`] if there was an error deserializing a
475
+ /// dealing from the signed and verified dealings in `transcript`; if there was an error
476
+ /// deserializing the internal transcript in `transcript`; or if there was an error
477
+ /// serializing any of the generated internal complaints.
478
+ /// * [`IDkgLoadTranscriptError::PrivateKeyNotFound`] if the private key corresponding to this
479
+ /// receiver's public key was not found in the canister secret keystore.
480
+ /// * [`IDkgLoadTranscriptError::InternalError`] if there was an internal error while loading
481
+ /// the transcript, e.g., an error writing to the canister secret keystore.
482
+ /// * [`IDkgLoadTranscriptError::MalformedPublicKey`] if this receiver's public key in the
483
+ /// registry is malformed.
484
+ /// * [`IDkgLoadTranscriptError::UnsupportedAlgorithm`] if this receiver's public key in the
485
+ /// registry has an unsupported algorithm.
486
+ /// * [`IDkgLoadTranscriptError::RegistryError`] if there was an error retrieving this
487
+ /// receiver's public key from the registry.
488
+ /// * [`IDkgLoadTranscriptError::TransientInternalError`] if there was a transient internal
489
+ /// error, e.g., when communicating with the remote CSP vault.
357
490
fn load_transcript_with_openings (
358
491
& self ,
359
492
transcript : & IDkgTranscript ,
@@ -374,9 +507,9 @@ pub trait IDkgProtocol {
374
507
/// IDKG threshold keys not identified by a transcript will be removed.
375
508
///
376
509
/// # Errors
377
- /// * `IDkgRetainThresholdKeysError::InternalError` if an internal error such as
510
+ /// * [ `IDkgRetainThresholdKeysError::InternalError`] if an internal error such as
378
511
/// an RPC error communicating with a remote CSP vault occurs
379
- /// * `IDkgRetainThresholdKeysError::SerializationError` if a transcript cannot
512
+ /// * [ `IDkgRetainThresholdKeysError::SerializationError`] if a transcript cannot
380
513
/// be serialized into a key id to identify the IDKG threshold secret key
381
514
fn retain_active_transcripts (
382
515
& self ,
0 commit comments