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

MIN_ENTROPY_SIZE in bites instead of bytes #19

Closed
pedrouid opened this Issue Feb 3, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@pedrouid
Copy link

pedrouid commented Feb 3, 2019

I'm trying to use this package with bip39 package to have a mnemonic for the entropy of the created identity but I keep getting the minimum entropy size error from this line:

https://github.com/pubkey/eth-crypto/blob/master/src/create-identity.js#L25

But after looking at it, isn't the MIN_ENTROPY_SIZE supposed to be in bytes? Or perhaps the check should be multiplied by 8?

@pubkey

This comment has been minimized.

Copy link
Owner

pubkey commented Feb 8, 2019

I wanted to implement exactly the same security like eth-lib which uses 4*32=128 bytes of entropy.
Providing your own entropy is risky so I decided that it would be better to force the programmer to have the same entropy-size as the one which is automatically used.

Does bip39 specify an entropy size? As far as I found out, it doesnt.

@pedrouid

This comment has been minimized.

Copy link
Author

pedrouid commented Feb 8, 2019

I was using this library bip39: https://www.npmjs.com/package/bip39

const bip39 = require('bip39')

const mnemonic = bip39.generateMnemonic()
// 'seed sock milk update focus rotate barely fade car face mechanic mercy'

const entropy = bip39.menmonicToEntropy(menmonic)
// c2f9c2327745a37844a28e224a3228c5

const byteLength = Buffer.byteLength(entropy, 'utf8')
// 32

Basically I just wanted to use this mnemonic for recovery while still using the eth-crypto library to generate an identity to keep it lightweight. We could instead integrate the generateMnemonic into eth-crypto?

@pubkey

This comment has been minimized.

Copy link
Owner

pubkey commented Feb 8, 2019

According to this the default strength of this module is also 128bytes.
As you can see on the online-tool, the size of BIP39 Seed is always 128bytes. I have no full understanding of the bip39-protocol, but shouldn't the seed be used to generate the private key?

@pedrouid

This comment has been minimized.

Copy link
Author

pedrouid commented Feb 8, 2019

Yeah, you're right! My bad! That was my fault

@pedrouid pedrouid closed this Feb 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment