-
- Downloads
feat(serialization): Add Serde support for `semi_avid::Block` struct (!194)
This PR adds serialization and deserialization support for the `semi_avid::Block` struct using Serde, while maintaining compatibility with Arkworks' canonical serialization. This implementation enables compatibility with ecosystem dependencies like libp2p that rely on Serde for network serialization and data exchange when using predefined codecs (like bincode, CBOR or JSON), improving interoperability of our cryptographic primitives across different libraries and network protocols. Changes: - Implement `Serialize` and `Deserialize` traits for `semi_avid::Block` - Use Arkworks' canonical serialization with compression - Use a `Visitor` to serialize and deserialize the bytes returned by `ark_serialize` - Add Bincode as dev dependency for testing - Add test for serialization round-trip validation using `semi_avid::Block`s, array of `semi_avid::Block`s and encapsulated `semi_avid::Block`s into enums. Implementation Details: - Serialization converts the block to a byte vector using the `CanonicalSerialize` trait - Deserialization reconstructs the block from bytes using the `CanonicalDeserialize` trait Added a test that: - Generates and prove some blocks - Serializes blocks using Bincode - Deserializes and compares blocks - Ensures correct serialization and deserialization integrity by comparing each deserialized objects to the original objects.
parent
c66f7e45
Checking pipeline status