infincia / bip39-rs

A Rust implementation of BIP-0039
Apache License 2.0
54 stars 61 forks source link

cache word list+word map using lazy_static! & introduce to_entropy/to_entropy_hex #7

Closed yannleretaille closed 6 years ago

yannleretaille commented 6 years ago

cache word list+word map using lazy_static!

The current implementation parses the word list over and over again. Using lazy_static! we can do the operation only once and use it directly the next time the crate is used.

introduce to_entropy / to_entropy_hex

other bip39 implementations all feature the to_entropy call, which converts a mnemonic to the original entropy value. to_entropy_hex returns a hex formatted string of the entropy bytes.

Feedback about the API

Generally, I agree with #4 and the API for this crate should by different. Seed and MNemonic should be distinct types that can be initialized by calling ::from(String) or ::new, expose functions to convert between each other and and to/from entropy, as well as each providing their own .as_hex() etc. . This way using the create would be a lot easier and intuitive.

steveatinfincia commented 6 years ago

This looks great, thanks :)

I agree about the API, I'll add further discussion to #4.