Sample
buffer 5.7.1: Buffer
Verified sample for npm buffer 5.7.1: Buffer. The contract ran on node 22 · linux alpine/x64 · docker and passed: Buffer.from creates Buffer from string with…
sha256:82a6b293fbe5f339c46db7e941f423b9ea17e4b66f0ffbe3633dfaf90c6271f0
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 x64 npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-28 |
Case
HOW- Goal
- verify pkg:npm/buffer@5.7.1
- Packages
- Symbols
-
- Buffer
- Created
- 2026-08-28T08:08:47Z
Contract
- Buffer.from creates Buffer from string with default utf8 encoding
- Buffer.from creates Buffer from string with hex and base64 encodings
- Buffer.from creates Buffer from byte array
- Buffer.from creates Buffer copy from existing Buffer
- Buffer.from creates Buffer from ArrayBuffer with byteOffset and length
- Buffer.alloc creates zero-filled buffer of specified size
- Buffer.alloc creates filled buffer with custom fill value
- Buffer.allocUnsafe creates uninitialized buffer of specified size
- Buffer.isBuffer returns true for Buffer instances and false for non-buffers
- Buffer.isEncoding returns true for valid encodings and false for invalid encodings
- Buffer.concat joins multiple Buffer instances into a single Buffer
- Buffer.byteLength returns byte length of strings across different encodings
- Buffer.compare orders buffers lexicographically
- Buffer instance supports write, toString, toJSON, slice, and binary read/write methods
- Buffer.from throws TypeError when value is a number
- Buffer.from throws TypeError when encoding is unknown
- Buffer.alloc throws RangeError when size is negative
- Buffer.alloc throws TypeError when size is not a number
- Buffer.concat throws TypeError when list is not an Array
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
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/buffer@5.7.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/buffer@5.7.1
Demonstrate these symbols/APIs:
- Buffer
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:f3f44a1f94fef86bed3048696a554c8ffe9cbfc5c5e2a3db793015475a8eda25","contract":["Buffer.from creates Buffer from string with default utf8 encoding","Buffer.from creates Buffer from string with hex and base64 encodings","Buffer.from creates Buffer from byte array","Buffer.from creates Buffer copy from existing Buffer","Buffer.from creates Buffer from ArrayBuffer with byteOffset and length","Buffer.alloc creates zero-filled buffer of specified size","Buffer.alloc creates filled buffer with custom fill value","Buffer.allocUnsafe creates uninitialized buffer of specified size","Buffer.isBuffer returns true for Buffer instances and false for non-buffers","Buffer.isEncoding returns true for valid encodings and false for invalid encodings","Buffer.concat joins multiple Buffer instances into a single Buffer","Buffer.byteLength returns byte length of strings across different encodings","Buffer.compare orders buffers lexicographically","Buffer instance supports write, toString, toJSON, slice, and binary read/write methods","Buffer.from throws TypeError when value is a number","Buffer.from throws TypeError when encoding is unknown","Buffer.alloc throws RangeError when size is negative","Buffer.alloc throws TypeError when size is not a number","Buffer.concat throws TypeError when list is not an Array"],"goal":"verify pkg:npm/buffer@5.7.1","kind":"HOW","packages":["pkg:npm/buffer@5.7.1"],"schemaVersion":1,"symbols":["Buffer"]},"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/buffer@5.7.1"],"schemaVersion":1,"subject":"pkg:npm/buffer@5.7.1","symbols":["Buffer"],"verifierAdapter":"node-typescript@1"}
{
"name": "buffer-verification",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "buffer-verification",
"version": "1.0.0",
"dependencies": {
"buffer": "5.7.1"
}
},
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/buffer": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT",
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.1.13"
}
},
"node_modules/ieee754": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "BSD-3-Clause"
}
}
}
{
"name": "buffer-verification",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for buffer",
"dependencies": {
"buffer": "5.7.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/buffer@5.7.1",
"kind": "HOW",
"packages": [
"pkg:npm/buffer@5.7.1"
],
"symbols": [
"Buffer"
]
}
import assert from 'node:assert';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { Buffer } = require('buffer/');
// 1. Buffer.from creates Buffer from string with default utf8 encoding
const strBuf = Buffer.from('hello world');
assert.ok(Buffer.isBuffer(strBuf));
assert.strictEqual(strBuf.toString('utf8'), 'hello world');
assert.strictEqual(strBuf.length, 11);
// 2. Buffer.from creates Buffer from string with hex and base64 encodings
const hexBuf = Buffer.from('68656c6c6f', 'hex');
assert.strictEqual(hexBuf.toString('utf8'), 'hello');
const b64Buf = Buffer.from('aGVsbG8=', 'base64');
assert.strictEqual(b64Buf.toString('utf8'), 'hello');
// 3. Buffer.from creates Buffer from byte array
const arrBuf = Buffer.from([104, 101, 108, 108, 111]);
assert.ok(Buffer.isBuffer(arrBuf));
assert.strictEqual(arrBuf.toString('utf8'), 'hello');
assert.strictEqual(arrBuf.length, 5);
// 4. Buffer.from creates Buffer copy from existing Buffer
const original = Buffer.from('copy-test');
const copied = Buffer.from(original);
assert.ok(Buffer.isBuffer(copied));
assert.strictEqual(copied.toString('utf8'), 'copy-test');
original[0] = 0x78;
assert.strictEqual(copied.toString('utf8'), 'copy-test');
// 5. Buffer.from creates Buffer from ArrayBuffer with byteOffset and length
const ab = new Uint8Array([1, 2, 3, 4, 5, 6]).buffer;
const abBuf = Buffer.from(ab, 2, 3);
assert.ok(Buffer.isBuffer(abBuf));
assert.strictEqual(abBuf.length, 3);
assert.deepStrictEqual(Array.from(abBuf), [3, 4, 5]);
// 6. Buffer.alloc creates zero-filled buffer of specified size
const zeroBuf = Buffer.alloc(10);
assert.ok(Buffer.isBuffer(zeroBuf));
assert.strictEqual(zeroBuf.length, 10);
assert.deepStrictEqual(Array.from(zeroBuf), [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
// 7. Buffer.alloc creates filled buffer with custom fill value
const filledBuf = Buffer.alloc(5, 'a');
assert.strictEqual(filledBuf.toString('utf8'), 'aaaaa');
// 8. Buffer.allocUnsafe creates uninitialized buffer of specified size
const unsafeBuf = Buffer.allocUnsafe(8);
assert.ok(Buffer.isBuffer(unsafeBuf));
assert.strictEqual(unsafeBuf.length, 8);
// 9. Buffer.isBuffer returns true for Buffer instances and false for non-buffers
assert.strictEqual(Buffer.isBuffer(Buffer.alloc(4)), true);
assert.strictEqual(Buffer.isBuffer(new Uint8Array(4)), false);
assert.strictEqual(Buffer.isBuffer('string'), false);
assert.strictEqual(Buffer.isBuffer(null), false);
// 10. Buffer.isEncoding returns true for valid encodings and false for invalid encodings
assert.strictEqual(Buffer.isEncoding('utf8'), true);
assert.strictEqual(Buffer.isEncoding('hex'), true);
assert.strictEqual(Buffer.isEncoding('base64'), true);
assert.strictEqual(Buffer.isEncoding('utf-8'), true);
assert.strictEqual(Buffer.isEncoding('invalid-enc'), false);
// 11. Buffer.concat joins multiple Buffer instances into a single Buffer
const c1 = Buffer.from('hello ');
const c2 = Buffer.from('world');
const concatenated = Buffer.concat([c1, c2]);
assert.strictEqual(concatenated.toString('utf8'), 'hello world');
assert.strictEqual(concatenated.length, 11);
// 12. Buffer.byteLength returns byte length of strings across different encodings
assert.strictEqual(Buffer.byteLength('hello', 'utf8'), 5);
assert.strictEqual(Buffer.byteLength('€', 'utf8'), 3);
assert.strictEqual(Buffer.byteLength('68656c6c6f', 'hex'), 5);
// 13. Buffer.compare orders buffers lexicographically
const cmpA = Buffer.from('abc');
const cmpB = Buffer.from('abd');
assert.strictEqual(Buffer.compare(cmpA, cmpB), -1);
assert.strictEqual(Buffer.compare(cmpB, cmpA), 1);
assert.strictEqual(Buffer.compare(cmpA, cmpA), 0);
assert.strictEqual(cmpA.compare(cmpB), -1);
// 14. Buffer instance supports write, toString, toJSON, slice, and binary read/write methods
const instanceBuf = Buffer.alloc(10);
instanceBuf.write('test', 0, 4, 'utf8');
assert.strictEqual(instanceBuf.toString('utf8', 0, 4), 'test');
const jsonRep = instanceBuf.toJSON();
assert.strictEqual(jsonRep.type, 'Buffer');
assert.ok(Array.isArray(jsonRep.data));
const sliced = instanceBuf.slice(0, 4);
assert.strictEqual(sliced.toString('utf8'), 'test');
const numBuf = Buffer.alloc(4);
numBuf.writeUInt16BE(0x1234, 0);
assert.strictEqual(numBuf.readUInt16BE(0), 0x1234);
// 15. Buffer.from throws TypeError when value is a number
assert.throws(
() => Buffer.from(123),
{
name: 'TypeError',
message: 'The "value" argument must not be of type number. Received type number'
}
);
// 16. Buffer.from throws TypeError when encoding is unknown
assert.throws(
() => Buffer.from('abc', 'invalid-encoding'),
{
name: 'TypeError',
message: 'Unknown encoding: invalid-encoding'
}
);
// 17. Buffer.alloc throws RangeError when size is negative
assert.throws(
() => Buffer.alloc(-1),
{
name: 'RangeError',
message: 'The value "-1" is invalid for option "size"'
}
);
// 18. Buffer.alloc throws TypeError when size is not a number
assert.throws(
() => Buffer.alloc('invalid'),
{
name: 'TypeError',
message: '"size" argument must be of type number'
}
);
// 19. Buffer.concat throws TypeError when list is not an Array
assert.throws(
() => Buffer.concat('not-an-array'),
{
name: 'TypeError',
message: '"list" argument must be an Array of Buffers'
}
);
console.log('Contract passed');
Origin Seeder
anonymous