English | 中文
The core shared type library for the PeerClaw identity & trust platform. Defines identity, message envelopes, Agent Card, protocol constants, and signaling types -- zero heavy dependencies, shared by both peerclaw-server and peerclaw-agent.
go get github.com/peerclaw/peerclaw-core| Package | Description |
|---|---|
identity |
Ed25519 key pair generation, loading, and saving; message signing and verification; X25519 key derivation |
envelope |
Unified message envelope Envelope, a cross-protocol common message format with encryption flag support |
agentcard |
Agent Card definition (compatible with the A2A standard + PeerClaw extensions), including structured capability declarations for Skills / Tools |
protocol |
Protocol (A2A / ACP / MCP) and transport method constants |
signaling |
WebRTC signaling message types (offer / answer / ICE candidate / config / bridge_message), ICE Server configuration, X25519 key exchange |
package main
import (
"fmt"
"github.com/peerclaw/peerclaw-core/identity"
)
func main() {
kp, _ := identity.GenerateKeypair()
fmt.Println("Public Key:", kp.PublicKeyString())
// Persist to file
identity.SaveKeypair(kp, "agent.key")
// Load from file
kp2, _ := identity.LoadKeypair("agent.key")
fmt.Println("Loaded: ", kp2.PublicKeyString())
}data := []byte("hello peerclaw")
sig := identity.Sign(kp.PrivateKey, data)
err := identity.Verify(kp.PublicKey, data, sig)
// err == nil means the signature is validDerive X25519 keys from an Ed25519 key pair for ECDH key exchange and end-to-end encryption:
x25519Priv, _ := kp.X25519PrivateKey()
x25519Pub, _ := kp.X25519PublicKey()
// Serialize to hex string
pubHex := kp.X25519PublicKeyString()
// Parse from hex
parsedPub, _ := identity.ParseX25519PublicKey(pubHex)import (
"github.com/peerclaw/peerclaw-core/envelope"
"github.com/peerclaw/peerclaw-core/protocol"
)
env := envelope.New("agent-alice", "agent-bob", protocol.ProtocolA2A, []byte(`{"text":"hi"}`))
env.WithTTL(30).WithMetadata("priority", "high")
// Mark the message as encrypted
env.Encrypted = true
env.SenderX25519 = "hex-encoded-x25519-public-key"Only depends on github.com/google/uuid -- kept minimal by design.
Licensed under the Apache License 2.0.
Copyright 2025 PeerClaw Contributors.