4

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
m1xolyd1an
  • 5,566
  • 2
  • 14
  • 30
  • 2
    Which test vector does not match? I don't see one for a private key of 1. AFAICT, you have the correct address. – Andrew Chow Nov 13 '21 at 16:12
  • Indeed, I also get `bc1pmfr3p9j00pfxjh0zmgp99y8zftmd3s5pmedqhyptwy6lm87hf5sspknck9` for the key-only P2TR address for private key 0x000...0001. – Pieter Wuille Nov 13 '21 at 16:17
  • Oh excellent news! I must have misunderstood your post when you said you used the 0x0...01 key because I couldn't locate this P2TR address in the test vectors post but now I'm looking at it again it must have been the input which explains why that address doesn't appear here https://github.com/bitcoin/bips/pull/1225#issuecomment-958124970 – m1xolyd1an Nov 14 '21 at 00:24
  • The 0x0000...0001 key is used for the address of one of the outputs of the test transaction there. The input keys are all random, and listed in the vector data. – Pieter Wuille Nov 14 '21 at 00:37

0 Answers0