Skip to content

Commit 45e1101

Browse files
committed
Merge branch 'mathias-CRP-1329-add-idkg-tecdsa-error-documentation' into 'master'
doc(crypto): CRP-1329: Add error documentation for IDKM functions for tECDSA Add documentation at the IDKM level for tECDSA. See merge request dfinity-lab/public/ic!13144
2 parents d12da95 + a81511a commit 45e1101

File tree

2 files changed

+163
-33
lines changed

2 files changed

+163
-33
lines changed

rs/interfaces/src/crypto/sign/canister_threshold_sig.rs

Lines changed: 163 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,30 @@ pub trait IDkgProtocol {
170170
///
171171
/// For resharing or multiplication, the relevant previous dealings
172172
/// 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.
173197
fn create_dealing(
174198
&self,
175199
params: &IDkgTranscriptParams,
@@ -181,10 +205,10 @@ pub trait IDkgProtocol {
181205
/// and it verifies the optional contextual proof.
182206
///
183207
/// # Errors
184-
/// * `IDkgVerifyDealingPublicError::TranscriptIdMismatch` if the transcript ID in the `params`
208+
/// * [`IDkgVerifyDealingPublicError::TranscriptIdMismatch`] if the transcript ID in the `params`
185209
/// 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.
188212
fn verify_dealing_public(
189213
&self,
190214
params: &IDkgTranscriptParams,
@@ -204,21 +228,21 @@ pub trait IDkgProtocol {
204228
/// Otherwise, calling this method may result in a security vulnerability!
205229
///
206230
/// # Errors
207-
/// * `IDkgVerifyDealingPrivateError::NotAReceiver` if the caller isn't in the
231+
/// * [`IDkgVerifyDealingPrivateError::NotAReceiver`] if the caller isn't in the
208232
/// 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
210234
/// 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
213237
/// 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
216240
/// 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
218242
/// 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
222246
/// connecting with the vault.
223247
fn verify_dealing_private(
224248
&self,
@@ -233,9 +257,9 @@ pub trait IDkgProtocol {
233257
/// * public dealing verification is successful for all dealings in `initial_dealings`
234258
///
235259
/// # Errors
236-
/// * `IDkgVerifyInitialDealingsError::MismatchingTranscriptParams` if the
260+
/// * [`IDkgVerifyInitialDealingsError::MismatchingTranscriptParams`] if the
237261
/// `params` are equal to the params of `initial_dealings`.
238-
/// * `IDkgVerifyInitialDealingsError::PublicVerificationFailure` if public
262+
/// * [`IDkgVerifyInitialDealingsError::PublicVerificationFailure`] if public
239263
/// dealing verification fails for some dealing in `initial_dealings`.
240264
fn verify_initial_dealings(
241265
&self,
@@ -250,6 +274,25 @@ pub trait IDkgProtocol {
250274
/// * Checks that the multisignature was computed by at least
251275
/// `IDkgTranscriptParams::verification_threshold` receivers
252276
/// * 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`.
253296
fn create_transcript(
254297
&self,
255298
params: &IDkgTranscriptParams,
@@ -260,6 +303,18 @@ pub trait IDkgProtocol {
260303
///
261304
/// Also checks that each multisignature was computed by at least
262305
/// `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`.
263318
fn verify_transcript(
264319
&self,
265320
params: &IDkgTranscriptParams,
@@ -277,9 +332,33 @@ pub trait IDkgProtocol {
277332
/// * Stores the recombined secret in the local canister secret key store
278333
///
279334
/// # 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`.
281337
/// * `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.
283362
fn load_transcript(
284363
&self,
285364
transcript: &IDkgTranscript,
@@ -296,31 +375,31 @@ pub trait IDkgProtocol {
296375
/// polynomial commitment.
297376
///
298377
/// # 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
301380
/// are invalid.
302-
/// * `IDkgVerifyComplaintError::InvalidArgumentsMismatchingTranscriptIDs` if
381+
/// * [`IDkgVerifyComplaintError::InvalidArgumentsMismatchingTranscriptIDs`] if
303382
/// the transcript IDs in the transcript and the complaint do not match (i.e.,
304383
/// are not equal).
305-
/// * `IDkgVerifyComplaintError::InvalidArgumentsMissingDealingInTranscript`
384+
/// * [`IDkgVerifyComplaintError::InvalidArgumentsMissingDealingInTranscript`]
306385
/// if the (verified) dealings in the transcript do not contain a dealing
307386
/// whose dealer ID matches the complaint's dealer ID.
308-
/// * `IDkgVerifyComplaintError::InvalidArgumentsMissingComplainerInTranscript`
387+
/// * [`IDkgVerifyComplaintError::InvalidArgumentsMissingComplainerInTranscript`]
309388
/// if the transcript's receivers do not contain a receiver whose ID matches
310389
/// the complaint's complainer ID.
311-
/// * `IDkgVerifyComplaintError::ComplainerPublicKeyNotInRegistry` if the
390+
/// * [`IDkgVerifyComplaintError::ComplainerPublicKeyNotInRegistry`] if the
312391
/// complainer's (MEGa) public key cannot be found in the registry.
313-
/// * `IDkgVerifyComplaintError::MalformedComplainerPublicKey` if the
392+
/// * [`IDkgVerifyComplaintError::MalformedComplainerPublicKey`] if the
314393
/// complainer's (MEGa) public key fetched from the registry is malformed.
315-
/// * `IDkgVerifyComplaintError::UnsupportedComplainerPublicKeyAlgorithm` if
394+
/// * [`IDkgVerifyComplaintError::UnsupportedComplainerPublicKeyAlgorithm`] if
316395
/// the algorithm of the complainer's (MEGa) public key in the registry is
317396
/// not supported.
318-
/// * `IDkgVerifyComplaintError::SerializationError` if the (internal raw)
397+
/// * [`IDkgVerifyComplaintError::SerializationError`] if the (internal raw)
319398
/// complaint cannot be deserialized, or if the dealing corresponding to the
320399
/// 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
322401
/// 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
324403
/// during the verification.
325404
fn verify_complaint(
326405
&self,
@@ -331,6 +410,23 @@ pub trait IDkgProtocol {
331410

332411
/// Generate an opening for the dealing given in `complaint`,
333412
/// 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.
334430
fn open_transcript(
335431
&self,
336432
transcript: &IDkgTranscript,
@@ -340,6 +436,19 @@ pub trait IDkgProtocol {
340436

341437
/// Verify that an opening corresponds to the complaint,
342438
/// 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.
343452
fn verify_opening(
344453
&self,
345454
transcript: &IDkgTranscript,
@@ -354,6 +463,30 @@ pub trait IDkgProtocol {
354463
/// # Preconditions
355464
/// * For each (complaint, (opener, opening)) tuple, it holds that
356465
/// `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.
357490
fn load_transcript_with_openings(
358491
&self,
359492
transcript: &IDkgTranscript,
@@ -374,9 +507,9 @@ pub trait IDkgProtocol {
374507
/// IDKG threshold keys not identified by a transcript will be removed.
375508
///
376509
/// # Errors
377-
/// * `IDkgRetainThresholdKeysError::InternalError` if an internal error such as
510+
/// * [`IDkgRetainThresholdKeysError::InternalError`] if an internal error such as
378511
/// an RPC error communicating with a remote CSP vault occurs
379-
/// * `IDkgRetainThresholdKeysError::SerializationError` if a transcript cannot
512+
/// * [`IDkgRetainThresholdKeysError::SerializationError`] if a transcript cannot
380513
/// be serialized into a key id to identify the IDKG threshold secret key
381514
fn retain_active_transcripts(
382515
&self,

rs/types/types/src/crypto/canister_threshold_sig/error.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,6 @@ pub enum IDkgCreateDealingError {
220220
SecretSharesNotFound {
221221
commitment_string: String,
222222
},
223-
AlgorithmMismatchWithSKS {
224-
algorithm_id: AlgorithmId,
225-
},
226223
TransientInternalError {
227224
internal_error: String,
228225
},

0 commit comments

Comments
 (0)