Skip to content

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

Draft
pavel-raykov wants to merge 7 commits into
developfrom
test-ocr3
Draft

[CRE-4317] Implement EVM ocr3types.OnchainKeyring2#469
pavel-raykov wants to merge 7 commits into
developfrom
test-ocr3

Conversation

@pavel-raykov
Copy link
Copy Markdown
Contributor

No description provided.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

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

✅ Compatible Changes (2)

pkg/keys/v2 (2)
  • CreateOCR3OnchainKeyring — ➕ 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
@pavel-raykov pavel-raykov requested a review from kaleofduty May 13, 2026 17:19
// CreateOCR3OnchainKeyring creates a new OCR3 onchain keyring.
// Note that key names are prefixed with PrefixEVM and PrefixOCR2Onchain (to preserve compatibility with OCR2)
// For example, a key named "test-key" will be stored at the path "evm/ocr2_onchain/test-key".
func CreateOCR3OnchainKeyring[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.

I am wondering whether we should (a) specialize this to RI being struct{} to make it more misuse resistant or (b) document the following caveat:
Products may embed safety-critical information affecting signature computation into RI. (E.g. marking reports as "specimen" that must not to be accepted onchain.) If we allow any RI, one could mistakenly use this keyring, but the safety-critical information would be silently discarded.

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.

Currently, for any types A and B we can create OnchainKeyring2[A] with CreateOCR3OnchainKeyring[A], and then read it as OnchainKeyring2[B] with ListOCR3OnchainKeyrings[B]. Do we want to do something to prevent that? If not, I would rather restrict these methods to struct{}.

Comment thread pkg/keys/v2/ocr3_onchain_keyring.go Outdated
Comment on lines +157 to +158
// hashReport performs OCR3 report hashing. The main difference from OCR2 hashing (https://github.com/smartcontractkit/chainlink-evm/blob/b4068bf735e6e1af28602eece9e29a0bd31eed37/pkg/keys/v2/ocr2_onchain_keyring.go#L98)
// is that we hash the sequence number `seqNr` instead of epoch||round (while also changing the hashing order).
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.

Suggested change
// hashReport performs OCR3 report hashing. The main difference from OCR2 hashing (https://github.com/smartcontractkit/chainlink-evm/blob/b4068bf735e6e1af28602eece9e29a0bd31eed37/pkg/keys/v2/ocr2_onchain_keyring.go#L98)
// is that we hash the sequence number `seqNr` instead of epoch||round (while also changing the hashing order).
// hashReport computes an EVM-friendly cryptographic hash function over configDigest, seqNr, and reportWithInfo.Report.
// The main difference from OCR2 hashing (https://github.com/smartcontractkit/chainlink-evm/blob/b4068bf735e6e1af28602eece9e29a0bd31eed37/pkg/keys/v2/ocr2_onchain_keyring.go#L98)
// is that we hash the sequence number `seqNr` instead of `epoch||round||extraHash`.
// Domain separation is guaranteed because the result of this function is a Keccak hash computed over 96 bytes
// while the aforementioned OCR2 function is a Keccak hash computed over 128 bytes.

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.

Done.

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.

2 participants