Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fixed width serde impls for keys #406

Merged
merged 4 commits into from Jun 15, 2022

Commits on Jun 9, 2022

  1. Use fixed width serde impls for keys

    Currently we serialize keys using the `BytesVisitor`, this causes the
    serialized data to contain additional metadata encoding the length (an
    extra 8 bytes) when serialized with the `bincode` crate. This extra data
    is unnecessary since we know in advance the length of these types.
    
    It would be useful for users of the lib to be able to get a fixed width
    binary serialization, this can be done but it depends on the crate used
    to do the serialization. We elect to optimise for `bincode` and add docs
    noting that other binary serialization crates may differ (rustdocs added
    in separate patches).
    
    Implement a tuple based visitor that encodes the keys as fixed width
    data.
    
    Do fixed width serde implementations for:
    
    - `SecretKey`
    - `PublicKey`
    - `KeyPair`
    - `XOnlyPublicKey`
    tcharding committed Jun 9, 2022
    Copy the full SHA
    6842383 View commit details
    Browse the repository at this point in the history
  2. Improve rustdocs for KeyPair

    Currently the rustdocs for `KeyPair` are stale in regards to serde, we
    _do_ implement `Serialize` and `Deserialize` for `KeyPair`.
    
    Improve the rustdocs for `KeyPair` by removing stale docs and adding
    docs on fixed width binary serialization.
    tcharding committed Jun 9, 2022
    Copy the full SHA
    c28808c View commit details
    Browse the repository at this point in the history
  3. Add rustdocs describing fixed width serde

    We recently added fixed width serialization for some types however
    serialization is only fixed width when data is serialized with the
    `bincode` crate.
    
    Add rustdocs describing fixed width serde to `SecretKey`, `PublicKey`,
    and `XOnlyPublicKey` (`KeyPair` is already done).
    tcharding committed Jun 9, 2022
    Copy the full SHA
    bf9f556 View commit details
    Browse the repository at this point in the history
  4. Add fixed-width-serde integration tests

    Add a `tests` directory. Add `serde` tests for the recently added fixed
    width binary serialization code.
    
    Please note, serialization is only fixed width when serialized with
    the `bincode` crate.
    tcharding committed Jun 9, 2022
    Copy the full SHA
    3ca7f49 View commit details
    Browse the repository at this point in the history