Skip to content

Commit 0de3bbf

Browse files
committed
Reword section about field order
1 parent 327f69a commit 0de3bbf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

index.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,11 @@ <h3 id="message-format">Message format</h3>
809809
<td>Dictionary containing free-form data for applications to interpret, plus a mandatory <em>type</em> field. The <em>type</em> field allows applications to filter out message types they don’t understand and must be a string between 3 and 52 characters long (inclusive).</td>
810810
</tr>
811811
</table>
812+
<aside style="align-self: start; position: relative; top: 19px;">
813+
<p>Only these fields are allowed and they all must be present.</p>
814+
<p>Fields must appear in this order (although <em>author</em> and <em>sequence</em> can be swapped for legacy reasons, but please don’t do this for new messages).</p>
815+
<p>Fields within <em>content</em> can appear in any order but the order must be remembered for later.</p>
816+
</aside>
812817

813818
<h4 id="signature">Signature</h4>
814819
<div>
@@ -833,17 +838,13 @@ <h5>Implementations</h5>
833838
<li>One space after the colon <code>:</code> for dictionary keys.</li>
834839
<li>Strings and numbers formatted according to the sections <em><a href="https://www.ecma-international.org/ecma-262/6.0/#sec-quotejsonstring">QuoteJSONString</a></em> and <em><a href="https://www.ecma-international.org/ecma-262/6.0/#sec-tostring-applied-to-the-number-type">ToString Applied to the Number Type</a></em>.
835840
<li>No trailing newline.</li>
836-
<li>The properties must be in an accepted order, no extra fields are permitted. Either <code>previous, author, sequence, timestamp, hash, content, signature</code> or <code>previous, sequence, author, timestamp, hash, content, signature</code>. (<code>author</code> and <code>sequence</code> are accepted in either order, but it's strongly recommended to put author first.</li>
837841
</ul>
838-
<aside>
839-
<p>Dictionary keys can appear in any order you choose, however the order needs to be remembered for later.</p>
840-
</aside>
841842
<p>Then sign the message by computing:</p>
842843
<pre><code>signature = nacl_sign_detached(
843844
msg: formatted_json_message,
844845
key: authors_longterm_sk
845846
)</code></pre>
846-
<p>Base64 encode the signature and put <code>.sig.ed25519</code> on the end. Finally, add the signature to the message itself:</p>
847+
<p>Base64 encode the signature and put <code>.sig.ed25519</code> on the end. Finally, add the signature to the message itself. It must be the last entry in the dictionary:</p>
847848
<pre><code>{
848849
"previous": "%XphMUkWQtomKjXQvFGfsGYpt69sgEY7Y4Vou9cEuJho=.sha256",
849850
"author": "@FCX/tsDLpubCPKKfIrw4gc+SQkHcaD17s7GI6i/ziWY=.ed25519",
@@ -858,7 +859,7 @@ <h5>Implementations</h5>
858859
IousK4cCn9T5qFa8E14GVek4cAMmMbjqDnAg==.sig.ed25519"
859860
}</code></pre>
860861

861-
<p>To verify the signature, first remove the signature field from the message. Make sure the remaining message is formatted as JSON using the same formatting rules. Here the order of dictionary keys matters; the keys must be in the same order that you received them.</p>
862+
<p>To verify the signature, first remove the signature field from the message. Make sure the remaining message is formatted as JSON using the same formatting rules. Here the order of dictionary entries within <em>content</em> matters; they must be in the same order that you received them.</p>
862863
<p>Then remove the <code>.sig.ed25519</code> suffix from the signature, base64 decode it and verify with:</p>
863864
<pre><code>nacl_sign_verify_detached(
864865
sig: signature,

0 commit comments

Comments
 (0)