CodeSampleX

Sample

golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a

Verified sample for golang golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:b0b48255fe46e16ccfa39e125e66d528fb9c1649312d9f76ce74a4ffc76e1608

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 go

Verification-run environments

Environment Contract Stages Run
go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a…
2026-10-22

Case

HOW
Goal
verify pkg:golang/golang.org/x/crypto@v0.0.0-20190313024323-a1f597ede03a
Packages
Created
2026-10-22T18:41:20Z

Contract

  1. bcrypt.GenerateFromPassword produces a non-empty hash at bcrypt.MinCost
  2. bcrypt.Cost extracts the configured cost from the generated hash
  3. bcrypt.CompareHashAndPassword returns nil when the password matches the hash
  4. bcrypt.CompareHashAndPassword returns bcrypt.ErrMismatchedHashAndPassword when password differs
  5. bcrypt.GenerateFromPassword returns bcrypt.InvalidCostError when cost exceeds bcrypt.MaxCost

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

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:golang/golang.org/x/crypto@v0.0.0-20190313024323-a1f597ede03a
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/crypto@v0.0.0-20190313024323-a1f597ede03a

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:d89135048737f62223de4423d09aa1229c2dec3f0294c56838703d991245b87d","contract":["bcrypt.GenerateFromPassword produces a non-empty hash at bcrypt.MinCost","bcrypt.Cost extracts the configured cost from the generated hash","bcrypt.CompareHashAndPassword returns nil when the password matches the hash","bcrypt.CompareHashAndPassword returns bcrypt.ErrMismatchedHashAndPassword when password differs","bcrypt.GenerateFromPassword returns bcrypt.InvalidCostError when cost exceeds bcrypt.MaxCost"],"goal":"verify pkg:golang/golang.org/x/crypto@v0.0.0-20190313024323-a1f597ede03a","kind":"HOW","packages":["pkg:golang/golang.org/x/crypto@v0.0.0-20190313024323-a1f597ede03a"],"schemaVersion":1},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/golang.org/x/crypto@v0.0.0-20190313024323-a1f597ede03a"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/crypto@v0.0.0-20190313024323-a1f597ede03a","verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.20

require golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a
go.sum
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a h1:YX8ljsm6wXlHZO+aRz9Exqr0evNhKRNe5K/gi+zKh4U=
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
main.go
package main

import (
	"fmt"
	"log"

	"golang.org/x/crypto/bcrypt"
)

func main() {
	secret := []byte("sample-passphrase")
	hashed, err := bcrypt.GenerateFromPassword(secret, bcrypt.MinCost)
	if err != nil {
		log.Fatalf("GenerateFromPassword failed: %v", err)
	}

	cost, err := bcrypt.Cost(hashed)
	if err != nil {
		log.Fatalf("Cost failed: %v", err)
	}

	if err := bcrypt.CompareHashAndPassword(hashed, secret); err != nil {
		log.Fatalf("CompareHashAndPassword failed: %v", err)
	}

	fmt.Printf("verified cost=%d\n", cost)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/golang.org/x/crypto@v0.0.0-20190313024323-a1f597ede03a",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/crypto@v0.0.0-20190313024323-a1f597ede03a"
  ]
}
test/contract.go
package main

import (
	"errors"
	"fmt"
	"os"

	"golang.org/x/crypto/bcrypt"
)

func main() {
	password := []byte("correct-passphrase")
	wrongPassword := []byte("wrong-passphrase")

	// 1. bcrypt.GenerateFromPassword produces a non-empty hash at bcrypt.MinCost
	hashed, err := bcrypt.GenerateFromPassword(password, bcrypt.MinCost)
	if err != nil || len(hashed) == 0 {
		fmt.Fprintf(os.Stderr, "GenerateFromPassword failed: len=%d err=%v\n", len(hashed), err)
		os.Exit(1)
	}

	// 2. bcrypt.Cost extracts the configured cost from the generated hash
	cost, err := bcrypt.Cost(hashed)
	if err != nil || cost != bcrypt.MinCost {
		fmt.Fprintf(os.Stderr, "expected cost %d, got %d (err=%v)\n", bcrypt.MinCost, cost, err)
		os.Exit(1)
	}

	// 3. bcrypt.CompareHashAndPassword returns nil when the password matches the hash
	if err := bcrypt.CompareHashAndPassword(hashed, password); err != nil {
		fmt.Fprintf(os.Stderr, "expected nil for matching password, got %v\n", err)
		os.Exit(1)
	}

	// 4. bcrypt.CompareHashAndPassword returns bcrypt.ErrMismatchedHashAndPassword when password differs
	if err := bcrypt.CompareHashAndPassword(hashed, wrongPassword); !errors.Is(err, bcrypt.ErrMismatchedHashAndPassword) {
		fmt.Fprintf(os.Stderr, "expected ErrMismatchedHashAndPassword, got %v\n", err)
		os.Exit(1)
	}

	// 5. bcrypt.GenerateFromPassword returns bcrypt.InvalidCostError when cost exceeds bcrypt.MaxCost
	if _, err := bcrypt.GenerateFromPassword(password, bcrypt.MaxCost+1); err != bcrypt.InvalidCostError(bcrypt.MaxCost+1) {
		fmt.Fprintf(os.Stderr, "expected InvalidCostError(%d), got %v\n", bcrypt.MaxCost+1, err)
		os.Exit(1)
	}

	fmt.Println("contract ok")
}

Origin Seeder

anonymous