runtimecrypto

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package runtimecrypto implements envelope-encryption for shipping sensitive payloads (model API keys, per-run secrets) from the OpenAgentCore server to a paired Agent Daemon without putting plaintext on the wire.

Algorithm: NaCl sealed box (X25519 + XSalsa20-Poly1305) via box.SealAnonymous. Nonce = BLAKE2b-24(ephPub || recipientPub). Wire format: base64(stdEncoding) so it travels safely inside JSON. The committed static fixture (testdata/wire_v1.json) keeps the wire format locked across refactors.

Threat model:

  • Server logs / debug dumps / DB middlewares see ciphertext only.
  • Daemon-machine compromise is OUT of scope (private key lives there and the host is trusted by definition).
  • Server compromise is OUT of scope (a malicious server could skip encryption entirely).

Index

Constants

View Source
const (
	PublicKeySize  = 32
	PrivateKeySize = 32
)

PublicKeySize / PrivateKeySize match nacl/box (32 bytes Curve25519).

Variables

View Source
var ErrDecryptFailed = errors.New("runtime crypto: decrypt failed")

ErrDecryptFailed is returned when ciphertext fails authentication (tampered, wrong recipient key, malformed envelope). Generic by design — exposing the specific reason helps attackers.

View Source
var ErrInvalidPublicKey = errors.New("runtime crypto: invalid public key")

ErrInvalidPublicKey wraps any reason the recipient public key is unusable (wrong length, bad base64). API layer returns 400.

Functions

func DecodeKey

func DecodeKey(b64 string) ([32]byte, error)

DecodeKey turns a base64-encoded 32-byte key into a [32]byte so daemon code and the API layer share one parser instead of inlining base64 + length checks at every caller.

func GenerateRuntimeKeypair

func GenerateRuntimeKeypair() (publicKeyB64, privateKeyB64 string, err error)

GenerateRuntimeKeypair returns a fresh (publicKey, privateKey) pair as base64. Caller MUST persist the private key with mode 0600 and never log it.

func OpenSeal

func OpenSeal(cipherB64 string, publicKey, privateKey [32]byte) ([]byte, error)

OpenSeal decrypts a SealForRuntime output using the recipient's keypair. Kept here for round-trip tests and to lock the wire format down in one place.

func SealForRuntime

func SealForRuntime(plaintext []byte, runnerPublicKeyB64 string) (string, error)

SealForRuntime encrypts plaintext for the runtime identified by its base64-encoded X25519 public key (as stored in runtimes.config.runner_public_key).

Output is base64(stdEncoding) of an anonymous sealed box: each call generates a fresh ephemeral keypair and embeds the public half in the envelope. Receiver derives the shared key from that and its own private key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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