From 853bd0ab7ddfbe5d41441fb8a764926dacf28fb8 Mon Sep 17 00:00:00 2001 From: kaia-docs Date: Wed, 8 Jan 2025 11:02:34 +0800 Subject: [PATCH] New translations keystorev4-single.mdx (Chinese Traditional) --- .../keystore/keystoreV4-single.mdx | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 i18n/zh-TW/docusaurus-plugin-content-docs/current/references/sdk/ethers-ext/v5/account-management/keystore/keystoreV4-single.mdx diff --git a/i18n/zh-TW/docusaurus-plugin-content-docs/current/references/sdk/ethers-ext/v5/account-management/keystore/keystoreV4-single.mdx b/i18n/zh-TW/docusaurus-plugin-content-docs/current/references/sdk/ethers-ext/v5/account-management/keystore/keystoreV4-single.mdx new file mode 100644 index 000000000000..c671f477c049 --- /dev/null +++ b/i18n/zh-TW/docusaurus-plugin-content-docs/current/references/sdk/ethers-ext/v5/account-management/keystore/keystoreV4-single.mdx @@ -0,0 +1,126 @@ +# V4 keystore single + +本例演示如何加密和解密 **keystore V4 single**。 + + + + ```js keystoreV4-single.js + const { Wallet } = require("@kaiachain/ethers-ext/v5"); + + // Klaytn V4 with one key. kcn account new --lightkdf + const encryptedKey = `{ + "address":"ec5eaa07b4d3cbafe7bf437a1ea9a898209f617c", + "keyring":[ + [ + { + "cipher":"aes-128-ctr", + "ciphertext":"0a5aa3749b9e83c2a4238445aeb66f59355c0363a54c163e34e454f76e061e47", + "cipherparams":{"iv":"2a0b2e02a61e0f721bd800ea6e23a588"}, + "kdf":"scrypt", + "kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"538ead57745bcd946b05fe294de08256628d9a0a393fd29ced933ba5fc045b07"}, + "mac":"30b5488bc97165bc7ecac8ff8dfec65a75a8ad206450aecff0ac2dfea6f79b08" + } + ] + ], + "id":"362c0766-f5e3-4b4d-af22-7e89d5fb613a", + "version":4 + }`; + const password = "password"; + const newPassword = "newPassword"; + + async function main() { + const account = Wallet.fromEncryptedJsonSync(encryptedKey, password); + + console.log("decrypted (address, privateKey)"); + console.log(account.klaytnAddr, ", ", account.privateKey); + + const v3encryptedKey = await account.encrypt(newPassword); + + const newAccount = Wallet.fromEncryptedJsonSync(v3encryptedKey, newPassword); + + console.log("\ndecrypted (address, privateKey) with new password"); + console.log(newAccount.address, ", ", newAccount.privateKey); + } + + main(); + ``` + + --- + + ```zsh output + ❯ node keystoreV4-single.js + decrypted (address, privateKey) + 0xec5eaa07b4d3cbafe7bf437a1ea9a898209f617c , 0x4062512193ef1dab8ccf3e3d7a4862e3c740bdf11d852954ed48bc73643e354f + + decrypted (address, privateKey) with new password + 0xEc5eAa07b4d3CbAfe7bf437a1Ea9A898209F617c , 0x4062512193ef1dab8ccf3e3d7a4862e3c740bdf11d852954ed48bc73643e354f + ``` + + + --- + + 從 **@kaiachain/ethers-ext/v5** 軟件包中導入錢包類。 + + ```js keystoreV4-single.js focus=1 + ``` + + --- + + 定義加密keystore **版本 4** + + ```js keystoreV4-single.js focus=4:20 + ``` + + --- + + 指定密鑰存儲的**當前密碼**和**新密碼**。 + + ```js keystoreV4-single.js focus=21:22 + ``` + + --- + + 使用**當前密碼**加載密鑰庫 + + ```js keystoreV4-single.js focus=25 + ``` + + --- + + 解密後,您可以訪問**公鑰**和**私鑰**。 + + + ```js keystoreV4-single.js focus=27:28 + ``` + + --- + + ```zsh output + decrypted (address, privateKey) + 0xec5eaa07b4d3cbafe7bf437a1ea9a898209f617c , 0x4062512193ef1dab8ccf3e3d7a4862e3c740bdf11d852954ed48bc73643e354f + ``` + + + --- + + 您可以使用解密密鑰和新密碼生成新的密鑰存儲。 請注意,新的加密密鑰將是 keystore v3。 + + ```js keystoreV4-single.js focus=30 + ``` + + --- + + 檢查新的密鑰庫 **public** 和 **private** 密鑰,它將與原始密鑰庫不同,因為密鑰庫 v3 \*\* 不支持 klaytn 賬戶系統。 + + + ```js keystoreV4-single.js focus=32:35 + ``` + + --- + + ```zsh output + decrypted (address, privateKey) with new password + 0xEc5eAa07b4d3CbAfe7bf437a1Ea9A898209F617c , 0x4062512193ef1dab8ccf3e3d7a4862e3c740bdf11d852954ed48bc73643e354f + ``` + +