willow-rs icon indicating copy to clipboard operation
willow-rs copied to clipboard

Encoding relations API

Open sgwilym opened this issue 5 months ago • 3 comments

Willow's site will soon define encoding relations for many encodings, which are a set of acceptable encodings for a given type. These will be useful for things like WGPS messages where we are decoding many messages and we do not want the implicit overhead of verifying that every message was encoded correctly.

We still want to retain the concept of canonical encodings, as these are important for things like Meadowcap signatures.

So this PR adds new RelationDecodable and RelativeRelationDecodable (open to suggestions) traits with a decode_relation and relative_decode_relation methods on them, respectively.

The methods have a default implementation which is an alias for Decodable / RelativeDecodable's decode_canonical and relative_decode_canonical.

I made these traits separate so that we can define types which have only a canonical decoder, or only a relation decoder (WGPS messages), or both!

Fuzz tests have been refactored to be synchronous and inclued additional checks on encoding tests.

There is also a new shell script for running all the fuzz tests sequentially (see the README) (closes #54).

sgwilym avatar Sep 11 '24 12:09 sgwilym