示例
golang.org/x/crypto v0.54.0: scrypt.Key
已验证示例 — golang golang.org/x/crypto v0.54.0: scrypt.Key. contract 在 go 1.26 · linux alpine/x64 · docker 上运行并通过: scrypt.Key derives deterministic key bytes…
sha256:b531235155587e69458e0c1bbf9485ff44aa29979115038ea48641ec3f3df3f8
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux 24 · ubuntu · glibc 2.39 x64 go
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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 |
案例
HOW- 目标
- verify scrypt.Key in pkg:golang/golang.org/x/crypto@v0.54.0
- 符号
-
- scrypt.Key
- 创建时间
- 2026-08-30T13:47:41Z
契约
- 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)
文件
- 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 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.")
}
原始种子者
匿名