Ejemplo
@noble/hashes 1.4.0: argon2id
Muestra verificada para npm @noble/hashes 1.4.0: argon2id. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.
sha256:3157b161c9d3c4fb0503c47b0e4c313645a7c79ac17180d72c9b88393732087d
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify @noble/hashes.argon2id in pkg:npm/%40noble/hashes@1.4.0
- Paquetes
- Símbolos
-
- @noble/hashes.argon2id
- Entorno
- node 22.23.2
- Creado
- 2026-09-06T12:17:31Z
Contrato
- assert argon2id produces exact 32-byte tag matching RFC 9106 test vector
- assert argon2id accepts string and Uint8Array inputs interchangeably producing identical digests
- assert argon2id supports custom dkLen derived key length
- assert argon2id incorporates secret key and personalization parameters
- assert argon2id supports version 16 and version 19
- assert argon2id onProgress callback reports incremental progress
- assert argon2id validates salt length, iteration count, memory allocation, and dkLen bounds
- assert module wrapper helpers compute expected key derivations
Archivos
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código fuente
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.argon2id 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.argon2id
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:0b6198a35d44ddad7916bca8a8af8c68c9b9a48a694960a57efa80b49b3e8a5b","contract":["assert argon2id produces exact 32-byte tag matching RFC 9106 test vector","assert argon2id accepts string and Uint8Array inputs interchangeably producing identical digests","assert argon2id supports custom dkLen derived key length","assert argon2id incorporates secret key and personalization parameters","assert argon2id supports version 16 and version 19","assert argon2id onProgress callback reports incremental progress","assert argon2id validates salt length, iteration count, memory allocation, and dkLen bounds","assert module wrapper helpers compute expected key derivations"],"goal":"verify @noble/hashes.argon2id in pkg:npm/%40noble/hashes@1.4.0","kind":"HOW","packages":["pkg:npm/%40noble/hashes@1.4.0"],"schemaVersion":1,"symbols":["@noble/hashes.argon2id"]},"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.argon2id"],"verifierAdapter":"node-typescript@1"}
const { argon2id } = require('@noble/hashes/argon2');
const { bytesToHex, utf8ToBytes, toBytes } = require('@noble/hashes/utils');
/**
* Derives a key using Argon2id password hashing.
* @param {string | Uint8Array} password
* @param {string | Uint8Array} salt
* @param {import('@noble/hashes/argon2').ArgonOpts} opts
* @returns {Uint8Array}
*/
function deriveArgon2id(password, salt, opts) {
return argon2id(password, salt, opts);
}
/**
* Derives a key using Argon2id and returns a lowercase hex string.
* @param {string | Uint8Array} password
* @param {string | Uint8Array} salt
* @param {import('@noble/hashes/argon2').ArgonOpts} opts
* @returns {string}
*/
function deriveArgon2idHex(password, salt, opts) {
return bytesToHex(argon2id(password, salt, opts));
}
module.exports = {
argon2id,
deriveArgon2id,
deriveArgon2idHex,
bytesToHex,
utf8ToBytes,
toBytes,
};
{
"name": "sample-noble-hashes-argon2id",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-noble-hashes-argon2id",
"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-argon2id",
"version": "1.0.0",
"private": true,
"description": "verify @noble/hashes.argon2id 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.argon2id in pkg:npm/%40noble/hashes@1.4.0",
"kind": "HOW",
"packages": [
"pkg:npm/%40noble/hashes@1.4.0"
],
"symbols": [
"@noble/hashes.argon2id"
]
}
import assert from 'node:assert';
import { argon2id } from '@noble/hashes/argon2';
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
import {
deriveArgon2id,
deriveArgon2idHex,
} from '../index.js';
// 1. RFC 9106 standard test vector verification
const pwd = new Uint8Array(32).fill(1);
const salt = new Uint8Array(16).fill(2);
const secret = new Uint8Array(8).fill(3);
const ad = new Uint8Array(12).fill(4);
const tag = argon2id(pwd, salt, {
t: 3,
m: 32,
p: 4,
key: secret,
personalization: ad,
dkLen: 32,
version: 19,
});
const tagHex = bytesToHex(tag);
assert.strictEqual(
tagHex,
'0d640df58d78766c08c037a34a8b53c9d01ef0452d75b65eb52520e96b01e659',
'Argon2id must match official RFC 9106 test vector'
);
assert.strictEqual(tag.length, 32, 'Derived tag length must be 32 bytes');
// 2. String and Uint8Array input equivalence
const hashFromStr = argon2id('password', 'saltsalt', { t: 2, m: 256, p: 1 });
const hashFromBytes = argon2id(utf8ToBytes('password'), utf8ToBytes('saltsalt'), { t: 2, m: 256, p: 1 });
assert.strictEqual(
bytesToHex(hashFromStr),
bytesToHex(hashFromBytes),
'String and Uint8Array utf8 inputs must produce identical digests'
);
assert.strictEqual(hashFromStr.length, 32, 'Default dkLen must be 32 bytes');
// 3. Custom dkLen output length
const hash64 = argon2id('password', 'saltsalt', { t: 2, m: 256, p: 1, dkLen: 64 });
assert.strictEqual(hash64.length, 64, 'Custom dkLen of 64 bytes must produce a 64-byte digest');
// 4. Secret key and personalization differentiation
const hashBase = argon2id('password', 'saltsalt', { t: 2, m: 256, p: 1 });
const hashWithKey = argon2id('password', 'saltsalt', { t: 2, m: 256, p: 1, key: 'secret-pepper' });
const hashWithPers = argon2id('password', 'saltsalt', { t: 2, m: 256, p: 1, personalization: 'app-scope' });
assert.notStrictEqual(
bytesToHex(hashBase),
bytesToHex(hashWithKey),
'Secret key must alter derived output'
);
assert.notStrictEqual(
bytesToHex(hashBase),
bytesToHex(hashWithPers),
'Personalization must alter derived output'
);
// 5. Algorithm versions (0x10 and 0x13)
const hashV16 = argon2id('password', 'saltsalt', { t: 2, m: 256, p: 1, version: 16 });
const hashV19 = argon2id('password', 'saltsalt', { t: 2, m: 256, p: 1, version: 19 });
assert.strictEqual(
bytesToHex(hashBase),
bytesToHex(hashV19),
'Default version must match explicit version 19 (0x13)'
);
assert.notStrictEqual(
bytesToHex(hashV16),
bytesToHex(hashV19),
'Version 16 and Version 19 must produce distinct outputs'
);
// 6. onProgress callback reporting
let progressInvocations = 0;
let lastReportedProgress = 0;
argon2id('password', 'saltsalt', {
t: 2,
m: 256,
p: 1,
onProgress: (p) => {
progressInvocations++;
lastReportedProgress = p;
},
});
assert(progressInvocations > 0, 'onProgress callback must be invoked during computation');
assert(lastReportedProgress > 0.9, 'Final reported progress must be near completion');
// 7. Input validation bounds
assert.throws(
() => argon2id('password', 'short', { t: 2, m: 256, p: 1 }),
/salt should be at least 8 bytes/,
'Salt shorter than 8 bytes must throw'
);
assert.throws(
() => argon2id('password', 'saltsalt', { t: 0, m: 256, p: 1 }),
/t \(iterations\) should be at least 1/,
't < 1 must throw'
);
assert.throws(
() => argon2id('password', 'saltsalt', { t: 2, m: 4, p: 1 }),
/memory should be at least 8\*p bytes/,
'Memory < 8*p must throw'
);
assert.throws(
() => argon2id('password', 'saltsalt', { t: 2, m: 256, p: 1, dkLen: 2 }),
/dkLen should be at least 4 bytes/,
'dkLen < 4 must throw'
);
// 8. Module wrapper helpers
assert.strictEqual(
deriveArgon2idHex('password', 'saltsalt', { t: 2, m: 256, p: 1 }),
bytesToHex(argon2id('password', 'saltsalt', { t: 2, m: 256, p: 1 })),
'deriveArgon2idHex helper must match direct bytesToHex(argon2id(...))'
);
assert.deepStrictEqual(
deriveArgon2id('password', 'saltsalt', { t: 2, m: 256, p: 1 }),
argon2id('password', 'saltsalt', { t: 2, m: 256, p: 1 }),
'deriveArgon2id helper must match direct argon2id(...)'
);
console.log('All @noble/hashes.argon2id contract assertions passed.');
Seeder de origen
anónimo