CodeSampleX

Sample

node-int64 0.4.0: Int64

Verified sample for npm node-int64 0.4.0: Int64. The contract ran on node 22 · linux alpine/x64 · docker and passed: new Int64(number) converts a JavaScript…

sha256:9bb6093f86aa6e7899c2aed876490385e978917a43c3724955f557a5f0274b92

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

Case

HOW
Goal
verify pkg:npm/node-int64@0.4.0
Packages
Symbols
  • Int64
Created
2026-08-26T08:20:22Z

Contract

  1. new Int64(number) converts a JavaScript number to a 64-bit integer representation
  2. new Int64(hi, lo) constructs an Int64 from high and low 32-bit integer values
  3. new Int64(string) parses a hexadecimal string into an Int64 value
  4. new Int64(buffer, offset) reads an 8-byte big-endian integer from a Buffer at the given offset
  5. Int64.prototype.toOctetString(separator) formats the 64-bit integer as an octet hex string
  6. Int64.prototype.toNumber(allowImprecise) converts to a JavaScript number or returns Infinity for values outside safe integer precision
  7. Int64.prototype.toBuffer() returns an 8-byte Buffer copy containing the raw int64 bytes
  8. Int64.prototype.copy(targetBuffer, targetOffset) writes the 8 int64 bytes into a destination buffer
  9. Int64.prototype.compare(other) and equals(other) perform signed 64-bit integer comparisons

Files

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

Download the source artifact (tar.gz)

Source

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 pkg:npm/node-int64@0.4.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/node-int64@0.4.0
Demonstrate these symbols/APIs:
  - Int64

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:9e301c89115a0d3f104c76d13997830b8e2b9c13e6c9a10abd77f21a12d8383c","contract":["new Int64(number) converts a JavaScript number to a 64-bit integer representation","new Int64(hi, lo) constructs an Int64 from high and low 32-bit integer values","new Int64(string) parses a hexadecimal string into an Int64 value","new Int64(buffer, offset) reads an 8-byte big-endian integer from a Buffer at the given offset","Int64.prototype.toOctetString(separator) formats the 64-bit integer as an octet hex string","Int64.prototype.toNumber(allowImprecise) converts to a JavaScript number or returns Infinity for values outside safe integer precision","Int64.prototype.toBuffer() returns an 8-byte Buffer copy containing the raw int64 bytes","Int64.prototype.copy(targetBuffer, targetOffset) writes the 8 int64 bytes into a destination buffer","Int64.prototype.compare(other) and equals(other) perform signed 64-bit integer comparisons"],"goal":"verify pkg:npm/node-int64@0.4.0","kind":"HOW","packages":["pkg:npm/node-int64@0.4.0"],"schemaVersion":1,"symbols":["Int64"]},"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/node-int64@0.4.0"],"schemaVersion":1,"subject":"pkg:npm/node-int64@0.4.0","symbols":["Int64"],"verifierAdapter":"node-typescript@1"}
index.mjs
import Int64 from 'node-int64';

export function createInt64(value, low) {
  if (low !== undefined) {
    return new Int64(value, low);
  }
  return new Int64(value);
}

export function fromBuffer(buf, offset = 0) {
  return new Int64(buf, offset);
}

export function formatHex(int64, sep = '') {
  return int64.toOctetString(sep);
}

export function toNativeNumber(int64, allowImprecise = false) {
  return int64.toNumber(allowImprecise);
}

export function compareInt64(a, b) {
  return a.compare(b);
}

export function equalsInt64(a, b) {
  return a.equals(b);
}

