Commit Graph

5 Commits

Author SHA1 Message Date
Tobin C. Harding e0e575dde7 Run cargo fmt
Run the command `cargo +nightly fmt` to fix formatting issues.

The formatter got confused in one place, adding an incorrect
indentation, this was manually fixed.
2022-11-16 11:06:12 +11:00
Tobin Harding 6842383161 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`
2022-06-09 16:09:31 +10:00
Thomas Eizinger c2fd5cefa4
Remove `visit_bytes` implementation from `FromStrVisitor`
This visitor is meant to deserialize strings using `FromStr` not
bytes.
2021-01-13 09:57:09 +11:00
Thomas Eizinger e6e23e9dd6
Rename `HexVisitor` to `FromStrVisitor`
The visitor works with all types that implement `FromStr`. Whether or
not that ends up being hex encoding depends on the implementation
of `FromStr`.
2021-01-13 09:54:33 +11:00
Elichai Turkel 1f08a313e5
Replace serde macros with generic visitor module
Co-authored-by: Elichai Turkel <elichai.turkel@gmail.com>
Co-authored-by: Sebastian Geisler <sebastian@blockstream.io>
2021-01-12 11:51:29 +11:00