37de4bf2f7
* Work in progress NIDKG * Encryption of multiple shares * Extracted baby-step giant-step lookup table as a separate entity * Proof of discrete log * Adjusted discrete log domainn * Producing proof of log during keygen * Zeroize for epoch * Proof of secret sharing * empty main for compiler appeasement * Construction of proof of chunking * Initial untested verification of proof of chunking * Converted chunk responses from Scalar to u64 * Additional tests for proof of chunking * Minor cleanup and reorganisation * Fixed enc/dec to use f0 * Deriving node coverage of required tree nodes * Finally seemingnly working encryption under nonzero epoch * Branch park * Decryption key updates to specified epochs * Ciphertext integrity checks * Progress in integration tests * Fixed ciphertext combining and integration test * Dealing type and simplification of the integration test * Benchmark for creation of baby-step-giant-step lookup table * Initial import cleanup + broken 2nd integration test * Using correct assertions in the integration test (and correctly combining shares) * Removed unused modules * Changed proof of sharing to allow for node indices being different from [1,2,...n] * Reorganised bte module * Benchmark for g2 precomputation * Created more strongly typed Epoch type which is essentially a Tau such that it is a leaf node * Extending tau with a temporary oracle output * Using random oracle for tau extension * More benchmarks! * encryption-related benchmarks * Serialization of PublicKeyWithProof * Typos * Removed any changes made in validator-api or smart contracts * Made the integration test slightly more concise * Further purge of unused modules * Fixed combining share to use lagrangian interpolation * Recovery of verification keys from the dealings * Verification key verification + extended integration tests * Fixed Tau not being included in digest for producing Tau_h * Tau serialization * Serialization of a BTE Node * Serialization of DecryptionKey * Serialization of PublicCoefficients * Utility method for setting constant coefficient of a polynomial * Serialization of Ciphertexts * Serialization of Proof of Secret Sharing * Serialization of Proof of Chunking * Serialization of Dealing * Adjusted capacity of responses_r in proof of chunking * Made notation more consistent with the paper equivalents * Optional arguments for creating/verifying resharing dealings
115 lines
3.6 KiB
Rust
115 lines
3.6 KiB
Rust
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
use thiserror::Error;
|
|
|
|
#[derive(Debug, Error)]
|
|
pub enum DkgError {
|
|
#[error("Provided set of values contained duplicate coordinate")]
|
|
DuplicateCoordinate,
|
|
|
|
#[error("The public key is malformed")]
|
|
MalformedPublicKey,
|
|
|
|
#[error("The decryption key is malformed")]
|
|
MalformedDecryptionKey,
|
|
|
|
#[error("Could not solve the discrete log")]
|
|
UnsolvableDiscreteLog,
|
|
|
|
#[error("Received share is malformed")]
|
|
MalformedShare,
|
|
|
|
#[error("The share encrypted under index {0} doesn't exist")]
|
|
UnavailableCiphertext(usize),
|
|
|
|
#[error("The provided lookup table is mismatched")]
|
|
MismatchedLookupTable,
|
|
|
|
#[error("Failed to verify proof of discrete logarithm")]
|
|
InvalidProofOfDiscreteLog,
|
|
|
|
#[error("Tried to construct proof of sharing with an invalid instance")]
|
|
MalformedProofOfSharingInstance,
|
|
|
|
#[error("Tried to construct proof of chunking with an invalid instance")]
|
|
MalformedProofOfChunkingInstance,
|
|
|
|
#[error("Aborted construction of proof of chunking - could not complete it within specified number of attempts")]
|
|
AbortedProofOfChunking,
|
|
|
|
#[error("Tried to update the decryption key to an epoch in the past")]
|
|
TargetEpochUpdateInThePast,
|
|
|
|
#[error("Provided epoch is malformed")]
|
|
MalformedEpoch,
|
|
|
|
#[error("Provided node is not a valid parent")]
|
|
NotAValidParent,
|
|
|
|
#[error("Provided decryption key has expired")]
|
|
ExpiredKey,
|
|
|
|
#[error("Provided threshold value ({actual}) is either 0 or larger than the total number of the participating parties ({participating})")]
|
|
InvalidThreshold { actual: usize, participating: usize },
|
|
|
|
#[error(
|
|
"Provided ciphertext has been generated for a different number of participating parties (expected: {expected}, actual: {actual})"
|
|
)]
|
|
WrongCiphertextSize { actual: usize, expected: usize },
|
|
|
|
#[error(
|
|
"Provided public coefficients have been generated for a different number of participating parties (expected: {expected}, actual: {actual})"
|
|
)]
|
|
WrongPublicCoefficientsSize { actual: usize, expected: usize },
|
|
|
|
#[error("The provided ciphertexts failed integrity check")]
|
|
FailedCiphertextIntegrityCheck,
|
|
|
|
#[error("The provided proof of secret sharing was invalid")]
|
|
InvalidProofOfSharing,
|
|
|
|
#[error("The provided proof of chunking was invalid")]
|
|
InvalidProofOfChunking,
|
|
|
|
#[error("Failed to deserialize {name} - {reason}")]
|
|
DeserializationFailure { name: String, reason: String },
|
|
|
|
#[error("No dealings were provided")]
|
|
NoDealingsAvailable,
|
|
|
|
#[error("Provided dealings were created under different parameters")]
|
|
MismatchedDealings,
|
|
|
|
#[error(
|
|
"Not enough dealings are available. We have {available} while require at least {required}"
|
|
)]
|
|
NotEnoughDealingsAvailable { available: usize, required: usize },
|
|
|
|
#[error("Received different number of x and y coordinates for lagrangian interpolation (xs: {x}, ys: {y})")]
|
|
MismatchedLagrangianSamplesLengths { x: usize, y: usize },
|
|
|
|
#[error("Derived partial verification key is mismatched")]
|
|
MismatchedVerificationKey,
|
|
|
|
#[error("Insufficient number of receivers was provided")]
|
|
NotEnoughReceiversProvided,
|
|
|
|
#[error(
|
|
"The reshared dealing has different public constant coefficient than its prior variant"
|
|
)]
|
|
InvalidResharing,
|
|
}
|
|
|
|
impl DkgError {
|
|
pub fn new_deserialization_failure<S: Into<String>, T: Into<String>>(
|
|
name: S,
|
|
reason: T,
|
|
) -> DkgError {
|
|
DkgError::DeserializationFailure {
|
|
name: name.into(),
|
|
reason: reason.into(),
|
|
}
|
|
}
|
|
}
|