-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split library into modules #20
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crypto_stream.js
Outdated
exports.crypto_stream = function (out, nonce, key) { | ||
out.fill(0) | ||
exports.crypto_stream_xor(out, out, nonce, key) | ||
exports.crypto_stream = function (c, cpos, clen, nonce, key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see a4cab9d
Looks great! Now we have them split we can start cleaning up. Stuff like |
@emilbayes we have ensure endianess also yes? |
Oh yeah, let's make issues |
depends on #21
|
I think we should just fail on BE for now, globally |
crypto_verify.js
Outdated
} | ||
|
||
function sodium_memcmp (a, b) { | ||
assert(a.byteLength = b.byteLength, 'buffers must be the same size') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am just a casual observer of this PR as I am excited about this! but it looks like the equality comparison is missing another =
character here, unless I am missing something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! fixed in 56416de
crypto_aead.js
Outdated
function write64LE (buf, int) { | ||
buf.fill(0, 0, 8) | ||
buf.writeUInt32LE(int & 0xffffffff) | ||
buf.writeUInt32LE((int >> 32) & 0xffffffff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this is buffer only
crypto_box.js
Outdated
|
||
const hash = Buffer.alloc(64) | ||
crypto_hash_sha512(hash, seed, 32) | ||
hash.copy(sk, 0, 0, 32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use .set to copy sk.set(hash, ) with typedarrays
|
||
function crypto_sign_seed_keypair (pk, sk, seed) { | ||
check(seed, crypto_sign_SEEDBYTES) | ||
seed.copy(sk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use sk.set(seed)
crypto_aead.js
Outdated
|
||
var ret = -1 | ||
|
||
if (c.length >= crypto_aead_chacha20poly1305_ietf_ABYTES) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can return early here instead of a nested conditional perhaps?
crypto_aead.js
Outdated
crypto_stream_chacha20_ietf_xor_ic(m, c, npub, 1, k) | ||
return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct?
No description provided.