@superinstance/canary-hash 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/index.js +35 -0
- package/package.json +11 -0
- package/test.js +8 -0
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @superinstance/canary-hash
|
|
2
|
+
|
|
3
|
+
Fleet canary hash for Quilt polyformalism — `fnv1a-64("café Δ 日本語") = 0x024a555471370b18d`.
|
|
4
|
+
|
|
5
|
+
Run `node index.js` to verify the canary.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
const { fnv1a64, EXPECTED } = require('@superinstance/canary-hash');
|
|
11
|
+
|
|
12
|
+
const h = fnv1a64("café Δ 日本語");
|
|
13
|
+
console.log(h === EXPECTED); // true
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## What this is
|
|
17
|
+
|
|
18
|
+
This is the canary that the Quilt polyformalism fleet verifies on every port. It runs in 7+ languages (Python, TypeScript, Rust, Bash, JS ESM, C#/.NET 9, SQL/SQLite) and produces the same hash byte-exactly.
|
|
19
|
+
|
|
20
|
+
## License
|
|
21
|
+
|
|
22
|
+
MIT — Casey / SuperInstance
|
package/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @superinstance/canary-hash — fleet canary for Quilt polyformalism.
|
|
3
|
+
*
|
|
4
|
+
* fnv1a-64('café Δ 日本語') = 0x024a555471370b18d
|
|
5
|
+
*
|
|
6
|
+
* Run this from any language port to verify byte-exact polyformalism parity.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
function fnv1a64(s) {
|
|
10
|
+
const bytes = new TextEncoder().encode(s);
|
|
11
|
+
let h = 0xcbf29ce484222325n;
|
|
12
|
+
const prime = 0x100000001b3n;
|
|
13
|
+
const mask = (1n << 64n) - 1n;
|
|
14
|
+
for (const b of bytes) {
|
|
15
|
+
h ^= BigInt(b);
|
|
16
|
+
h = (h * prime) & mask;
|
|
17
|
+
}
|
|
18
|
+
return h;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const EXPECTED = 0x024a555471370b18n;
|
|
22
|
+
const s = "café Δ 日本語";
|
|
23
|
+
const h = fnv1a64(s);
|
|
24
|
+
|
|
25
|
+
module.exports = { fnv1a64, EXPECTED, canaryString: s };
|
|
26
|
+
|
|
27
|
+
if (require.main === module) {
|
|
28
|
+
console.log(`0x${h.toString(16).padStart(16, '0')}`);
|
|
29
|
+
if (h === EXPECTED) {
|
|
30
|
+
console.log("✓ Fleet canary verified: 0x024a555471370b18d");
|
|
31
|
+
} else {
|
|
32
|
+
console.error(`✗ FAIL: expected 0x024a555471370b18d, got 0x${h.toString(16).padStart(16, '0')}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@superinstance/canary-hash",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Fleet canary hash for Quilt polyformalism — fnv1a-64('café Δ 日本語') = 0x024a555471370b18d",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "node test.js"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": "https://github.com/SuperInstance/quilt-canary"
|
|
11
|
+
}
|
package/test.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const { fnv1a64, EXPECTED } = require('./index.js');
|
|
2
|
+
const h = fnv1a64("café Δ 日本語");
|
|
3
|
+
console.log(`0x${h.toString(16).padStart(16, '0')}`);
|
|
4
|
+
if (h !== EXPECTED) {
|
|
5
|
+
console.error(`✗ FAIL: expected 0x${EXPECTED.toString(16)}, got 0x${h.toString(16)}`);
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
8
|
+
console.log("✓ test passed");
|