サンプル
@noble/hashes 2.3.0: blake3
検証済みサンプル — npm @noble/hashes 2.3.0: blake3. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: blake3 exports function with outputLen 32 blockLen 64…
sha256:8346a625e237e65c4e0e638eff7285eca78b1df76ec02f5a556d30e0c543132a
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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 |
ケース
HOW- ゴール
- verify @noble/hashes.blake3 in pkg:npm/%40noble/hashes@2.3.0
- パッケージ
- シンボル
-
- @noble/hashes.blake3
- 環境
- node 22.23.2
- 作成日
- 2026-09-06T12:13:40Z
コントラクト
- blake3 exports function with outputLen 32 blockLen 64 canXOF true and create function
- blake3 computes standard 32-byte hash from Uint8Array matching official BLAKE3 test vectors
- blake3 supports incremental hashing via create update and digest yielding identical output to one-shot
- blake3 supports optional 32-byte key for keyed MAC computation
- blake3 supports optional context for key derivation function mode
- blake3 supports extendable output via dkLen option and xof method
- blake3 throws TypeError or Error when input is not Uint8Array or when key length is invalid or when key and context are both provided
ファイル
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
ソース
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.blake3 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.blake3
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:62642f990d40e22d73d135380dde01b28d3b88c5cf09218355c3a31e352a4f07","contract":["blake3 exports function with outputLen 32 blockLen 64 canXOF true and create function","blake3 computes standard 32-byte hash from Uint8Array matching official BLAKE3 test vectors","blake3 supports incremental hashing via create update and digest yielding identical output to one-shot","blake3 supports optional 32-byte key for keyed MAC computation","blake3 supports optional context for key derivation function mode","blake3 supports extendable output via dkLen option and xof method","blake3 throws TypeError or Error when input is not Uint8Array or when key length is invalid or when key and context are both provided"],"goal":"verify @noble/hashes.blake3 in pkg:npm/%40noble/hashes@2.3.0","kind":"HOW","packages":["pkg:npm/%40noble/hashes@2.3.0"],"schemaVersion":1,"symbols":["@noble/hashes.blake3"]},"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.blake3"],"verifierAdapter":"node-typescript@1"}
import { blake3 } from '@noble/hashes/blake3.js';
/**
* Computes BLAKE3 hash of the given byte array.
*
* @param {Uint8Array} data
* @param {object} [opts]
* @returns {Uint8Array}
*/
export function hashBlake3(data, opts) {
return blake3(data, opts);
}
/**
* Creates an incremental BLAKE3 hasher instance.
*
* @param {object} [opts]
* @returns {object}
*/
export function createBlake3(opts) {
return blake3.create(opts);
}
export { blake3 };
export default blake3;
{
"name": "sample-noble-hashes-blake3",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-noble-hashes-blake3",
"version": "1.0.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-blake3",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"@noble/hashes": "2.3.0"
}
}
{
"schemaVersion": 1,
"goal": "verify @noble/hashes.blake3 in pkg:npm/%40noble/hashes@2.3.0",
"kind": "HOW",
"packages": [
"pkg:npm/%40noble/hashes@2.3.0"
],
"symbols": [
"@noble/hashes.blake3"
]
}
import assert from 'node:assert/strict';
import { blake3, hashBlake3, createBlake3 } from '../index.mjs';
function toHex(bytes) {
return Buffer.from(bytes).toString('hex');
}
// 1. blake3 exports function with outputLen 32 blockLen 64 canXOF true and create function
{
assert.strictEqual(typeof blake3, 'function', 'blake3 should be a function');
assert.strictEqual(blake3.outputLen, 32, 'outputLen should be 32');
assert.strictEqual(blake3.blockLen, 64, 'blockLen should be 64');
assert.strictEqual(blake3.canXOF, true, 'canXOF should be true');
assert.strictEqual(typeof blake3.create, 'function', 'blake3.create should be a function');
assert.strictEqual(typeof hashBlake3, 'function', 'hashBlake3 helper should be a function');
assert.strictEqual(typeof createBlake3, 'function', 'createBlake3 helper should be a function');
}
// 2. blake3 computes standard 32-byte hash from Uint8Array matching official BLAKE3 test vectors
{
const emptyHash = blake3(new Uint8Array(0));
assert.strictEqual(emptyHash instanceof Uint8Array, true);
assert.strictEqual(emptyHash.length, 32);
assert.strictEqual(
toHex(emptyHash),
'af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262',
'empty input hash must match official BLAKE3 vector'
);
const abc = new Uint8Array([0x61, 0x62, 0x63]);
const abcHash = hashBlake3(abc);
assert.strictEqual(abcHash.length, 32);
assert.strictEqual(
toHex(abcHash),
'6437b3ac38465133ffb63b75273a8db548c558465d79db03fd359c6cd5bd9d85',
'abc hash must match official BLAKE3 vector'
);
}
// 3. blake3 supports incremental hashing via create update and digest yielding identical output to one-shot
{
const part1 = new Uint8Array([1, 2, 3, 4, 5]);
const part2 = new Uint8Array([6, 7, 8, 9, 10]);
const full = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
const hasher = createBlake3();
hasher.update(part1);
hasher.update(part2);
const digest = hasher.digest();
const oneShot = blake3(full);
assert.deepStrictEqual(digest, oneShot, 'incremental hash must equal one-shot hash');
}
// 4. blake3 supports optional 32-byte key for keyed MAC computation
{
const msg = new Uint8Array([0x61, 0x62, 0x63]);
const key = new Uint8Array(32).fill(0x42);
const keyed = blake3(msg, { key });
const unkeyed = blake3(msg);
assert.strictEqual(keyed.length, 32);
assert.notDeepStrictEqual(keyed, unkeyed, 'keyed hash must differ from unkeyed hash');
const keyedHasher = blake3.create({ key });
keyedHasher.update(msg);
assert.deepStrictEqual(keyedHasher.digest(), keyed, 'incremental keyed hash must match one-shot keyed hash');
}
// 5. blake3 supports optional context for key derivation function mode
{
const msg = new Uint8Array([0x61, 0x62, 0x63]);
const context = new Uint8Array([0x61, 0x70, 0x70]);
const kdf = blake3(msg, { context });
const unkeyed = blake3(msg);
assert.strictEqual(kdf.length, 32);
assert.notDeepStrictEqual(kdf, unkeyed, 'derived key must differ from default hash');
}
// 6. blake3 supports extendable output via dkLen option and xof method
{
const msg = new Uint8Array([0x61, 0x62, 0x63]);
const abcHash = blake3(msg);
for (const dkLen of [16, 32, 64, 128]) {
const out = blake3(msg, { dkLen });
assert.strictEqual(out.length, dkLen, `digest length must match dkLen ${dkLen}`);
}
const xof64 = blake3(msg, { dkLen: 64 });
assert.strictEqual(xof64.length, 64);
assert.deepStrictEqual(xof64.subarray(0, 32), abcHash, 'first 32 bytes must match default digest');
const hasher = blake3.create();
hasher.update(msg);
const xofOut = hasher.xof(64);
assert.deepStrictEqual(xofOut, xof64, 'hasher xof must match one-shot xof output');
}
// 7. blake3 throws TypeError or Error when input is not Uint8Array or when key length is invalid or when key and context are both provided
{
const msg = new Uint8Array([0x61, 0x62, 0x63]);
const key = new Uint8Array(32).fill(0x42);
const context = new Uint8Array([0x61, 0x70, 0x70]);
assert.throws(
() => blake3('not bytes'),
/Uint8Array/i,
'should throw when input is not Uint8Array'
);
assert.throws(
() => blake3([1, 2, 3]),
/Uint8Array/i,
'should throw when input is an array'
);
assert.throws(
() => blake3(msg, { key: new Uint8Array(16) }),
/key/i,
'should throw when key length is not 32 bytes'
);
assert.throws(
() => blake3(msg, { key, context }),
/cannot use both "key" and "context"/i,
'should throw when both key and context are provided'
);
}
console.log('All @noble/hashes.blake3 contract assertions passed.');
オリジンシーダー
匿名