-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIP-15: Use Bech32 encoding for private key in wallets import and exports #15
Conversation
Hello @joyqvq Thanks for your SIP proposal. In order to process the SIP, the SIP Editor requires write access to the forked repository in order to change the status and add additional information. Could you please grant write access on the forked repository to the following GitHub accounts? SA124 Once this has been completed, we can move the proposal forward. Best regards, |
This SIP has been assigned |
## Description See details: sui-foundation/sips#15 note: after discussion we decide not to change the sui.keystore file storage encoding itself, but only change the import and export interface for sui.keystore CLI. same for import and export for typescript interface. `sui keytool convert`: this converts hex, base64 to bech32 `sui keytool import`: can only import as bech32 `sui keytoo export`: new, export as bech32 ## Test Plan - unit test - CLI scenario ``` # import bech32 works target/debug/sui keytool import suiprivkey1q8typ5p96jtw3s3cqlnxulcg6me26cswjcpa8984z6k4ey4dwefcwlssmpg ed25519 Keys saved as Base64 with 33 bytes `flag || privkey` ($BASE64_STR). To see Bech32 format encoding, use `sui keytool export --address $ADDR` where $ADDR can be found with `sui keytool list`. Or use `sui keytool convert $BASE64_STR`. ╭─────────────────┬──────────────────────────────────────────────────────────────────────╮ │ alias │ │ │ suiAddress │ 0x1b87a727f58830d9ba2bfe6ecdc8fb49aa96fa2a2bbe175e128bfee13f6895ff │ │ publicBase64Key │ AQMSxGmd92VJuD30t5sAOVMO//UWqx85kbuOMDRrUCzWfw== │ │ keyScheme │ secp256k1 │ │ flag │ 1 │ │ peerId │ │ ╰─────────────────┴──────────────────────────────────────────────────────────────────────╯ # import with alias and bech32 works target/debug/sui keytool import suiprivkey1q8typ5p96jtw3s3cqlnxulcg6me26cswjcpa8984z6k4ey4dwefcwlssmpg --alias test-pr ed25519 Keys saved as Base64 with 33 bytes `flag || privkey` ($BASE64_STR). To see Bech32 format encoding, use `sui keytool export --address $ADDR` where $ADDR can be found with `sui keytool list`. Or use `sui keytool convert $BASE64_STR`. ╭─────────────────┬──────────────────────────────────────────────────────────────────────╮ │ alias │ │ │ suiAddress │ 0x1b87a727f58830d9ba2bfe6ecdc8fb49aa96fa2a2bbe175e128bfee13f6895ff │ │ publicBase64Key │ AQMSxGmd92VJuD30t5sAOVMO//UWqx85kbuOMDRrUCzWfw== │ │ keyScheme │ secp256k1 │ │ flag │ 1 │ │ peerId │ │ ╰─────────────────┴──────────────────────────────────────────────────────────────────────╯ # import hex does not work target/debug/sui keytool import 0x1b87a727f58830d9ba2bfe6ecdc8fb49aa96fa2a2bbe175e128bfee13f6895ff ed25519 Sui Keystore and Sui Wallet no longer support importing private key as Hex, if you are sure your private key is encoded in Hex, use `sui keytool convert $HEX` to convert first then import the Bech32 encoded private key starting with `suiprivkey`. # export works target/debug/sui keytool export 0x1b87a727f58830d9ba2bfe6ecdc8fb49aa96fa2a2bbe175e128bfee13f6895ff ╭────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────╮ │ exportedPrivateKey │ suiprivkey1q8typ5p96jtw3s3cqlnxulcg6me26cswjcpa8984z6k4ey4dwefcwlssmpg │ │ key │ ╭─────────────────┬──────────────────────────────────────────────────────────────────────╮ │ │ │ │ alias │ │ │ │ │ │ suiAddress │ 0x1b87a727f58830d9ba2bfe6ecdc8fb49aa96fa2a2bbe175e128bfee13f6895ff │ │ │ │ │ publicBase64Key │ AQMSxGmd92VJuD30t5sAOVMO//UWqx85kbuOMDRrUCzWfw== │ │ │ │ │ keyScheme │ secp256k1 │ │ │ │ │ flag │ 1 │ │ │ │ │ peerId │ │ │ │ │ ╰─────────────────┴──────────────────────────────────────────────────────────────────────╯ │ ╰────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────╯ # export alias works target/debug/sui keytool export --alias nostalgic-hiddenite ✔ 10119 10:40:40 ╭────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────╮ │ exportedPrivateKey │ suiprivkey1q8typ5p96jtw3s3cqlnxulcg6me26cswjcpa8984z6k4ey4dwefcwlssmpg │ │ key │ ╭─────────────────┬──────────────────────────────────────────────────────────────────────╮ │ │ │ │ alias │ │ │ │ │ │ suiAddress │ 0x1b87a727f58830d9ba2bfe6ecdc8fb49aa96fa2a2bbe175e128bfee13f6895ff │ │ │ │ │ publicBase64Key │ AQMSxGmd92VJuD30t5sAOVMO//UWqx85kbuOMDRrUCzWfw== │ │ │ │ │ keyScheme │ secp256k1 │ │ │ │ │ flag │ 1 │ │ │ │ │ peerId │ │ │ │ │ ╰─────────────────┴──────────────────────────────────────────────────────────────────────╯ │ ╰────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────╯ # convert works target/debug/sui keytool convert 0x1b87a727f58830d9ba2bfe6ecdc8fb49aa96fa2a2bbe175e128bfee13f6895ff ╭────────────────┬──────────────────────────────────────────────────────────────────────────╮ │ bech32WithFlag │ suiprivkey1qqdc0fe87kyrpkd690lxanwgldy649h69g4mu967z29lacfldz2l766z9q2 │ │ base64WithFlag │ ABuHpyf1iDDZuiv+bs3I+0mqlvoqK74XXhKL/uE/aJX/ │ │ hexWithoutFlag │ 1b87a727f58830d9ba2bfe6ecdc8fb49aa96fa2a2bbe175e128bfee13f6895ff │ │ scheme │ ed25519 │ ╰────────────────┴──────────────────────────────────────────────────────────────────────────╯ ``` - wallet <img width="360" alt="image" src="https://github.com/MystenLabs/sui/assets/108701016/6f9eb733-ae93-4027-8bc6-913eac2c77af"> <img width="328" alt="image" src="https://github.com/MystenLabs/sui/assets/108701016/f05877b0-9b76-4be5-8b8e-5f6d22d136b5"> --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] protocol change - [x] user-visible impact - [x] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes Sui Keystore in CLI no longer support import private key as 32-byte hex string. It now only supports import or export Bech32 string encoded 33-byte `flag || private_key` starting with `suiprivkey`. See usage for `sui keytool convert -h` if you would like to see all formatted private keys. See `sui keytool export -h` if you need to export a private key in bech32 format. This also matches import and export private key format in Sui Wallet and SDK. See [SIP](sui-foundation/sips#15) for more standard details. --------- Co-authored-by: stefan-mysten <135084671+stefan-mysten@users.noreply.github.com> Co-authored-by: Pavlos Chrysochoidis <pavlos@mystenlabs.com>
SIP-15, which proposes changing the private key import and export interface to use Bech32 encoding, is currently in Last Call status! This is the last chance to put forward any comments before this SIP is finalised. |
…ion#15) * SIP: Change private key import export to Bech32 * add sdk changes * edits on backward compat * Update and rename bech32-temp.md to sip-15.md * Move SIP-15 to Last Call status * Move SIP-15 to Final --------- Co-authored-by: SA124 <34786204+SA124@users.noreply.github.com> Co-authored-by: Will Riches <will@riches.im>
No description provided.