Other implementations:  Python TypeScript Node.js Rust

The Go implementation uses zero external dependencies – SHA3-256 is implemented in pure Go (FIPS 202). 27 unit tests, 14/14 cross-verification vectors passing.

View source → API reference →


Requirements

  • Go 1.21+
  • Zero external dependencies

Install

git clone https://github.com/aioschema/aioschema.git
cd aioschema/implementations/go

Quick Start

package main

import (
    "fmt"
    "os"
    aios "github.com/aioschema/aioschema/implementations/go"
)

func main() {
    // Read asset
    data, _ := os.ReadFile("photo.jpg")

    // Generate manifest
    manifest, err := aios.GenerateManifest(data, aios.GenerateOptions{})
    if err != nil {
        panic(err)
    }

    // Verify
    result, err := aios.VerifyManifest(data, manifest, aios.VerifyOptions{})
    if err != nil {
        panic(err)
    }
    fmt.Println(result.Success)    // true
    fmt.Println(result.MatchType)  // "hard"
}

With signing

import (
    "crypto/ed25519"
    "crypto/rand"
    "encoding/hex"
)

// Generate keypair
pubKey, privKey, _ := ed25519.GenerateKey(rand.Reader)
pubKeyHex := hex.EncodeToString(pubKey)

// Generate signed manifest
manifest, _ := aios.GenerateManifest(data, aios.GenerateOptions{
    PrivateKeyHex: hex.EncodeToString(privKey),
})

// Verify with public key
result, _ := aios.VerifyManifest(data, manifest, aios.VerifyOptions{
    PublicKeyHex: pubKeyHex,
})
fmt.Println(result.SignatureVerified) // true

Run Tests

# All tests (27 unit tests + 14 CV vectors)
go test ./...

# Unit tests only
go test -run "^Test" ./...

# Cross-verification vectors only
go test -run "CrossVerify" ./...

# With custom vectors path
AIOSCHEMA_VECTORS=/path/to/cross_verify_vectors.json go test ./...

API Summary

Function Description
GenerateManifest(data, opts) Generate a manifest from asset bytes
VerifyManifest(data, manifest, opts) Verify asset bytes against a manifest
ComputeHash(data, algorithm) Compute a prefixed hash string
CanonicalJSON(v) Deterministic sorted-key JSON as bytes
ParseHashPrefix(value) Parse alg-hexdigest into components

Full contracts: API.md


View conformance vectors → View all implementations →