Documentation
¶
Overview ¶
Package trust provides integrity verification, signature handling, and trust policy enforcement for forge skills.
Index ¶
- func ComputeChecksum(content []byte) string
- func GenerateKeyPair() (ed25519.PublicKey, ed25519.PrivateKey, error)
- func MarshalManifest(m *Manifest) ([]byte, error)
- func Sign(content []byte, privateKey ed25519.PrivateKey) []byte
- func SignSkill(skillContent []byte, privateKey ed25519.PrivateKey) ([]byte, error)
- func Verify(content []byte, signature []byte, publicKey ed25519.PublicKey) bool
- func VerifyChecksum(content []byte, expected string) bool
- func VerifySkill(skillContent, signature []byte, publicKey ed25519.PublicKey) bool
- type IntegrityViolation
- type Keyring
- type Manifest
- type TrustPolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeChecksum ¶
ComputeChecksum returns the SHA-256 checksum of content as "sha256:<hex>".
func GenerateKeyPair ¶
func GenerateKeyPair() (ed25519.PublicKey, ed25519.PrivateKey, error)
GenerateKeyPair creates a new Ed25519 key pair.
func MarshalManifest ¶
MarshalManifest serializes a manifest to JSON.
func Sign ¶
func Sign(content []byte, privateKey ed25519.PrivateKey) []byte
Sign produces an Ed25519 signature of content.
func SignSkill ¶
func SignSkill(skillContent []byte, privateKey ed25519.PrivateKey) ([]byte, error)
SignSkill produces a detached signature for skill content.
func VerifyChecksum ¶
VerifyChecksum checks whether content matches the expected checksum string.
Types ¶
type IntegrityViolation ¶
type IntegrityViolation struct {
SkillName string `json:"skill_name"`
Expected string `json:"expected"`
Actual string `json:"actual"`
Reason string `json:"reason"` // "mismatch", "missing_in_manifest", "missing_in_registry"
}
IntegrityViolation describes a checksum mismatch or missing entry.
func VerifyManifest ¶
func VerifyManifest(registry contract.SkillRegistry, manifest *Manifest) []IntegrityViolation
VerifyManifest checks all skills in the registry against the manifest. It returns a list of violations (empty if everything matches).
type Keyring ¶
type Keyring struct {
// contains filtered or unexported fields
}
Keyring manages a set of trusted Ed25519 public keys.
func DefaultKeyring ¶
func DefaultKeyring() *Keyring
DefaultKeyring loads trusted keys from ~/.forge/trusted-keys/.
func (*Keyring) LoadFromDir ¶
LoadFromDir reads all *.pub files from a directory and adds them to the keyring. Each file should contain a base64-encoded Ed25519 public key. The key ID is derived from the filename (without .pub extension).
type Manifest ¶
type Manifest struct {
Version string `json:"version"`
Checksums map[string]string `json:"checksums"` // skill name -> "sha256:<hex>"
}
Manifest stores checksums for all skills in a registry.
func GenerateManifest ¶
func GenerateManifest(registry contract.SkillRegistry) (*Manifest, error)
GenerateManifest creates a Manifest from all skills in the registry.
func UnmarshalManifest ¶
UnmarshalManifest deserializes a manifest from JSON.
type TrustPolicy ¶
type TrustPolicy struct {
MinTrustLevel contract.TrustLevel `yaml:"min_trust_level" json:"min_trust_level"`
RequireChecksum bool `yaml:"require_checksum" json:"require_checksum"`
RequireSignature bool `yaml:"require_signature" json:"require_signature"`
}
TrustPolicy defines minimum trust requirements for skill loading.
func DefaultTrustPolicy ¶
func DefaultTrustPolicy() TrustPolicy
DefaultTrustPolicy returns a policy that accepts local skills without signatures.
func (TrustPolicy) Accepts ¶
func (p TrustPolicy) Accepts(level contract.TrustLevel) bool
Accepts reports whether the given trust level satisfies the policy.