identity

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package identity manages the endpoint signing identity and signed envelopes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Verify

func Verify(publicKeyText string, value any, signatureText string) error

Verify verifies raw-base64 Ed25519 bytes over canonical JSON.

func VerifyCheckpoint

func VerifyCheckpoint(checkpoint Checkpoint) error

VerifyCheckpoint verifies the self-contained signature. Trust in PublicKey still requires an independently pinned key or earlier trusted checkpoint.

func VerifyRotation

func VerifyRotation(rotation Rotation, identityName, pinnedPublicKey string) error

VerifyRotation verifies both signatures and the expected currently pinned identity. A transition for any other key or peer fails closed.

Types

type Checkpoint

type Checkpoint struct {
	Version          int    `json:"version"`
	Identity         string `json:"identity"`
	PublicKey        string `json:"public_key"`
	Sequence         uint64 `json:"sequence"`
	AuditHead        string `json:"audit_head"`
	DeploymentSHA256 string `json:"deployment_sha256"`
	CreatedAt        string `json:"created_at"`
	Signature        string `json:"signature"`
}

Checkpoint is an independently storable signed audit head.

type Revocation

type Revocation struct {
	Identity  string `json:"identity"`
	PublicKey string `json:"public_key"`
	CreatedAt string `json:"created_at"`
	Signature string `json:"signature"`
}

Revocation proves that the local identity intentionally destroyed its private key. Peers must remove the pinned key separately.

type RevocationPlan

type RevocationPlan struct {
	// contains filtered or unexported fields
}

RevocationPlan holds a signed final certificate until the caller has durably recorded it.

func PrepareRevocation

func PrepareRevocation(auditDir, name string, now time.Time) (*RevocationPlan, error)

PrepareRevocation signs a certificate without deleting the private key.

func (*RevocationPlan) Certificate

func (p *RevocationPlan) Certificate() Revocation

Certificate returns the signed public revocation evidence.

func (*RevocationPlan) Commit

func (p *RevocationPlan) Commit() error

Commit deletes the key only if it still matches the prepared certificate.

type Rotation

type Rotation struct {
	Identity          string `json:"identity"`
	PreviousPublicKey string `json:"previous_public_key"`
	NewPublicKey      string `json:"new_public_key"`
	CreatedAt         string `json:"created_at"`
	PreviousSignature string `json:"previous_signature"`
	NewSignature      string `json:"new_signature"`
}

Rotation proves continuity from the currently pinned key to a new key. Both keys sign the transition before the old private key is atomically replaced.

type RotationPlan

type RotationPlan struct {
	// contains filtered or unexported fields
}

RotationPlan holds a signed transition until its caller has durably recorded the certificate. Commit then atomically replaces the old private key.

func PrepareRotation

func PrepareRotation(auditDir, name string, now time.Time) (*RotationPlan, error)

PrepareRotation creates a transition without mutating the current identity.

func (*RotationPlan) Certificate

func (p *RotationPlan) Certificate() Rotation

Certificate returns the dual-signed public transition.

func (*RotationPlan) Commit

func (p *RotationPlan) Commit() error

Commit replaces the key only if the current identity still matches the certificate's previous key.

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

Signer owns one endpoint's private signing key.

func LoadOrCreate

func LoadOrCreate(auditDir, name string, create bool) (*Signer, error)

LoadOrCreate loads the identity key in auditDir, creating it when requested.

func (*Signer) Checkpoint

func (s *Signer) Checkpoint(sequence uint64, head, deploymentSHA256 string, now time.Time) (Checkpoint, error)

Checkpoint signs a current audit head for independent anchoring.

func (*Signer) Name

func (s *Signer) Name() string

Name returns the configured endpoint name.

func (*Signer) PublicKey

func (s *Signer) PublicKey() string

PublicKey returns the raw-base64 public identity key.

func (*Signer) Sign

func (s *Signer) Sign(value any) (string, error)

Sign signs canonical JSON and returns raw-base64 Ed25519 bytes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL