샘플
golang.org/x/crypto v0.27.0: hkdf.Expand
검증된 샘플 — golang golang.org/x/crypto v0.27.0: hkdf.Expand. go 1.26 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: hkdf.Expand expands pseudorandom key…
sha256:ee94fe6b48089ffd60ddd5c5014a7d8b4227db03a3a4da5526cd6989ab0b4597
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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 golang.org/x/crypto/hkdf.Expand in pkg:golang/golang.org/x/crypto@v0.27.0
- 심벌
-
- golang.org/x/crypto/hkdf.Expand
- 생성일
- 2026-08-30T17:31:24Z
컨트랙트
- hkdf.Expand expands pseudorandom key into key stream matching RFC 5869 test vector
- hkdf.Expand with distinct info produces distinct key streams
- hkdf.Expand returns error when reading beyond 255 times hash size
- hkdf.Expand supports sequential reads matching single full read
파일
- 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 golang.org/x/crypto/hkdf.Expand in pkg:golang/golang.org/x/crypto@v0.27.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/crypto@v0.27.0
Demonstrate these symbols/APIs:
- golang.org/x/crypto/hkdf.Expand
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:05e6a98004fb4c7bd80dab47497f72e59c1faf35d6f748e05adacee7d940d80b","contract":["hkdf.Expand expands pseudorandom key into key stream matching RFC 5869 test vector","hkdf.Expand with distinct info produces distinct key streams","hkdf.Expand returns error when reading beyond 255 times hash size","hkdf.Expand supports sequential reads matching single full read"],"goal":"verify golang.org/x/crypto/hkdf.Expand in pkg:golang/golang.org/x/crypto@v0.27.0","kind":"HOW","packages":["pkg:golang/golang.org/x/crypto@v0.27.0"],"schemaVersion":1,"symbols":["golang.org/x/crypto/hkdf.Expand"]},"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.27.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/crypto@v0.27.0","symbols":["golang.org/x/crypto/hkdf.Expand"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.22
require golang.org/x/crypto v0.27.0
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
package main
import (
"crypto/sha256"
"fmt"
"io"
"log"
"golang.org/x/crypto/hkdf"
)
func main() {
// Pseudorandom key (PRK) typically obtained from an extraction step or key exchange
prk := []byte{
0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf,
0x0d, 0xdc, 0x3f, 0x0d, 0xc4, 0x7b, 0xba, 0x63,
0x90, 0xb6, 0xc7, 0x3b, 0xb5, 0x0f, 0x9c, 0x31,
0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0xb3, 0xe5,
}
info := []byte("example.com/sample/v1/aes-key")
// Expand the PRK into application-specific output keying material (OKM)
expandReader := hkdf.Expand(sha256.New, prk, info)
derivedKey := make([]byte, 32) // 256-bit AES key
if _, err := io.ReadFull(expandReader, derivedKey); err != nil {
log.Fatalf("Failed to expand key: %v", err)
}
fmt.Printf("Derived key: %x\n", derivedKey)
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/crypto/hkdf.Expand in pkg:golang/golang.org/x/crypto@v0.27.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/crypto@v0.27.0"
],
"symbols": [
"golang.org/x/crypto/hkdf.Expand"
]
}
package main
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"os"
"golang.org/x/crypto/hkdf"
)
func main() {
// RFC 5869 Test Case 1 (SHA-256)
prk1, _ := hex.DecodeString("077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5")
info1, _ := hex.DecodeString("f0f1f2f3f4f5f6f7f8f9")
expectedOKM1, _ := hex.DecodeString("3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865")
// 1. hkdf.Expand expands pseudorandom key into key stream matching RFC 5869 test vector
expandReader1 := hkdf.Expand(sha256.New, prk1, info1)
okm1 := make([]byte, len(expectedOKM1))
if _, err := io.ReadFull(expandReader1, okm1); err != nil {
fmt.Fprintf(os.Stderr, "hkdf.Expand read failed: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(okm1, expectedOKM1) {
fmt.Fprintf(os.Stderr, "hkdf.Expand OKM mismatch: got %x, want %x\n", okm1, expectedOKM1)
os.Exit(1)
}
// 2. hkdf.Expand with distinct info produces distinct key streams
expandReader2A := hkdf.Expand(sha256.New, prk1, info1)
expandReader2B := hkdf.Expand(sha256.New, prk1, []byte("different info parameter"))
bufA := make([]byte, 32)
bufB := make([]byte, 32)
if _, err := io.ReadFull(expandReader2A, bufA); err != nil {
fmt.Fprintf(os.Stderr, "expandReader2A read failed: %v\n", err)
os.Exit(1)
}
if _, err := io.ReadFull(expandReader2B, bufB); err != nil {
fmt.Fprintf(os.Stderr, "expandReader2B read failed: %v\n", err)
os.Exit(1)
}
if bytes.Equal(bufA, bufB) {
fmt.Fprintf(os.Stderr, "hkdf.Expand produced identical output for different info\n")
os.Exit(1)
}
// 3. hkdf.Expand returns error when reading beyond 255 times hash size
maxBytes := 255 * sha256.Size // 8160 bytes for SHA-256
limitReader := hkdf.Expand(sha256.New, prk1, info1)
maxBuf := make([]byte, maxBytes)
if _, err := io.ReadFull(limitReader, maxBuf); err != nil {
fmt.Fprintf(os.Stderr, "Failed to read max allowed HKDF bytes (%d): %v\n", maxBytes, err)
os.Exit(1)
}
extraByte := make([]byte, 1)
if _, err := limitReader.Read(extraByte); err == nil {
fmt.Fprintf(os.Stderr, "hkdf.Expand unexpectedly allowed reading beyond 255 * hash.Size\n")
os.Exit(1)
}
// 4. hkdf.Expand supports sequential reads matching single full read
seqReader := hkdf.Expand(sha256.New, prk1, info1)
part1 := make([]byte, 10)
part2 := make([]byte, 16)
part3 := make([]byte, len(expectedOKM1)-26)
if _, err := io.ReadFull(seqReader, part1); err != nil {
fmt.Fprintf(os.Stderr, "seqReader part1 failed: %v\n", err)
os.Exit(1)
}
if _, err := io.ReadFull(seqReader, part2); err != nil {
fmt.Fprintf(os.Stderr, "seqReader part2 failed: %v\n", err)
os.Exit(1)
}
if _, err := io.ReadFull(seqReader, part3); err != nil {
fmt.Fprintf(os.Stderr, "seqReader part3 failed: %v\n", err)
os.Exit(1)
}
combined := append(append(part1, part2...), part3...)
if !bytes.Equal(combined, expectedOKM1) {
fmt.Fprintf(os.Stderr, "Sequential reads mismatch with single read: got %x, want %x\n", combined, expectedOKM1)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
오리진 시더
익명