Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ test/reqaddr.sh
test/sign.sh
.DS_Store
.vscode
build/bin
temtest
24 changes: 24 additions & 0 deletions cmd/gsmpc-lib/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/ecdsa"
"encoding/hex"
"github.com/anyswap/FastMulThreshold-DSA/crypto"
nitroToolkit "github.com/anyswap/nitro-toolkit"
)

// LoadECDSA loads a secp256k1 private key from the given file.
Expand Down Expand Up @@ -50,6 +51,29 @@ func TeeGetAttestation(t *Atte) (string,error) {

//--------------------------------------------------------

var (
// simulation the tee encryption
DATA_KEY = []byte("12345678901234567890123456789012")
)

func NitroKmsEncrypt(data string) (string,error) {
dataBytes := []byte(data)
cipherBytes, err := nitroToolkit.EncryptByDataKey(DATA_KEY, dataBytes)
if err != nil {
return "", err
}
return string(cipherBytes), nil
}

func NitroKmsDecrypt(cm string) (string,error) {
cipherBytes := []byte(cm)
dataBytes, err := nitroToolkit.DecryptByDataKey(DATA_KEY, cipherBytes)
if err != nil {
return "", err
}
return string(dataBytes), nil
}

//TODO
func TeeKmsEncrypt(data string) (string,error) {
return data,nil
Expand Down
Loading