@ethereumjs/wallet (英语) v10
轻量级钱包执行 。 目前它支持各种格式之间的密钥创建和转换.
由以下一揽子方案加以补充:
- @ethereumjs/tx (英语) 以签署交易
- 乙型六氯环己烷 操作 ICAP 地址
- 存储.js 要使用浏览器存储
动机是:
- 轻量级
- 在浏览器中工作
- 使用一个单一的、维护的加密库(这应符合
@ethereumjs/util财务报告和审定财务报表@ethereumjs/tx(中文(简体) ) - 支持不同钱包格式之间的导入/导出
- 支持 BIP32 HD 键
不支持的特性 :
- 签名交易
- 管理存储(无论是节点.js还是浏览器)
目录
钱包 API
关于钱包的API,请前往 ./docs/class/wallet.md。 。 。 .
您可以导入 Wallet 像这样的课
节点.js/ES6:
// ./examples/wallet.cjs
const { Wallet } = require('@ethereumjs/wallet')
const wallet = Wallet.generate()
console.log(wallet.getAddressString()) // should output an Ethereum address
无害环境管理/类型脚本:
// ./examples/wallet.ts
import { Wallet } from '@ethereumjs/wallet'
const wallet = Wallet.generate()
console.log(wallet.getAddressString()) // should output an Ethereum address
第三方 API
可以通过 thirdparty 子模块 :
节点.js/ES5:
// ./examples/thirdparty.cjs
const { thirdparty } = require('@ethereumjs/wallet')
const wallet = thirdparty.fromQuorumWallet('mySecretQuorumWalletPassphrase', 'myPublicQuorumUserId')
console.log(wallet.getAddressString()) // An Ethereum address
无害环境管理/类型脚本:
// ./examples/thirdparty.ts
import { thirdparty } from '@ethereumjs/wallet'
const wallet = thirdparty.fromQuorumWallet('mySecretQuorumWalletPassphrase', 'myPublicQuorumUserId')
console.log(wallet.getAddressString()) // An Ethereum address
请去 ./文件/README.md 需要更多信息.
HD 钱包 API
要使用 BIP32 HD 钱包,首先包括 hdkey 子模块 :
节点.js/ES5:
// ./examples/hdKey.cjs
const { hdkey } = require('@ethereumjs/wallet')
const wallet = hdkey.EthereumHDKey.fromMnemonic(
'clown galaxy face oxygen birth round modify fame correct stumble kind excess',
)
console.log(wallet.getWallet().getAddressString()) // Should print an Ethereum address
无害环境管理/类型脚本:
// ./examples/hdKey.ts
import { hdkey } from '@ethereumjs/wallet'
const wallet = hdkey.EthereumHDKey.fromMnemonic(
'clown galaxy face oxygen birth round modify fame correct stumble kind excess',
)
console.log(wallet.getWallet().getAddressString()) // Should print an Ethereum address
请去 ./docs/class/etherumhdkey.md 需要更多信息.
专题
关于 toV3
这个 options 是一个可选对象散列,其中所有序列化参数都可以被细调:
- uuid - UUID (英语). 一是随机生成.
- 盐 -- -- 随机盐
kdf。大小必须符合 KDF(关键衍生函数)的要求。 随机数通过crypto.getRandomBytes如果一无所获. - iv - 初始化矢量
cipher。大小必须符合密码的要求。 随机数通过crypto.getRandomBytes如果一无所获. - 缩略语 关键衍生函数,见下文.
- dklen - 衍生出密钥长度. 当然
cipher设置,此设置必须与这些设置的块大小相匹配 . - 密码 - 要使用的密码. 名称必须与所支持的名称相匹配
OpenSSL,比如说.aes-128-ctr或者说aes-128-cbc。 。 。 .
取决于 kdf 选项.
对于 pbkdf2数字 :
c- 重复次数。 默认为262144.prf- 唯一支持(和默认)值是hmac-sha256所以没有意义改变它.
对于 scrypt数字 :
n- 重复计数 默认为262144.r- 基本散列的块大小 默认为 8.p- 平行因素。 默认为 1 .
Go Ethereum 的执行有利于以下设置,我们默认为:
kdf数字 :scryptdklen数字 :32n数字 :262144r数字 :8p数字 :1cipher数字 :aes-128-ctr
爱丽丝
看我们的组织 文档 介绍 EthereumJS 以及关于现行标准和最佳做法的资料.
如果你想参加工作或改进图书馆,请看看我们 捐款准则。 。 。 .
许可证
MIT 许可证
版权(C)2016 Alex Beregszaszi