Skip to content

[CRE-4317] Implement EVM ocr3types.OnchainKeyring2 - #469

Merged
pavel-raykov merged 16 commits into
developfrom
test-ocr3
Jun 24, 2026
Merged

[CRE-4317] Implement EVM ocr3types.OnchainKeyring2#469
pavel-raykov merged 16 commits into
developfrom
test-ocr3

Conversation

@pavel-raykov

@pavel-raykov pavel-raykov commented May 13, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

✅ API Diff Results - github.com/smartcontractkit/chainlink-evm

✅ Compatible Changes (2)

pkg/keys/v2 (2)
  • CreateOCR3OnchainKeyringIgnoringRI — ➕ Added

  • ListOCR3OnchainKeyrings — ➕ Added


📄 View full apidiff report

Comment thread pkg/keys/v2/ocr3_onchain_keyring_test.go
Comment thread pkg/keys/v2/ocr3_onchain_keyring.go Outdated
Comment thread pkg/keys/v2/ocr3_onchain_keyring.go Outdated
@pavel-raykov
pavel-raykov requested a review from kaleofduty May 13, 2026 17:19
Comment thread pkg/keys/v2/ocr3_onchain_keyring.go Outdated
Comment thread pkg/keys/v2/ocr3_onchain_keyring.go Outdated
@pavel-raykov
pavel-raykov marked this pull request as ready for review June 23, 2026 11:27
@pavel-raykov
pavel-raykov requested review from a team as code owners June 23, 2026 11:27
Copilot AI review requested due to automatic review settings June 23, 2026 11:27
@pavel-raykov
pavel-raykov requested a review from a team as a code owner June 23, 2026 11:27
george-dorin
george-dorin previously approved these changes Jun 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an EVM implementation of ocr3types.OnchainKeyring2 backed by chainlink-common/keystore, including signature compression compatible with the OCR3 ECDSA attestation verifier, plus test vectors and dependency bumps required for the new interfaces.

Changes:

  • Implement CreateOCR3OnchainKeyring / ListOCR3OnchainKeyrings and an EVM-backed OnchainKeyring2 implementation.
  • Add OCR3 onchain signing/verification test vectors to validate hashing + signature compression behavior.
  • Bump chainlink-common/keystore, libocr, and other indirect deps in go.mod/go.sum.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 6 comments.

File Description
pkg/keys/v2/ocr3_onchain_keyring.go New OCR3 onchain keyring implementation (hashing + signature compression).
pkg/keys/v2/ocr3_onchain_keyring_test.go New test-vector based coverage for OCR3 onchain signing/verification.
go.mod Dependency updates to pull in required OCR3/keystore interfaces.
go.sum Checksums updated for bumped dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/keys/v2/ocr3_onchain_keyring.go
Comment thread pkg/keys/v2/ocr3_onchain_keyring.go
Comment thread pkg/keys/v2/ocr3_onchain_keyring.go
Comment thread pkg/keys/v2/ocr3_onchain_keyring.go
Comment thread pkg/keys/v2/ocr3_onchain_keyring_test.go
Comment thread pkg/keys/v2/ocr3_onchain_keyring_test.go
Comment thread pkg/keys/v2/ocr3_onchain_keyring.go Outdated
// The generic RI parameter is not used anywhere in the implementation. It acts as a defensive interface boundary to
// avoid signing a wrong type of reports. Note that it is not 100% bulletproof since one can also create a key with
// CreateOCR3OnchainKeyring[A] and then read it with ListOCR3OnchainKeyrings[B].
func CreateOCR3OnchainKeyring[RI any](ctx context.Context, ks keystore.Keystore, keyringName string) (ocr3types.OnchainKeyring2[RI], error) {

@kaleofduty kaleofduty Jun 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pavel-raykov , do we still want RI here? My understanding of our previous discussion was that we wanted consumers of the library to follow this pattern:

keyring := keys.CreateOCR3OnchainKeyring(ctx, ks, "test-key")
ocr3keyring := ocr3util.AsOCR3OnchainKeyring2IgnoringRI[whatver](keyring)
// pass ocr3keyring to libocr via OCR3OracleArgs2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, RI is a part of the interface coming from OCR library, so the clients should have a convenient function to instantiate it (by itself RI-less interface should be useless to them)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the function name with IgnoringRI suffix and updated the comment

Comment on lines +25 to +27
// Be careful! The generic RI parameter is not used anywhere in the implementation. It acts as a defensive interface boundary to avoid signing a wrong type of reports.
// If you have security-critical information in RI, you should make your own ocr3types.OnchainKeyring2 that does use the information in RI for signing.
func CreateOCR3OnchainKeyringIgnoringRI[RI any](ctx context.Context, ks keystore.Keystore, keyringName string) (ocr3types.OnchainKeyring2[RI], error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💙

Comment thread pkg/keys/v2/ocr3_onchain_keyring.go

@PhilippSchindler PhilippSchindler left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed the cryptographic part of the implementation.

Overall verdict: Looks good — the implementation is correct and closely matches what we previously implemented in offchain-reporting (PR #528). The (r, s) v-stripping scheme, the s to n-s normalization for v=0, the report hashing (incl. comment regarding domain separation), and Verify all check out.

One minor suggestion I had to remove a latent footgun (uncompressSignature) was already addressed.

LGTM, great. 👍

@pavel-raykov
pavel-raykov merged commit 10f5d8a into develop Jun 24, 2026
33 checks passed
@pavel-raykov
pavel-raykov deleted the test-ocr3 branch June 24, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants