我应该如何使用 Ripple-lib 或官方 api 正确创建 Ripple 纸钱包?
How should I properly create a Ripple Paper Wallet using Ripple-lib or an official api?
我正在尝试使用官方 Ripple Api、ripple-lib 创建一个纸钱包。
generateAddress() 接受一些参数。
'use strict';
const RippleAPI = require('ripple-lib').RippleAPI;
const api = new RippleAPI({
server: 'wss://s1.ripple.com' // Public rippled server
});
api.connect().then(() => {
return api.generateAddress();
}).then(info => {
console.log(info);
console.log('getAccountInfo done');
/* end custom code -------------------------------------- */
}).then(() => {
return api.disconnect();
}).then(() => {
console.log('done and disconnected.');
}).catch(console.error);
这段代码实际上创建了一个密钥和一个"Address"。
{
secret: 'sheWb..................HRyLhk',
address: 'rNLJ.......................qu3nbb'
}
好的。现在我已经创建了我的帐户。如果我用 20XRP 储备为其提供资金,它将成为一个活跃的 Ripple 账户。耶!
但是我不明白:
- 哪个是或如何获得我的 Public 密钥?
- 哪个是我的主 Public 密钥?
- generateAddress() 方法接受三个参数。此处描述:https://ripple.com/build/rippleapi/#generateaddress 但我不知道如何编写这些参数。我对此很感兴趣,因为我认为在第一个参数中, "options" 对象是我可以为密钥定义密码的地方。也许我错了。
任何人都可以阐明这些问题吗?
编辑:
我认为现在传递给 generateAddress()
的选项对象与传递给此处描述的构造函数 RippleApi()
的选项参数相同 https://ripple.com/build/rippleapi/#parameters 有人可以确认这一点吗?
纸钱包只需要地址(public)和秘密(私有):
https://github.com/Bithomp/xrp-paper-wallet
实际上,只有 secret 就足够了,因为你可以从 secret[=71] 中得到一个 address =].
https://github.com/Bithomp/bithomp-tools
在 Ripple 中,您不必为每个新帐户都使用一个新帐户 order/user。对于每个新交易,您可以使用 目标标签 。这就是您识别 customer/order 的方式。 Ripple 还支持密钥轮换,因此如果 主密钥 暴露了,您可以禁用它并使用 常规密钥 。在最佳实践中,您分配一个 常规密钥 并使用它在线签署交易,而主密钥始终处于离线状态。如果常规密钥暴露,您可以用新的常规密钥替换它。
在 ripple 中,您可以使用 keypair(public 密钥 + 私钥)或 secret 签署交易.
您可以在此处获取 ripple 的密钥对 https://iancoleman.io/bip39/
ripple-lib 的 generateAddress()
给你:
1) 涟漪地址(您的public地址)以r
开头
你可以分享它,它可以用来给你付款。
您可以在资源管理器中搜索public地址。
例如:https://bithomp.com/explorer/r9fVvKgMMPkBHQ3n28sifxi22zKphwkf8u
2) 秘密 - 主密钥,将用于签署交易。
3) 您还可以分配一个 常规键 (https://developers.ripple.com/assign-a-regular-key-pair.html)
Options 只有两个参数:
algorithm 字符串,生成地址的数字签名算法。可以是 ecdsa-secp256k1(默认)或 ed25519.
entropy array\integer,用于生成种子的熵。
希望对您有所帮助..
The generateAddress() methods accepts three parameters. Described
here: https://ripple.com/build/rippleapi/#generateaddress But I don't
have a clue on how to write those parameters. I'm interested on this
because I think that in the first parameter, the "options" object is
where I could define the passphrase for the secret key. Maybe I'm
wrong.
下面是一些 javascript 代码,用于演示将熵输入 generateAddress 方法。
// This functions works on modern browswers, not sure about Node.js. Try https://www.npmjs.com/package/js-sha512 or https://nodejs.org/api/crypto.html
async function fun_SHA512_array(entropy) {
'use strict';
// Turns a string into an array of integers.
// Made possible by https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
const msgUint8 = new TextEncoder().encode(entropy); // encode as (utf-8) Uint8Array
const hashBuffer = await crypto.subtle.digest('SHA-512', msgUint8); // hash the message
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
// const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
return hashArray;
}
const str_entropy = "Use a cryptographically strong, randomly created string of characters here.";
// Or, your passphrase string would go here.
// Or, you could use a BIP39 Mnemonic but you'd have to remember how you constructed the string. e.g. Did you separate the words with a comma or with a space?
// Or, on the linux terminal you can use: openssl rand -base64 n
// Where n = the number of characters you wish to randomly generate. Which are then converted to base64, therefore the amount of characters ends up being more than n.
var array_sha512 = [];
fun_SHA512_array(str_entropy).then(array_sha512 => {
var obj_new_account = api.generateAddress({"entropy": array_sha512});
var str_secret = obj_new_account.secret;
var str_public_address = obj_new_account.address;
console.log(str_secret);
console.log(str_public_address);
});
记住,熵就像一颗种子,总是会产生相同的 secret 和 address.
我正在尝试使用官方 Ripple Api、ripple-lib 创建一个纸钱包。
generateAddress() 接受一些参数。
'use strict';
const RippleAPI = require('ripple-lib').RippleAPI;
const api = new RippleAPI({
server: 'wss://s1.ripple.com' // Public rippled server
});
api.connect().then(() => {
return api.generateAddress();
}).then(info => {
console.log(info);
console.log('getAccountInfo done');
/* end custom code -------------------------------------- */
}).then(() => {
return api.disconnect();
}).then(() => {
console.log('done and disconnected.');
}).catch(console.error);
这段代码实际上创建了一个密钥和一个"Address"。
{
secret: 'sheWb..................HRyLhk',
address: 'rNLJ.......................qu3nbb'
}
好的。现在我已经创建了我的帐户。如果我用 20XRP 储备为其提供资金,它将成为一个活跃的 Ripple 账户。耶!
但是我不明白:
- 哪个是或如何获得我的 Public 密钥?
- 哪个是我的主 Public 密钥?
- generateAddress() 方法接受三个参数。此处描述:https://ripple.com/build/rippleapi/#generateaddress 但我不知道如何编写这些参数。我对此很感兴趣,因为我认为在第一个参数中, "options" 对象是我可以为密钥定义密码的地方。也许我错了。
任何人都可以阐明这些问题吗?
编辑:
我认为现在传递给 generateAddress()
的选项对象与传递给此处描述的构造函数 RippleApi()
的选项参数相同 https://ripple.com/build/rippleapi/#parameters 有人可以确认这一点吗?
纸钱包只需要地址(public)和秘密(私有):
https://github.com/Bithomp/xrp-paper-wallet
实际上,只有 secret 就足够了,因为你可以从 secret[=71] 中得到一个 address =].
https://github.com/Bithomp/bithomp-tools
在 Ripple 中,您不必为每个新帐户都使用一个新帐户 order/user。对于每个新交易,您可以使用 目标标签 。这就是您识别 customer/order 的方式。 Ripple 还支持密钥轮换,因此如果 主密钥 暴露了,您可以禁用它并使用 常规密钥 。在最佳实践中,您分配一个 常规密钥 并使用它在线签署交易,而主密钥始终处于离线状态。如果常规密钥暴露,您可以用新的常规密钥替换它。
在 ripple 中,您可以使用 keypair(public 密钥 + 私钥)或 secret 签署交易.
您可以在此处获取 ripple 的密钥对 https://iancoleman.io/bip39/
ripple-lib 的 generateAddress()
给你:
1) 涟漪地址(您的public地址)以r
你可以分享它,它可以用来给你付款。 您可以在资源管理器中搜索public地址。
例如:https://bithomp.com/explorer/r9fVvKgMMPkBHQ3n28sifxi22zKphwkf8u
2) 秘密 - 主密钥,将用于签署交易。
3) 您还可以分配一个 常规键 (https://developers.ripple.com/assign-a-regular-key-pair.html)
Options 只有两个参数:
algorithm 字符串,生成地址的数字签名算法。可以是 ecdsa-secp256k1(默认)或 ed25519.
entropy array\integer,用于生成种子的熵。
希望对您有所帮助..
The generateAddress() methods accepts three parameters. Described here: https://ripple.com/build/rippleapi/#generateaddress But I don't have a clue on how to write those parameters. I'm interested on this because I think that in the first parameter, the "options" object is where I could define the passphrase for the secret key. Maybe I'm wrong.
下面是一些 javascript 代码,用于演示将熵输入 generateAddress 方法。
// This functions works on modern browswers, not sure about Node.js. Try https://www.npmjs.com/package/js-sha512 or https://nodejs.org/api/crypto.html
async function fun_SHA512_array(entropy) {
'use strict';
// Turns a string into an array of integers.
// Made possible by https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
const msgUint8 = new TextEncoder().encode(entropy); // encode as (utf-8) Uint8Array
const hashBuffer = await crypto.subtle.digest('SHA-512', msgUint8); // hash the message
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
// const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
return hashArray;
}
const str_entropy = "Use a cryptographically strong, randomly created string of characters here.";
// Or, your passphrase string would go here.
// Or, you could use a BIP39 Mnemonic but you'd have to remember how you constructed the string. e.g. Did you separate the words with a comma or with a space?
// Or, on the linux terminal you can use: openssl rand -base64 n
// Where n = the number of characters you wish to randomly generate. Which are then converted to base64, therefore the amount of characters ends up being more than n.
var array_sha512 = [];
fun_SHA512_array(str_entropy).then(array_sha512 => {
var obj_new_account = api.generateAddress({"entropy": array_sha512});
var str_secret = obj_new_account.secret;
var str_public_address = obj_new_account.address;
console.log(str_secret);
console.log(str_public_address);
});
记住,熵就像一颗种子,总是会产生相同的 secret 和 address.