Skip to content
Snippets Groups Projects

feat(serialization): Add Serde support for Block struct

Open DETCHART Jonathan requested to merge add_serde into main

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 by ark_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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading