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 Nov 22, 2021
1 parent 4612c71 commit eeb300e
Show file tree
Hide file tree
Showing 3 changed files with 1,204 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@ pub enum Error {
CannotCreateWhitelistSignature,
/// The given whitelist signature doesn't correctly prove inclusion in the whitelist.
InvalidWhitelistProof,
/// Cannot establish Musig pre-session
InvalidMusigPreSession,
/// Invalid tweak to Musig public key
InvalidMusigTweak,
/// Cannot establish a Musig session
InvalidMusigSession,
/// Invalid Musig public nonces
CannotGenMusigNonce,
/// Invalid Musig public nonce
InvalidMusigPubNonce,
/// Invalid Musig aggregated nonce
InvalidMusigAggNonce,
/// Invalid Musig partial signature
InvalidMusigPartSig,
/// Cannot extract Musig secret adaptor
InvalidMusigExtract,
}

// Passthrough Debug to Display, since errors should be user-visible
Expand Down Expand Up @@ -145,6 +161,14 @@ impl fmt::Display for Error {
Error::InvalidWhitelistProof => {
"given whitelist signature doesn't correctly prove inclusion in the whitelist"
}
Error::InvalidMusigPreSession => "failed to create Musig pre-session",
Error::InvalidMusigTweak => "malformed Musig tweak",
Error::InvalidMusigSession => "failed to create a Musig session",
Error::CannotGenMusigNonce => "failed to create a Musig nonce pair",
Error::InvalidMusigPubNonce => "malformed Musig public nonce(s)",
Error::InvalidMusigAggNonce => "malformed Musig aggregated nonce",
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 @@ -12,6 +14,8 @@ mod whitelist;
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 eeb300e

Please sign in to comment.