Avoid public keys starting with `02`, `03` and `04` bytes #1060

pull dr-orlovsky wants to merge 1 commits into bitcoin:master from dr-orlovsky:patch-4 changing 1 files +1 −1
  1. dr-orlovsky commented at 5:20 PM on January 30, 2021: contributor

    Currently when doing stream deserialization it will be impossible to guess serialized key format without using special dedicated tag. It was not the case with previous deserialization for compressed/uncompressed Secp keys since the first byte uniquely defined key length and format. Here I propose to avoid use of public keys starting with 02, 03 and 04 bytes to avoid such ambiguity and make keys deserializable from I/O stream without the need for custom encoding prefiexes and additional standards for wallets.

  2. Avoid public keys starting with `02`, `03` and `04` bytes
    Currently when doing stream deserialization it will be impossible to guess serialized key format without using special dedicated tag. It was not the case with previous deserialization for compressed/uncompressed Secp keys since the first byte uniquely defined key length and format. Here I propose to avoid use of public keys starting with `02`, `03` and `04` bytes to avoid such ambiguity and make keys deserializable from I/O stream without the need for custom encoding prefiexes and additional standards for wallets.
    671393a95e
  3. sipa commented at 5:33 PM on January 30, 2021: member

    NACK, needing to change derivation functions is a huge pain, as it intersects several layers.

    If you need a way to serialize keys in a place where they could be confused with SEC1-encoded keys, why not just use that directly (i.e. prefix them with 0x02), or invent a new prefix to mean "BIP340 key follows"?

  4. dr-orlovsky commented at 5:39 PM on January 30, 2021: contributor

    If you need a way to serialize keys in a place where they could be confused with SEC1-encoded keys, why not just use that directly (i.e. prefix them with 0x02), or invent a new prefix to mean "BIP340 key follows"?

    Because this will be a non-standard way, and different software will end up using different prefixes.

    I agree with that changing derivation function is crazy. Maybe make a non-consensus Schnorr key serialization prefix (let's say 01) part of this standard?

  5. dr-orlovsky commented at 5:58 PM on January 30, 2021: contributor

    I have faced this problem when was working on rust-bitcoin new PublicKey type that will be an umbrella type for all possible bitcoin public keys as was originally discussed with @apoelstra in https://github.com/rust-bitcoin/rust-bitcoin/issues/554

  6. sipa commented at 6:24 PM on January 30, 2021: member

    I think this is a terrible idea, sorry. Just keep metadata around in your type to know what encoding to use. This shouldn't leak into the specification of the BIP340 key type or its usage.

  7. dr-orlovsky closed this on Feb 3, 2021

Contributors

github-metadata-mirror

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

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