ssbc / chloride

MIT License
90 stars 17 forks source link

Converting ed25519 does not throw in browser #3

Open emilbayes opened 7 years ago

emilbayes commented 7 years ago

Consider the following snippet:

var sodium = require('chloride')

// crypto_sign_SEEDBYTES is missing too

var seed = Buffer.alloc(sodium.crypto_sign_SEEDBYTES || 32).fill('bug')

var keypair = sodium.crypto_sign_seed_keypair(seed)

var box_pk = sodium.crypto_sign_ed25519_pk_to_curve25519(keypair.secretKey)

console.log(box_pk)

In node the above throws an error due to the input being too long (here the secretKey is mistakenly used) but in the browser it happily continues. I'm not sure where to report this? Should I ensure the input myself instead?

emilbayes commented 7 years ago

Oh yeah, here are the commands I used to test, just for reference

Node:

node bug.js

Browser:

browserify bug.js | browser-run
dominictarr commented 7 years ago

okay, what we should do, is extend https://github.com/dominictarr/chloride-test to also test for throws with invalid inputs. then make sure that everything does.

emilbayes commented 7 years ago

Do you want me to look into that? There are some other compatibility issues between the browser versions and node-sodium that I'm unsure about. Is there a better place to ask questions than here?

dominictarr commented 7 years ago

well, you'll get me either way, but that is where we should lock down the behavior. if they are not exactly the same then that is a bug!

emilbayes commented 7 years ago

Hehe, I was thinking another venue than Github. IRC? I'm active on #stackvm and #scuttlebutt

dominictarr commented 7 years ago

ah, well I don't really keep regular hours so async (github, ssb) works best for me