示例
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2: Fingerprint128
已验证示例 — golang github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2: Fingerprint128. contract 在 go 1.26 · linux debian/x64 · docker 上运行并通过.
sha256:a8c3b22c69172672bafb27c40f2c2bf4705e331e70c6659c4e39ebb60a1e18f7
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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-04 |
案例
HOW- 目标
- verify github.com/dgryski/go-farm.Fingerprint128 in pkg:golang/github.com/dgryski/go-farm@v0.0.0-20190423205320-6a90982ecee2
- 符号
-
- github.com/dgryski/go-farm.Fingerprint128
- 环境
- go 1.26.6
- 创建时间
- 2026-09-04T13:08:05Z
契约
- farm.Fingerprint128 computes deterministic 128-bit lo and hi components for byte slices
- farm.Fingerprint128 produces distinct 128-bit fingerprints for differing inputs without collision
- farm.Fingerprint128 matches reference FarmHash test vectors for empty and standard inputs
- farm.Fingerprint128 handles sub-slice inputs consistently with identical byte content
文件
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
源代码
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 github.com/dgryski/go-farm.Fingerprint128 in pkg:golang/github.com/dgryski/go-farm@v0.0.0-20190423205320-6a90982ecee2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/dgryski/go-farm@v0.0.0-20190423205320-6a90982ecee2
Demonstrate these symbols/APIs:
- github.com/dgryski/go-farm.Fingerprint128
Required runtime conditions:
- ecosystem: golang
- language: go
- packageManager: go@1.26.6
- runtime: go@1.26.6
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:c6c0fba6049ace23673b6962602f45e489e5ce36559571f0cb1dfaff76889546","contract":["farm.Fingerprint128 computes deterministic 128-bit lo and hi components for byte slices","farm.Fingerprint128 produces distinct 128-bit fingerprints for differing inputs without collision","farm.Fingerprint128 matches reference FarmHash test vectors for empty and standard inputs","farm.Fingerprint128 handles sub-slice inputs consistently with identical byte content"],"goal":"verify github.com/dgryski/go-farm.Fingerprint128 in pkg:golang/github.com/dgryski/go-farm@v0.0.0-20190423205320-6a90982ecee2","kind":"HOW","packages":["pkg:golang/github.com/dgryski/go-farm@v0.0.0-20190423205320-6a90982ecee2"],"schemaVersion":1,"symbols":["github.com/dgryski/go-farm.Fingerprint128"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/dgryski/go-farm@v0.0.0-20190423205320-6a90982ecee2"],"schemaVersion":1,"subject":"pkg:golang/github.com/dgryski/go-farm@v0.0.0-20190423205320-6a90982ecee2","symbols":["github.com/dgryski/go-farm.Fingerprint128"],"verifierAdapter":"golang@1"}
module example.com/farm-fingerprint128
go 1.22.0
require github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
package main
import (
"fmt"
farm "github.com/dgryski/go-farm"
)
// ComputeFingerprint128 returns the low and high 64-bit halves of the 128-bit FarmHash fingerprint.
func ComputeFingerprint128(data []byte) (lo, hi uint64) {
return farm.Fingerprint128(data)
}
// FormatFingerprint128 returns a 32-character hex representation of the 128-bit fingerprint.
func FormatFingerprint128(lo, hi uint64) string {
return fmt.Sprintf("%016x%016x", hi, lo)
}
func main() {
input := []byte("hello farmhash")
lo, hi := ComputeFingerprint128(input)
fmt.Printf("Fingerprint128: %s (lo=%#016x, hi=%#016x)\n", FormatFingerprint128(lo, hi), lo, hi)
}
{
"schemaVersion": 1,
"goal": "verify github.com/dgryski/go-farm.Fingerprint128 in pkg:golang/github.com/dgryski/go-farm@v0.0.0-20190423205320-6a90982ecee2",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/dgryski/go-farm@v0.0.0-20190423205320-6a90982ecee2"
],
"symbols": [
"github.com/dgryski/go-farm.Fingerprint128"
],
"runtimeConditions": {
"ecosystem": "golang",
"language": "go",
"packageManager": "go@1.26.6",
"runtime": "go@1.26.6"
}
}
package main
import (
"bytes"
"fmt"
"os"
farm "github.com/dgryski/go-farm"
)
func main() {
// Assertion 1: farm.Fingerprint128 computes deterministic 128-bit lo and hi components for byte slices
input1 := []byte("The quick brown fox jumps over the lazy dog.")
lo1a, hi1a := farm.Fingerprint128(input1)
lo1b, hi1b := farm.Fingerprint128(input1)
if lo1a != lo1b || hi1a != hi1b {
fmt.Fprintf(os.Stderr, "FAIL: Fingerprint128 is not deterministic: (%#x, %#x) != (%#x, %#x)\n", lo1a, hi1a, lo1b, hi1b)
os.Exit(1)
}
// Assertion 2: farm.Fingerprint128 produces distinct 128-bit fingerprints for differing inputs without collision
input2 := []byte("The quick brown fox jumps over the lazy cog.")
lo2, hi2 := farm.Fingerprint128(input2)
if lo1a == lo2 && hi1a == hi2 {
fmt.Fprintf(os.Stderr, "FAIL: Fingerprint128 collision on distinct inputs: (%#x, %#x)\n", lo1a, hi1a)
os.Exit(1)
}
diffPairs := [][2]string{
{"sample-key-alpha", "sample-key-beta"},
{"user:1001:session", "user:1002:session"},
{"data/chunk/0001", "data/chunk/0002"},
}
for _, pair := range diffPairs {
lA, hA := farm.Fingerprint128([]byte(pair[0]))
lB, hB := farm.Fingerprint128([]byte(pair[1]))
if lA == lB && hA == hB {
fmt.Fprintf(os.Stderr, "FAIL: Fingerprint128 collision between %q and %q\n", pair[0], pair[1])
os.Exit(1)
}
}
// Assertion 3: farm.Fingerprint128 matches reference FarmHash test vectors for empty and standard inputs
vectors := []struct {
in string
wantLo uint64
wantHi uint64
}{
{"", 0x3df09dfc64c09a2b, 0x3cb540c392e51e29},
{"a", 0x6e97d6bbdfc0a0c4, 0x52a71e38f43be561},
{"ab", 0x13e834f38a6c88b8, 0xcfdbce01c0e7622e},
{"abc", 0x3980b2afd2126c04, 0xa085f09013029e45},
{"abcd", 0xb8d7175e11647e82, 0x0906d778016538d9},
{"0123456789", 0xcf650cdfad0d0675, 0x6f6cb496e4b429c5},
}
for _, vec := range vectors {
gotLo, gotHi := farm.Fingerprint128([]byte(vec.in))
if gotLo != vec.wantLo || gotHi != vec.wantHi {
fmt.Fprintf(os.Stderr, "FAIL: Fingerprint128(%q) = (%#016x, %#016x), want (%#016x, %#016x)\n",
vec.in, gotLo, gotHi, vec.wantLo, vec.wantHi)
os.Exit(1)
}
}
// Assertion 4: farm.Fingerprint128 handles sub-slice inputs consistently with identical byte content
base := []byte("prefix-0123456789-suffix")
subSlice := base[7:17] // "0123456789"
standalone := []byte("0123456789")
if !bytes.Equal(subSlice, standalone) {
fmt.Fprintf(os.Stderr, "FAIL: test setup issue: bytes not equal\n")
os.Exit(1)
}
subLo, subHi := farm.Fingerprint128(subSlice)
stdLo, stdHi := farm.Fingerprint128(standalone)
if subLo != stdLo || subHi != stdHi {
fmt.Fprintf(os.Stderr, "FAIL: Fingerprint128 on sub-slice mismatch: (%#x, %#x) != (%#x, %#x)\n",
subLo, subHi, stdLo, stdHi)
os.Exit(1)
}
fmt.Println("PASS: farm.Fingerprint128 contract passed")
}
原始种子者
匿名