CodeSampleX

Sample

golang.org/x/crypto v0.48.0: sha3.NewShake256

Verified sample for golang golang.org/x/crypto v0.48.0: sha3.NewShake256. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:61e607f07caee66fccb07d88166808fffc4e98152a5f6db74132bd7c6948ccd2

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-09-01

Case

HOW
Goal
verify sha3.NewShake256 in pkg:golang/golang.org/x/crypto@v0.48.0
Packages
Symbols
  • sha3.NewShake256
Created
2026-09-01T20:31:21Z

Contract

  1. sha3.NewShake256 derives variable-length output matching SHAKE256 test vector
  2. sha3.NewShake256 produces deterministic output for identical input and distinct output for different input
  3. sha3.NewShake256 Clone produces identical output stream from cloned state
  4. sha3.NewShake256 Reset restarts stream from initial state

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 sha3.NewShake256 in pkg:golang/golang.org/x/crypto@v0.48.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/crypto@v0.48.0
Demonstrate these symbols/APIs:
  - sha3.NewShake256

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:a0d28ea775547fb59a8d1d649b5d9d2093e186d88c5cd50cf38e963ea38e9f1b","contract":["sha3.NewShake256 derives variable-length output matching SHAKE256 test vector","sha3.NewShake256 produces deterministic output for identical input and distinct output for different input","sha3.NewShake256 Clone produces identical output stream from cloned state","sha3.NewShake256 Reset restarts stream from initial state"],"goal":"verify sha3.NewShake256 in pkg:golang/golang.org/x/crypto@v0.48.0","kind":"HOW","packages":["pkg:golang/golang.org/x/crypto@v0.48.0"],"schemaVersion":1,"symbols":["sha3.NewShake256"]},"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.48.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/crypto@v0.48.0","symbols":["sha3.NewShake256"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require golang.org/x/crypto v0.48.0

require golang.org/x/sys v0.41.0 // indirect
go.sum
golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=
golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
main.go
package main

import (
	"encoding/hex"
	"fmt"
	"io"

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

func main() {
	data := []byte("CodeSampleX verification input")

	// 1. Create a new SHAKE-256 extendable-output function (XOF)
	shake := sha3.NewShake256()
	shake.Write(data)

	// 2. Read variable-length output stream (e.g., 64 bytes)
	out64 := make([]byte, 64)
	if _, err := io.ReadFull(shake, out64); err != nil {
		panic(err)
	}
	fmt.Printf("SHAKE-256 (64 bytes): %s\n", hex.EncodeToString(out64))

	// 3. Clone SHAKE state to continue reading identical stream
	cloned := shake.Clone()
	outMore1 := make([]byte, 32)
	outMore2 := make([]byte, 32)
	if _, err := io.ReadFull(shake, outMore1); err != nil {
		panic(err)
	}
	if _, err := io.ReadFull(cloned, outMore2); err != nil {
		panic(err)
	}
	fmt.Printf("Original continued: %s\n", hex.EncodeToString(outMore1))
	fmt.Printf("Cloned continued:   %s\n", hex.EncodeToString(outMore2))

	// 4. Reset SHAKE state
	shake.Reset()
	shake.Write(data)
	outReset := make([]byte, 64)
	if _, err := io.ReadFull(shake, outReset); err != nil {
		panic(err)
	}
	fmt.Printf("Reset + re-run:     %s\n", hex.EncodeToString(outReset))
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify sha3.NewShake256 in pkg:golang/golang.org/x/crypto@v0.48.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/crypto@v0.48.0"
  ],
  "symbols": [
    "sha3.NewShake256"
  ]
}
test/contract.go
package main

