tyler-smith / go-bip39

The BIP39 library for Go.
MIT License
549 stars 196 forks source link

Possible optimisations #31

Closed cpl closed 3 years ago

cpl commented 5 years ago

Hi, I used your implementation as a reference but managed to get some optimisations in. Bellow you can see a benchmark between yours (BIP39) and mine (MWords).

BenchmarkBIP39-4          200000          8332 ns/op        1343 B/op         59 allocs/op
BenchmarkMWords-4         500000          3856 ns/op         816 B/op          7 allocs/op

If you'd like to have a look over the implementation you can find it here: https://github.com/cpl/cryptor/tree/master/crypt/mwords

The main changes are in this function: https://github.com/cpl/cryptor/blob/master/crypt/mwords/mwords.go#L61

tyler-smith commented 5 years ago

These numbers looks great. Do you have the benchmark code?

cpl commented 5 years ago

Yes, It's all in that package mwords https://github.com/cpl/cryptor/blob/master/crypt/mwords/mwords_bench_test.go