BIP-178: Extend WIF format with key type #12869

pull kallewoof wants to merge 2 commits into bitcoin:master from kallewoof:importmulti-wif-extended changing 21 files +116 −79
  1. kallewoof commented at 7:52 AM on April 3, 2018: member

    BIP pull request: https://github.com/bitcoin/bips/pull/673

    This PR does not change the behavior. It only adds underlying support for formats beyond 'compressed pubkey' and 'uncompressed pubkey'. It partially implements BIP-178.

    The key types are based on the key types in Ethereum Electrum 3.0: https://github.com/spesmilo/electrum/blob/82e88cb89df35288b80dfdbe071da74247351251/RELEASE-NOTES#L95-L108

    The legacy types KEY_P2PKH_{UN}COMPRESSED map to the current WIF format. If used/seen, they indicate that the corresponding public key type is unknown, and when imported, they will simply iterate over all types and watch all of them (P2PKH, P2SH-P2WPKH, P2WPKH (bech32), and so on). (Current behavior.)

    When one of the other types is used, the current code will behave exactly the same as above. In a future PR, the code will be changed to only import the corresponding type when importing a private key.

    This is related to #12705, see in particular #12705 (comment).

  2. fanquake added the label Wallet on Apr 3, 2018
  3. kallewoof force-pushed on Apr 3, 2018
  4. kallewoof force-pushed on Apr 3, 2018
  5. kallewoof commented at 7:57 AM on April 3, 2018: member

    Ping @sipa & @promag

  6. fanquake commented at 11:41 AM on April 3, 2018: member
    The key types are based on the key types in Ethereum 3.0: 
    

    😯

  7. instagibbs commented at 3:19 PM on April 3, 2018: member

    TIL Ethereum has Segwit.

  8. kallewoof commented at 2:02 AM on April 4, 2018: member

    Oops.. fixed.

  9. kallewoof force-pushed on Apr 4, 2018
  10. jonasschnelli commented at 11:43 AM on April 4, 2018: contributor

    Ideally we would first draft/spec the WIF "standard" in the form of a BIP.

    General Concpet ACK

  11. kallewoof commented at 4:31 AM on April 6, 2018: member

    Ideally we would first draft/spec the WIF "standard" in the form of a BIP.

    I did. The PR proposal* is here: https://github.com/kallewoof/bips/blob/bip-typed-wif/bip-0178.mediawiki

    I posted it in the ML but as a reply to the existing thread, here: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-April/015870.html

    (* It is not actually a PR yet.)

  12. kallewoof force-pushed on Apr 11, 2018
  13. kallewoof renamed this:
    Extend WIF format with key type
    BIP-178: Extend WIF format with key type
    on May 9, 2018
  14. Janaka-Steph commented at 5:29 PM on May 17, 2018: none

    @kallewoof This link https://github.com/kallewoof/bips/blob/bip-typed-wif/bip-extended-privkey.mediawiki is broken. I can't find this BIP-178 proposal anywhere else than in the mailing list. What is the plan? @kallewoof can you add it to your repo? Thanks

  15. kallewoof force-pushed on May 18, 2018
  16. kallewoof force-pushed on May 18, 2018
  17. kallewoof force-pushed on May 18, 2018
  18. MarcoFalke commented at 3:30 PM on May 21, 2018: member

    Needs rebase due to merge of #12924

  19. kallewoof force-pushed on May 21, 2018
  20. [wallet] Add KeyType enum 0ca546a36b
  21. [wallet] Switch to using KeyType in CKey f3b064c00a
  22. kallewoof force-pushed on May 21, 2018
  23. kallewoof commented at 12:34 AM on May 22, 2018: member

    Rebased.

  24. sipa commented at 6:14 PM on May 24, 2018: member

    It feels wrong to store the address type in CKey. CKey is a representation of a private key, not an address. Address derivation and knowledge about that belongs in the wallet code, not the ECDSA wrapper.

  25. kallewoof commented at 4:14 AM on May 25, 2018: member

    @sipa The compressed byte is in the private key right now, and BIP-178 extends that so it feels like it makes sense to keep it in the key class. Where else would it go?

  26. sipa commented at 4:35 AM on May 25, 2018: member

    @kallewoof The compressed flag affects the public key, not the address. Different private keys (including compressed flag) correspond to different public keys (when looking at the bytes, which is what matters to us).

    Where should it go? Right now, nowhere - we can't use it, as the IsMine can't take it into account, it just looks at what we can sign. importmulti can use it to automatically figure out which redeemscript/witnessscript to compute, but it will inevitably overshoot what it matches again because of the IsMine logic. Later (see https://gist.github.com/sipa/125cfa1615946d0c3f3eec2ad7f250a2) it should go into the ismine record data. But it's not necessarily something associated with a single key, but with an entire record (so it can apply to a whole HD chain or even more complex structures).

    I understand it seems easiest to store it in CKey for now, but that's just due to the code historically conflating keys with addresses. I really would try to avoid continuing that.

  27. kallewoof commented at 4:46 AM on May 25, 2018: member

    That makes sense. Maybe I should just close this PR, then. I could always rework it to split out the WIF stuff from the key stuff. Would that make sense or just a waste of time, you think?

  28. kallewoof closed this on May 27, 2018

  29. meshcollider deleted a comment on Nov 12, 2018
  30. kallewoof deleted the branch on Oct 17, 2019
  31. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me