サンプル
golang.org/x/crypto v0.36.0: scrypt.Key
検証済みサンプル — golang golang.org/x/crypto v0.36.0: scrypt.Key. go 1.26 · linux debian/x64 · docker で contract を実行し、成功しました: scrypt.Key derives deterministic key…
sha256:73ccd4397e4063e6f5a9638168fcaa719fe76a0a80b0101428ede3777d6e74d8
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 3
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 go
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | SKIPPED | compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-02 |
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | SKIPPED | compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-02 |
| 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-02 |
ケース
HOW- ゴール
- verify scrypt.Key in pkg:golang/golang.org/x/crypto@v0.36.0
- シンボル
-
- scrypt.Key
- 作成日
- 2026-09-02T14:34:37Z
コントラクト
- scrypt.Key derives deterministic key bytes matching the specified 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 parameters
- scrypt.Key produces different derived keys for different salts with identical parameters
- scrypt.Key produces different derived keys when cost parameter N is varied
- scrypt.Key returns an error when N is not a power of 2 or less than or equal to 1
- scrypt.Key returns an error when parameters r and p are too large
ファイル
- 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.36.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/crypto@v0.36.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:544a8f3014a8b9877a266c5eff6ff5f073c031803035f7ba13c45dde48994466","contract":["scrypt.Key derives deterministic key bytes matching the specified 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 parameters","scrypt.Key produces different derived keys for different salts with identical parameters","scrypt.Key produces different derived keys when cost parameter N is varied","scrypt.Key returns an error when N is not a power of 2 or less than or equal to 1","scrypt.Key returns an error when parameters r and p are too large"],"goal":"verify scrypt.Key in pkg:golang/golang.org/x/crypto@v0.36.0","kind":"HOW","packages":["pkg:golang/golang.org/x/crypto@v0.36.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.36.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/crypto@v0.36.0","symbols":["scrypt.Key"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require golang.org/x/crypto v0.36.0
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
package main
import (
"fmt"
"log"
"golang.org/x/crypto/scrypt"
)
func main() {
password := []byte("example-user-password")
salt := []byte("example-unique-salt-1234")
// Standard recommended 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.36.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/crypto@v0.36.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 specified 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 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 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 N is not a power of 2 or less than or equal to 1
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 are too large
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.")
}
オリジンシーダー
匿名