pkg: upgrade n64.

This commit is contained in:
Christopher Jeffrey 2017-08-15 18:47:34 -07:00
parent 2ce2f1f9f7
commit f9eca70374
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 12 additions and 12 deletions

View File

@ -7,11 +7,11 @@
'use strict';
const assert = require('assert');
const Int64 = require('./int64');
const {U64} = require('./int64');
const digest = require('../crypto/digest');
const siphash = require('../crypto/siphash');
const DUMMY = Buffer.alloc(0);
const EOF = new Int64(-1);
const EOF = new U64(-1);
/**
* GCSFilter
@ -22,7 +22,7 @@ const EOF = new Int64(-1);
function GCSFilter() {
this.n = 0;
this.p = 0;
this.m = new Int64(0);
this.m = new U64(0);
this.data = DUMMY;
}
@ -38,7 +38,7 @@ GCSFilter.prototype.header = function header(prev) {
GCSFilter.prototype.match = function match(key, data) {
const br = new BitReader(this.data);
const term = siphash24(data, key).imod(this.m);
let last = new Int64(0);
let last = new U64(0);
while (last.lt(term)) {
const value = this.readU64(br);
@ -61,7 +61,7 @@ GCSFilter.prototype.matchAny = function matchAny(key, items) {
assert(items.length > 0);
const br = new BitReader(this.data);
const last1 = new Int64(0);
const last1 = new U64(0);
const values = [];
for (const item of items) {
@ -111,7 +111,7 @@ GCSFilter.prototype.readU64 = function readU64(br) {
};
GCSFilter.prototype._readU64 = function _readU64(br) {
const num = new Int64(0);
const num = new U64(0);
// Unary
while (br.readBit())
@ -166,7 +166,7 @@ GCSFilter.prototype.fromItems = function fromItems(P, key, items) {
this.n = items.length;
this.p = P;
this.m = Int64(this.n).ishln(this.p);
this.m = U64(this.n).ishln(this.p);
const values = [];
@ -179,7 +179,7 @@ GCSFilter.prototype.fromItems = function fromItems(P, key, items) {
values.sort(compare);
const bw = new BitWriter();
let last = new Int64(0);
let last = new U64(0);
for (const hash of values) {
const rem = hash.sub(last).imaskn(this.p);
@ -210,7 +210,7 @@ GCSFilter.prototype.fromBytes = function fromBytes(N, P, data) {
this.n = N;
this.p = P;
this.m = Int64(this.n).ishln(this.p);
this.m = U64(this.n).ishln(this.p);
this.data = data;
return this;
@ -490,7 +490,7 @@ BitReader.prototype.readBits64 = function readBits64(count) {
assert(count >= 0);
assert(count <= 64);
const num = new Int64();
const num = new U64();
if (count > 32) {
num.hi = this.readBits(count - 32);
@ -512,7 +512,7 @@ function compare(a, b) {
function siphash24(data, key) {
const [hi, lo] = siphash(data, key);
return new Int64().join(hi, lo);
return U64.fromBits(hi, lo);
}
function getPushes(items, script) {

View File

@ -25,7 +25,7 @@
"dependencies": {
"bn.js": "4.11.7",
"elliptic": "6.4.0",
"n64": "0.0.13"
"n64": "0.0.14"
},
"optionalDependencies": {
"bcoin-native": "0.0.23",