Compare commits

..

5 Commits

7 changed files with 54 additions and 36 deletions

13
.buildbot/node/Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM node:16
RUN apt-get update
RUN apt-get install -yq --no-install-suggests --no-install-recommends xauth xvfb
WORKDIR /app
ADD src ./src
COPY package*.json binding.gyp ./
RUN npm install
# RUN npm audit fix
COPY . .

6
.buildbot/node/build.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/sh
mkdir -p ../out
cp package*.json ../out
npm pack
mv *.tgz ../out/

3
.buildbot/node/test.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
npm test

3
docker-test.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
docker build --tag bitmessage-js -f .buildbot/node/Dockerfile .
docker run -it --rm bitmessage-js:latest .buildbot/node/test.sh

View File

@ -104,17 +104,15 @@ var encrypted = exports.encrypted = {
assert(buf.readUInt16BE(16, true) === SECP256K1_TYPE, "Bad curve type");
assert(buf.readUInt16BE(18, true) === 32, "Bad Rx length");
assert(buf.readUInt16BE(52, true) === 32, "Bad Ry length");
var iv = new Buffer(16);
var iv = Buffer.alloc(16);
buf.copy(iv, 0, 0, 16);
var ephemPublicKey = new Buffer(65);
ephemPublicKey[0] = 0x04;
buf.copy(ephemPublicKey, 1, 20, 52);
buf.copy(ephemPublicKey, 33, 54, 86);
var ephemPublicKey = Buffer.alloc(70);
buf.copy(ephemPublicKey, 0, 16, 86);
// NOTE(Kagami): We do copy instead of slice to protect against
// possible source buffer modification by user.
var ciphertext = new Buffer(buf.length - 118);
var ciphertext = Buffer.alloc(buf.length - 118);
buf.copy(ciphertext, 0, 86, buf.length - 32);
var mac = new Buffer(32);
var mac = Buffer.alloc(32);
buf.copy(mac, 0, buf.length - 32);
return {
iv: iv,
@ -126,19 +124,13 @@ var encrypted = exports.encrypted = {
encode: function(opts) {
assert(opts.iv.length === 16, "Bad IV");
assert(opts.ephemPublicKey.length === 65, "Bad public key");
assert(opts.ephemPublicKey.length === 70, "Bad public key");
assert(
opts.ephemPublicKey.readUInt16BE(0, true) === SECP256K1_TYPE,
"Bad curve type");
assert(opts.mac.length === 32, "Bad MAC");
// 16 + 2 + 2 + 32 + 2 + 32 + ? + 32
var buf = new Buffer(118 + opts.ciphertext.length);
opts.iv.copy(buf);
buf.writeUInt16BE(SECP256K1_TYPE, 16, true); // Curve type
buf.writeUInt16BE(32, 18, true); // Rx length
opts.ephemPublicKey.copy(buf, 20, 1, 33); // Rx
buf.writeUInt16BE(32, 52, true); // Ry length
opts.ephemPublicKey.copy(buf, 54, 33); // Ry
opts.ciphertext.copy(buf, 86);
opts.mac.copy(buf, 86 + opts.ciphertext.length);
return buf;
return Buffer.concat(
[opts.iv, opts.ephemPublicKey, opts.ciphertext, opts.mac])
},
};

View File

@ -1,6 +1,6 @@
{
"name": "bitmessage",
"version": "0.6.6",
"name": "@bitmessage/bitmessage",
"version": "0.6.7",
"description": "JavaScript Bitmessage library",
"main": "./lib/index.js",
"browser": {
@ -18,7 +18,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/bitchan/bitmessage.git"
"url": "https://git.bitmessage.org/lee.miller/bitmessage-js.git"
},
"keywords": [
"bitmessage",
@ -29,28 +29,29 @@
"author": "Kagami Hiiragi",
"license": "CC0-1.0",
"bugs": {
"url": "https://github.com/bitchan/bitmessage/issues"
"url": "https://git.bitmessage.org/lee.miller/bitmessage-js/issues"
},
"homepage": "https://github.com/bitchan/bitmessage",
"homepage": "https://git.bitmessage.org/lee.miller/bitmessage-js",
"devDependencies": {
"browserify": "16.5.0",
"chai": "*",
"jsdoc": "^3.3.2",
"jshint": "*",
"karma": "^0.12.31",
"karma-browserify": "^2.0.0",
"karma-chrome-launcher": "^0.1.7",
"karma-cli": "~0.0.4",
"karma": "6.4.1",
"karma-browserify": "8.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-cli": "2.0.0",
"karma-env-preprocessor": "^0.1.0",
"karma-firefox-launcher": "^0.1.4",
"karma-mocha": "^0.1.10",
"karma-mocha-reporter": "^0.3.1",
"karma-firefox-launcher": "1.2.0",
"karma-mocha": "2.0.1",
"karma-mocha-reporter": "2.2.5",
"mocha": "*"
},
"dependencies": {
"bn.js": "^3.0.1",
"bs58": "^2.0.0",
"buffer-equal": "~0.0.1",
"eccrypto": "^1.0.3",
"eccrypto": "git+https://git.bitmessage.org/Bitmessage/eccrypto.git#tests",
"es6-promise": "^3.0.2",
"hash.js": "^1.0.2",
"nan": "^2.1.0",
@ -59,6 +60,6 @@
"webworkify": "^1.0.1"
},
"optionalDependencies": {
"bignum": "^0.11.0"
"bignum": "^0.13.1"
}
}

View File

@ -2,7 +2,7 @@
#include <nan.h>
#include "./pow.h"
using v8::Handle;
// using v8::Handle;
using v8::Local;
using v8::FunctionTemplate;
using v8::Function;
@ -71,8 +71,8 @@ NAN_METHOD(PowAsync) {
return Nan::ThrowError("Bad input");
}
size_t pool_size = info[0]->Uint32Value();
uint64_t target = info[1]->IntegerValue();
size_t pool_size = (size_t)Nan::To<uint32_t>(info[0]).FromJust();
uint64_t target = Nan::To<int64_t>(info[1]).FromJust();
char* buf = node::Buffer::Data(info[2]);
size_t length = node::Buffer::Length(info[2]);
if (pool_size < 1 ||