@@ -17,6 +17,7 @@ import (
1717 "github.com/ethereum/go-ethereum/accounts/abi"
1818 ethCommon "github.com/ethereum/go-ethereum/common"
1919 "github.com/oasisprotocol/oasis-core/go/common/cbor"
20+ "github.com/oasisprotocol/oasis-core/go/common/crypto/signature"
2021 "github.com/oasisprotocol/oasis-core/go/common/quantity"
2122 sdkConfig "github.com/oasisprotocol/oasis-sdk/client-sdk/go/config"
2223 "github.com/oasisprotocol/oasis-sdk/client-sdk/go/modules/accounts"
@@ -35,6 +36,7 @@ import (
3536 "github.com/oasisprotocol/nexus/analyzer/util/eth"
3637 apiTypes "github.com/oasisprotocol/nexus/api/v1/types"
3738 "github.com/oasisprotocol/nexus/common"
39+ "github.com/oasisprotocol/nexus/coreapi/v24.0/common/node"
3840 "github.com/oasisprotocol/nexus/log"
3941 "github.com/oasisprotocol/nexus/storage"
4042 "github.com/oasisprotocol/nexus/storage/oasis/nodeapi"
@@ -534,7 +536,42 @@ func ExtractRound(blockHeader nodeapi.RuntimeBlockHeader, txrs []nodeapi.Runtime
534536 return nil
535537 },
536538 RoflRegister : func (body * rofl.Register ) error {
537- blockTransactionData .Body = body
539+ // Serialize the transaction body with enhanced attestation parsing for SGX hardware.
540+ // If the CapabilityTEE's hardware type is SGX, attempts to parse the attestation field,
541+ // replacing it with a structured SGXAttestation. If parsing fails or the hardware type
542+ // is not SGX, the original transaction body is returned unchanged.
543+ customSerialize := func (body * rofl.Register ) interface {} {
544+ // If not SGX attestation, return original body.
545+ if uint8 (body .EndorsedCapability .CapabilityTEE .Hardware ) != uint8 (node .TEEHardwareIntelSGX ) {
546+ return body
547+ }
548+
549+ // Try parsing the SGX Attestation.
550+ var sa node.SGXAttestation
551+ if err := cbor .Unmarshal (body .EndorsedCapability .CapabilityTEE .Attestation , & sa ); err != nil {
552+ logger .Error ("error unmarshalling SGX attestation" , "err" , err )
553+ return body
554+ }
555+
556+ wrapper := struct {
557+ rofl.Register
558+ // Override Attestation field.
559+ EndorsedCapability struct {
560+ CapabilityTEE struct {
561+ node.CapabilityTEE
562+ Attestation node.SGXAttestation `json:"attestation"`
563+ } `json:"capability_tee"`
564+ NodeEndorsement signature.Signature `json:"node_endorsement"`
565+ } `json:"ect"`
566+ }{
567+ Register : * body ,
568+ }
569+ wrapper .EndorsedCapability .CapabilityTEE .Attestation = sa
570+
571+ return wrapper
572+ }
573+
574+ blockTransactionData .Body = customSerialize (body )
538575 return nil
539576 },
540577 UnknownMethod : func (methodName string ) error {
0 commit comments