我们如何使用单词的 mnemonic列表作为种子(就像我们已经习惯了使用加密货币钱包的习惯)能够恢复私钥,以防私钥丢失,不小心擦除或粘在破损的设备?
这对于客户端之间的E2E加密可能很有用:应在客户端上生成密钥,只有公共密钥才能与服务器共享。
用户可以在需要时再生键,只要他们能够再次提供助记符,显然可以安全地存储和离线。
疯子种子应足够长以提供安全量的熵。
some q& a似乎已经过时了:我们如何在JavaScript/Typescript(可能使用维护的库)中实现这一目标?
How do we use a mnemonic list of words as a seed (like we have been become accustomed using cryptocurrency wallets) to be able to recover a private key in case it gets lost, accidentally erased, or stuck on a broken device?
This could be useful for e2e encryption between clients: the keys are supposed to be generated on the client, only the public key will be shared with the server.
Users could be regenerating the keys offline when needed, as long as they are able to provide the mnemonic again, obviously to be stored safely and offline.
The mnemonic seed should be long enough to provide a safe amount of entropy.
Some Q&A appear to be very outdated: how can we achieve this in Javascript/Typescript, possibly using maintained libraries?
发布评论
评论(1)
解决方案:
bip39
和node-forge
quote 此答案引导我实现了此解决方案:
我们可以假设 128位熵应该足够在可预见的将来,我们可以预防这种攻击,但是我们可以幸运的是,决定我们的助记符的强度。
1。
首先,我们可以使用
bip-39
bip-39 JS实现。2。创建确定性prng函数
现在我们可以使用
生成我们的钥匙。
node-forge
pki.rsa.generateKeypair
函数接受a 确定性),而是从mnemonic 中返回计算的值。3。生成键盘,
馈送
GenerateKeyPair
函数,我们现在可以使用我们的“ aidged” prng: etvoilà!
我们现在拥有直接在客户端和客户端生成的安全和确定性的RSA键与输入相同的助记符可靠。
请考虑使用确定性密钥涉及的风险,并确保您的用户将不要在线或其他任何地方存储助记符(通常建议将其写下来并将其存储在纸上并将其存储在安全的地方) 。
Solution:
bip39
andnode-forge
To quote this answer which has guided me to achieve this solution:
We can assume that 128 bits of entropy should be enough for preventing this kind of attacks, in the foreseeable future, however we can fortunately decide how strong our mnemonic will be.
1. Generate mnemonic
First of all we can generate a mnemonic using the
bip-39
JS implementation.2. Create deterministic PRNG function
Now we can use
node-forge
to generate our keys.The
pki.rsa.generateKeyPair
function accepts a pseudo-random number generator function in input. The goal is getting this function to NOT compute a pseudo-random number (this would not be deterministic anymore), but rather return a value computed from the mnemonic.3. Generating keypair
We can now feed the
generateKeyPair
function with our "rigged" prng:Et voilà!
We now have safe and deterministic RSA keys, directly generated on the client and restorable with the same mnemonic as a input.
Please consider the risks involved using deterministic keys and make sure your users will NOT store the mnemonic online or anywhere else on their client (generally, it is suggested to write it down on paper and store it somewhere safe).