Skip to content

Commit

Permalink
Merge pull request #1664 from scrtlabs/dcap-12
Browse files Browse the repository at this point in the history
Dcap 12
  • Loading branch information
valdok authored Jun 17, 2024
2 parents ba3fc98 + d48834b commit bfaf7cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
14 changes: 7 additions & 7 deletions cmd/secretd/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand All @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions x/registration/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion x/registration/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ const (
SeedConfigVersion = 2
)

const AttestationCertPath = "attestation_cert.der"
const (
AttestationCertPath = "attestation_cert.der"
AttestationCombinedPath = "attestation_combined.bin"
)

type NodeID []byte

Expand Down

0 comments on commit bfaf7cf

Please sign in to comment.