Skip to content

Conversation

@oliviathet
Copy link
Contributor

@oliviathet oliviathet commented Mar 10, 2024

Summary & Motivation (Problem vs. Solution)

  • Supports importing wallets and private keys via 3 steps (init import to generate encryption key in secure enclave, encrypt plaintext seed phrase, import ciphertext to secure enclave)
  • Bumps Go 1.19 to 1.21
  • Replaces Toolchain with Stagex for deterministic Go builds because Toolchain doesn't support Go 1.21

Wallet Import Flow:

# Init import (online)
turnkey wallets init-import \
--user <user_id> \
--import-bundle-output "./import_bundle.txt" \
--key-name demo 

# Encrypt without saving plaintext to filesystem (offline)
turnkey encrypt \
--import-bundle-input "./import_bundle.txt" \
--encrypted-bundle-output "./encrypted_bundle.txt" \
--plaintext-input /dev/fd/3 3<<<"$SEEDPHRASE_1"

# Import (online)
turnkey wallets import \
--user <user_id> \
--name "demo wallet" \
--encrypted-bundle-input "./encrypted_bundle.txt" \
--key-name demo 

Private Key Import Flow:

# Init import (online)
turnkey private-keys init-import \
--user <user_id> \
--import-bundle-output "./import_bundle.txt" \
--key-name demo 

# Encrypt without saving plaintext to filesystem (offline)
turnkey encrypt \
--import-bundle-input "./import_bundle.txt" \
--encrypted-bundle-output "./encrypted_bundle.txt" \
--plaintext-input /dev/fd/3 3<<<"$RAW_KEY_1"

# Import (online)
turnkey private-keys import \
--user <user_id> --name "demo wallet"  \
--encrypted-bundle-input "./encrypted_bundle.txt" \
--address-format ADDRESS_FORMAT_ETHEREUM \
--curve CURVE_SECP256K1 \
--key-name demo 

Release Steps

See README for additional details.

  • Tag the release (once approved)
  • Attest (once merged)
  • Create release with changelog
  • Update Homebrew tap

@oliviathet oliviathet requested a review from timurnkey March 11, 2024 20:36
Copy link
Contributor

@Ulexus Ulexus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some small things, but looks good to me

}

var plaintextBytes []byte
plaintextBytes, err = hex.DecodeString(plaintext)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gosimplify: just instantiate with the return: plaintextBytes, err := hex.Decode...?

walletCreateCmd.Flags().StringVar(&walletNameOrID, "name", "", "name to be applied to the wallet")
walletCreateCmd.Flags().StringVar(&walletNameOrID, "name", "", "name to be applied to the wallet.")

walletInitImportCmd.Flags().StringVar(&user, "user", "", "ID of user to importing the wallet")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For things like this in a common namespace, it would be safer to additionally namespaces the package-scoped variable here. Perhaps something like user -> walletInitImportUser?

walletInitImportCmd.Flags().StringVar(&user, "user", "", "ID of user to importing the wallet")
walletInitImportCmd.Flags().StringVar(&importBundlePath, "import-bundle-output", "", "filepath to write the import bundle to.")

walletImportCmd.Flags().StringVar(&user, "user", "", "ID of user to importing the wallet")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While these two commands should never be executed on the same run, it feels dangerous to reuse the variables like this

Copy link
Contributor

@timurnkey timurnkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LFG!!!! 🚀

@oliviathet oliviathet merged commit 2281a2b into main Mar 12, 2024
@Ulexus Ulexus deleted the olivia/import branch March 13, 2024 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants