ntzwrk / blockstack.ts

work in progress, please check back later
MIT License
10 stars 1 forks source link

Can `encryptECIES()` take a Buffer as input? #10

Closed vsund closed 6 years ago

vsund commented 6 years ago

In https://github.com/ntzwrk/blockstack.ts/commit/ae6bc6015fe2e3c5edbb414badc2f74c97e2b7b2 I fixed a potential doubly buffered input (content can be either string or Buffer, but the constructor of Buffer only takes string as input type). Wondering now what would happen if new Buffer() gets a Buffer as input. Should we fix this in blockstack.js or does this work?

vsund commented 6 years ago

Fixed an error with this solution in https://github.com/ntzwrk/blockstack.ts/commit/d677b248e257ff861bd004c042fa5fe17fa5de2a

kantai commented 6 years ago

It's deprecated (like other Buffer constructors), but Buffers can take buffers as inputs. It just makes a copy: https://nodejs.org/api/buffer.html#buffer_new_buffer_buffer

vsund commented 6 years ago

Ah ok, thanks! Since it's deprecated, should I raise a PR against blockstack.js or leave it as it is?

kantai commented 6 years ago

You can raise a PR -- should be a pretty direct conversion to just using the Buffer.from()

vsund commented 6 years ago

Thanks, did so: https://github.com/blockstack/blockstack.js/pull/395