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

same public key for different private keys #46

Open
HimanshuSingh2308 opened this issue Feb 27, 2019 · 2 comments
Open

same public key for different private keys #46

HimanshuSingh2308 opened this issue Feb 27, 2019 · 2 comments

Comments

@HimanshuSingh2308
Copy link

try to generate the public key for these two private keys you will get an exact same public key

  1. 5KhV5DqYYLYuxKkFjNZj7vGTYFUP8wux1ND4xArGYeLb1rKbNjR
  2. 5KhV5DqYYLYuxKkFjNZj7vGTYFUP8wux1ND4xArGYeLb1rKbNjS

is it the limitation of the ECC ????

@ajose01
Copy link

ajose01 commented Jul 16, 2019

Moving over from telegram and raising the same issue here:

Hey folks - anyone familiar with the way the PKs are formatted and what "matters". We were doing some random QA and realized that we can modify a PK slightly and generate the same EOS pub key via eosjs-ecc. Sample:  
5JnRmBMYoBP7z2zKufcgEsj3cfWsjFtd74ghj7oYaLe3f8NSruV
EOS7XVnBmY2XNHnVQHRF17Wv2xyoy1i73MFYcugukshkG3HkXxvwL

5JnRmBMYoBP7z2zKufcgEsj3cfWsjFtd74ghj7oYaLe3f8NSruA
EOS7XVnBmY2XNHnVQHRF17Wv2xyoy1i73MFYcugukshkG3HkXxvwL

I was trying to read through the WIF format, and I'm guessing it has to do w/ using the compressed version of the key. Just trying to see if there's any reference out there that would explain this.

@ajose01
Copy link

ajose01 commented Jul 18, 2019

Doing some additional tests... it seems that ecc.checkDecode should have thrown a checksum error. Manually following the steps I see the following when using the 2nd key aka bad key 5JnRmBMYoBP7z2zKufcgEsj3cfWsjFtd74ghj7oYaLe3f8NSruA

Bad key:

> badkey = '5JnRmBMYoBP7z2zKufcgEsj3cfWsjFtd74ghj7oYaLe3f8NSruA'
'5JnRmBMYoBP7z2zKufcgEsj3cfWsjFtd74ghj7oYaLe3f8NSruA'
'5JnRmBMYoBP7z2zKufcgEsj3cfWsjFtd74ghj7oYaLe3f8NSruV'
> buffer1 = new Buffer(base58.decode(badkey))
<Buffer 80 7f 79 a1 dc ee b8 f4 bf cf 1d 51 e9 64 47 31 f3 a1 7f b0 ce 3c e9 58 6b 6f e4 61 a1 87 90 ca 2e 92 ab 18 cd>
> checksum = buffer1.slice(-4)
<Buffer 92 ab 18 cd>
> chesumhex = checksum.toString('hex')
'92ab18cd'
> key = buffer1.slice(0, -4)
<Buffer 80 7f 79 a1 dc ee b8 f4 bf cf 1d 51 e9 64 47 31 f3 a1 7f b0 ce 3c e9 58 6b 6f e4 61 a1 87 90 ca 2e>
> newCheck = hash.sha256(hash.sha256(key)).slice(0,4)
<Buffer 92 ab 18 e0>
> checksum.toString('hex')
'92ab18cd'
> newCheck.toString('hex')
'92ab18e0'
>

Good Key:

> goodkey = '5JnRmBMYoBP7z2zKufcgEsj3cfWsjFtd74ghj7oYaLe3f8NSruV'
> buffer = new Buffer(base58.decode(goodkey))
<Buffer 80 7f 79 a1 dc ee b8 f4 bf cf 1d 51 e9 64 47 31 f3 a1 7f b0 ce 3c e9 58 6b 6f e4 61 a1 87 90 ca 2e 92 ab 18 e0>
> checksum = buffer.slice(-4)
<Buffer 92 ab 18 e0>
> key = buffer.slice(0, -4)
<Buffer 80 7f 79 a1 dc ee b8 f4 bf cf 1d 51 e9 64 47 31 f3 a1 7f b0 ce 3c e9 58 6b 6f e4 61 a1 87 90 ca 2e>
> newCheck = hash.sha256(hash.sha256(key)).slice(0,4)
<Buffer 92 ab 18 e0>
> checksum.toString('hex')
'92ab18e0'
> newCheck.toString('hex')
'92ab18e0'
>

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

2 participants