Skip to content

Commit

Permalink
feat: fix sign args
Browse files Browse the repository at this point in the history
  • Loading branch information
ieow committed Oct 25, 2024
1 parent 9c98d5b commit 2a42ae4
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions mpc-core-kit-web/mpc-core-kit-bitcoin/src/BitcoinSigner.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import { secp256k1 } from "@tkey/common-types";
import { sigToRSV, Web3AuthMPCCoreKit } from "@web3auth/mpc-core-kit";
import { networks, SignerAsync } from "bitcoinjs-lib";
import { recover } from "@bitcoinerlab/secp256k1";

export function createBitcoinJsSigner(props: { coreKitInstance: Web3AuthMPCCoreKit; network: networks.Network }): SignerAsync {
return {
sign: async (hash: Buffer, lowR?: boolean) => {
let sig = await props.coreKitInstance.sign(hash);
console.log("sig", sig);
const { r, s,v } = sigToRSV(sig);
console.log("r", r);
console.log("s", s);
let sig = await props.coreKitInstance.sign(hash, true);
const { r, s } = sigToRSV(sig);
const sigBuffer = Buffer.concat([r, s]);
console.log("sigBuffer", sigBuffer);

const recoverPub = recover( new Uint8Array(hash.buffer),new Uint8Array(sigBuffer.buffer), v ? 1 :0 , true)
console.log("recoverPub", recoverPub)
console.log(props.coreKitInstance.getPubKeyPoint().toSEC1(secp256k1, true))
return sigBuffer;
},
publicKey: props.coreKitInstance.getPubKeyPoint().toSEC1(secp256k1, true),
Expand Down

0 comments on commit 2a42ae4

Please sign in to comment.