CodeSampleX

Ejemplo

@noble/hashes 2.3.0: sha3_256

Muestra verificada para npm @noble/hashes 2.3.0: sha3_256. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.

sha256:e1376ea6601a220851fcf9f7cb77487b0203106f585ecab58af094b547629289

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 linux 24 · ubuntu · glibc 2.39 x64 npm

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-17

Caso

HOW
Objetivo
verify @noble/hashes.sha3_256 in pkg:npm/%40noble/hashes@2.3.0
Paquetes
Símbolos
  • @noble/hashes.sha3_256
Creado
2026-09-17T04:49:17Z

Contrato

  1. sha3_256 computes standard NIST 32-byte digest for empty input
  2. sha3_256 computes standard NIST 32-byte digest for byte sequence
  3. sha3_256 exposes blockLen 136 and outputLen 32 metadata
  4. sha3_256.create supports incremental hashing via update and digest
  5. sha3_256.create supports writing digest into preallocated buffer via digestInto
  6. sha3_256 throws TypeError when input is not a Uint8Array
  7. sha3_256 instance throws Error when digest is called more than once

Archivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Descargar el artefacto de código fuente (tar.gz)

Código fuente

PROMPT.md
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_256 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_256

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.
csx.json
{"case":{"caseId":"case:sha256:7fbe1f26b76a0885a31015251c8939d307e44cf789407181987f49a641afb37c","contract":["sha3_256 computes standard NIST 32-byte digest for empty input","sha3_256 computes standard NIST 32-byte digest for byte sequence","sha3_256 exposes blockLen 136 and outputLen 32 metadata","sha3_256.create supports incremental hashing via update and digest","sha3_256.create supports writing digest into preallocated buffer via digestInto","sha3_256 throws TypeError when input is not a Uint8Array","sha3_256 instance throws Error when digest is called more than once"],"goal":"verify @noble/hashes.sha3_256 in pkg:npm/%40noble/hashes@2.3.0","kind":"HOW","packages":["pkg:npm/%40noble/hashes@2.3.0"],"schemaVersion":1,"symbols":["@noble/hashes.sha3_256"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","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_256"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-noble-hashes-sha3",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-noble-hashes-sha3",
      "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"
      }
    }
  }
}
package.json
{
  "name": "sample-noble-hashes-sha3",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "description": "Clean-room verification for @noble/hashes sha3_256",
  "dependencies": {
    "@noble/hashes": "2.3.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @noble/hashes.sha3_256 in pkg:npm/%40noble/hashes@2.3.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40noble/hashes@2.3.0"
  ],
  "symbols": [
    "@noble/hashes.sha3_256"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import { sha3_256 } from '@noble/hashes/sha3.js';

// 1. sha3_256 computes standard NIST 32-byte digest for empty input
const emptyDigest = sha3_256(new Uint8Array([]));
assert.strictEqual(emptyDigest.length, 32);
assert.strictEqual(
  Buffer.from(emptyDigest).toString('hex'),
  'a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a'
);

// 2. sha3_256 computes standard NIST 32-byte digest for byte sequence
const msg = new TextEncoder().encode('abc');
const abcDigest = sha3_256(msg);
assert.strictEqual(abcDigest.length, 32);
assert.strictEqual(
  Buffer.from(abcDigest).toString('hex'),
  '3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532'
);

// 3. sha3_256 exposes blockLen 136 and outputLen 32 metadata
assert.strictEqual(sha3_256.blockLen, 136);
assert.strictEqual(sha3_256.outputLen, 32);

// 4. sha3_256.create supports incremental hashing via update and digest
const incremental = sha3_256.create();
incremental.update(new TextEncoder().encode('a'));
incremental.update(new TextEncoder().encode('bc'));
const incrementalDigest = incremental.digest();
assert.deepStrictEqual(incrementalDigest, abcDigest);

// 5. sha3_256.create supports writing digest into preallocated buffer via digestInto
const bufferOut = new Uint8Array(32);
const intoHasher = sha3_256.create();
intoHasher.update(msg);
intoHasher.digestInto(bufferOut);
assert.deepStrictEqual(bufferOut, abcDigest);

// 6. sha3_256 throws TypeError when input is not a Uint8Array
assert.throws(
  () => {
    sha3_256('abc');
  },
  (err) => err instanceof TypeError
);

// 7. sha3_256 instance throws Error when digest is called more than once
assert.throws(
  () => {
    incremental.digest();
  },
  (err) => err instanceof Error && /digest\(\) was already called/.test(err.message)
);

console.log('Contract passed');

Seeder de origen

anónimo