Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
426ca77d47 | ||
|
|
25c97802f4 | ||
|
|
87ff2a56bd | ||
|
|
7ef6e52870 | ||
|
|
0227f45c6b | ||
|
|
ca32540960 |
@@ -1 +1,2 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
package-lock.json
|
||||||
|
|||||||
+1
-1
@@ -452,7 +452,7 @@ function crypto_sign_ed25519_sk_to_curve25519 (curveSk, edSk) {
|
|||||||
assert(curveSk && curveSk.byteLength === crypto_scalarmult_BYTES, "curveSk must be 'crypto_sign_SECRETKEYBYTES' long")
|
assert(curveSk && curveSk.byteLength === crypto_scalarmult_BYTES, "curveSk must be 'crypto_sign_SECRETKEYBYTES' long")
|
||||||
assert(edSk && edSk.byteLength === crypto_sign_ed25519_SECRETKEYBYTES, "edSk must be 'crypto_sign_ed25519_SECRETKEYBYTES' long")
|
assert(edSk && edSk.byteLength === crypto_sign_ed25519_SECRETKEYBYTES, "edSk must be 'crypto_sign_ed25519_SECRETKEYBYTES' long")
|
||||||
|
|
||||||
var h = Buffer.alloc(crypto_hash_sha512_BYTES)
|
var h = new Uint8Array(crypto_hash_sha512_BYTES)
|
||||||
crypto_hash(h, edSk, 32)
|
crypto_hash(h, edSk, 32)
|
||||||
|
|
||||||
h[0] &= 248
|
h[0] &= 248
|
||||||
|
|||||||
@@ -1,21 +1,28 @@
|
|||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
var MessageChannel = global.MessageChannel
|
|
||||||
if (MessageChannel == null) ({ MessageChannel } = require('worker' + '_threads'))
|
|
||||||
|
|
||||||
function sodium_malloc (n) {
|
function sodium_malloc (n) {
|
||||||
return new Uint8Array(n)
|
return new Uint8Array(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
const sink = new MessageChannel()
|
|
||||||
function sodium_free (n) {
|
function sodium_free (n) {
|
||||||
sodium_memzero(n)
|
sodium_memzero(n)
|
||||||
sink.port1.postMessage(n.buffer, [n.buffer])
|
loadSink().port1.postMessage(n.buffer, [n.buffer])
|
||||||
}
|
}
|
||||||
|
|
||||||
function sodium_memzero (arr) {
|
function sodium_memzero (arr) {
|
||||||
arr.fill(0)
|
arr.fill(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sink
|
||||||
|
|
||||||
|
function loadSink () {
|
||||||
|
if (sink) return sink
|
||||||
|
var MessageChannel = globalThis.MessageChannel
|
||||||
|
if (MessageChannel == null) ({ MessageChannel } = require('worker' + '_threads'))
|
||||||
|
sink = new MessageChannel()
|
||||||
|
return sink
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
sodium_malloc,
|
sodium_malloc,
|
||||||
sodium_free,
|
sodium_free,
|
||||||
|
|||||||
+2
-5
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sodium-javascript",
|
"name": "sodium-javascript",
|
||||||
"version": "0.7.2",
|
"version": "0.7.4",
|
||||||
"description": "WIP - a pure javascript version of sodium-native",
|
"description": "WIP - a pure javascript version of sodium-native",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"browserify": "^16.5.1",
|
"browserify": "^16.5.1",
|
||||||
"sodium-test": "^0.10.0",
|
"sodium-test": "^0.10.0",
|
||||||
"standard": "^14.3.4",
|
"standard": "^15.0.1",
|
||||||
"tape-run": "^7.0.0"
|
"tape-run": "^7.0.0"
|
||||||
},
|
},
|
||||||
"standard": {
|
"standard": {
|
||||||
@@ -27,9 +27,6 @@
|
|||||||
"crypto": false,
|
"crypto": false,
|
||||||
"worker_threads": false
|
"worker_threads": false
|
||||||
},
|
},
|
||||||
"react-native": {
|
|
||||||
"crypto": "crypto"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"pretest": "standard",
|
"pretest": "standard",
|
||||||
"test": "node test.js",
|
"test": "node test.js",
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ var assert = require('nanoassert')
|
|||||||
|
|
||||||
var randombytes = (function () {
|
var randombytes = (function () {
|
||||||
var QUOTA = 65536 // limit for QuotaExceededException
|
var QUOTA = 65536 // limit for QuotaExceededException
|
||||||
var crypto = global.crypto || global.msCrypto
|
var crypto = globalThis.crypto || globalThis.msCrypto
|
||||||
|
|
||||||
function browserBytes (out, n) {
|
function browserBytes (out, n) {
|
||||||
for (let i = 0; i < n; i += QUOTA) {
|
for (let i = 0; i < n; i += QUOTA) {
|
||||||
|
|||||||
Reference in New Issue
Block a user