blockchain-certificates / cert-issuer

Issues Blockcerts using either the Bitcoin or Ethereum blockchain
MIT License
409 stars 208 forks source link

Unexpected first byte of WIF error for privateKey #170

Closed arycloud closed 2 years ago

arycloud commented 4 years ago

I'm using BitPay testnet wallet on mac and. I have exported the private key as a json file and then I copied all of its content paste in this tool to get WIF key and when I put the xPrivKey into my key.txt file which is mentioned in conf.ini I got another error as:

pycoin.encoding.EncodingError: unexpected first byte of WIF xprv9s21ZrQH143K31uJMPo9x8bWpuj9HS6cSAkJ67CDyzcB5LKwLMswKJECJz8LgpiAwzWjjY6p1943A9GYA12J2uPgBsXgqYHTqLS72e1pimr

ghost commented 4 years ago

What it looks like you have there is a bip39 extended private key. You need a private key for a single public key / address. You can learn more about BIP39 here https://iancoleman.io/bip39/

arycloud commented 4 years ago

I'm new to the blockchain so don't min my basic questions, please! I'm using the BitPay app on mac for my bitcoin testnet wallet and when I exported my key from that app and decrypted it using this tool, I got the above mentioned private key. Here's what I got when exported from BitPay:

{"iv":"FZwTXaK6mcPoaHqegqunxQ==","v":1,"iter":10000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"vqA3WtB/5N0=","ct":"+cx1xNHSxNTbsz6OCGOpSwzQKEUxJQNCpT3QK3X49UYZ6KtIOF4yAYQlVAl0wm8zlA+k9aahze0oXuTTRsCZXqFGz281+G2k1YFnjz69vdpz5cjdBbxzzhMBDOTlaGJAkfmAqjYVrTE5Qh12e9bfnrxLpMskLuMs5eG94zLeixpOxhSYqfmTUrDXoDkv2H7adA5bZua74n+Z6GXHlrSwVu3yxHaqwJBClYra77ySwRgsb6QHY7RLudUU27Zy2aRn73EsKHxsu1fO0La8rx6HFNIifSuEDA7lhtcxXvyX97nzOx3qf+YM0+UQBPZ47xmGPDBVe4hiH2mDiE0xFZwjwxU+lpfg/gVJkAoXN4V9kdVcStsmcxicvgR2L9pYUxfH/Y2kKBtZ6LvDb06MwbqYTjyaXarTDPVhxKPElroQouqgccautO8Eyf98Sz0i3lx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j3AlbDr/wxOolhfnmwYNksUbpXzQQ2Of5Fovug7gftuf9yNBSymPeecZ4XfVv3Cxw+C20rifSfZrIqYFJEjqLoCDduuzkRpDy0ejl7q4d+JuJEhFMPENQvfmETt3WJIb+AWUTVbiNvmfCFqFaE9j4G9mHcvb/pqy08VlrnKbC90BYekpjFdceeDtyyyWlTuTEQN5zuiVXeXuKH1fJi3tQaTvKA64YVYP5XuM/5y1JcrbbPezVFYbXMwY4AWpa2AwcqRgmoMbXkiMX06dkGbU/EP1cuE2S0m6t9WtDtImdr6oqoLTH/lQQbJg+iR714n2zH/zL4U4N9Fb9+uJp0PfNX5HlMDOAMTZPXixyMLgFl+ZASw5oSLw1bgLihfsXYpJA3"}

So, how can I get a valid private key from this JSON?

ghost commented 4 years ago

I don't know. We have instructions for getting a bitcoin testnet key here: https://github.com/blockchain-certificates/cert-issuer#create-a-bitcoin-issuing-address

arycloud commented 4 years ago

@AnthonyRonning this wallet is not working even, I have generated a wallet using the link mentioned on docs but I'm not able to transfer funds to that address.

ghost commented 4 years ago

Haven't used that one in awhile, looks like it's only doing mainnet now. Try this one https://bitcoinpaperwallet.com/bitcoinpaperwallet/generate-wallet.html?design=alt-testnet#

Med-ELOMARI commented 4 years ago

Hi @arycloud

Befor we start : For "safety" ! it's recommended to run these sites OFFLINE by downloading them and running them locally : https://github.com/iancoleman/bip39

You have the xPrivKey and the mnemonic... Both of them can be used on https://iancoleman.io/bip39/ with a derivation path listed in the Json you decrypted then click on the BIP44 tab to generate a list of your addresses/private keys .Or, you can simply restore the seed mnemonic into any BIP44 compatible wallet :)

steps :

  1. Put your mnemonic in https://iancoleman.io/bip39/ (OFFLINE)
  2. choose Coin type (ex : BTCtestnet)
  3. choose Derivation Path BIP44
  4. edit to match your rootPath (rootPath listed in the json file ex : m/44'/1'/0')
  5. Et voila your Derived Addresses are bellow search for the exact one you interested in , and use the Private Key with the issuer 🥇

Hope the process is clear .

@AnthonyRonning it works on the testnet 👍