cardano (ada) 的私钥和签名密钥是什么?
What is private key and signing key for cardano (ada)?
我正在尝试使用 nodejs 和@emurgo/cardano-serialization-lib-nodejs lib (CardanoWasm) 生成地址并创建交易。
按照我正在尝试的文档:
const rootkey = CardanoWasm.Bip32PrivateKey.from_bip39_entropy(
Buffer.from(someEntropy, 'hex'), // entropy is generated from mnemonic
Buffer.from('')
);
const account = rootkey
.derive(harden(1852)) // harden is a function returning 0x80000000+arg
.derive(harden(1815))
.derive(harden(0));
const utxokey = account
.derive(0)
.derive(0)
.to_public();
const stake1 = account
.derive(2)
.derive(0)
.to_public();
const address = CardanoWasm.BaseAddress.new(
CardanoWasm.NetworkInfo.mainnet().network_id(),
CardanoWasm.StakeCredential.from_keyhash(utxokey.to_raw_key().hash()),
CardanoWasm.StakeCredential.from_keyhash(stakekey.to_raw_key().hash())
);
const addressBech32 = address.to_address().to_bech32();
因此在我的示例中,addressBech32 是钱包的实际 public 地址。当我通过助记符将钱包导入 guarda(例如)时,它工作正常。
但是rootkey和account到底是什么?我的示例中的私钥和签名密钥是什么?我应该使用什么密钥来签署交易以及如何使用 cardano wasm 获取该密钥?我应该使用什么私钥导入钱包(如果我出于某种原因不想使用助记词)?
可以看看Cardano Shelley地址样式文档
https://input-output-hk.github.io/cardano-addresses/haddock/cardano-addresses-3.2.0/Cardano-Address-Style-Shelley.html#g:2
When I import the wallet to the guarda (for example) by mnemonic it works fine. But what is actually rootkey and account?
rootKey
代表您的 xpriv,您的主私钥,所有质押和支出、私钥和 public 密钥均从中生成。
CIP-0003 中描述了生成质押和签名密钥的过程,基本上是搭载比特币 BIP32 和 BIP44 standard。
简而言之,该方案允许使用主密钥生成多个单独的钱包'accounts'。在你的例子中:
const account = rootkey
.derive(harden(1852)) // harden is a function returning 0x80000000+arg
.derive(harden(1815))
.derive(harden(0));
生成卡尔达诺账户零的私钥。
更进一步:
account
.derive(0) # external chain (designated for receive addresses)
.derive(0); # index (the first address)
将为该帐户中的接收地址零生成私钥。
What is private key and signing key in my example? What key should i use to sign the transaction and how to get that key using cardano wasm?
您的示例为(Cardano 账户 0)接收地址 0 创建了一个 bech32 地址。
所以从这个地址花费的私钥将与上面的相同:
const utxo_privkey = account
.derive(0)
.derive(0);
What private key should I use to import the wallet (if I don't want to use mnemonic for some reason)?
您可以提供字节形式的熵,就像您在 rootKey
的示例中所做的那样,或者您可以像这样使用 bech32 编码的私钥:
const rootKey = CardanoWasm.BIP32PrivateKey.from_bech32("xprv17qx9vxm6060qjn5fgazfue9nwyf448w7upk60c3epln82vumg9r9kxzsud9uv5rfscxp382j2aku254zj3qfx9fx39t6hjwtmwq85uunsd8x0st3j66lzf5yn30hwq5n75zeuplepx8vxc502txx09ygjgx06n0p");
我正在尝试使用 nodejs 和@emurgo/cardano-serialization-lib-nodejs lib (CardanoWasm) 生成地址并创建交易。 按照我正在尝试的文档:
const rootkey = CardanoWasm.Bip32PrivateKey.from_bip39_entropy(
Buffer.from(someEntropy, 'hex'), // entropy is generated from mnemonic
Buffer.from('')
);
const account = rootkey
.derive(harden(1852)) // harden is a function returning 0x80000000+arg
.derive(harden(1815))
.derive(harden(0));
const utxokey = account
.derive(0)
.derive(0)
.to_public();
const stake1 = account
.derive(2)
.derive(0)
.to_public();
const address = CardanoWasm.BaseAddress.new(
CardanoWasm.NetworkInfo.mainnet().network_id(),
CardanoWasm.StakeCredential.from_keyhash(utxokey.to_raw_key().hash()),
CardanoWasm.StakeCredential.from_keyhash(stakekey.to_raw_key().hash())
);
const addressBech32 = address.to_address().to_bech32();
因此在我的示例中,addressBech32 是钱包的实际 public 地址。当我通过助记符将钱包导入 guarda(例如)时,它工作正常。 但是rootkey和account到底是什么?我的示例中的私钥和签名密钥是什么?我应该使用什么密钥来签署交易以及如何使用 cardano wasm 获取该密钥?我应该使用什么私钥导入钱包(如果我出于某种原因不想使用助记词)?
可以看看Cardano Shelley地址样式文档 https://input-output-hk.github.io/cardano-addresses/haddock/cardano-addresses-3.2.0/Cardano-Address-Style-Shelley.html#g:2
When I import the wallet to the guarda (for example) by mnemonic it works fine. But what is actually rootkey and account?
rootKey
代表您的 xpriv,您的主私钥,所有质押和支出、私钥和 public 密钥均从中生成。
CIP-0003 中描述了生成质押和签名密钥的过程,基本上是搭载比特币 BIP32 和 BIP44 standard。
简而言之,该方案允许使用主密钥生成多个单独的钱包'accounts'。在你的例子中:
const account = rootkey
.derive(harden(1852)) // harden is a function returning 0x80000000+arg
.derive(harden(1815))
.derive(harden(0));
生成卡尔达诺账户零的私钥。
更进一步:
account
.derive(0) # external chain (designated for receive addresses)
.derive(0); # index (the first address)
将为该帐户中的接收地址零生成私钥。
What is private key and signing key in my example? What key should i use to sign the transaction and how to get that key using cardano wasm?
您的示例为(Cardano 账户 0)接收地址 0 创建了一个 bech32 地址。 所以从这个地址花费的私钥将与上面的相同:
const utxo_privkey = account
.derive(0)
.derive(0);
What private key should I use to import the wallet (if I don't want to use mnemonic for some reason)?
您可以提供字节形式的熵,就像您在 rootKey
的示例中所做的那样,或者您可以像这样使用 bech32 编码的私钥:
const rootKey = CardanoWasm.BIP32PrivateKey.from_bech32("xprv17qx9vxm6060qjn5fgazfue9nwyf448w7upk60c3epln82vumg9r9kxzsud9uv5rfscxp382j2aku254zj3qfx9fx39t6hjwtmwq85uunsd8x0st3j66lzf5yn30hwq5n75zeuplepx8vxc502txx09ygjgx06n0p");