Skip to content

SGXVerifier

SGXVerifieris a smart contract that implements SGX (Software Guard Extensions) signature proof verification on-chain. It ensures the integrity and security of rollup state transitions by validating SGX-generated signatures. The contract also manages SGX instance registration, tracking, and lifecycle operations.

SGX instances are uniquely identified by Ethereum addresses, derived from an ECDSA public-private key pair generated within the SGX enclave. The SGXVerifier contract ensures only authorized instances participate in rollup verification.


Features

  • Instance Registry: Tracks valid SGX instances and enforces expiration policies.
  • Instance Lifecycle Management: Registers new intsances, rotates old instances, and removes compromised or outdated instances.
  • SGX Proof Verification: Validates block state transitions using SGX-generated signatures and supports batch proof verification for efficiency.

Contract Methods

addInstances

Registers new SGX instances.

Input ParameterTypeDescription
_instancesaddress[]List of SGX instance Ethereum addresses to register.

Access Control: Only callable by the contract owner.


deleteInstances

Removes registered SGX instances.

Input ParameterTypeDescription
_idsuint256[]Array of instance IDs to be removed.

Access Control: Restricted to the owner or SGX_WATCHDOG role.


registerInstance

Registers an SGX instance after verifying its attestation off-chain.

Input ParameterTypeDescription
_attestationbytesAttestation quote containing SGX enclave report details.

Returns: The assigned instance ID.

Access Control: Open to external calls.


verifyProof

Verifies an SGX proof for a single block state transition.

Input ParameterTypeDescription
_ctxbytes32Context of the proof.
_tranbytes32Block transition data.
_proofbytesSGX signature proof.

Mechanism:

  • Validates the instance ID and signature.
  • Ensures the SGX instance is not expired.
  • Replaces the SGX instance if invalid.

verifyBatchProof

Verifies multiple SGX proofs for batch block state transitions.

Input ParameterTypeDescription
_ctxsbytes32[]Array of proof contexts.
_proofbytesSGX batch signature proof.

Mechanism:

  • Verifies the signature against public inputs for all blocks.
  • Automatically rotates instances if an invalid proof is detected.

Events

InstanceAdded

Triggered when a new SGX instance is added or replaced.

Event ParameterTypeDescription
iduint256ID of the SGX instance.
instanceaddressAddress of the added SGX instance.
replacedaddressAddress of the replaced instance (if any).
validSinceuint256Timestamp when the instance became valid.

InstanceDeleted

Triggered when an SGX instance is removed.

Event ParameterTypeDescription
iduint256ID of the removed SGX instance.
instanceaddressAddress of the removed instance.

Constants

Constant NameValueDescription
INSTANCE_EXPIRY365 daysDuration before an SGX instance expires.
INSTANCE_VALIDITY_DELAY1 hourDelay before a newly registered instance becomes valid.