From 4f247bafa37987ed9c85b32776b419d248bb1f13 Mon Sep 17 00:00:00 2001 From: Michael de Hoog Date: Wed, 11 Dec 2024 18:58:46 -1000 Subject: [PATCH] Add README for register-signer --- register-signer/README.md | 29 +++++++++++++++++++++++++++++ register-signer/main.go | 31 ++++++------------------------- 2 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 register-signer/README.md diff --git a/register-signer/README.md b/register-signer/README.md new file mode 100644 index 0000000..47eecdc --- /dev/null +++ b/register-signer/README.md @@ -0,0 +1,29 @@ +# Signer registration utility + +This utility can be used to register an op-enclave signer key with the +[SystemConfigGlobal](../contracts/src/SystemConfigGlobal.sol) contract. + +## Installation + +``` +go install github.com/base-org/op-enclave/register-signer +``` + +## Usage + +Query an AWS Nitro attestation from op-enclave server: +```bash +curl -d '{"id":0,"jsonrpc":"2.0","method":"enclave_signerAttestation"}' -H "Content-Type: application/json" http://op-enclave:7333 +``` + +``` +Usage of register-signer: + -attestation string + attestation hex + -deployment string + deployment file (default "deployments/84532-deploy.json") + -private-key string + private key + -rpc string + rpc url (default "https://sepolia.base.org") +``` diff --git a/register-signer/main.go b/register-signer/main.go index 12794a1..53c8f6c 100644 --- a/register-signer/main.go +++ b/register-signer/main.go @@ -1,9 +1,7 @@ package main import ( - "bytes" "context" - "encoding/json" "flag" "fmt" "os" @@ -20,22 +18,18 @@ import ( "github.com/hf/nitrite" ) -type deployment struct { - SystemConfigGlobalProxy common.Address `json:"SystemConfigGlobalProxy"` -} - func main() { var attestationHex string var rpcUrl string var privateKeyHex string - var deploymentFile string + var configAddress string flag.StringVar(&attestationHex, "attestation", "", "attestation hex") flag.StringVar(&rpcUrl, "rpc", "https://sepolia.base.org", "rpc url") flag.StringVar(&privateKeyHex, "private-key", "", "private key") - flag.StringVar(&deploymentFile, "deployment", "deployments/84532-deploy.json", "deployment file") + flag.StringVar(&configAddress, "address", "", "address of the SystemConfigGlobal proxy contract") flag.Parse() - if attestationHex == "" || privateKeyHex == "" { + if attestationHex == "" || privateKeyHex == "" || configAddress == "" { flag.Usage() os.Exit(1) } @@ -60,20 +54,6 @@ func main() { panic(err) } - deploy, err := os.ReadFile(deploymentFile) - if err != nil { - panic(err) - } - var d deployment - err = json.Unmarshal(deploy, &d) - if err != nil { - panic(err) - } - - if bytes.Equal(common.Address{}.Bytes(), d.SystemConfigGlobalProxy.Bytes()) { - panic("SystemConfigGlobalProxy address not found in deployment file") - } - key, err := crypto.ToECDSA(privateKey) if err != nil { panic(err) @@ -91,7 +71,7 @@ func main() { }, } - systemConfigGlobal, err := bindings.NewSystemConfigGlobal(d.SystemConfigGlobalProxy, client) + systemConfigGlobal, err := bindings.NewSystemConfigGlobal(common.HexToAddress(configAddress), client) if err != nil { panic(err) } @@ -106,10 +86,11 @@ func main() { panic(err) } fmt.Printf("Public key: %s\n", hexutil.Encode(res.Document.PublicKey)) - fmt.Printf("Signer: %s\n", signerAddr.String()) if validSigner { fmt.Printf("Signer already registered: %s\n", signerAddr.String()) return + } else { + fmt.Printf("Registering signer: %s\n", signerAddr.String()) } certManagerAddr, err := systemConfigGlobal.CertManager(&bind.CallOpts{})