Exemple
@sigstore/verify 2.1.1: Verifier, toSignedEntity, toTrustMaterial
Échantillon vérifié pour npm @sigstore/verify 2.1.1: Verifier, toSignedEntity, toTrustMaterial. Le contrat s'est exécuté sur node 22 · linux debian/x64 …
sha256:c6a6e060c709470af17ee9c33b623941c68721d8849ab6715e52712c77473692
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
node linux 24 · ubuntu · glibc 2.39 x64 node javascript npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-10-18 |
Cas
HOW- Objectif
- verify pkg:npm/%40sigstore/verify@2.1.1
- Paquets
- Symboles
-
- Verifier
- toSignedEntity
- toTrustMaterial
- VerificationError
- Environnement
- node
- Créé
- 2026-10-18T04:31:29Z
Contrat
- toTrustMaterial converts a TrustedRoot and public key map into TrustMaterial
- toSignedEntity converts a Sigstore bundle and artifact buffer into a SignedEntity
- Verifier.verify returns the Signer with key when signature matches the artifact and throws VerificationError with code SIGNATURE_ERROR when tampered
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
Code 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 pkg:npm/%40sigstore/verify@2.1.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40sigstore/verify@2.1.1
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:b2bf6fd78e31e9cec2fb975b3db779f636de5779a2024406decbd6060301957b","contract":["toTrustMaterial converts a TrustedRoot and public key map into TrustMaterial","toSignedEntity converts a Sigstore bundle and artifact buffer into a SignedEntity","Verifier.verify returns the Signer with key when signature matches the artifact and throws VerificationError with code SIGNATURE_ERROR when tampered"],"goal":"verify pkg:npm/%40sigstore/verify@2.1.1","kind":"HOW","packages":["pkg:npm/%40sigstore/verify@2.1.1"],"schemaVersion":1,"symbols":["Verifier","toSignedEntity","toTrustMaterial","VerificationError"]},"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","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40sigstore/verify@2.1.1"],"schemaVersion":1,"subject":"pkg:npm/%40sigstore/verify@2.1.1","symbols":["Verifier","toSignedEntity","toTrustMaterial","VerificationError"],"verifierAdapter":"node-typescript@1"}
{
"name": "sigstore-verify-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sigstore-verify-sample",
"version": "1.0.0",
"dependencies": {
"@sigstore/verify": "2.1.1"
}
},
"node_modules/@sigstore/bundle": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@sigstore/bundle/-/bundle-3.1.0.tgz",
"integrity": "sha512-Mm1E3/CmDDCz3nDhFKTuYdB47EdRFRQMOE/EAbiG1MJW77/w1b3P7Qx7JSrVJs8PfwOLOVcKQCHErIwCTyPbag==",
"license": "Apache-2.0",
"dependencies": {
"@sigstore/protobuf-specs": "^0.4.0"
},
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
},
"node_modules/@sigstore/core": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@sigstore/core/-/core-2.0.0.tgz",
"integrity": "sha512-nYxaSb/MtlSI+JWcwTHQxyNmWeWrUXJJ/G4liLrGG7+tS4vAz6LF3xRXqLH6wPIVUoZQel2Fs4ddLx4NCpiIYg==",
"license": "Apache-2.0",
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
},
"node_modules/@sigstore/protobuf-specs": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/@sigstore/protobuf-specs/-/protobuf-specs-0.4.3.tgz",
"integrity": "sha512-fk2zjD9117RL9BjqEwF7fwv7Q/P9yGsMV4MUJZ/DocaQJ6+3pKr+syBq1owU5Q5qGw5CUbXzm+4yJ2JVRDQeSA==",
"license": "Apache-2.0",
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
},
"node_modules/@sigstore/verify": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@sigstore/verify/-/verify-2.1.1.tgz",
"integrity": "sha512-hVJD77oT67aowHxwT4+M6PGOp+E2LtLdTK3+FC0lBO9T7sYwItDMXZ7Z07IDCvR1M717a4axbIWckrW67KMP/w==",
"license": "Apache-2.0",
"dependencies": {
"@sigstore/bundle": "^3.1.0",
"@sigstore/core": "^2.0.0",
"@sigstore/protobuf-specs": "^0.4.1"
},
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
}
}
}
{
"name": "sigstore-verify-sample",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"@sigstore/verify": "2.1.1"
},
"scripts": {
"test": "node test/contract.mjs"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40sigstore/verify@2.1.1",
"kind": "HOW",
"packages": [
"pkg:npm/%40sigstore/verify@2.1.1"
]
}
import { Verifier, toSignedEntity, toTrustMaterial, VerificationError } from '@sigstore/verify';
import crypto from 'node:crypto';
export function createKeyPairAndSign(artifact) {
const { publicKey, privateKey } = crypto.generateKeyPairSync('ec', {
namedCurve: 'P-256',
});
const signature = crypto.sign(null, artifact, privateKey);
const digest = crypto.createHash('sha256').update(artifact).digest();
const spkiDer = publicKey.export({ type: 'spki', format: 'der' });
const bundle = {
mediaType: 'application/vnd.dev.sigstore.bundle.v0.3+json',
verificationMaterial: {
content: {
$case: 'publicKey',
publicKey: {
hint: 'key-1',
},
},
tlogEntries: [],
timestampVerificationData: {
rfc3161Timestamps: [],
},
},
content: {
$case: 'messageSignature',
messageSignature: {
messageDigest: {
algorithm: 1,
digest,
},
signature,
},
},
};
const trustedRoot = {
mediaType: 'application/vnd.dev.sigstore.trustedroot+json;version=0.1',
certificateAuthorities: [],
timestampAuthorities: [],
tlogs: [],
ctlogs: [],
};
const trustMaterial = toTrustMaterial(trustedRoot, {
'key-1': {
rawBytes: spkiDer,
keyDetails: 5,
},
});
return { bundle, trustMaterial, publicKey };
}
export function verifyBundle(bundle, artifact, trustMaterial) {
const entity = toSignedEntity(bundle, artifact);
const verifier = new Verifier(trustMaterial, {
tlogThreshold: 0,
ctlogThreshold: 0,
tsaThreshold: 0,
});
return verifier.verify(entity);
}
export { VerificationError };
import assert from 'node:assert/strict';
import { createKeyPairAndSign, verifyBundle, VerificationError } from '../src/index.mjs';
const artifact = Buffer.from('hello sigstore verification');
const { bundle, trustMaterial } = createKeyPairAndSign(artifact);
// 1. Valid verification succeeds and returns signer with public key
const signer = verifyBundle(bundle, artifact, trustMaterial);
assert.ok(signer && signer.key, 'Expected verifyBundle to return a signer with a key');
assert.equal(signer.key.asymmetricKeyType, 'ec');
// 2. Tampered artifact fails signature verification with VerificationError
const tamperedArtifact = Buffer.from('tampered content');
assert.throws(
() => verifyBundle(bundle, tamperedArtifact, trustMaterial),
(err) => err instanceof VerificationError && err.code === 'SIGNATURE_ERROR'
);
Seeder d'origine
anonyme