Skip to content

Capture payload size in the multihash #163

@Gozala

Description

@Gozala

Almost in all instance where we use raw multihash we find ourselves capturing payload size an the side. It is also probably worth calling the fact that somewhat recently fr32-sha2-256-trunc254-padded-binary-tree multihash was defined to capture payload size to address potential vulnerabilities.

Given how common it is to want to capture payload size I would like to propose "multihash multihash" format that is multihash variant that uses multihash code 0x31 and encodes information about payload size and digest. Here is the exact format I'd like to propose

Format

<0x31><varint payload size in bytes><varint hash function code><varint digest size in bytes><hash function output>

FAQ

  • Should CIDs adopt this multihash format instead of what they use now ?

    I don't have use case for that unless anyone already has one I'd say lets not until we do have one. Also adopting it in CID would make their size arbitrary which can introduce various problems

  • Should it be possible for CIDs to use this multihash format ?

    I don't see why not. They could use whatever hashing algorithm they want so it make sense to do the same here

  • Should blockstore keys use this format or should they be unwrapping and using inner multihash ?

    I think block stores do not need to capture size in the key, which probably means they should not use this format to avoid duplication ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions