[CRE-4317] Implement EVM ocr3types.OnchainKeyring2#469
Conversation
✅ API Diff Results -
|
| // 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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{}.
| // 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). |
There was a problem hiding this comment.
| // 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. |
No description provided.