Allow capability DONs to include OCR attestation of the responses#1907
Allow capability DONs to include OCR attestation of the responses#1907dhaidashenko wants to merge 1 commit intomainfrom
Conversation
|
✅ API Diff Results -
|
There was a problem hiding this comment.
Pull request overview
This PR extends the capabilities response metadata to optionally carry an OCR attestation (config digest, sequence number, and attributed signatures), enabling Capability DONs to include OCR-style attestations alongside responses.
Changes:
- Added
ocr_attestation(withResponseOCRAttestation+AttributedSignature) toResponseMetadatain the capabilities protobuf schema. - Updated Go capability types and pb helper conversions to serialize/deserialize OCR attestation data.
- Added test coverage for attestation round-tripping and invalid config digest length handling; refactored EVM keyring blob verification into a reusable function.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/capabilities/pb/capabilities_helpers_test.go | Adds subtests for invalid digest length and round-trip conversion including OCR attestation metadata. |
| pkg/capabilities/pb/capabilities_helpers.go | Adds OCR attestation marshaling/unmarshaling logic to capability response proto helpers. |
| pkg/capabilities/pb/capabilities.proto | Introduces ocr_attestation on ResponseMetadata and new messages for attestation + signatures. |
| pkg/capabilities/pb/capabilities.pb.go | Regenerated protobuf Go output for the updated schema. |
| pkg/capabilities/capabilities.go | Adds OCR attestation types to response metadata and introduces ResponseToReportData hashing helper. |
| keystore/corekeys/ocr2key/evm_keyring.go | Extracts EVM blob verification into EvmVerifyBlob and reuses it from the keyring method. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1de3504 to
82a189c
Compare
There was a problem hiding this comment.
Pull request overview
Adds OCR attestation metadata support to capability responses so Capability DONs can include verifiable OCR context (config digest, sequence number, signatures) alongside the response.
Changes:
- Extend
ResponseMetadataprotobuf schema with an optionalocr_attestationmessage (including attributed signatures). - Update Go conversion helpers to marshal/unmarshal OCR attestation between internal types and protobuf types, plus add round-trip/validation tests.
- Introduce response-to-report hashing helper and extract EVM blob verification into a reusable function.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/capabilities/pb/capabilities.proto | Adds ResponseOCRAttestation + AttributedSignature and wires it into ResponseMetadata. |
| pkg/capabilities/pb/capabilities.pb.go | Regenerated protobuf Go types to include the new messages/field. |
| pkg/capabilities/pb/capabilities_helpers.go | Adds proto ↔ internal mapping for OCR attestation on capability responses. |
| pkg/capabilities/pb/capabilities_helpers_test.go | Adds validation + round-trip coverage for response OCR attestation conversions. |
| pkg/capabilities/capabilities.go | Adds internal OCR attestation types and ResponseToReportData hashing helper. |
| keystore/corekeys/ocr2key/evm_keyring.go | Extracts EVM blob verification into EvmVerifyBlob and reuses it from the keyring method. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| attestation = &capabilities.ResponseOCRAttestation{ | ||
| ConfigDigest: [32]byte(pr.Metadata.OcrAttestation.ConfigDigest), | ||
| SequenceNumber: pr.Metadata.OcrAttestation.SequenceNumber, | ||
| Sigs: make([]capabilities.AttributedSignature, len(pr.Metadata.OcrAttestation.Signatures)), | ||
| } |
pkg/capabilities/capabilities.go
Outdated
| func ResponseToReportData(requestID string, responsePayload []byte, spendUnit, spendValue string) []byte { | ||
| hash := sha3.New256() | ||
| const domainSeparator = "CapabilityResponseReportData:v1" | ||
| hash.Write([]byte(domainSeparator)) | ||
| // Helper to write a length-prefixed byte slice. | ||
| writeField := func(b []byte) { | ||
| // Use a fixed-width length prefix to make encoding unambiguous. | ||
| _ = binary.Write(hash, binary.BigEndian, uint64(len(b))) | ||
| _, _ = hash.Write(b) | ||
| } | ||
| writeField([]byte(requestID)) | ||
| writeField(responsePayload) | ||
| writeField([]byte(spendUnit)) | ||
| writeField([]byte(spendValue)) | ||
|
|
||
| return hash.Sum(nil) |
| func EvmVerifyBlob(pubkey types.OnchainPublicKey, b, sig []byte) bool { | ||
| authorPubkey, err := crypto.SigToPub(b, sig) | ||
| if err != nil { | ||
| return false | ||
| } | ||
| authorAddress := crypto.PubkeyToAddress(*authorPubkey) | ||
| // no need for constant time compare since neither arg is sensitive | ||
| return bytes.Equal(pubkey[:], authorAddress[:]) | ||
| } |
82a189c to
76aac32
Compare
https://smartcontract-it.atlassian.net/browse/PLEX-2611
Supports: