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
<p>All messages in a feed are signed by that feed’s long-term secret key. This enables recipients to verify that a message was really posted by a particular identity and not tampered with as it gets gossiped and replicated throughout the Scuttlebutt network.</p>
816
-
<p>Before signing a message it must be formatted as JSON as shown above. The formatting rules are:</p>
816
+
<p>Before signing a message it must be serialized according to a specific canonical JSON format. This means for any given message there is exactly one way to serialize it as a sequence of bytes, which is necessary for signature verification to work. The reference implementation verifies that all messages it receives are in the canonical format and rejects messages that aren’t.</p>
<p>The canonical format is defined by the <em>ECMA-262 6<sup>th</sup> Edition</em> section <em><ahref="https://www.ecma-international.org/ecma-262/6.0/#sec-json.stringify">JSON.stringify</a></em>. For an example, see how the above message is formatted.</p>
828
+
<p>In brief, the rules are:</p>
827
829
<ul>
828
830
<li>Two spaces for indentation.</li>
829
831
<li>Dictionary entries and list elements each on their own line.</li>
830
832
<li>Empty dictionaries appear as <code>{}</code> and empty lists appear as <code>[]</code>.</li>
831
833
<li>One space after the colon <code>:</code> for dictionary keys.</li>
832
-
<li>Strings and numbers must be cannonically encoded. That is, they should be the form<em>produced</em>by <ahref="https://www.ecma-international.org/ecma-262/6.0/#sec-json.stringify"><code>JSON.stringify</code></a></li>
834
+
<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>.
833
835
<li>No trailing newline.</li>
834
836
</ul>
835
837
<aside>
836
-
<p>Dictionary keys can appear in any order you choose, however the order needs to be remembered for later.
837
-
</p>
838
-
</aside>
839
-
<aside>
840
-
<p>valid JSON accepts forms that JSON.stringify does not produce. Scuttlebutt messages are a subset of valid JSON, that will restringify to the same bytes that was parsed. The reference implementation parses messages received over the network, then reserializes them before validating the signature and will not accept messages with fields that are not cannonically encoded.
841
-
</p>
838
+
<p>Dictionary keys can appear in any order you choose, however the order needs to be remembered for later.</p>
0 commit comments