bitcoinjs / bip38

BIP38 is a standard process to encrypt Bitcoin and crypto currency private keys that is less susceptible to brute force attacks thus protecting the user.
http://cryptocoinjs.com/modules/currency/bip38/
MIT License
205 stars 100 forks source link

lib: use buffer-xor over inline #9

Closed dcousens closed 9 years ago

dcousens commented 9 years ago

I've written this function enough times :), why not? Eh @jprichardson haha

edit: Maybe wait out on https://github.com/crypto-browserify/buffer-xor/issues/1?

dcousens commented 9 years ago

It is interesting, because in other languages with a less verbose syntax, it might just be as simple as:

D-lang

int[3] c = a[] ^ b[]

Or say in Python w/ numpy:

c = numpy.bitwise_xor(a, b)

Or if there wasn't that overhead for functional idioms, and the lack of decent binary arrays in JS, using ES6:

c = a.map((x, i) => a[i] ^ b[i])

But, alas. We don't have these things, and this stuff can be finicky. So, what do?

It is 10 lines of code, that were previously untested in isolation, they are now tested and consistent.

coveralls commented 9 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 485242714e54f96ff6cb7463c77dd55484bbe0b1 on bufxor into 9c4af830f1ab5ff33604ac8888361ccec642920e on master.

dcousens commented 9 years ago

@jprichardson thoughts?

jprichardson commented 9 years ago

Yeah, I'm fine with it.