Skip to content
This repository was archived by the owner on Dec 19, 2020. It is now read-only.
This repository was archived by the owner on Dec 19, 2020. It is now read-only.

Things before upstreaming #5

Closed
Closed
@vmx

Description

@vmx

There are a few things I'd like to tackle before upstreaming. I put them into a single issue so that they can be discussed easily and we don't span this across zillions of issues or bloat PRs.

I split them into "ideas" which I think would make sense, but I'm, not sure about and "issues" which I think need to be fixed. Though they are all open for dicussions.

Ideas:

  • Re-export all generic_array::typenum:: as multihash::sizes:: or so
    Currently we only re-export some sized

Issues:

  • size() should return the actual size. For most of the digests it's the same as the digest size. But it's not the case for the Identity hash.
    • This is connected to digest() should return the slice of the actual digest. This is again an issue for the Identity hash, where it should be trimmed to size().
  • Implement TryFrom traits (and potentially remove the other functions from the traits (that's open for discussion):
    • For from_bytes()/to_bytes() in the MultihashDigest
    • For from_mh()/to_mh() in RawMultihash

I've crated a list of things a Multihash implementation should implement and I think all those will be addressed. If I miss anything that should be supported (and perhaps already is by this library), please let me know:

  • An instance of a Multihash can be created in several ways:

    • From an existing Multihash, represented as bytes.
      • Also needs to support Multihashes that don't have an implementation. Such a Multihash wouldn't be able to create new hashed, but only be able to return code, size and digest.
    • From an existing (non-Multihash) hash digest together with a Multihash Code. The size may either be given, calculated directly from the digest itself or implied (e.g. the type system).
    • From data that still needs to get hashed together with a Multihash Code. The size may either be given or implied (e.g. the type system).
  • The Multihash instance then provides access to the properties of a hash:

    • code: The code of the Multihash.
    • size: The size needs to be the actual size. It may differ from the default hash size due to two reasons. Multihash supports trunctated hashes and there is also hash functions with arbitrary sizes, like Blake3.
    • digest: The actual hash.

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