Exemple
golang.org/x/crypto v0.54.0: scrypt.Key
Échantillon vérifié pour golang golang.org/x/crypto v0.54.0: scrypt.Key. Le contrat s'est exécuté sur go 1.26 · linux alpine/x64 · docker et a réussi.
sha256:b531235155587e69458e0c1bbf9485ff44aa29979115038ea48641ec3f3df3f8
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 go
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-30 |
Cas
HOW- Objectif
- verify scrypt.Key in pkg:golang/golang.org/x/crypto@v0.54.0
- Paquets
- Symboles
-
- scrypt.Key
- Créé
- 2026-08-30T13:47:41Z
Contrat
- scrypt.Key derives deterministic key bytes matching the requested key length
- scrypt.Key produces identical derived keys for identical password, salt, and parameters
- scrypt.Key produces different derived keys for different passwords with identical salt and cost parameters
- scrypt.Key produces different derived keys for different salts with identical password and cost parameters
- scrypt.Key produces different derived keys when cost parameter N is varied
- scrypt.Key returns an error when cost parameter N is less than or equal to 1 or not a power of 2
- scrypt.Key returns an error when parameters r and p exceed limit (r * p >= 1<<30)
Fichiers
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Code source
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 scrypt.Key in pkg:golang/golang.org/x/crypto@v0.54.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/crypto@v0.54.0
Demonstrate these symbols/APIs:
- scrypt.Key
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:000ad239a960aa655290440d0ba3e6b5f7a80fd9584a26ae62760b2419849a4a","contract":["scrypt.Key derives deterministic key bytes matching the requested key length","scrypt.Key produces identical derived keys for identical password, salt, and parameters","scrypt.Key produces different derived keys for different passwords with identical salt and cost parameters","scrypt.Key produces different derived keys for different salts with identical password and cost parameters","scrypt.Key produces different derived keys when cost parameter N is varied","scrypt.Key returns an error when cost parameter N is less than or equal to 1 or not a power of 2","scrypt.Key returns an error when parameters r and p exceed limit (r * p \u003e= 1\u003c\u003c30)"],"goal":"verify scrypt.Key in pkg:golang/golang.org/x/crypto@v0.54.0","kind":"HOW","packages":["pkg:golang/golang.org/x/crypto@v0.54.0"],"schemaVersion":1,"symbols":["scrypt.Key"]},"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.54.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/crypto@v0.54.0","symbols":["scrypt.Key"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require golang.org/x/crypto v0.54.0
golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
package main
import (
"fmt"
"log"
"golang.org/x/crypto/scrypt"
)
func main() {
password := []byte("example-user-password")
salt := []byte("example-unique-salt-1234")
// Standard parameters: N=16384, r=8, p=1, keyLen=32
derivedKey, err := scrypt.Key(password, salt, 16384, 8, 1, 32)
if err != nil {
log.Fatalf("scrypt.Key failed: %v", err)
}
fmt.Printf("Derived key (32 bytes): %x\n", derivedKey)
fmt.Println("scrypt key derivation successful.")
}
{
"schemaVersion": 1,
"goal": "verify scrypt.Key in pkg:golang/golang.org/x/crypto@v0.54.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/crypto@v0.54.0"
],
"symbols": [
"scrypt.Key"
]
}
package main
import (
"bytes"
"fmt"
"os"
"golang.org/x/crypto/scrypt"
)
func main() {
password := []byte("test-password-input")
salt := []byte("test-salt-bytes-16")
const N = 16
const r = 8
const p = 1
const keyLen = 32
// 1. scrypt.Key derives deterministic key bytes matching the requested key length
key1, err := scrypt.Key(password, salt, N, r, p, keyLen)
if err != nil {
fmt.Fprintf(os.Stderr, "scrypt.Key failed: %v\n", err)
os.Exit(1)
}
if len(key1) != keyLen {
fmt.Fprintf(os.Stderr, "scrypt.Key length mismatch: expected %d, got %d\n", keyLen, len(key1))
os.Exit(1)
}
// 2. scrypt.Key produces identical derived keys for identical password, salt, and parameters
key2, err := scrypt.Key(password, salt, N, r, p, keyLen)
if err != nil {
fmt.Fprintf(os.Stderr, "scrypt.Key second call failed: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(key1, key2) {
fmt.Fprintf(os.Stderr, "scrypt.Key is not deterministic for identical inputs\n")
os.Exit(1)
}
// 3. scrypt.Key produces different derived keys for different passwords with identical salt and cost parameters
keyDiffPassword, err := scrypt.Key([]byte("different-password"), salt, N, r, p, keyLen)
if err != nil {
fmt.Fprintf(os.Stderr, "scrypt.Key with different password failed: %v\n", err)
os.Exit(1)
}
if bytes.Equal(key1, keyDiffPassword) {
fmt.Fprintf(os.Stderr, "scrypt.Key should produce different keys for different passwords\n")
os.Exit(1)
}
// 4. scrypt.Key produces different derived keys for different salts with identical password and cost parameters
keyDiffSalt, err := scrypt.Key(password, []byte("different-salt-9999"), N, r, p, keyLen)
if err != nil {
fmt.Fprintf(os.Stderr, "scrypt.Key with different salt failed: %v\n", err)
os.Exit(1)
}
if bytes.Equal(key1, keyDiffSalt) {
fmt.Fprintf(os.Stderr, "scrypt.Key should produce different keys for different salts\n")
os.Exit(1)
}
// 5. scrypt.Key produces different derived keys when cost parameter N is varied
keyDiffN, err := scrypt.Key(password, salt, 32, r, p, keyLen)
if err != nil {
fmt.Fprintf(os.Stderr, "scrypt.Key with N=32 failed: %v\n", err)
os.Exit(1)
}
if bytes.Equal(key1, keyDiffN) {
fmt.Fprintf(os.Stderr, "scrypt.Key should produce different keys for different cost parameter N\n")
os.Exit(1)
}
// 6. scrypt.Key returns an error when cost parameter N is less than or equal to 1 or not a power of 2
invalidNs := []int{0, 1, -1, 3, 15, 100}
for _, invalidN := range invalidNs {
if _, err := scrypt.Key(password, salt, invalidN, r, p, keyLen); err == nil {
fmt.Fprintf(os.Stderr, "scrypt.Key expected error for invalid N=%d, got nil\n", invalidN)
os.Exit(1)
}
}
// 7. scrypt.Key returns an error when parameters r and p exceed limit (r * p >= 1<<30)
if _, err := scrypt.Key(password, salt, N, 1<<15, 1<<15, keyLen); err == nil {
fmt.Fprintf(os.Stderr, "scrypt.Key expected error when r*p >= 1<<30, got nil\n")
os.Exit(1)
}
fmt.Println("All scrypt.Key contract assertions passed.")
}
Seeder d'origine
anonyme