Skip to content
Snippets Groups Projects

feat(serialization): Add Serde support for Block struct

Open DETCHART Jonathan requested to merge add_serde into main
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 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

Merge request pipeline #7742 failed

Merge request pipeline failed for f178416b

Ready to merge by members who can write to the target branch.

Merge details

  • 0 commits and 1 merge commit will be added to .
  • Source branch will be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • STEVAN Antoine resolved all threads

    resolved all threads

  • added 1 commit

    • 9517e324 - Correct serde support for Block struct and implement more serialization/deserialization tests

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • DETCHART Jonathan changed the description

    changed the description

  • added 1 commit

    Compare with previous version

  • STEVAN Antoine mentioned in merge request !196

    mentioned in merge request !196

  • Please register or sign in to reply