File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -156,13 +156,22 @@ The checksum is calculated by converting the top-level JSON object to an array o
156156SHA256 hash of the result in lowercase hexadecimal format, and taking a prefix of at least 8
157157characters.
158158
159- For example:
159+ "stringifying" in this context means converting the array to a JSON string following
160+ [https://262.ecma-international.org/16.0/index.html#sec-json.stringify ECMAScript's JSON.stringify function specification ]
161+ (without additional <code>replacer </code> or <code>space </code> arguments).
162+ This specification covers special cases such as non-ascii characters and newlines.
163+
164+ Optional fields without a value should not be included in the key-value pairs array.
165+ Also, there should not be a key-value pair for the "checksum" field itself.
166+
167+ Code example:
160168<source lang="javascript">
169+ delete recoveryPlanJson.checksum; // In case the checksum was calculated previously and the object was then modified
161170const checksumData = new TextEncoder().encode(
162171 JSON.stringify(Object.entries(recoveryPlanJson).sort()),
163172);
164173const checksum = new Uint8Array(await crypto.subtle.digest('SHA-256', checksumData));
165- const checksumHex = Array.from(checksum).map(b => b.toString(16).padStart(2, '0')).join('').slice(0, 8);
174+ recoveryPlanJson.checksum = Array.from(checksum).map(b => b.toString(16).padStart(2, '0')).join('').slice(0, 8);
166175</source>
167176
168177Checksum hex string should be at least 8 characters long. Wallets may choose to use a longer
You can’t perform that action at this time.
0 commit comments