From 48920b1b05e8527025c9ac52c37e065c369c3ccc Mon Sep 17 00:00:00 2001 From: valdok Date: Mon, 17 Jun 2024 09:22:20 +0000 Subject: [PATCH 1/2] Fixed auto-register --- cmd/secretd/attestation.go | 14 +++++++------- x/registration/alias.go | 1 + x/registration/internal/types/types.go | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cmd/secretd/attestation.go b/cmd/secretd/attestation.go index 3be37cba1..7c6d582aa 100644 --- a/cmd/secretd/attestation.go +++ b/cmd/secretd/attestation.go @@ -41,7 +41,7 @@ const ( const ( mainnetRegistrationService = "https://mainnet-register.scrtlabs.com/api/registernode" - pulsarRegistrationService = "https://testnet-register.scrtlabs.com/api/registernode" + pulsarRegistrationService = "https://registration-service-testnet.azurewebsites.net/api/registernode" ) func InitAttestation() *cobra.Command { @@ -452,7 +452,7 @@ Please report any issues with this command } sgxEnclaveKeyPath := filepath.Join(sgxSecretsFolder, reg.EnclaveRegistrationKey) - sgxAttestationCert := filepath.Join(sgxSecretsFolder, reg.AttestationCertPath) + sgxAttestationCombined := filepath.Join(sgxSecretsFolder, reg.AttestationCombinedPath) resetFlag, err := cmd.Flags().GetBool(flagReset) if err != nil { @@ -472,7 +472,7 @@ Please report any issues with this command } } else { fmt.Println("Reset enclave flag set, generating new enclave registration key. You must now re-register the node") - _ = os.Remove(sgxAttestationCert) + _ = os.Remove(sgxAttestationCombined) _, err := api.KeyGen() if err != nil { return fmt.Errorf("failed to initialize enclave: %w", err) @@ -493,14 +493,14 @@ Please report any issues with this command } // read the attestation certificate that we just created - cert, err := os.ReadFile(sgxAttestationCert) + certCombined, err := os.ReadFile(sgxAttestationCombined) if err != nil { - _ = os.Remove(sgxAttestationCert) + _ = os.Remove(sgxAttestationCombined) return err } // verify certificate - _, err = ra.UNSAFE_VerifyRaCert(cert) + _, err = ra.VerifyCombinedCert(certCombined) if err != nil { return err } @@ -531,7 +531,7 @@ Please report any issues with this command // call registration service to register us data := []byte(fmt.Sprintf(`{ "certificate": "%s" - }`, base64.StdEncoding.EncodeToString(cert))) + }`, base64.StdEncoding.EncodeToString(certCombined))) resp, err := http.Post(regUrl, "application/json", bytes.NewBuffer(data)) if err != nil { diff --git a/x/registration/alias.go b/x/registration/alias.go index 2c4b2f95e..4a11008bd 100644 --- a/x/registration/alias.go +++ b/x/registration/alias.go @@ -25,6 +25,7 @@ const ( EncryptedKeyLength = types.EncryptedKeyLength LegacyEncryptedKeyLength = types.LegacyEncryptedKeyLength AttestationCertPath = types.AttestationCertPath + AttestationCombinedPath = types.AttestationCombinedPath IoExchMasterKeyPath = types.IoExchMasterKeyPath LegacyIoMasterCertificate = types.LegacyIoMasterCertificate NodeExchMasterKeyPath = types.NodeExchMasterKeyPath diff --git a/x/registration/internal/types/types.go b/x/registration/internal/types/types.go index fdb2dd6d4..d601be3cf 100644 --- a/x/registration/internal/types/types.go +++ b/x/registration/internal/types/types.go @@ -26,6 +26,7 @@ const ( ) const AttestationCertPath = "attestation_cert.der" +const AttestationCombinedPath = "attestation_combined.bin" type NodeID []byte From d48834b68e596d493ffc09686c58c524f82dbdd4 Mon Sep 17 00:00:00 2001 From: valdok Date: Mon, 17 Jun 2024 09:40:42 +0000 Subject: [PATCH 2/2] gofumpt changes --- x/registration/internal/types/types.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x/registration/internal/types/types.go b/x/registration/internal/types/types.go index d601be3cf..3b1ff1a78 100644 --- a/x/registration/internal/types/types.go +++ b/x/registration/internal/types/types.go @@ -25,8 +25,10 @@ const ( SeedConfigVersion = 2 ) -const AttestationCertPath = "attestation_cert.der" -const AttestationCombinedPath = "attestation_combined.bin" +const ( + AttestationCertPath = "attestation_cert.der" + AttestationCombinedPath = "attestation_combined.bin" +) type NodeID []byte