use "JSON Canonicalization Scheme" (JSC) as deterministic JSON stringify (#4)

This commit is contained in:
Mikey 2023-05-09 19:27:47 +12:00 committed by GitHub
parent d1247afb06
commit f8bc73d52b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 11 deletions

View File

@ -1,6 +1,6 @@
const blake3 = require('blake3')
const base58 = require('bs58')
const stringify = require('fast-json-stable-stringify')
const stringify = require('canonicalize')
/**
* @typedef {import('./index').Msg} Msg

View File

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: LGPL-3.0-only
const stringify = require('fast-json-stable-stringify')
const stringify = require('canonicalize')
const ed25519 = require('ssb-keys/sodium')
const base58 = require('bs58')
const union = require('set.prototype.union')

View File

@ -1,6 +1,6 @@
const blake3 = require('blake3')
const base58 = require('bs58')
const stringify = require('fast-json-stable-stringify')
const stringify = require('canonicalize')
/**
* @param {any} content

View File

@ -1,6 +1,6 @@
const base58 = require('bs58')
const ed25519 = require('ssb-keys/sodium')
const stringify = require('fast-json-stable-stringify')
const stringify = require('canonicalize')
const Tangle = require('./tangle')
const representContent = require('./represent-content')

View File

@ -30,7 +30,7 @@
"async-append-only-log": "^4.3.10",
"blake3": "^2.1.7",
"bs58": "^5.0.0",
"fast-json-stable-stringify": "^2.1.0",
"canonicalize": "^2.0.0",
"obz": "^1.1.0",
"promisify-4loc": "^1.0.0",
"push-stream": "^11.2.0",

View File

@ -65,9 +65,4 @@ Given the root msg ID, any peer can thus refer to the feed tangle, because the r
## JSON serialization
Whenever we need to serialize any JSON in the context of creating a Feed V1 message, we use the following rules:
- Object fields are ordered alphabetically by field key
- No whitespace nor newliners are added
- No trailing commas are added
- UTF-8 encoding
Whenever we need to serialize any JSON in the context of creating a Feed V1 message, we follow the "JSON Canonicalization Scheme" (JSC) defined by [RFC 8785](https://tools.ietf.org/html/rfc8785).