{"modulePath":"github.com/MiniMax-AI/OpenAgentCore","version":"v0.0.9","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package runtimecrypto\n\nPackage 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.\n\nAlgorithm: 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.\n\nThreat model:\n\n  - Server logs / debug dumps / DB middlewares see ciphertext only.\n  - Daemon-machine compromise is OUT of scope (private key lives there and the host is trusted by definition).\n  - Server compromise is OUT of scope (a malicious server could skip encryption entirely).\n\n## Constants\n\n```go\nconst (\n\tPublicKeySize  = 32\n\tPrivateKeySize = 32\n)\n```\nPublicKeySize / PrivateKeySize match nacl/box (32 bytes Curve25519).\n\n## Variables\n\n```go\nvar ErrDecryptFailed = errors.New(\"runtime crypto: decrypt failed\")\n```\nErrDecryptFailed is returned when ciphertext fails authentication (tampered, wrong recipient key, malformed envelope). Generic by design — exposing the specific reason helps attackers.\n\n```go\nvar ErrInvalidPublicKey = errors.New(\"runtime crypto: invalid public key\")\n```\nErrInvalidPublicKey wraps any reason the recipient public key is unusable (wrong length, bad base64). API layer returns 400.\n\n## Functions\n\n```go\nfunc DecodeKey(b64 string) ([32]byte, error)\n```\nDecodeKey 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.\n\n```go\nfunc GenerateRuntimeKeypair() (publicKeyB64, privateKeyB64 string, err error)\n```\nGenerateRuntimeKeypair returns a fresh (publicKey, privateKey) pair as base64. Caller MUST persist the private key with mode 0600 and never log it.\n\n```go\nfunc OpenSeal(cipherB64 string, publicKey, privateKey [32]byte) ([]byte, error)\n```\nOpenSeal 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.\n\n```go\nfunc SealForRuntime(plaintext []byte, runnerPublicKeyB64 string) (string, error)\n```\nSealForRuntime encrypts plaintext for the runtime identified by its base64-encoded X25519 public key (as stored in runtimes.config.runner\\_public\\_key).\n\nOutput 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.\n\n","path":"github.com/MiniMax-AI/OpenAgentCore/internal/runtimecrypto","name":"runtimecrypto","synopsis":"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.","isRedistributable":true}
