샘플
@noble/hashes 1.4.0: blake2b
검증된 샘플 — npm @noble/hashes 1.4.0: blake2b. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: assert blake2b produces exact 64-byte hash matching…
sha256:a0004f50e723e56a9a78a675a4a9b2cfba61134619efc015ea159b1c582b1dec
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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.blake2b in pkg:npm/%40noble/hashes@1.4.0
- 심벌
-
- @noble/hashes.blake2b
- 환경
- node 22.23.2
- 생성일
- 2026-09-06T12:46:17Z
컨트랙트
- assert blake2b produces exact 64-byte hash matching RFC 7693 standard test vectors for empty and standard inputs
- assert blake2b accepts both UTF-8 string and Uint8Array byte inputs interchangeably
- assert blake2b exposes outputLen as 64 bytes and blockLen as 128 bytes
- assert blake2b supports variable output digest lengths via dkLen option
- assert blake2b supports keyed hashing for MAC generation via key option
- assert blake2b.create supports incremental streaming hash updates via update and digest
- assert blake2b incremental hash instance supports clone to branch hash computation
- assert blake2b incremental hash instance supports digestInto to write digest into pre-allocated Uint8Array
- assert blake2b incremental hash instance supports destroy to clean up internal buffer state
- assert blake2b throws error when dkLen exceeds maximum keyLen limit
파일
- PROMPT.md
- csx.json
- index.js
- 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.blake2b in pkg:npm/%40noble/hashes@1.4.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40noble/hashes@1.4.0
Demonstrate these symbols/APIs:
- @noble/hashes.blake2b
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:449cbc4e05a928cfe9c4ff8462ffa499a33f38930deb9b155a1b39c0f26b0416","contract":["assert blake2b produces exact 64-byte hash matching RFC 7693 standard test vectors for empty and standard inputs","assert blake2b accepts both UTF-8 string and Uint8Array byte inputs interchangeably","assert blake2b exposes outputLen as 64 bytes and blockLen as 128 bytes","assert blake2b supports variable output digest lengths via dkLen option","assert blake2b supports keyed hashing for MAC generation via key option","assert blake2b.create supports incremental streaming hash updates via update and digest","assert blake2b incremental hash instance supports clone to branch hash computation","assert blake2b incremental hash instance supports digestInto to write digest into pre-allocated Uint8Array","assert blake2b incremental hash instance supports destroy to clean up internal buffer state","assert blake2b throws error when dkLen exceeds maximum keyLen limit"],"goal":"verify @noble/hashes.blake2b in pkg:npm/%40noble/hashes@1.4.0","kind":"HOW","packages":["pkg:npm/%40noble/hashes@1.4.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@1.4.0"],"schemaVersion":1,"subject":"pkg:npm/%40noble/hashes@1.4.0","symbols":["@noble/hashes.blake2b"],"verifierAdapter":"node-typescript@1"}
const { blake2b } = require('@noble/hashes/blake2b');
const { bytesToHex, utf8ToBytes, toBytes } = require('@noble/hashes/utils');
/**
* Computes BLAKE2b hash of an input.
* @param {string | Uint8Array} input
* @param {object} [opts]
* @returns {Uint8Array}
*/
function hashBlake2b(input, opts) {
return blake2b(input, opts);
}
/**
* Computes BLAKE2b hash and returns lowercase hex string.
* @param {string | Uint8Array} input
* @param {object} [opts]
* @returns {string}
*/
function hashBlake2bHex(input, opts) {
return bytesToHex(blake2b(input, opts));
}
/**
* Creates an incremental BLAKE2b hasher.
* @param {object} [opts]
* @returns {import('@noble/hashes/utils').Hash<any>}
*/
function createBlake2bHasher(opts) {
return blake2b.create(opts);
}
/**
* Computes BLAKE2b over chunks and returns hex digest.
* @param {Array<string | Uint8Array>} chunks
* @param {object} [opts]
* @returns {string}
*/
function hashChunksHex(chunks, opts) {
const hasher = blake2b.create(opts);
for (const chunk of chunks) {
hasher.update(typeof chunk === 'string' ? utf8ToBytes(chunk) : chunk);
}
return bytesToHex(hasher.digest());
}
module.exports = {
blake2b,
hashBlake2b,
hashBlake2bHex,
createBlake2bHasher,
hashChunksHex,
bytesToHex,
utf8ToBytes,
toBytes,
};
{
"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": "1.4.0"
}
},
"node_modules/@noble/hashes": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz",
"integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==",
"license": "MIT",
"engines": {
"node": ">= 16"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
}
}
}
{
"name": "sample-noble-hashes-blake2b",
"version": "1.0.0",
"private": true,
"description": "verify @noble/hashes.blake2b in pkg:npm/%40noble/hashes@1.4.0",
"main": "index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"@noble/hashes": "1.4.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify @noble/hashes.blake2b in pkg:npm/%40noble/hashes@1.4.0",
"kind": "HOW",
"packages": [
"pkg:npm/%40noble/hashes@1.4.0"
],
"symbols": [
"@noble/hashes.blake2b"
]
}
import assert from 'node:assert';
import { blake2b } from '@noble/hashes/blake2b';
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
import {
hashBlake2b,
hashBlake2bHex,
createBlake2bHasher,
hashChunksHex,
} from '../index.js';
// 1. One-shot hashing of empty input matches RFC 7693 standard vector
const emptyHashBytes = blake2b('');
const emptyHashHex = bytesToHex(emptyHashBytes);
assert.strictEqual(
emptyHashHex,
'786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce',
'Empty string blake2b must match RFC 7693 standard vector'
);
assert.strictEqual(emptyHashBytes.length, 64, 'Default digest byte length must be 64');
// 2. One-shot hashing with known test vector (string and Uint8Array)
const abcHashHex = bytesToHex(blake2b('abc'));
const abcHashFromBytes = bytesToHex(blake2b(utf8ToBytes('abc')));
assert.strictEqual(
abcHashHex,
'ba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923',
'blake2b("abc") must match RFC 7693 test vector'
);
assert.strictEqual(
abcHashHex,
abcHashFromBytes,
'String and Uint8Array byte inputs must produce identical digests'
);
// 3. Algorithm properties: outputLen and blockLen
assert.strictEqual(blake2b.outputLen, 64, 'blake2b.outputLen must be 64 bytes');
assert.strictEqual(blake2b.blockLen, 128, 'blake2b.blockLen must be 128 bytes');
// 4. Variable output digest length (dkLen)
const hash32Bytes = blake2b('abc', { dkLen: 32 });
assert.strictEqual(hash32Bytes.length, 32, 'Digest length with dkLen: 32 must be 32 bytes');
assert.strictEqual(
bytesToHex(hash32Bytes),
'bddd813c634239723171ef3fee98579b94964e3bb1cb3e427262c8c068d52319',
'blake2b("abc", { dkLen: 32 }) must match expected BLAKE2b-256 output'
);
// 5. Keyed hashing for MAC generation
const key = utf8ToBytes('secret-key-for-mac');
const keyedHash = blake2b('authenticated payload', { key });
assert.strictEqual(keyedHash.length, 64, 'Keyed hash output must be 64 bytes');
const unkeyedHash = blake2b('authenticated payload');
assert.notStrictEqual(
bytesToHex(keyedHash),
bytesToHex(unkeyedHash),
'Keyed hash must differ from unkeyed hash'
);
// 6. Incremental streaming updates with blake2b.create()
const streamHasher = blake2b.create({ dkLen: 32 });
streamHasher.update(utf8ToBytes('a'));
streamHasher.update('bc');
const streamDigest = bytesToHex(streamHasher.digest());
assert.strictEqual(
streamDigest,
bytesToHex(hash32Bytes),
'Incremental blake2b.create() stream must match one-shot hash'
);
// 7. Cloning hash state mid-stream to branch computations
const baseHasher = blake2b.create();
baseHasher.update('common prefix: ');
const branchA = baseHasher.clone();
const branchB = baseHasher.clone();
branchA.update('branch_alpha');
branchB.update('branch_beta');
assert.strictEqual(
bytesToHex(branchA.digest()),
bytesToHex(blake2b('common prefix: branch_alpha')),
'Cloned branch A must compute independent digest matching one-shot hash'
);
assert.strictEqual(
bytesToHex(branchB.digest()),
bytesToHex(blake2b('common prefix: branch_beta')),
'Cloned branch B must compute independent digest matching one-shot hash'
);
// 8. digestInto pre-allocated Uint8Array buffer
const outputBuffer = new Uint8Array(64);
const directHasher = blake2b.create();
directHasher.update('abc');
directHasher.digestInto(outputBuffer);
assert.strictEqual(
bytesToHex(outputBuffer),
abcHashHex,
'digestInto must write digest into target buffer'
);
// 9. State cleanup with destroy()
const destroyHasher = blake2b.create();
destroyHasher.update('transient data');
destroyHasher.destroy();
// 10. Error on invalid dkLen
assert.throws(
() => {
blake2b('abc', { dkLen: 65 });
},
/outputLen|keyLen/,
'blake2b must throw when dkLen exceeds maximum limit'
);
// 11. Module wrapper helpers
assert.strictEqual(
hashBlake2bHex('abc'),
abcHashHex,
'hashBlake2bHex helper must match expected hex digest'
);
assert.strictEqual(
hashChunksHex(['a', 'bc'], { dkLen: 32 }),
bytesToHex(hash32Bytes),
'hashChunksHex helper must correctly stream array of chunks'
);
console.log('All blake2b contract assertions passed.');
오리진 시더
익명