feat(serialization): Add Serde support for Block struct
All threads resolved!
All threads resolved!
This PR adds serialization and deserialization support for the 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 cbor or json), improving interoperability of our cryptographic primitives across different libraries and network protocols.
Changes:
- Implement Serialize and Deserialize traits for Block
- Use Arkworks' canonical serialization with compression
- Use a
Visitor
to serialize and deserialize the bytes returned byark_serialize
- Add Bincode and cbor4ii as dev dependency for testing
- Add test for serialization round-trip validation using Blocks, array of Blocks and encapsulated Blocks into enums.
Implementation Details:
- Serialization converts the block to a byte vector using
CanonicalSerialize
trait - Deserialization reconstructs the block from bytes using
CanonicalDeserialize
trait
Added a test that:
- Generates and prove some blocks
- Serializes blocks using Bincode and cbor4ii
- Deserializes and compares blocks
- Ensures correct serialization and deserialization integrity by comparing each deserialized objects to the original objects.
Edited by DETCHART Jonathan
Merge request reports
Activity
Filter activity
added 9 commits
-
f4ea1131...3c8afac4 - 8 commits from branch
main
- f25816ad - Merge branch 'main' into add_serde
-
f4ea1131...3c8afac4 - 8 commits from branch
added improvement label
requested review from @a.stevan
- Resolved by STEVAN Antoine
added 1 commit
- 9517e324 - Correct serde support for Block struct and implement more serialization/deserialization tests
mentioned in merge request !196
Please register or sign in to reply