-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add "attestation_server" feature * refactor: add go build tag for attestation server * feat: move attestation server to separate command * feat: add build_AS command * feat: add draft CLI commands * chore: add protobuf requests * refactor: update seal function * refactor: update `unseal` function * refactor: update `random` keymanager function * refactor: update encryption process * refactor: update keys derivation * fix: fix build issues * chore: clippy * feat: add support of legacy format * refactor: fix naming * refactor: update naming * refactor: correct naming * fix: fix issue with deserialization * refactor: correct naming * intermediate: fixing errors * fix: fix compilation issues * refactor: use block number to manage node pk * fix: restore tests * feat: implement commands for epochs management * chore: intermediate commit * fix: fix borrow checker issuer * chore: small improvements * refactor: return list of epoch numbers and starting blocks * test: add tests for keys management * test: add test for get node public key * test: add test draft for contract tx * test: use correct node public key * test: update tests * test: update encryption test * chore: add test part * test: restoring tests * test: update encryption test * test: update encryption test * fix: fix issue with broken decryption * chore: increase test balances * fix: fix typo * chore: disable debug * fix: fix getNodePublicKey request * refactor: remove unused code * feat: add list epochs command * feat: skip integration test
- Loading branch information
Showing
65 changed files
with
4,054 additions
and
1,079 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/SigmaGmbH/librustgo/internal/api" | ||
"github.com/spf13/cobra" | ||
"strconv" | ||
) | ||
|
||
func RootCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "attestation-server", | ||
Short: "Commands for interaction with Swisstronik Attestation Server", | ||
} | ||
|
||
cmd.AddCommand( | ||
StartAttestationServer(), | ||
AddNewEpoch(), | ||
ListEpochs(), | ||
RemoveLatestEpoch(), | ||
) | ||
|
||
return cmd | ||
} | ||
|
||
// StartAttestationServer returns start-attestation-server cobra Command. | ||
func StartAttestationServer() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "start-server [epid-address-with-port] [dcap-address-with-port]", | ||
Short: "Starts attestation server", | ||
Long: "Start server for Intel SGX Remote Attestation to share encryption keys with new nodes", | ||
Args: cobra.ExactArgs(2), | ||
RunE: func(_ *cobra.Command, args []string) error { | ||
if err := api.StartAttestationServer(args[0], args[1]); err != nil { | ||
return err | ||
} | ||
return WaitForQuitSignals() | ||
}, | ||
} | ||
|
||
return cmd | ||
} | ||
|
||
// AddNewEpoch returns create-epoch-key cobra Command. | ||
func AddNewEpoch() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "add-new-epoch [starting-block]", | ||
Short: "Creates new epoch", | ||
Long: "Creates new epoch inside Intel SGX Enclave", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(_ *cobra.Command, args []string) { | ||
startingBlock, err := strconv.ParseUint(args[0], 10, 64) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
if err := api.AddEpoch(startingBlock); err != nil { | ||
panic(err) | ||
} | ||
}, | ||
} | ||
|
||
return cmd | ||
} | ||
|
||
// ListEpochs returns list-epochs cobra Command. | ||
func ListEpochs() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "list-epochs", | ||
Short: "Lists all stored epochs", | ||
Long: "Lists all stored epochs with their starting blocks", | ||
Run: func(_ *cobra.Command, args []string) { | ||
res, err := api.ListEpochs() | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
for _, epoch := range res { | ||
fmt.Println("Epoch #", epoch.EpochNumber, "Starting block: ", epoch.StartingBlock) | ||
} | ||
}, | ||
} | ||
|
||
return cmd | ||
} | ||
|
||
// RemoveLatestEpoch returns remove-epoch cobra Command. | ||
func RemoveLatestEpoch() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "remove-latest-epoch", | ||
Short: "Removes latest epoch ", | ||
Long: "Allows to remove latest epoch, for example in case, if epoch starting block was set incorrectly", | ||
Run: func(_ *cobra.Command, args []string) { | ||
if err := api.RemoveLatestEpoch(); err != nil { | ||
panic(err) | ||
} | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package cmd | ||
|
||
import ( | ||
"os" | ||
"os/signal" | ||
"strconv" | ||
"syscall" | ||
) | ||
|
||
// ErrorCode contains the exit code for server exit. | ||
type ErrorCode struct { | ||
Code int | ||
} | ||
|
||
func (e ErrorCode) Error() string { | ||
return strconv.Itoa(e.Code) | ||
} | ||
|
||
// WaitForQuitSignals waits for SIGINT and SIGTERM and returns. | ||
func WaitForQuitSignals() ErrorCode { | ||
sigs := make(chan os.Signal, 1) | ||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) | ||
sig := <-sigs | ||
return ErrorCode{Code: int(sig.(syscall.Signal)) + 128} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package main | ||
|
||
import "github.com/SigmaGmbH/librustgo/cmd/attestation/cmd" | ||
|
||
func main() { | ||
if err := cmd.RootCmd().Execute(); err != nil { | ||
panic(err) | ||
} | ||
} |
Oops, something went wrong.