Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not find a way to restore a keypair created from Keypair.makeRandom() #244

Open
idoor88 opened this issue Oct 13, 2021 · 3 comments
Open

Comments

@idoor88
Copy link

idoor88 commented Oct 13, 2021

Hi, I created a KeyPair from:
let keypair = await Keypair.makeRandom();
then I have the pubilcKey, privateKey and address saved, later on I need to restore the keypair object so I can use it when sign:
const signedPaymentTxn = await paymentTxn.sign({ payer: keypair });

it seems I can not find a way to restore the keypair from the pubilcKey, privateKey and address I saved.

Any clues?
Thanks in advance

@sawyerru
Copy link

Hello,

I am facing a similar issue and raised the following issue. I was told to basically store the entropy that is used to generate the keypair initially. Like so:

import { Keypair, utils } from '@helium/crypto'

const keypairEntropy = await utils.randomBytes(32)
const keypair = await Keypair.fromEntropy(keypairEntropy)

I would prefer to have some ability to regenerate the keypair from the privateKey hex string, so I'll keep you updated if theres a separate method in the underlying libsodium-wrapper method that can be used.

@idoor88
Copy link
Author

idoor88 commented Oct 21, 2021

Yes, I ended up doing the same thing.
Thanks

@ygcool
Copy link

ygcool commented Nov 20, 2021

Is there a solution? Are there any examples?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants