Skip to content

Commit

Permalink
Clarify format of Multihash values.
Browse files Browse the repository at this point in the history
  • Loading branch information
msporny committed Jun 10, 2024
1 parent 8cc80fd commit 80e93af
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1329,11 +1329,11 @@ <h2>Multibase</h2>
<h2>Multihash</h2>

<p>
A Multihash value starts with a binary header, which identifies the specific
cryptographic hash algorithm and parameters used to generate the digest,
followed by the cryptographic digest value. The normative Multihash header
values defined by this specification, and their associated output sizes and
associated specifications, are provided below:
A Multihash value starts with a binary header, which includes 1) an identifier
for the specific cryptographic hash algorithm, 2) the length of the
cryptographic hash, and 3) the value of the cryptographic hash. The normative
Multihash header values defined by this specification, and their associated
output sizes and associated specifications, are provided below:
</p>

<table class="simple">
Expand Down Expand Up @@ -1383,15 +1383,18 @@ <h2>Multihash</h2>
</p>

<p>
To encode to a Multihash value, an implementation MUST prepend the associated
Multihash header value to the cryptographic hash value.
To encode to a Multihash value, an implementation MUST concatenate the
associated Multihash header, the cryptographic hash length, and the
cryptographic hash value, in that order.
</p>

<p>
To decode a Multihash value, an implementation MUST remove the prepended
To decode a Multihash value, an implementation MUST 1) remove the prepended
Multihash header value, which identifies the type of cryptographic hashing
algorithm as well as its output length, leaving the raw cryptographic hash
value which MUST match the output length associated with the Multihash header.
algorithm, 2) remove the output length, and 3) extract the raw cryptographic
hash value which MUST match the expected output length associated with the
Multihash header as well as the output length provided in the Multihash
value itself.
</p>

</section>
Expand Down

0 comments on commit 80e93af

Please sign in to comment.