export { Int64 };
package-lock.json
{
  "name": "sample-node-int64",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-node-int64",
      "version": "1.0.0",
      "dependencies": {
        "node-int64": "0.4.0"
      }
    },
    "node_modules/node-int64": {
      "version": "0.4.0",
      "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
      "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-node-int64",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "node-int64": "0.4.0"
  },
  "scripts": {
    "test": "node test/contract.mjs"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/node-int64@0.4.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/node-int64@0.4.0"
  ],
  "symbols": [
    "Int64"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import Int64 from 'node-int64';
import {
  createInt64,
  fromBuffer,
  formatHex,
  toNativeNumber,
  compareInt64,
  equalsInt64
} from '../index.mjs';

// 1. new Int64(number) converts a JavaScript number to a 64-bit integer representation
{
  const positive = createInt64(12345678);
  assert.equal(positive.toNumber(), 12345678);
  assert.equal(positive.toString(), '12345678');

  const negative = createInt64(-987654);
  assert.equal(negative.toNumber(), -987654);
  assert.equal(negative.toString(), '-987654');
}

// 2. new Int64(hi, lo) constructs an Int64 from high and low 32-bit integer values
{
  const hiLo = createInt64(0x01234567, 0x89abcdef);
  assert.equal(hiLo.toOctetString(), '0123456789abcdef');
}

// 3. new Int64(string) parses a hexadecimal string into an Int64 value
{
  const fromHexStr = createInt64('0x0123456789abcdef');
  const expected = createInt64(0x01234567, 0x89abcdef);
  assert.equal(fromHexStr.toOctetString(), '0123456789abcdef');
  assert.ok(fromHexStr.equals(expected));
}

// 4. new Int64(buffer, offset) reads an 8-byte big-endian integer from a Buffer at the given offset
{
  const raw = Buffer.from([0xaa, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00]);
  const fromBuf = fromBuffer(raw, 2);
  assert.equal(fromBuf.toNumber(), 256);
  assert.equal(fromBuf.toOctetString(), '0000000000000100');
}

// 5. Int64.prototype.toOctetString(separator) formats the 64-bit integer as an octet hex string
{
  const val = createInt64(0x01234567, 0x89abcdef);
  assert.equal(formatHex(val), '0123456789abcdef');
  assert.equal(formatHex(val, ' '), '01 23 45 67 89 ab cd ef');
  assert.equal(formatHex(val, '-'), '01-23-45-67-89-ab-cd-ef');
}

// 6. Int64.prototype.toNumber(allowImprecise) converts to a JavaScript number or returns Infinity for values outside safe integer precision
{
  const safeVal = createInt64(42);
  assert.equal(toNativeNumber(safeVal), 42);

  const overflow = createInt64('7fffffffffffffff');
  assert.equal(toNativeNumber(overflow, false), Infinity);
  assert.notEqual(toNativeNumber(overflow, true), Infinity);
}

// 7. Int64.prototype.toBuffer() returns an 8-byte Buffer copy containing the raw int64 bytes
{
  const val = createInt64(0x12345678, 0x90abcdef);
  const buf = val.toBuffer();
  assert.ok(Buffer.isBuffer(buf));
  assert.equal(buf.length, 8);
  assert.equal(buf[0], 0x12);
  assert.equal(buf[7], 0xef);
}

// 8. Int64.prototype.copy(targetBuffer, targetOffset) writes the 8 int64 bytes into a destination buffer
{
  const val = createInt64(0x12345678, 0x90abcdef);
  const dest = Buffer.alloc(12, 0);
  val.copy(dest, 2);
  assert.equal(dest[2], 0x12);
  assert.equal(dest[9], 0xef);
  assert.equal(dest[0], 0);
  assert.equal(dest[10], 0);
}

// 9. Int64.prototype.compare(other) and equals(other) perform signed 64-bit integer comparisons
{
  const small = createInt64(100);
  const medium = createInt64(200);
  const duplicateSmall = createInt64(100);

  assert.ok(compareInt64(small, medium) < 0);
  assert.ok(compareInt64(medium, small) > 0);
  assert.equal(compareInt64(small, duplicateSmall), 0);

  assert.equal(equalsInt64(small, duplicateSmall), true);
  assert.equal(equalsInt64(small, medium), false);
}

console.log('Contract tests passed successfully.');

Origin Seeder

anonymous