Beispiel
@noble/hashes 2.3.0: sha3_512
Verifiziertes Beispiel für npm @noble/hashes 2.3.0: sha3_512. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.
sha256:35fb9742e7657f5772aab82182b148d76abe300ccbfadb42e15c30799e311ae4
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-19 |
Fall
HOW- Ziel
- verify @noble/hashes.sha3_512 in pkg:npm/%40noble/hashes@2.3.0
- Pakete
- Symbole
-
- @noble/hashes.sha3_512
- Umgebung
- node 22.23.2
- Erstellt
- 2026-09-19T17:13:27Z
Contract
- sha3_512 is exported as a callable function from @noble/hashes/sha3.js
- sha3_512 strictly requires Uint8Array inputs and throws TypeError on string inputs
- sha3_512 produces exact 64-byte digest matching standard SHA3-512 test vectors for empty, ASCII, and multi-block byte inputs
- sha3_512 exposes outputLen as 64 bytes and blockLen as 72 bytes
- sha3_512.create supports incremental streaming hash updates via update and digest with Uint8Array inputs
- sha3_512 incremental hash instance supports clone to independently branch hash computation
- sha3_512 incremental hash instance supports digestInto to write digest into pre-allocated Uint8Array
- sha3_512 incremental hash instance supports destroy which cleans state and prevents further updates
- module wrapper helpers hashSha3_512, hashSha3_512Hex, and hashChunksHex accept string and Uint8Array inputs to compute correct digests
Dateien
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Quelltext
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify @noble/hashes.sha3_512 in pkg:npm/%40noble/hashes@2.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40noble/hashes@2.3.0
Demonstrate these symbols/APIs:
- @noble/hashes.sha3_512
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:b4bc9fd9ab9b09e8a6293074b35a3b9c41cc5063c225e0c2ac244534a6bfe3b0","contract":["sha3_512 is exported as a callable function from @noble/hashes/sha3.js","sha3_512 strictly requires Uint8Array inputs and throws TypeError on string inputs","sha3_512 produces exact 64-byte digest matching standard SHA3-512 test vectors for empty, ASCII, and multi-block byte inputs","sha3_512 exposes outputLen as 64 bytes and blockLen as 72 bytes","sha3_512.create supports incremental streaming hash updates via update and digest with Uint8Array inputs","sha3_512 incremental hash instance supports clone to independently branch hash computation","sha3_512 incremental hash instance supports digestInto to write digest into pre-allocated Uint8Array","sha3_512 incremental hash instance supports destroy which cleans state and prevents further updates","module wrapper helpers hashSha3_512, hashSha3_512Hex, and hashChunksHex accept string and Uint8Array inputs to compute correct digests"],"goal":"verify @noble/hashes.sha3_512 in pkg:npm/%40noble/hashes@2.3.0","kind":"HOW","packages":["pkg:npm/%40noble/hashes@2.3.0"],"schemaVersion":1,"symbols":["@noble/hashes.sha3_512"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40noble/hashes@2.3.0"],"schemaVersion":1,"subject":"pkg:npm/%40noble/hashes@2.3.0","symbols":["@noble/hashes.sha3_512"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-noble-hashes-sha3-512",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-noble-hashes-sha3-512",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@noble/hashes": "2.3.0"
}
},
"node_modules/@noble/hashes": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.3.0.tgz",
"integrity": "sha512-oN+QwyX7VSHotibwubG3kpzbwKrfnyR6OOO+3Nk/53ADL7FmgHHz4TgrbaYKvvOw09u6QTx0oiH1cNCIOuN0CQ==",
"license": "MIT",
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
}
}
}
{
"name": "sample-noble-hashes-sha3-512",
"version": "1.0.0",
"private": true,
"type": "module",
"description": "Clean-room code sample for @noble/hashes sha3_512",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"@noble/hashes": "2.3.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify @noble/hashes.sha3_512 in pkg:npm/%40noble/hashes@2.3.0",
"kind": "HOW",
"packages": [
"pkg:npm/%40noble/hashes@2.3.0"
],
"symbols": [
"@noble/hashes.sha3_512"
]
}
import { sha3_512 } from '@noble/hashes/sha3.js';
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils.js';
/**
* Normalizes input to Uint8Array, encoding strings as UTF-8.
* In @noble/hashes v2, functions strictly require Uint8Array inputs.
* @param {string | Uint8Array} input
* @returns {Uint8Array}
*/
export function toBytes(input) {
if (typeof input === 'string') {
return utf8ToBytes(input);
}
return input;
}
/**
* Computes the SHA3-512 hash of a string or Uint8Array and returns the raw 64-byte Uint8Array digest.
* @param {string | Uint8Array} input
* @returns {Uint8Array}
*/
export function hashSha3_512(input) {
return sha3_512(toBytes(input));
}
/**
* Computes the SHA3-512 hash of a string or Uint8Array and returns a lowercase hex string.
* @param {string | Uint8Array} input
* @returns {string}
*/
export function hashSha3_512Hex(input) {
return bytesToHex(sha3_512(toBytes(input)));
}
/**
* Creates an incremental SHA3-512 hasher.
* @returns {ReturnType<typeof sha3_512.create>}
*/
export function createSha3_512Hasher() {
return sha3_512.create();
}
/**
* Computes SHA3-512 hash over an array of sequential chunks.
* @param {Array<string | Uint8Array>} chunks
* @returns {string}
*/
export function hashChunksHex(chunks) {
const hasher = sha3_512.create();
for (const chunk of chunks) {
hasher.update(toBytes(chunk));
}
return bytesToHex(hasher.digest());
}
export { sha3_512, bytesToHex, utf8ToBytes };
import assert from 'node:assert/strict';
import { sha3_512 as directSha3_512 } from '@noble/hashes/sha3.js';
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils.js';
import {
sha3_512,
toBytes,
hashSha3_512,
hashSha3_512Hex,
createSha3_512Hasher,
hashChunksHex,
} from '../src/index.js';
// 1. sha3_512 is exported as a callable function from @noble/hashes/sha3.js
assert.equal(typeof directSha3_512, 'function', 'sha3_512 must be a function');
assert.equal(typeof sha3_512, 'function', 're-exported sha3_512 must be a function');
// 2. sha3_512 strictly requires Uint8Array inputs and throws TypeError on string inputs
{
assert.throws(
() => directSha3_512('string-input'),
{
name: 'TypeError',
message: /expected Uint8Array/,
},
'sha3_512 must throw TypeError when given a string'
);
assert.throws(
() => {
const hasher = directSha3_512.create();
hasher.update('string-input');
},
{
name: 'TypeError',
message: /expected Uint8Array/,
},
'hasher.update must throw TypeError when given a string'
);
}
// 3. sha3_512 produces exact 64-byte digest matching standard SHA3-512 test vectors for empty, ASCII, and multi-block byte inputs
{
const emptyBytes = new Uint8Array(0);
const emptyDigest = directSha3_512(emptyBytes);
assert.equal(emptyDigest.length, 64, 'Empty input digest length must be 64 bytes');
assert.equal(
bytesToHex(emptyDigest),
'a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26',
'Empty input digest must match SHA3-512 vector'
);
const abcBytes = utf8ToBytes('abc');
const abcDigest = directSha3_512(abcBytes);
assert.equal(abcDigest.length, 64, 'abc digest length must be 64 bytes');
assert.equal(
bytesToHex(abcDigest),
'b751850b1a57168a5693cd924b6b096e08f621827444f70d884f5d0240d2712e10e116e9192af3c91a7ec57647e3934057340b4cf408d5a56592f8274eec53f0',
'abc digest must match SHA3-512 vector'
);
const foxMsg = 'The quick brown fox jumps over the lazy dog';
const foxDigest = directSha3_512(utf8ToBytes(foxMsg));
assert.equal(foxDigest.length, 64, 'fox digest length must be 64 bytes');
assert.equal(
bytesToHex(foxDigest),
'01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450',
'fox message digest must match SHA3-512 vector'
);
}
// 4. sha3_512 exposes outputLen as 64 bytes and blockLen as 72 bytes
assert.equal(directSha3_512.outputLen, 64, 'sha3_512.outputLen must be 64 bytes');
assert.equal(directSha3_512.blockLen, 72, 'sha3_512.blockLen must be 72 bytes');
// 5. sha3_512.create supports incremental streaming hash updates via update and digest with Uint8Array inputs
{
const hasher = directSha3_512.create();
hasher.update(utf8ToBytes('The quick '));
hasher.update(utf8ToBytes('brown fox '));
hasher.update(utf8ToBytes('jumps over the lazy dog'));
const digestHex = bytesToHex(hasher.digest());
assert.equal(
digestHex,
'01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450',
'Incremental sha3_512 stream must match expected multi-part digest'
);
}
// 6. sha3_512 incremental hash instance supports clone to independently branch hash computation
{
const base = directSha3_512.create();
base.update(utf8ToBytes('common prefix: '));
const branchA = base.clone();
const branchB = base.clone();
branchA.update(utf8ToBytes('action_alpha'));
branchB.update(utf8ToBytes('action_beta'));
assert.equal(
bytesToHex(branchA.digest()),
bytesToHex(directSha3_512(utf8ToBytes('common prefix: action_alpha'))),
'Cloned branch A must compute independent digest'
);
assert.equal(
bytesToHex(branchB.digest()),
bytesToHex(directSha3_512(utf8ToBytes('common prefix: action_beta'))),
'Cloned branch B must compute independent digest'
);
}
// 7. sha3_512 incremental hash instance supports digestInto to write digest into pre-allocated Uint8Array
{
const outBuf = new Uint8Array(64);
const hasher = directSha3_512.create();
hasher.update(utf8ToBytes('abc'));
hasher.digestInto(outBuf);
assert.equal(
bytesToHex(outBuf),
'b751850b1a57168a5693cd924b6b096e08f621827444f70d884f5d0240d2712e10e116e9192af3c91a7ec57647e3934057340b4cf408d5a56592f8274eec53f0',
'digestInto must write digest into target Uint8Array buffer'
);
}
// 8. sha3_512 incremental hash instance supports destroy which cleans state and prevents further updates
{
const hasher = directSha3_512.create();
hasher.update(utf8ToBytes('sensitive data'));
hasher.destroy();
assert.throws(
() => hasher.update(utf8ToBytes('more data')),
/destroyed/,
'Calling update after destroy must throw'
);
}
// 9. module wrapper helpers hashSha3_512, hashSha3_512Hex, and hashChunksHex accept string and Uint8Array inputs to compute correct digests
{
const rawFromStr = hashSha3_512('abc');
const rawFromBytes = hashSha3_512(utf8ToBytes('abc'));
assert(rawFromStr instanceof Uint8Array, 'hashSha3_512 must return Uint8Array');
assert.equal(rawFromStr.length, 64, 'hashSha3_512 length must be 64');
assert.equal(bytesToHex(rawFromStr), bytesToHex(rawFromBytes), 'String and byte input must produce identical hash');
assert.equal(
hashSha3_512Hex('abc'),
'b751850b1a57168a5693cd924b6b096e08f621827444f70d884f5d0240d2712e10e116e9192af3c91a7ec57647e3934057340b4cf408d5a56592f8274eec53f0',
'hashSha3_512Hex must return correct lowercase hex string'
);
const chunksHex = hashChunksHex(['The quick ', 'brown fox ', utf8ToBytes('jumps over the lazy dog')]);
assert.equal(
chunksHex,
'01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450',
'hashChunksHex must match expected multi-part digest'
);
}
console.log('All @noble/hashes.sha3_512 contract assertions passed.');
Ursprungs-Seeder
anonym