Skip to content

Commit d9ee87f

Browse files
committed
zkp: Add Musig2 module
1 parent b77f47f commit d9ee87f

File tree

3 files changed

+1186
-0
lines changed

3 files changed

+1186
-0
lines changed

src/lib.rs

+24
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ pub enum Error {
110110
CannotRecoverAdaptorSecret,
111111
/// Given adaptor signature is not valid for the provided combination of public key, encryption key and message
112112
CannotVerifyAdaptorSignature,
113+
/// Cannot establish Musig pre-session
114+
InvalidMusigPreSession,
115+
/// Invalid tweak to Musig public key
116+
InvalidMusigTweak,
117+
/// Cannot establish a Musig session
118+
InvalidMusigSession,
119+
/// Invalid Musig public nonces
120+
CannotGenMusigNonce,
121+
/// Invalid Musig public nonce
122+
InvalidMusigPubNonce,
123+
/// Invalid Musig aggregated nonce
124+
InvalidMusigAggNonce,
125+
/// Invalid Musig partial signature
126+
InvalidMusigPartSig,
127+
/// Cannot extract Musig secret adaptor
128+
InvalidMusigExtract,
113129
}
114130

115131
// Passthrough Debug to Display, since errors should be user-visible
@@ -129,6 +145,14 @@ impl fmt::Display for Error {
129145
Error::Upstream(inner) => return write!(f, "{}", inner),
130146
Error::InvalidTweakLength => "Tweak must of size 32",
131147
Error::TweakOutOfBounds => "Tweak must be less than secp curve order",
148+
Error::InvalidMusigPreSession => "failed to create Musig pre-session",
149+
Error::InvalidMusigTweak => "malformed Musig tweak",
150+
Error::InvalidMusigSession => "failed to create a Musig session",
151+
Error::CannotGenMusigNonce => "failed to create a Musig nonce pair",
152+
Error::InvalidMusigPubNonce => "malformed Musig public nonce(s)",
153+
Error::InvalidMusigAggNonce => "malformed Musig aggregated nonce",
154+
Error::InvalidMusigPartSig => "malformed Musig partial signature",
155+
Error::InvalidMusigExtract => "failed to extract Musig secret adaptor",
132156
};
133157

134158
f.write_str(str)

src/zkp/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
mod ecdsa_adaptor;
22
mod generator;
33
#[cfg(feature = "std")]
4+
mod musig;
5+
#[cfg(feature = "std")]
46
mod pedersen;
57
#[cfg(feature = "std")]
68
mod rangeproof;
@@ -11,6 +13,8 @@ mod tag;
1113
pub use self::ecdsa_adaptor::*;
1214
pub use self::generator::*;
1315
#[cfg(feature = "std")]
16+
pub use self::musig::*;
17+
#[cfg(feature = "std")]
1418
pub use self::pedersen::*;
1519
#[cfg(feature = "std")]
1620
pub use self::rangeproof::*;

0 commit comments

Comments
 (0)