import (
	"bytes"
	"encoding/hex"
	"fmt"
	"io"
	"os"

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

func main() {
	// 1. sha3.NewShake256 derives variable-length output matching SHAKE256 test vector
	expectedShakeAbc, _ := hex.DecodeString("483366601360a8771c6863080cc4114d8db44530f8f1e1ee4f94ea37e78b5739d5a15bef186a5386c75744c0527e1faa9f8726e462a12a4feb06bd8801e751e4")
	shake := sha3.NewShake256()
	shake.Write([]byte("abc"))
	shakeBuf := make([]byte, 64)
	if _, err := io.ReadFull(shake, shakeBuf); err != nil {
		fmt.Fprintf(os.Stderr, "sha3.NewShake256 Read failed: %v\n", err)
		os.Exit(1)
	}
	if !bytes.Equal(shakeBuf, expectedShakeAbc) {
		fmt.Fprintf(os.Stderr, "sha3.NewShake256 'abc' 64-byte mismatch: got %x, want %x\n", shakeBuf, expectedShakeAbc)
		os.Exit(1)
	}

	// 2. sha3.NewShake256 produces deterministic output for identical input and distinct output for different input
	shake1 := sha3.NewShake256()
	shake1.Write([]byte("test secret seed"))
	out1 := make([]byte, 64)
	if _, err := io.ReadFull(shake1, out1); err != nil {
		fmt.Fprintf(os.Stderr, "shake1 Read failed: %v\n", err)
		os.Exit(1)
	}

	shake2 := sha3.NewShake256()
	shake2.Write([]byte("test secret seed"))
	out2 := make([]byte, 64)
	if _, err := io.ReadFull(shake2, out2); err != nil {
		fmt.Fprintf(os.Stderr, "shake2 Read failed: %v\n", err)
		os.Exit(1)
	}

	if !bytes.Equal(out1, out2) {
		fmt.Fprintf(os.Stderr, "sha3.NewShake256 deterministic check failed\n")
		os.Exit(1)
	}

	shakeDiff := sha3.NewShake256()
	shakeDiff.Write([]byte("different secret seed"))
	outDiff := make([]byte, 64)
	if _, err := io.ReadFull(shakeDiff, outDiff); err != nil {
		fmt.Fprintf(os.Stderr, "shakeDiff Read failed: %v\n", err)
		os.Exit(1)
	}

	if bytes.Equal(out1, outDiff) {
		fmt.Fprintf(os.Stderr, "sha3.NewShake256 failed to produce distinct output for different input\n")
		os.Exit(1)
	}

	// 3. sha3.NewShake256 Clone produces identical output stream from cloned state
	shakeSource := sha3.NewShake256()
	shakeSource.Write([]byte("shared state data"))
	firstChunk := make([]byte, 32)
	if _, err := io.ReadFull(shakeSource, firstChunk); err != nil {
		fmt.Fprintf(os.Stderr, "shakeSource firstChunk Read failed: %v\n", err)
		os.Exit(1)
	}

	shakeClone := shakeSource.Clone()

	secondChunkSource := make([]byte, 64)
	if _, err := io.ReadFull(shakeSource, secondChunkSource); err != nil {
		fmt.Fprintf(os.Stderr, "shakeSource secondChunk Read failed: %v\n", err)
		os.Exit(1)
	}

	secondChunkClone := make([]byte, 64)
	if _, err := io.ReadFull(shakeClone, secondChunkClone); err != nil {
		fmt.Fprintf(os.Stderr, "shakeClone secondChunk Read failed: %v\n", err)
		os.Exit(1)
	}

	if !bytes.Equal(secondChunkSource, secondChunkClone) {
		fmt.Fprintf(os.Stderr, "sha3.NewShake256 Clone stream output mismatch\n")
		os.Exit(1)
	}

	// 4. sha3.NewShake256 Reset restarts stream from initial state
	shakeReset := sha3.NewShake256()
	shakeReset.Write([]byte("arbitrary data"))
	dumpBuf := make([]byte, 100)
	if _, err := io.ReadFull(shakeReset, dumpBuf); err != nil {
		fmt.Fprintf(os.Stderr, "shakeReset dumpBuf Read failed: %v\n", err)
		os.Exit(1)
	}

	shakeReset.Reset()
	shakeReset.Write([]byte("abc"))
	resetBuf := make([]byte, 64)
	if _, err := io.ReadFull(shakeReset, resetBuf); err != nil {
		fmt.Fprintf(os.Stderr, "shakeReset resetBuf Read failed: %v\n", err)
		os.Exit(1)
	}
	if !bytes.Equal(resetBuf, expectedShakeAbc) {
		fmt.Fprintf(os.Stderr, "sha3.NewShake256 Reset did not restart to initial state\n")
		os.Exit(1)
	}

	fmt.Println("All contract assertions passed.")
}

Origin Seeder

anonymous