Sample
@noble/hashes 2.3.0: blake2b
Verified sample for npm @noble/hashes 2.3.0: blake2b. The contract ran on node 22 · linux debian/x64 · docker and passed: blake2b computes standard 64-byte…
sha256:ed9558a09077b96d507cbefc4eff04f9b266a73ed2847e6b6eb3afa8713ae44b
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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-06 |
Case
HOW- Goal
- verify @noble/hashes.blake2b in pkg:npm/%40noble/hashes@2.3.0
- Packages
- Symbols
-
- @noble/hashes.blake2b
- Environment
- node 22.23.2
- Created
- 2026-09-06T10:05:35Z
Contract
- blake2b computes standard 64-byte BLAKE2b cryptographic hash digests for byte inputs
- blake2b supports configurable output digest length via dkLen option from 1 to 64 bytes
- blake2b supports streaming incremental hashing with create, update, and digest
- blake2b supports keyed hashing in MAC mode with a secret key
- blake2b supports optional salt and personalization byte arrays
- blake2b instance clone preserves internal state for branch hashing
- blake2b digestInto writes the computed hash directly into a pre-allocated destination buffer
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
Source
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.blake2b 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.blake2b
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:e1cd7d2a3dfd8def72667cb2588be07f39bb5c58a196836548ae2bd8f1f3efa9","constraints":{"executionContext":"node"},"contract":["blake2b computes standard 64-byte BLAKE2b cryptographic hash digests for byte inputs","blake2b supports configurable output digest length via dkLen option from 1 to 64 bytes","blake2b supports streaming incremental hashing with create, update, and digest","blake2b supports keyed hashing in MAC mode with a secret key","blake2b supports optional salt and personalization byte arrays","blake2b instance clone preserves internal state for branch hashing","blake2b digestInto writes the computed hash directly into a pre-allocated destination buffer"],"goal":"verify @noble/hashes.blake2b in pkg:npm/%40noble/hashes@2.3.0","kind":"HOW","packages":["pkg:npm/%40noble/hashes@2.3.0"],"schemaVersion":1,"symbols":["@noble/hashes.blake2b"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","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.blake2b"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-noble-hashes-blake2b",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-noble-hashes-blake2b",
"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-blake2b",
"version": "1.0.0",
"type": "module",
"private": true,
"description": "verify @noble/hashes.blake2b in pkg:npm/%40noble/hashes@2.3.0",
"main": "src/index.mjs",
"license": "MIT-0",
"dependencies": {
"@noble/hashes": "2.3.0"
}
}
{
"schemaVersion": 1,
"goal": "verify @noble/hashes.blake2b in pkg:npm/%40noble/hashes@2.3.0",
"kind": "HOW",
"packages": [
"pkg:npm/%40noble/hashes@2.3.0"
],
"symbols": [
"@noble/hashes.blake2b"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import { blake2b } from '@noble/hashes/blake2.js';
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils.js';
export { blake2b, bytesToHex, utf8ToBytes };
/**
* Computes BLAKE2b hash of an input (string or Uint8Array) and returns Uint8Array digest.
* @param {string|Uint8Array} input
* @param {import('@noble/hashes/blake2.js').Blake2Opts} [options]
* @returns {Uint8Array}
*/
export function hashBlake2b(input, options) {
const bytes = typeof input === 'string' ? utf8ToBytes(input) : input;
return blake2b(bytes, options);
}
/**
* Computes BLAKE2b hash of an input and returns hexadecimal string.
* @param {string|Uint8Array} input
* @param {import('@noble/hashes/blake2.js').Blake2Opts} [options]
* @returns {string} Hex-encoded digest
*/
export function hashBlake2bHex(input, options) {
return bytesToHex(hashBlake2b(input, options));
}
/**
* Computes BLAKE2b MAC with a secret key.
* @param {Uint8Array} key
* @param {string|Uint8Array} message
* @param {import('@noble/hashes/blake2.js').Blake2Opts} [options]
* @returns {Uint8Array}
*/
export function computeBlake2bMac(key, message, options = {}) {
const msgBytes = typeof message === 'string' ? utf8ToBytes(message) : message;
return blake2b(msgBytes, { ...options, key });
}
/**
* Creates an incremental BLAKE2b instance.
* @param {import('@noble/hashes/blake2.js').Blake2Opts} [options]
* @returns {ReturnType<typeof blake2b.create>}
*/
export function createBlake2b(options) {
return blake2b.create(options);
}
import assert from 'node:assert/strict';
import {
blake2b,
bytesToHex,
utf8ToBytes,
hashBlake2b,
hashBlake2bHex,
computeBlake2bMac,
createBlake2b
} from '../src/index.mjs';
// 1. Export verification
assert.equal(typeof blake2b, 'function', 'blake2b must be a function');
assert.equal(blake2b.outputLen, 64, 'default outputLen must be 64 bytes');
assert.equal(blake2b.blockLen, 128, 'blockLen must be 128 bytes');
// 2. blake2b computes standard 64-byte BLAKE2b cryptographic hash digests for byte inputs
{
const msg = utf8ToBytes('The quick brown fox jumps over the lazy dog');
const digest = blake2b(msg);
assert.equal(digest.length, 64, 'digest length must be 64 bytes');
const expectedHex = 'a8add4bdddfd93e4877d2746e62817b116364a1fa7bc148d95090bc7333b3673f82401cf7aa2e4cb1ecd90296e3f14cb5413f8ed77be73045b13914cdcd6a918';
assert.equal(bytesToHex(digest), expectedHex, 'digest must match standard BLAKE2b-512 test vector');
assert.equal(hashBlake2bHex('The quick brown fox jumps over the lazy dog'), expectedHex);
// Empty string vector
const emptyDigest = blake2b(utf8ToBytes(''));
assert.equal(
bytesToHex(emptyDigest),
'786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce',
'empty input must match standard empty BLAKE2b digest'
);
}
// 3. blake2b supports configurable output digest length via dkLen option from 1 to 64 bytes
{
const msg = utf8ToBytes('The quick brown fox jumps over the lazy dog');
const digest32 = blake2b(msg, { dkLen: 32 });
assert.equal(digest32.length, 32, 'dkLen: 32 must produce 32-byte digest');
assert.equal(
bytesToHex(digest32),
'01718cec35cd3d796dd00020e0bfecb473ad23457d063b75eff29c0ffa2e58a9',
'32-byte digest must match expected BLAKE2b-256 test vector'
);
const digest16 = blake2b(msg, { dkLen: 16 });
assert.equal(digest16.length, 16, 'dkLen: 16 must produce 16-byte digest');
const digest1 = blake2b(msg, { dkLen: 1 });
assert.equal(digest1.length, 1, 'dkLen: 1 must produce 1-byte digest');
const digest64 = blake2b(msg, { dkLen: 64 });
assert.equal(digest64.length, 64, 'dkLen: 64 must produce 64-byte digest');
assert.deepEqual(digest64, blake2b(msg));
}
// 4. blake2b supports streaming incremental hashing with create, update, and digest
{
const hasher = createBlake2b({ dkLen: 32 });
hasher.update(utf8ToBytes('The quick brown '));
hasher.update(utf8ToBytes('fox jumps over the lazy dog'));
const incrementalDigest = hasher.digest();
assert.equal(incrementalDigest.length, 32);
assert.equal(
bytesToHex(incrementalDigest),
'01718cec35cd3d796dd00020e0bfecb473ad23457d063b75eff29c0ffa2e58a9',
'incremental hashing must match one-shot hash result'
);
}
// 5. blake2b supports keyed hashing in MAC mode with a secret key
{
const msg = utf8ToBytes('The quick brown fox jumps over the lazy dog');
const key = new Uint8Array(32).fill(0x5a);
const mac1 = computeBlake2bMac(key, msg, { dkLen: 32 });
const mac2 = blake2b(msg, { key, dkLen: 32 });
assert.equal(mac1.length, 32);
assert.deepEqual(mac1, mac2, 'computeBlake2bMac must match blake2b with key option');
const unkeyed = blake2b(msg, { dkLen: 32 });
assert.notDeepEqual(mac1, unkeyed, 'keyed MAC must differ from unkeyed digest');
const diffKey = new Uint8Array(32).fill(0x5b);
const macDiff = blake2b(msg, { key: diffKey, dkLen: 32 });
assert.notDeepEqual(mac1, macDiff, 'different keys must produce different MACs');
}
// 6. blake2b supports optional salt and personalization byte arrays
{
const msg = utf8ToBytes('The quick brown fox jumps over the lazy dog');
const salt = new Uint8Array(16).fill(0x11);
const personalization = new Uint8Array(16).fill(0x22);
const salted = blake2b(msg, { dkLen: 32, salt, personalization });
assert.equal(salted.length, 32);
const regular = blake2b(msg, { dkLen: 32 });
assert.notDeepEqual(salted, regular, 'salted/personalized digest must differ from default');
const diffSalt = new Uint8Array(16).fill(0x12);
const salted2 = blake2b(msg, { dkLen: 32, salt: diffSalt, personalization });
assert.notDeepEqual(salted, salted2, 'different salts must produce different digests');
}
// 7. blake2b instance clone preserves internal state for branch hashing
{
const prefix = utf8ToBytes('common-prefix-data-');
const branchA = utf8ToBytes('branch-alpha');
const branchB = utf8ToBytes('branch-beta');
const original = blake2b.create({ dkLen: 32 });
original.update(prefix);
const cloned = original.clone();
original.update(branchA);
cloned.update(branchB);
const digestA = original.digest();
const digestB = cloned.digest();
assert.notDeepEqual(digestA, digestB, 'branched hashes from clone must differ');
// Verify that cloned prefix matches a fresh instance
const freshA = blake2b.create({ dkLen: 32 });
freshA.update(prefix);
freshA.update(branchA);
assert.deepEqual(digestA, freshA.digest(), 'cloned state must faithfully reproduce continuous hashing');
}
// 8. blake2b digestInto writes the computed hash directly into a pre-allocated destination buffer
{
const msg = utf8ToBytes('The quick brown fox jumps over the lazy dog');
const expectedDigest = blake2b(msg);
const destBuffer = new Uint8Array(64);
const hasher = blake2b.create();
hasher.update(msg);
hasher.digestInto(destBuffer);
assert.deepEqual(destBuffer, expectedDigest, 'digestInto must write full digest into buffer');
// Offset destination buffer with 4-byte aligned byteOffset
const bigBuffer = new Uint8Array(100).fill(0xff);
const view = bigBuffer.subarray(12, 76); // 12 is 4-byte aligned
const hasher2 = blake2b.create();
hasher2.update(msg);
hasher2.digestInto(view);
assert.deepEqual(view, expectedDigest, 'digestInto must write into 4-byte aligned subarray correctly');
assert.equal(bigBuffer[11], 0xff, 'bytes outside destination slice must remain untouched');
assert.equal(bigBuffer[76], 0xff, 'bytes outside destination slice must remain untouched');
// Unaligned byteOffset throws RangeError
const unalignedView = bigBuffer.subarray(10, 74);
const hasher3 = blake2b.create();
assert.throws(
() => hasher3.digestInto(unalignedView),
RangeError,
'digestInto must reject non-4-byte aligned buffers with RangeError'
);
}
console.log('Contract assertions passed.');
Origin Seeder
anonymous