Skip to main content
add nodejs tag
Link
m1xolyd1an
  • 5.7k
  • 2
  • 15
  • 31
Source Link
m1xolyd1an
  • 5.7k
  • 2
  • 15
  • 31

P2TR bech32m mismatch

When attempting to create a p2tr address using the private key 0x0000...01 I get, bc1pmfr3p9j00pfxjh0zmgp99y8zftmd3s5pmedqhyptwy6lm87hf5sspknck9 which does not match the provided test vectors provided here: https://github.com/bitcoin/bips/pull/1225

However if I search this bech32m address in github or google I find others arriving at this same address for key 0x0000..01 so I know I at least have the bech32m encoding right, but not right for p2tr.

Is there another step I'm missing in the below code so that it matches the examples included here (https://github.com/bitcoin/bips/pull/1225)?

const ecurve = require('ecurve')
const secp256k1 = ecurve.getCurveByName('secp256k1')
const schnorr = require('bip-schnorr')
const bech32 = require('bech32').bech32
const bech32m = require('bech32').bech32m    

  const pubKey = ecurve.Point.decodeFrom(secp256k1, keyPair.getPublicKeyBuffer())
  const taprootPubkey = schnorr.taproot.taprootConstruct(pubKey)
  const words = bech32.toWords(taprootPubkey)
  words.unshift(1)
  return bech32m.encode('bc',words)
  //bc1pmfr3p9j00pfxjh0zmgp99y8zftmd3s5pmedqhyptwy6lm87hf5sspknck9