Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ generic message signing and verification.

## Types of Signatures

At the moment this crate supports `P2TR`, `P2WPKH` and `P2SH-P2WPKH` single-sig
addresses. Feedback through issues or PRs on the interface design and security
is welcome and encouraged.
At the moment this crate supports `P2TR`, `P2WPKH`, `P2WSH`, `P2SH-P2WPKH`, `P2SH-P2WSH`, and `P2SH` (legacy multisig) addresses. Feedback through issues or PRs on the interface design and security is welcome and encouraged.

- [x] simple
- [x] full
- [ ] full (proof-of-funds)
- [ ] legacy (BIP-137)
- [x] full (proof-of-funds)
- [x] legacy (BIP-137)

The goal is to provide a full signing and verifying library similar to
[this](https://github.com/ACken2/bip322-js/tree/main) Javascript library.
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_sign_verify_encoded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn main() {
let message = "Hello World";
let wif_private_key = "L3VFeEujGtevx9w18HD1fhRbCH67Az2dpCymeRE1SoPK6XQtaN2k";

let base64_signature = sign_simple_encoded(address, message, wif_private_key).unwrap();
let base64_signature = sign_simple_encoded(address, message, &[wif_private_key], None).unwrap();

assert!(verify_simple_encoded(address, message, &base64_signature).is_ok());
}
24 changes: 23 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub enum Error {
},
#[snafu(display("Failed to parse private key"))]
PrivateKeyParse { source: bitcoin::key::FromWifError },
#[snafu(display("Unsuported address `{address}`, only P2TR, P2WPKH and P2SH-P2WPKH allowed"))]
#[snafu(display("Unsupported address `{address}`, type"))]
UnsupportedAddress { address: String },
#[snafu(display("Decode error for signature `{signature}`"))]
SignatureDecode {
Expand Down Expand Up @@ -66,4 +66,26 @@ pub enum Error {
InvalidWitness,
#[snafu(display("Public key does not match"))]
PublicKeyMismatch,
#[snafu(display("At least one private key is required"))]
NoPrivateKeys,
#[snafu(display("Non-standard sighash type: {source}"))]
SigHashTypeNonStandard {
source: bitcoin::sighash::NonStandardSighashTypeError,
},
#[snafu(display("Signer's public key not present in multisig script"))]
UnknownSigner,
#[snafu(display("Duplicate private key provided"))]
DuplicateSigner,
#[snafu(display("Multisig requires exactly {required} signatures, got {provided}"))]
SignatureCount { required: usize, provided: usize },
#[snafu(display("Invalid BIP-137 recovery flag `{flag}`"))]
InvalidRecoveryFlag { flag: u8 },
#[snafu(display("Invalid legacy signature: {source}"))]
LegacyRecover {
source: bitcoin::sign_message::MessageSignatureError,
},
#[snafu(display("Invalid proof input at index {index}: {reason}"))]
InvalidProofInput { index: usize, reason: String },
#[snafu(display("Cannot interpret script `{script}`"))]
UnknownScriptType { script: String },
}
Loading