Beispiel
golang.org/x/crypto v0.58.0: argon2.IDKey, bcrypt.GenerateFromPassword, bcrypt.CompareHashAndPassword
Verifiziertes Beispiel für golang golang.org/x/crypto v0.58.0: argon2.IDKey, bcrypt.GenerateFromPassword, bcrypt.CompareHashAndPassword. Der Vertrag lief auf…
sha256:e7a03011c02651cc7f3b0deab237f39eed428c05912bdc00e7a37a8445267a14
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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-29 |
Fall
HOW- Ziel
- verify pkg:golang/golang.org/x/crypto@v0.58.0
- Pakete
- Symbole
-
- argon2.IDKey
- bcrypt.GenerateFromPassword
- bcrypt.CompareHashAndPassword
- sha3.Sum256
- Umgebung
- go 1.26.6
- Erstellt
- 2026-10-29T17:03:05Z
Contract
- argon2.IDKey derives deterministic 32-byte key slices and produces distinct keys when password or salt changes
- bcrypt.GenerateFromPassword hashes passwords at the requested cost and bcrypt.CompareHashAndPassword accepts the matching password while returning bcrypt.ErrMismatchedHashAndPassword on mismatch
- sha3.Sum256 and streaming sha3.New256 produce identical 32-byte digests for the same input and distinct digests for different inputs
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Quelltext
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.58.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/crypto@v0.58.0
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:cdff1b51f3e6a7941c3c0eb53962b56cee88beb42a3f0a7af48c33d7dcf876af","contract":["argon2.IDKey derives deterministic 32-byte key slices and produces distinct keys when password or salt changes","bcrypt.GenerateFromPassword hashes passwords at the requested cost and bcrypt.CompareHashAndPassword accepts the matching password while returning bcrypt.ErrMismatchedHashAndPassword on mismatch","sha3.Sum256 and streaming sha3.New256 produce identical 32-byte digests for the same input and distinct digests for different inputs"],"goal":"verify pkg:golang/golang.org/x/crypto@v0.58.0","kind":"HOW","packages":["pkg:golang/golang.org/x/crypto@v0.58.0"],"schemaVersion":1,"symbols":["argon2.IDKey","bcrypt.GenerateFromPassword","bcrypt.CompareHashAndPassword","sha3.Sum256"]},"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/golang.org/x/crypto@v0.58.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/crypto@v0.58.0","symbols":["argon2.IDKey","bcrypt.GenerateFromPassword","bcrypt.CompareHashAndPassword","sha3.Sum256"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require golang.org/x/crypto v0.58.0
require golang.org/x/sys v0.49.0 // indirect
golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54=
golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w=
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
package main
import (
"encoding/hex"
"fmt"
"golang.org/x/crypto/argon2"
"golang.org/x/crypto/bcrypt"
"golang.org/x/crypto/sha3"
)
func main() {
password := []byte("example-passphrase")
salt := []byte("example-salt-16b")
derived := argon2.IDKey(password, salt, 1, 32*1024, 2, 32)
fmt.Printf("argon2id: %s\n", hex.EncodeToString(derived))
hashed, err := bcrypt.GenerateFromPassword(password, bcrypt.MinCost)
if err != nil {
panic(err)
}
if err := bcrypt.CompareHashAndPassword(hashed, password); err != nil {
panic(err)
}
digest := sha3.Sum256(password)
fmt.Printf("sha3-256: %s\n", hex.EncodeToString(digest[:]))
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/crypto@v0.58.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/crypto@v0.58.0"
]
}
package main
import (
"bytes"
"errors"
"fmt"
"os"
"golang.org/x/crypto/argon2"
"golang.org/x/crypto/bcrypt"
"golang.org/x/crypto/sha3"
)
func main() {
pass := []byte("verification-passphrase")
salt := []byte("verification-salt-16")
// 1. argon2.IDKey derives deterministic key bytes matching requested length and varies with password or salt
key1 := argon2.IDKey(pass, salt, 1, 32*1024, 2, 32)
if len(key1) != 32 {
fmt.Fprintf(os.Stderr, "expected key length 32, got %d\n", len(key1))
os.Exit(1)
}
key2 := argon2.IDKey(pass, salt, 1, 32*1024, 2, 32)
if !bytes.Equal(key1, key2) {
fmt.Fprintf(os.Stderr, "expected deterministic argon2.IDKey output\n")
os.Exit(1)
}
keyDiffPass := argon2.IDKey([]byte("other-passphrase"), salt, 1, 32*1024, 2, 32)
if bytes.Equal(key1, keyDiffPass) {
fmt.Fprintf(os.Stderr, "expected different argon2.IDKey output for different password\n")
os.Exit(1)
}
keyDiffSalt := argon2.IDKey(pass, []byte("other-salt-value-16"), 1, 32*1024, 2, 32)
if bytes.Equal(key1, keyDiffSalt) {
fmt.Fprintf(os.Stderr, "expected different argon2.IDKey output for different salt\n")
os.Exit(1)
}
// 2. bcrypt.GenerateFromPassword and bcrypt.CompareHashAndPassword verify matching passwords and reject mismatches
hash, err := bcrypt.GenerateFromPassword(pass, bcrypt.MinCost)
if err != nil {
fmt.Fprintf(os.Stderr, "bcrypt.GenerateFromPassword failed: %v\n", err)
os.Exit(1)
}
cost, err := bcrypt.Cost(hash)
if err != nil || cost != bcrypt.MinCost {
fmt.Fprintf(os.Stderr, "expected bcrypt cost %d, got %d (err=%v)\n", bcrypt.MinCost, cost, err)
os.Exit(1)
}
if err := bcrypt.CompareHashAndPassword(hash, pass); err != nil {
fmt.Fprintf(os.Stderr, "expected bcrypt.CompareHashAndPassword to succeed: %v\n", err)
os.Exit(1)
}
if err := bcrypt.CompareHashAndPassword(hash, []byte("wrong-passphrase")); !errors.Is(err, bcrypt.ErrMismatchedHashAndPassword) {
fmt.Fprintf(os.Stderr, "expected ErrMismatchedHashAndPassword, got: %v\n", err)
os.Exit(1)
}
// 3. sha3.Sum256 and sha3.New256 produce identical 32-byte digests for the same input
sum := sha3.Sum256(pass)
h := sha3.New256()
_, _ = h.Write(pass)
streamSum := h.Sum(nil)
if !bytes.Equal(sum[:], streamSum) {
fmt.Fprintf(os.Stderr, "expected sha3.Sum256 and sha3.New256 to match\n")
os.Exit(1)
}
otherSum := sha3.Sum256([]byte("different-input"))
if bytes.Equal(sum[:], otherSum[:]) {
fmt.Fprintf(os.Stderr, "expected different sha3-256 digests for distinct inputs\n")
os.Exit(1)
}
fmt.Println("Contract passed.")
}
Ursprungs-Seeder
anonym