Repository navigation
Add an OCR keystore service to libs/capability - #913
Merged
Merged
Conversation
product-security-plaid-production
Bot
requested review from
Krish-vemula and
silaslenihan
November 16, 2026 15:50
Contributor
|
👋 cedric-cordenier, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
nolag
reviewed
Nov 16, 2026
1 task
Adds libs/capability/keystore, which lets a capability process use the node's OCR2 key bundles without the private keys leaving the node. - OCRKeystore gRPC service: list and get bundles, then sign onchain, verify onchain, sign offchain and compute the config Diffie-Hellman by bundle ID. - Server side: OCRKeyBundle/OCRKeystore interfaces for the node to implement, and Keystores/RegisterServers so further keystores can be added as sibling services. - Client side: each bundle as an ocrtypes.OnchainKeyring and OffchainKeyring, plus a local client for embedded runs and tests. - Run dependency under the keystore namespace (CL_KEYSTORE_URL). Exports capability.Dial and provides loop.GRPCOpts to the injector so the dependency can dial the node. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Autofix: true
- keystore/ocr: the Keystore and KeyBundle interfaces the node implements, the Client and KeyBundleClient a process uses, and the local client. - keystore/ocr/remote: the gRPC server and client, with the proto in keystore/ocr/remote/pb. - keystore/ocr/ocrtest: an in-memory Keystore for tests. - keystore keeps what every keystore shares: Keystores, RegisterServers and the CL_KEYSTORE_URL run dependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ocr.NewLocalClient had no caller. It goes back in with the embed support that will use it. - The OCR keystore server never logged, so RegisterServer and RegisterServers no longer take a logger. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each instance of an embedded run gets an ocr.Client holding a key bundle derived from its index, so instances can compute each other's public keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Autofix: true
NewSeededKeyBundle derives ed25519 signing keys and an X25519 config key from a seed. The embedded keystore and ocrtest both build on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StaticKeystore replaces ocrtest.Keystore, and NewLocalClient turns any Keystore into a Client, so the embedded client no longer repeats the list and get logic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests build bundles with ocr.NewSeededKeyBundle and serve them from an ocr.StaticKeystore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cedric-cordenier
force-pushed
the
ocr-keystore
branch
from
November 17, 2026 17:17
bb52dfc to
5a6cd36
Compare
nolag
approved these changes
Nov 23, 2026
nolag
enabled auto-merge
November 23, 2026 14:40
Krish-vemula
approved these changes
Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
libs/capability/keystore, which lets a capability process use the node's OCR2 key bundles without the private keys leaving the node. The process fetches the bundles it needs by ID, gets back libocr keyrings, and passes them tolibocr.NewOracle.This is the first of three PRs. smartcontractkit/chainlink#24212 serves the API from standard capabilities v2; after that,
libs/ocrand consensus switch over to it.Layout
keystoreKeystoresandRegisterServers, so future keystores (P2P and so on) can be added as sibling services on one server, and the run dependency under thekeystorenamespace (CL_KEYSTORE_URL)keystore/ocrKeystoreandKeyBundlefor the node to implement;ClientandKeyBundleClientfor the process;StaticKeystore,NewLocalClientandNewSeededKeyBundlefor keys in the process itselfkeystore/ocr/remoteRegisterServerandNewClientkeystore/ocr/remote/pbOCRKeystoregRPC serviceThe OCRKeystore service
ListKeyBundlesandGetKeyBundlereturn each bundle's ID, chain type and public keys. The client reads them once.SignOnchain,VerifyOnchain,SignOffchainandConfigDiffieHellmantake a bundle ID and call that bundle on the node. Verification runs on the node too, so the client has no per-chain verification code.ocrtypes.OnchainKeyringand anocrtypes.OffchainKeyring. libocr's keyrings take no context, so each call to the node gets a 10s timeout.NotFoundfor an unknown bundle,InvalidArgumentfor malformed input,Internalfor keystore failures.Embedded runs
Each instance of an embedded run gets an
ocr.ClientfromEmbedInjectorholding one bundle,EmbeddedKeyBundle(instance). Its ed25519 and X25519 keys are derived from the instance index, so every instance can compute every other's public keys. Anyone can derive them, so this is for local runs and tests only.libs/capabilityalso exportsDialand providesloop.GRPCOptsto the injector, matching what the OCR consensus branch needs.Not included: the multichain onchain keyring builder. It needs ocr2key helpers that aren't released in chainlink-common yet.
Testing
go test -race ./capability/keystore/...serves aStaticKeystoreof seeded bundles over an in-memory gRPC connection. It checks listing, filtering by chain type, getting by ID, and that signing, verifying and Diffie-Hellman give the same results as calling the bundle directly. It also checks every gRPC error code, that a failed verify call returns false,RegisterServersskipping nil keystores, the dependency with and without a URL, and that embedded instances get distinct, deterministic keys that verify each other's signatures.go test ./capability/passes.🤖 Generated with Claude Code