Skip to content

Commit

Permalink
zkp: Add Musig2 module
Browse files Browse the repository at this point in the history
  • Loading branch information
GeneFerneau committed Aug 24, 2021
1 parent f735f14 commit d4eeaa3
Show file tree
Hide file tree
Showing 3 changed files with 1,197 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ pub enum Error {
CannotRecoverAdaptorSecret,
/// Given adaptor signature is not valid for the provided combination of public key, encryption key and message
CannotVerifyAdaptorSignature,
/// Cannot establish Musig pre-session
InvalidMusigPreSession,
/// Invalid tweak to Musig public key
InvalidMusigTweak,
/// Cannot establish a Musig session
InvalidMusigSession,
/// Invalid Musig public nonces
InvalidMusigPubNonce,
/// Invalid Musig partial signature
InvalidMusigPartSig,
/// Cannot extract Musig secret adaptor
InvalidMusigExtract,
}

// Passthrough Debug to Display, since errors should be user-visible
Expand All @@ -127,6 +139,12 @@ impl fmt::Display for Error {
Error::Upstream(inner) => return write!(f, "{}", inner),
Error::InvalidTweakLength => "Tweak must of size 32",
Error::TweakOutOfBounds => "Tweak must be less than secp curve order",
Error::InvalidMusigPreSession => "failed to create Musig pre-session",
Error::InvalidMusigTweak => "malformed Musig tweak",
Error::InvalidMusigSession => "failed to create a Musig session",
Error::InvalidMusigPubNonce => "malformed Musig public nonce(s)",
Error::InvalidMusigPartSig => "malformed Musig partial signature",
Error::InvalidMusigExtract => "failed to extract Musig secret adaptor",
};

f.write_str(str)
Expand Down
4 changes: 4 additions & 0 deletions src/zkp/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
mod ecdsa_adaptor;
mod generator;
#[cfg(feature = "std")]
mod musig;
#[cfg(feature = "std")]
mod pedersen;
#[cfg(feature = "std")]
mod rangeproof;
Expand All @@ -11,6 +13,8 @@ mod tag;
pub use self::ecdsa_adaptor::*;
pub use self::generator::*;
#[cfg(feature = "std")]
pub use self::musig::*;
#[cfg(feature = "std")]
pub use self::pedersen::*;
#[cfg(feature = "std")]
pub use self::rangeproof::*;
Expand Down
Loading

0 comments on commit d4eeaa3

Please sign in to comment.