Skip to content

[Proposal] Use nicer formatting for human-readable serialization of checksums #29180

Description

@mitchmindtree

Context

Currently, it appears we serialize checksums using the default derived implementation for lists of bytes:

       Leo     The program checksum is: '[167u8, 156u8, 237u8, 201u8, 116u8, 83u8, 250u8, 38u8, 129u8, 210u8, 60u8, 95u8, 245u8, 200u8, 10u8, 21u8, 14u8, 3u8, 230u8, 145u8, 106u8, 235u8, 21u8, 146u8, 115u8, 92u8, 241u8, 22u8, 235u8, 234u8, 119u8, 58u8]'.

These are unwieldy and add a lot of noise to the leo CLI output.

Possible Formats

Ideally these would be formatted as one of the following:

  • Hex - simplest, universally understood, and the standard for checksums everywhere else (git, sha256sum, etc.). e.g.
    Leo     The program checksum is: a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2
    
  • Bech32m with a custom HRP (e.g. chksum1...) - most consistent with Aleo's ecosystem conventions for public-facing data. e.g.
    Leo     The program checksum is: chksum1q9s4wz8xhv7y3k2m5n6p8r0t1u4v7w9x2y5z8a3b6c9d2e5f8g0h3j6k9
    
  • Field element literal - if the checksum is actually a field element internally, we could consider just displaying it as <value>field. e.g.
    Leo     The program checksum is: 73198264501938475620384756102938475610293847561029384756102938field
    

Implementation

Provide simple hand-rolled Serialize and Deserialize implementations for the checksum type that check the is_human_readable flag on the serializer, and use this to select between the encoded string or raw forms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalA proposal for something new.🖥️ CLIAnything related to the Leo CLI.🚀 featureA new feature.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions