Skip to content

Commit

Permalink
zkp: Add Musig2 module
Browse files Browse the repository at this point in the history
squash! zkp: Add Musig2 module

Remove agg_pk from KeyAggCache
  • Loading branch information
GeneFerneau authored and sanket1729 committed Mar 21, 2022
1 parent 865e8ca commit 3eef309
Show file tree
Hide file tree
Showing 3 changed files with 1,238 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 @@ -116,6 +116,22 @@ pub enum Error {
CannotCreateWhitelistSignature,
/// The given whitelist signature doesn't correctly prove inclusion in the whitelist.
InvalidWhitelistProof,
/// Cannot establish Musig pre-session
InvalidMusigKeyAggCache,
/// 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 @@ -143,6 +159,14 @@ impl fmt::Display for Error {
Error::InvalidWhitelistProof => {
"given whitelist signature doesn't correctly prove inclusion in the whitelist"
}
Error::InvalidMusigKeyAggCache => "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 3eef309

Please sign in to comment.