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
- Variables
- func DecodeKey(b64 string) ([32]byte, error)
- func GenerateRuntimeKeypair() (publicKeyB64, privateKeyB64 string, err error)
- func OpenSeal(cipherB64 string, publicKey, privateKey [32]byte) ([]byte, error)
- func SealForRuntime(plaintext []byte, runnerPublicKeyB64 string) (string, error)
Constants ¶
const ( PublicKeySize = 32 PrivateKeySize = 32 )
PublicKeySize / PrivateKeySize match nacl/box (32 bytes Curve25519).
Variables ¶
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.
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 ¶
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 ¶
GenerateRuntimeKeypair returns a fresh (publicKey, privateKey) pair as base64. Caller MUST persist the private key with mode 0600 and never log it.
func OpenSeal ¶
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 ¶
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.