샘플
filippo.io/edwards25519 v1.1.0: Perform Edwards25519 point and scalar multiplication and addition with filippo.io/edwards25519
검증된 샘플 — golang filippo.io/edwards25519 v1.1.0: Perform Edwards25519 point and scalar multiplication and addition with filippo.io/edwards25519. go 1.26 …
sha256:9265dd8d73a2f966f5f5abd17d60948d082b25fcd77e46a0a7b0a7eb1bc073b1
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 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-23 |
| 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-07 |
케이스
HOW- 목표
- Perform Edwards25519 point and scalar multiplication and addition with filippo.io/edwards25519
- 생성일
- 2026-08-23T17:54:13Z
컨트랙트
- Point.ScalarBaseMult multiplies base point by scalar
- Point.ScalarMult multiplies arbitrary point by scalar
- Scalar.Multiply performs scalar multiplication
- ScalarMult satisfies associativity s2*(s1*B) == (s1*s2)*B
- Point.Add adds identity point leaving point unchanged
- Point.SetBytes roundtrips serialized point bytes
- Scalar.SetCanonicalBytes roundtrips canonical scalar bytes
- Scalar.SetCanonicalBytes rejects non-canonical scalar bytes
파일
- 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: Perform Edwards25519 point and scalar multiplication and addition with filippo.io/edwards25519
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/filippo.io/edwards25519@v1.1.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:b5dd2d21b032e87147c74883f554abac2050ff9b7b7aef6a35251420c7375a8f","contract":["Point.ScalarBaseMult multiplies base point by scalar","Point.ScalarMult multiplies arbitrary point by scalar","Scalar.Multiply performs scalar multiplication","ScalarMult satisfies associativity s2*(s1*B) == (s1*s2)*B","Point.Add adds identity point leaving point unchanged","Point.SetBytes roundtrips serialized point bytes","Scalar.SetCanonicalBytes roundtrips canonical scalar bytes","Scalar.SetCanonicalBytes rejects non-canonical scalar bytes"],"goal":"Perform Edwards25519 point and scalar multiplication and addition with filippo.io/edwards25519","kind":"HOW","packages":["pkg:golang/filippo.io/edwards25519@v1.1.0"],"schemaVersion":1},"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/filippo.io/edwards25519@v1.1.0"],"schemaVersion":1,"subject":"pkg:golang/filippo.io/edwards25519@v1.1.0","verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require filippo.io/edwards25519 v1.1.0
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
package main
import (
"fmt"
"log"
"filippo.io/edwards25519"
)
func main() {
// Initialize scalar s1
var seed1 [64]byte
for i := range seed1 {
seed1[i] = byte(i + 1)
}
s1, err := edwards25519.NewScalar().SetUniformBytes(seed1[:])
if err != nil {
log.Fatalf("SetUniformBytes s1 failed: %v", err)
}
// Initialize scalar s2
var seed2 [64]byte
for i := range seed2 {
seed2[i] = byte(i + 42)
}
s2, err := edwards25519.NewScalar().SetUniformBytes(seed2[:])
if err != nil {
log.Fatalf("SetUniformBytes s2 failed: %v", err)
}
// Compute base point scalar multiplication: P1 = s1 * B
p1 := edwards25519.NewIdentityPoint().ScalarBaseMult(s1)
fmt.Printf("P1 (s1 * B) serialized length: %d bytes\n", len(p1.Bytes()))
// Compute arbitrary point scalar multiplication: P2 = s2 * P1
p2 := edwards25519.NewIdentityPoint().ScalarMult(s2, p1)
// Compute scalar multiplication: s3 = s1 * s2
s3 := edwards25519.NewScalar().Multiply(s1, s2)
// Compute P3 = s3 * B = (s1 * s2) * B
p3 := edwards25519.NewIdentityPoint().ScalarBaseMult(s3)
// Verify equality: s2 * (s1 * B) == (s1 * s2) * B
if p2.Equal(p3) == 1 {
fmt.Println("Scalar multiplication associativity verified: s2*(s1*B) == (s1*s2)*B")
} else {
log.Fatalf("Associativity check failed")
}
// Point addition with identity: P + 0 = P
identity := edwards25519.NewIdentityPoint()
pAdded := edwards25519.NewIdentityPoint().Add(p2, identity)
if pAdded.Equal(p2) == 1 {
fmt.Println("Point addition with identity verified.")
}
}
{
"schemaVersion": 1,
"goal": "Perform Edwards25519 point and scalar multiplication and addition with filippo.io/edwards25519",
"kind": "HOW",
"packages": [
"pkg:golang/filippo.io/edwards25519@v1.1.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package main
import (
"bytes"
"fmt"
"os"
"filippo.io/edwards25519"
)
func main() {
var seed1 [64]byte
for i := range seed1 {
seed1[i] = byte(i + 1)
}
var seed2 [64]byte
for i := range seed2 {
seed2[i] = byte(i + 42)
}
s1, err := edwards25519.NewScalar().SetUniformBytes(seed1[:])
if err != nil {
fmt.Fprintf(os.Stderr, "SetUniformBytes s1 failed: %v\n", err)
os.Exit(1)
}
s2, err := edwards25519.NewScalar().SetUniformBytes(seed2[:])
if err != nil {
fmt.Fprintf(os.Stderr, "SetUniformBytes s2 failed: %v\n", err)
os.Exit(1)
}
// 1. Point.ScalarBaseMult multiplies base point by scalar
p1 := edwards25519.NewIdentityPoint().ScalarBaseMult(s1)
if p1.Equal(edwards25519.NewIdentityPoint()) == 1 {
fmt.Fprintf(os.Stderr, "Point.ScalarBaseMult resulted in identity point\n")
os.Exit(1)
}
// 2. Point.ScalarMult multiplies arbitrary point by scalar
p2 := edwards25519.NewIdentityPoint().ScalarMult(s2, p1)
// 3. Scalar.Multiply performs scalar multiplication
s3 := edwards25519.NewScalar().Multiply(s1, s2)
// 4. ScalarMult satisfies associativity s2*(s1*B) == (s1*s2)*B
p3 := edwards25519.NewIdentityPoint().ScalarBaseMult(s3)
if p2.Equal(p3) != 1 {
fmt.Fprintf(os.Stderr, "ScalarMult associativity failed: s2*(s1*B) != (s1*s2)*B\n")
os.Exit(1)
}
// 5. Point.Add adds identity point leaving point unchanged
identity := edwards25519.NewIdentityPoint()
pAdded := edwards25519.NewIdentityPoint().Add(p2, identity)
if pAdded.Equal(p2) != 1 {
fmt.Fprintf(os.Stderr, "Point.Add identity addition failed\n")
os.Exit(1)
}
// 6. Point.SetBytes roundtrips serialized point bytes
pBytes := p2.Bytes()
pRestored, err := edwards25519.NewIdentityPoint().SetBytes(pBytes)
if err != nil {
fmt.Fprintf(os.Stderr, "Point.SetBytes failed: %v\n", err)
os.Exit(1)
}
if pRestored.Equal(p2) != 1 {
fmt.Fprintf(os.Stderr, "Point.SetBytes roundtrip equality failed\n")
os.Exit(1)
}
// 7. Scalar.SetCanonicalBytes roundtrips canonical scalar bytes
sBytes := s1.Bytes()
sRestored, err := edwards25519.NewScalar().SetCanonicalBytes(sBytes)
if err != nil {
fmt.Fprintf(os.Stderr, "Scalar.SetCanonicalBytes failed: %v\n", err)
os.Exit(1)
}
if sRestored.Equal(s1) != 1 {
fmt.Fprintf(os.Stderr, "Scalar.SetCanonicalBytes roundtrip equality failed\n")
os.Exit(1)
}
if !bytes.Equal(sBytes, sRestored.Bytes()) {
fmt.Fprintf(os.Stderr, "Scalar.Bytes() mismatch\n")
os.Exit(1)
}
// 8. Scalar.SetCanonicalBytes rejects non-canonical scalar bytes
nonCanonicalBytes := bytes.Repeat([]byte{0xff}, 32)
if _, err := edwards25519.NewScalar().SetCanonicalBytes(nonCanonicalBytes); err == nil {
fmt.Fprintf(os.Stderr, "Scalar.SetCanonicalBytes should have rejected non-canonical bytes\n")
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
오리진 시더
익명