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

Derivation of stellar public key fails #645

Closed
TheTrunk opened this issue May 11, 2021 · 3 comments
Closed

Derivation of stellar public key fails #645

TheTrunk opened this issue May 11, 2021 · 3 comments
Labels

Comments

@TheTrunk
Copy link

Describe the bug
Trying to get a public key from stellar secret key can throw an error in library

What version are you on?
Latest 8.1.1

To Reproduce
Simply try to generate many keypairs

const StellarSdk = require("stellar-sdk");

for (let i = 0; i < 1000; i++) {
  try {
    const pair = StellarSdk.Keypair.random();
    const sec = pair.secret();
    console.log(sec);
    const pub = pair.publicKey();
    console.log(pub);
  } catch (error) {
    console.log(error);
  }
}

You will encounter failiure approximantelly every 200th derivation.
Known private keys from which publicKey fails to derive

SDUYQO2PCSM7WUCX7SAFQOYGNGLNISPMILCHXQVPXVDFYYZ7LYTBPRXD
SB3M57ZLGRTL7PLBXS2BTBT3JLFEVMDTDUI3ERBCZBLF4GUIWLHEPAYC
SDNGQTMWIVCEISCYUWGBUFTKOB5MGEGGXGLKMXWDJADN5KQWSRMNGHDH
SDZIG2WTBW6AM7O6T7JYC6TVSBMMYH3I7DMUCTO5VXIHH45RDWKXVMIH

Expected behavior
Generation does not fail

Additional context

TypeError: medKey.ed25519 is not a function
    at Function.encodeEd25519PublicKey (C:\Users\User\Source\Repos\zelcore\node_modules\stellar-base\lib\strkey.js:73:51)
    at Keypair.publicKey (C:\Users\User\Source\Repos\zelcore\node_modules\stellar-base\lib\keypair.js:128:29)
@TheTrunk TheTrunk added the bug label May 11, 2021
@TheTrunk
Copy link
Author

TheTrunk commented May 11, 2021

Version 8.0.0 and lower works well. Bug was introduced in v8.1.0 with the bump of major version of stellar-base

@Shaptic
Copy link
Contributor

Shaptic commented May 11, 2021

Thank you for bringing this to my attention! It's resolved by stellar/js-stellar-base#429 and will be included in base-5.2.1 and subsequently the pending sdk-8.2.0.

@Shaptic
Copy link
Contributor

Shaptic commented May 11, 2021

This should be closed as of v8.2.0!

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

No branches or pull requests

3 participants
@Shaptic @TheTrunk and others