/** * BIP-322 "simple" signature verification for P2TR key-path and P2WPKH. * * Mirrors the Rust reference in * `btc-vault/crates/btc-signer/src/message.rs` (`verify_bip322_message` * and the P2WPKH arm of `verify_pop_witness`, both of which delegate to * the `bip322` crate 0.0.10's `verify_simple`). * * The algorithm: * * 1. Compute the BIP-322 tagged-hash of the message: * m_hash = SHA256( SHA256(tag) || SHA256(tag) || message ) * where tag = "BIP0322-signed-message". * * 2. Build a virtual "to_spend" transaction with one input (prevout * all-zero txid + 0xFFFFFFFF vout, scriptSig = `OP_0 PUSH32 m_hash`, * sequence = 0) and one output (value 0, scriptPubKey = the signer's * address: P2TR key-path-only, or P2WPKH of the compressed pubkey). * * 3. Build a "to_sign" transaction that spends to_spend[0] and has a * single `OP_RETURN` output (value 0). * * 4. Compute the sighash of to_sign input 0: BIP-341 taproot for P2TR * (SIGHASH_DEFAULT 0x00 unless the witness item carried a trailing * SIGHASH_ALL 0x01 byte), BIP-143 with the standard P2WPKH * scriptCode for P2WPKH (SIGHASH_ALL only). * * 5. Verify the signature: Schnorr against the **tweaked** output key * `Q = P + tap_tweak(P) * G` for P2TR (no merkle root — key-path * only), ECDSA against the compressed pubkey for P2WPKH. * * `bitcoinjs-lib` handles (2)–(4); `tiny-secp256k1-asmjs` provides * the tweak and the Schnorr/ECDSA verifies. Pulling in a full BIP-322 * library would add a peer dep for what amounts to ~40 lines of glue. * * @module tbv/core/clients/vault-provider/auth/bip322Verify */ /** * vaultd's P2WPKH BIP-322 verifier accepts ONLY 71/72-byte encoded * signatures — DER (70/71B) + sighash byte (`bip322` crate 0.0.10 * `verify.rs:141-153`). A shorter (short-DER) signature fails ingestion * permanently, so this gate must be exactly as strict. Exported so * `verifyPopWitness` can pre-screen with a cause-naming error. */ export declare const P2WPKH_ENCODED_SIG_MIN = 71; export declare const P2WPKH_ENCODED_SIG_MAX = 72; /** * Verify a BIP-322 "simple" P2TR key-path signature over an arbitrary * byte message. * * @internal Consumed by `verifyServerIdentity` (VP auth) and * `verifyPopWitness` (PoP pre-registration check), and exposed so the * golden-vector test suite can pin the verifier independently. * * @param messageBytes - The bytes that were signed (e.g. a CBOR-encoded * payload). Not pre-hashed; this function applies * the BIP-322 tagged hash internally. * @param xOnlyPubkey - 32-byte x-only pubkey of the signer (pre-tweak). * @param signature - 64-byte raw Schnorr signature (BIP-340), as * emitted by a key-path witness. The trailing * sighash byte of a 65-byte witness item is not * part of it — pass it as `hashType` instead. * @param hashType - BIP-341 sighash type the signature commits to. * `SIGHASH_DEFAULT` (0x00) for a 64-byte witness * item, `SIGHASH_ALL` (0x01) for a 65-byte one. * @returns `true` if the signature verifies against the address * derived from `xOnlyPubkey`; `false` otherwise. */ export declare function verifyBip322Simple(messageBytes: Uint8Array, xOnlyPubkey: Uint8Array, signature: Uint8Array, hashType?: number): boolean; /** * Verify a BIP-322 "simple" P2WPKH signature over an arbitrary byte * message, mirroring the verifier vaultd runs on a two-item PoP witness * (`bip322` crate 0.0.10 `verify.rs:102-186 verify_full_p2wpkh`). * * @internal Consumed by `verifyPopWitness` for Native SegWit software * wallets, and exposed so the BIP-322 official-vector test suite can pin * the verifier independently. * * @param compressedPubkey - 33-byte SEC1 compressed pubkey of the signer * (witness item 1). The address is derived from * it; network affects only bech32 encoding, not * script or sighash (`message.rs:125-127`). * @param encodedSignature - Witness item 0: DER signature with trailing * sighash byte, 71 or 72 bytes, SIGHASH_ALL only * (`verify.rs:141-161`). * @returns `true` if the signature verifies against the P2WPKH address of * `compressedPubkey`; `false` otherwise. */ export declare function verifyBip322P2wpkhSimple(messageBytes: Uint8Array, compressedPubkey: Uint8Array, encodedSignature: Uint8Array): boolean; //# sourceMappingURL=bip322Verify.d.ts.map