diff --git a/digests.txt b/digests.txt index 2d8b632..e5354aa 100644 --- a/digests.txt +++ b/digests.txt @@ -1,4 +1,4 @@ -01ab04b339665e62223015b7fcf8a8189956dc967967eaa7007856b69b1bf609 turnkey.darwin-aarch64 -175db6f89e62eb192509600d63425333c43d283dbe2370bf2ca74a5b786fa808 turnkey.darwin-x86_64 -5ee6e78e9e4d769b47e0132a449246863c4cff0d012b542090ba31d7df6931b6 turnkey.linux-aarch64 -0fc53177e42030084d748a2920d5680ca63a51c9fc6d3d8d6f3757dda7639069 turnkey.linux-x86_64 +4e6881ec55c1172aa6fcc870710eb4b36bcfc906cd3df334b4041c7ce558db32 turnkey.darwin-aarch64 +118f9162601dd9c4a1f2f3630cb21ba63a832719596958ea2d416cff7fc9926a turnkey.darwin-x86_64 +766943ceae6945de5f70c43b923a743026b22f7563c21e0bf7299634db5343dd turnkey.linux-aarch64 +4b688b6c8bc032fda2ddb78ba1b8c1753ca597832d3462882e8ae63db0127a4d turnkey.linux-x86_64 diff --git a/src/cmd/turnkey/pkg/decrypt.go b/src/cmd/turnkey/pkg/decrypt.go index 2ebac32..b850033 100644 --- a/src/cmd/turnkey/pkg/decrypt.go +++ b/src/cmd/turnkey/pkg/decrypt.go @@ -2,7 +2,10 @@ package pkg import ( "crypto/ecdsa" + "encoding/hex" + "fmt" + "github.com/btcsuite/btcutil/base58" "github.com/rotisserie/eris" "github.com/spf13/cobra" "github.com/tkhq/go-sdk/pkg/enclave_encrypt" @@ -15,12 +18,16 @@ var ( // EncryptionKeypair is the loaded Encryption Keypair. EncryptionKeypair *encryptionkey.Key + + // Solana address, required for exporting Solana private keys in the proper format + solanaAddress string ) func init() { decryptCmd.Flags().StringVar(&exportBundlePath, "export-bundle-input", "", "filepath to read the export bundle from.") decryptCmd.Flags().StringVar(&plaintextPath, "plaintext-output", "", "optional filepath to write the plaintext from that will be decrypted.") decryptCmd.Flags().StringVar(&signerPublicKeyOverride, "signer-quorum-key", "", "optional override for the signer quorum key. This option should be used for testing only. Leave this value empty for production decryptions.") + decryptCmd.Flags().StringVar(&solanaAddress, "solana-address", "", "optional solana address, for use when exporting solana private keys.") rootCmd.AddCommand(decryptCmd) } @@ -71,11 +78,27 @@ var decryptCmd = &cobra.Command{ // decrypt ciphertext plaintextBytes, err := encryptClient.Decrypt([]byte(exportBundle), Organization) if err != nil { - OutputError(err) + OutputError(eris.Errorf("unable to decrypt export bundle: %v", err)) } plaintext := string(plaintextBytes) + // apply formatting, if applicable + if solanaAddress != "" { + hexEncodedPlaintext := hex.EncodeToString(plaintextBytes) + + decodedAddressBytes := base58.Decode(solanaAddress) + decodedAddress := hex.EncodeToString(decodedAddressBytes) + + combinedHex := fmt.Sprintf("%s%s", hexEncodedPlaintext, decodedAddress) + combinedBytes, err := hex.DecodeString(combinedHex) + if err != nil { + OutputError(eris.Errorf("unable to decode combined hex string: %v", err)) + } + + plaintext = base58.Encode(combinedBytes) + } + // output the plaintext if no filepath is passed if plaintextPath == "" { Output(plaintext) @@ -84,7 +107,7 @@ var decryptCmd = &cobra.Command{ err = writeFile(plaintext, plaintextPath) if err != nil { - OutputError(err) + OutputError(eris.Errorf("unable to write plaintext secret to file: %v", err)) } }, } diff --git a/src/cmd/turnkey/pkg/wallets.go b/src/cmd/turnkey/pkg/wallets.go index 10c6372..b3b79aa 100644 --- a/src/cmd/turnkey/pkg/wallets.go +++ b/src/cmd/turnkey/pkg/wallets.go @@ -48,6 +48,7 @@ func init() { walletAccountsCmd.AddCommand(walletAccountsListCmd) walletAccountsCmd.AddCommand(walletAccountCreateCmd) + walletAccountsCmd.AddCommand(walletAccountExportCmd) walletsCmd.AddCommand(walletCreateCmd) walletsCmd.AddCommand(walletsListCmd) walletsCmd.AddCommand(walletExportCmd)