You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<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>
<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>
812
817
813
818
<h4id="signature">Signature</h4>
814
819
<div>
@@ -833,17 +838,13 @@ <h5>Implementations</h5>
833
838
<li>One space after the colon <code>:</code> for dictionary keys.</li>
834
839
<li>Strings and numbers formatted according to the sections <em><ahref="https://www.ecma-international.org/ecma-262/6.0/#sec-quotejsonstring">QuoteJSONString</a></em> and <em><ahref="https://www.ecma-international.org/ecma-262/6.0/#sec-tostring-applied-to-the-number-type">ToString Applied to the Number Type</a></em>.
835
840
<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>
837
841
</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>
841
842
<p>Then sign the message by computing:</p>
842
843
<pre><code>signature = nacl_sign_detached(
843
844
msg: formatted_json_message,
844
845
key: authors_longterm_sk
845
846
)</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>
<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>
862
863
<p>Then remove the <code>.sig.ed25519</code> suffix from the signature, base64 decode it and verify with:</p>
0 commit comments