Skip to content

Commit

Permalink
Switch error library to this error
Browse files Browse the repository at this point in the history
and bump version to 0.6.0
  • Loading branch information
CjS77 committed Jul 28, 2020
1 parent 2247806 commit 91f8b8d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 39 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Expand Up @@ -7,7 +7,7 @@ categories = ["cryptography"]
homepage = "https://tari.com"
readme = "README.md"
license = "BSD-3-Clause"
version = "0.5.0"
version = "0.6.0"
edition = "2018"

[dependencies]
Expand All @@ -20,7 +20,7 @@ curve25519-dalek = { version = "2.0.0" }
bulletproofs = { version = "2.0.0" }
merlin = "2.0.0"
sha2 = "0.8.0"
derive-error = "0.0.4"
thiserror = "1.0.20"
blake2 = "0.8.1"
rmp-serde = "0.13.7"
serde = "1.0.89"
Expand Down
47 changes: 16 additions & 31 deletions src/musig.rs
Expand Up @@ -21,60 +21,45 @@
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use crate::keys::{PublicKey, SecretKey};
use derive_error::Error;
use digest::Digest;
use std::{ops::Mul, prelude::v1::Vec};
use thiserror::Error;

//---------------------------------------------- Constants ------------------------------------------------//
pub const MAX_SIGNATURES: usize = 32768; // If you need more, call customer support

//---------------------------------------------- Error Codes ------------------------------------------------//
#[derive(Clone, Debug, Error, PartialEq, Eq)]
pub enum MuSigError {
/// The number of public nonces must match the number of public keys in the joint key
#[error(no_from, non_std)]
#[error("The number of public nonces must match the number of public keys in the joint key")]
MismatchedNonces,
/// The number of partial signatures must match the number of public keys in the joint key
#[error(no_from, non_std)]
#[error("The number of partial signatures must match the number of public keys in the joint key")]
MismatchedSignatures,
/// The aggregate signature did not verify
#[error(no_from, non_std)]
#[error("The aggregate signature did not verify")]
InvalidAggregateSignature,
/// A partial signature did not validate
#[error(no_from, non_std)]
#[error("A partial signature did not validate: {0}")]
InvalidPartialSignature(usize),
/// The participant list must be sorted before making this call
#[error(no_from, non_std)]
#[error("The participant list must be sorted before making this call")]
NotSorted,
/// The participant key is not in the list
#[error(no_from, non_std)]
#[error("The participant key is not in the list")]
ParticipantNotFound,
/// An attempt was made to perform an invalid MuSig state transition
#[error(no_from, non_std)]
#[error("An attempt was made to perform an invalid MuSig state transition")]
InvalidStateTransition,
/// An attempt was made to add a duplicate public key to a MuSig signature
#[error(no_from, non_std)]
#[error("An attempt was made to add a duplicate public key to a MuSig signature")]
DuplicatePubKey,
/// There are too many parties in the MuSig signature
#[error(no_from, non_std)]
#[error("There are too many parties in the MuSig signature")]
TooManyParticipants,
/// There are too few parties in the MuSig signature
#[error(no_from, non_std)]
#[error("There are too few parties in the MuSig signature")]
NotEnoughParticipants,
/// A nonce hash is missing
#[error(no_from, non_std)]
#[error("A nonce hash is missing")]
MissingHash,
/// The message to be signed can only be set once
#[error(no_from, non_std)]
#[error("The message to be signed can only be set once")]
MessageAlreadySet,
/// The message to be signed MUST be set before the final nonce is added to the MuSig ceremony
#[error(no_from, non_std)]
#[error("The message to be signed MUST be set before the final nonce is added to the MuSig ceremony")]
MissingMessage,
/// The message to sign is invalid. have you hashed it?
#[error(no_from, non_std)]
#[error("The message to sign is invalid. have you hashed it?")]
InvalidMessage,
/// MuSig requires a hash function with a 32 byte digest
#[error(no_from, non_std)]
#[error("MuSig requires a hash function with a 32 byte digest")]
IncompatibleHashFunction,
}

Expand Down
8 changes: 4 additions & 4 deletions src/range_proof.rs
Expand Up @@ -24,16 +24,16 @@ use crate::{
commitment::HomomorphicCommitment,
keys::{PublicKey, SecretKey},
};
use derive_error::Error;
use serde::{Deserialize, Serialize};
use thiserror::Error;

#[derive(Debug, Clone, Error, PartialEq, Deserialize, Serialize)]
pub enum RangeProofError {
/// Could not construct range proof
#[error("Could not construct range proof")]
ProofConstructionError,
/// The deserialization of the range proof failed
#[error("The deserialization of the range proof failed")]
InvalidProof,
/// Invalid input was provided to the RangeProofService constructor
#[error("Invalid input was provided to the RangeProofService constructor")]
InitializationError,
}

Expand Down
4 changes: 2 additions & 2 deletions src/signatures.rs
Expand Up @@ -3,17 +3,17 @@
//! of the underlying elliptic curve implementation

use crate::keys::{PublicKey, SecretKey};
use derive_error::Error;
use serde::{Deserialize, Serialize};
use std::{
cmp::Ordering,
ops::{Add, Mul},
};
use tari_utilities::{hex::Hex, ByteArray};
use thiserror::Error;

#[derive(Clone, Debug, Error, PartialEq, Eq, Deserialize, Serialize)]
pub enum SchnorrSignatureError {
// An invalid challenge was provided
#[error("An invalid challenge was provided")]
InvalidChallenge,
}

Expand Down

0 comments on commit 91f8b8d

Please sign in to comment.