mol_crypto_lib 0.1.1222 → 0.1.1223
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node.deps.json +1 -1
- package/node.js +52 -25
- package/node.js.map +1 -1
- package/node.mjs +52 -25
- package/node.test.js +60 -29
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.deps.json +1 -1
- package/web.js +52 -25
- package/web.js.map +1 -1
- package/web.mjs +52 -25
- package/web.test.js +8 -4
- package/web.test.js.map +1 -1
package/node.mjs
CHANGED
@@ -1414,34 +1414,61 @@ var $;
|
|
1414
1414
|
let h2 = hash[2];
|
1415
1415
|
let h3 = hash[3];
|
1416
1416
|
let h4 = hash[4];
|
1417
|
-
for (let j = 0; j <
|
1418
|
-
|
1419
|
-
if (
|
1420
|
-
|
1421
|
-
if (k === klens) {
|
1422
|
-
sponge[j] = bits;
|
1423
|
-
}
|
1424
|
-
else {
|
1425
|
-
let word = k === words.length ? tail :
|
1426
|
-
k > words.length ? 0 :
|
1427
|
-
words[k];
|
1428
|
-
word = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF;
|
1429
|
-
if (k === kbits)
|
1430
|
-
word |= kword;
|
1431
|
-
sponge[j] = word;
|
1432
|
-
}
|
1433
|
-
turn = (h1 & h2 | ~h1 & h3) + 1518500249;
|
1417
|
+
for (let j = 0; j < 16; ++j) {
|
1418
|
+
const k = i + j;
|
1419
|
+
if (k === klens) {
|
1420
|
+
sponge[j] = bits;
|
1434
1421
|
}
|
1435
1422
|
else {
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1423
|
+
let word = k === words.length ? tail :
|
1424
|
+
k > words.length ? 0 :
|
1425
|
+
words[k];
|
1426
|
+
word = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF;
|
1427
|
+
if (k === kbits)
|
1428
|
+
word |= kword;
|
1429
|
+
sponge[j] = word;
|
1443
1430
|
}
|
1444
|
-
const next =
|
1431
|
+
const next = ((h1 & h2 | ~h1 & h3) + 1518500249 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27)));
|
1432
|
+
h4 = h3;
|
1433
|
+
h3 = h2;
|
1434
|
+
h2 = (h1 << 30) | (h1 >>> 2);
|
1435
|
+
h1 = h0;
|
1436
|
+
h0 = next;
|
1437
|
+
}
|
1438
|
+
for (let j = 16; j < 20; ++j) {
|
1439
|
+
const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16];
|
1440
|
+
sponge[j] = shuffle << 1 | shuffle >>> 31;
|
1441
|
+
const next = ((h1 & h2 | ~h1 & h3) + 1518500249 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27)));
|
1442
|
+
h4 = h3;
|
1443
|
+
h3 = h2;
|
1444
|
+
h2 = (h1 << 30) | (h1 >>> 2);
|
1445
|
+
h1 = h0;
|
1446
|
+
h0 = next;
|
1447
|
+
}
|
1448
|
+
for (let j = 20; j < 40; ++j) {
|
1449
|
+
const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16];
|
1450
|
+
sponge[j] = shuffle << 1 | shuffle >>> 31;
|
1451
|
+
const next = ((h1 ^ h2 ^ h3) + 1859775393 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27)));
|
1452
|
+
h4 = h3;
|
1453
|
+
h3 = h2;
|
1454
|
+
h2 = (h1 << 30) | (h1 >>> 2);
|
1455
|
+
h1 = h0;
|
1456
|
+
h0 = next;
|
1457
|
+
}
|
1458
|
+
for (let j = 40; j < 60; ++j) {
|
1459
|
+
const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16];
|
1460
|
+
sponge[j] = shuffle << 1 | shuffle >>> 31;
|
1461
|
+
const next = ((h1 & h2 | h1 & h3 | h2 & h3) - 1894007588 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27)));
|
1462
|
+
h4 = h3;
|
1463
|
+
h3 = h2;
|
1464
|
+
h2 = (h1 << 30) | (h1 >>> 2);
|
1465
|
+
h1 = h0;
|
1466
|
+
h0 = next;
|
1467
|
+
}
|
1468
|
+
for (let j = 60; j < 80; ++j) {
|
1469
|
+
const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16];
|
1470
|
+
sponge[j] = shuffle << 1 | shuffle >>> 31;
|
1471
|
+
const next = ((h1 ^ h2 ^ h3) - 899497514 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27)));
|
1445
1472
|
h4 = h3;
|
1446
1473
|
h3 = h2;
|
1447
1474
|
h2 = (h1 << 30) | (h1 >>> 2);
|
package/node.test.js
CHANGED
@@ -1405,34 +1405,61 @@ var $;
|
|
1405
1405
|
let h2 = hash[2];
|
1406
1406
|
let h3 = hash[3];
|
1407
1407
|
let h4 = hash[4];
|
1408
|
-
for (let j = 0; j <
|
1409
|
-
|
1410
|
-
if (
|
1411
|
-
|
1412
|
-
if (k === klens) {
|
1413
|
-
sponge[j] = bits;
|
1414
|
-
}
|
1415
|
-
else {
|
1416
|
-
let word = k === words.length ? tail :
|
1417
|
-
k > words.length ? 0 :
|
1418
|
-
words[k];
|
1419
|
-
word = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF;
|
1420
|
-
if (k === kbits)
|
1421
|
-
word |= kword;
|
1422
|
-
sponge[j] = word;
|
1423
|
-
}
|
1424
|
-
turn = (h1 & h2 | ~h1 & h3) + 1518500249;
|
1408
|
+
for (let j = 0; j < 16; ++j) {
|
1409
|
+
const k = i + j;
|
1410
|
+
if (k === klens) {
|
1411
|
+
sponge[j] = bits;
|
1425
1412
|
}
|
1426
1413
|
else {
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1414
|
+
let word = k === words.length ? tail :
|
1415
|
+
k > words.length ? 0 :
|
1416
|
+
words[k];
|
1417
|
+
word = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF;
|
1418
|
+
if (k === kbits)
|
1419
|
+
word |= kword;
|
1420
|
+
sponge[j] = word;
|
1434
1421
|
}
|
1435
|
-
const next =
|
1422
|
+
const next = ((h1 & h2 | ~h1 & h3) + 1518500249 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27)));
|
1423
|
+
h4 = h3;
|
1424
|
+
h3 = h2;
|
1425
|
+
h2 = (h1 << 30) | (h1 >>> 2);
|
1426
|
+
h1 = h0;
|
1427
|
+
h0 = next;
|
1428
|
+
}
|
1429
|
+
for (let j = 16; j < 20; ++j) {
|
1430
|
+
const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16];
|
1431
|
+
sponge[j] = shuffle << 1 | shuffle >>> 31;
|
1432
|
+
const next = ((h1 & h2 | ~h1 & h3) + 1518500249 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27)));
|
1433
|
+
h4 = h3;
|
1434
|
+
h3 = h2;
|
1435
|
+
h2 = (h1 << 30) | (h1 >>> 2);
|
1436
|
+
h1 = h0;
|
1437
|
+
h0 = next;
|
1438
|
+
}
|
1439
|
+
for (let j = 20; j < 40; ++j) {
|
1440
|
+
const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16];
|
1441
|
+
sponge[j] = shuffle << 1 | shuffle >>> 31;
|
1442
|
+
const next = ((h1 ^ h2 ^ h3) + 1859775393 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27)));
|
1443
|
+
h4 = h3;
|
1444
|
+
h3 = h2;
|
1445
|
+
h2 = (h1 << 30) | (h1 >>> 2);
|
1446
|
+
h1 = h0;
|
1447
|
+
h0 = next;
|
1448
|
+
}
|
1449
|
+
for (let j = 40; j < 60; ++j) {
|
1450
|
+
const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16];
|
1451
|
+
sponge[j] = shuffle << 1 | shuffle >>> 31;
|
1452
|
+
const next = ((h1 & h2 | h1 & h3 | h2 & h3) - 1894007588 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27)));
|
1453
|
+
h4 = h3;
|
1454
|
+
h3 = h2;
|
1455
|
+
h2 = (h1 << 30) | (h1 >>> 2);
|
1456
|
+
h1 = h0;
|
1457
|
+
h0 = next;
|
1458
|
+
}
|
1459
|
+
for (let j = 60; j < 80; ++j) {
|
1460
|
+
const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16];
|
1461
|
+
sponge[j] = shuffle << 1 | shuffle >>> 31;
|
1462
|
+
const next = ((h1 ^ h2 ^ h3) - 899497514 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27)));
|
1436
1463
|
h4 = h3;
|
1437
1464
|
h3 = h2;
|
1438
1465
|
h2 = (h1 << 30) | (h1 >>> 2);
|
@@ -3049,16 +3076,20 @@ var $;
|
|
3049
3076
|
(function ($) {
|
3050
3077
|
$mol_test({
|
3051
3078
|
'empty hash'() {
|
3052
|
-
$
|
3079
|
+
$mol_assert_equal($mol_crypto_hash(new Uint8Array([])), new Uint8Array([218, 57, 163, 238, 94, 107, 75, 13, 50, 85, 191, 239, 149, 96, 24, 144, 175, 216, 7, 9]));
|
3053
3080
|
},
|
3054
3081
|
'three bytes hash'() {
|
3055
|
-
$
|
3082
|
+
$mol_assert_equal($mol_crypto_hash(new Uint8Array([255, 254, 253])), new Uint8Array([240, 150, 38, 243, 255, 128, 96, 0, 72, 215, 207, 228, 19, 149, 113, 52, 2, 125, 27, 77]));
|
3056
3083
|
},
|
3057
3084
|
'six bytes hash'() {
|
3058
|
-
$
|
3085
|
+
$mol_assert_equal($mol_crypto_hash(new Uint8Array([0, 255, 10, 250, 32, 128])), new Uint8Array([23, 25, 155, 181, 46, 200, 221, 83, 254, 0, 166, 68, 91, 255, 67, 140, 114, 88, 218, 155]));
|
3059
3086
|
},
|
3060
3087
|
'seven bytes hash'() {
|
3061
|
-
$
|
3088
|
+
$mol_assert_equal($mol_crypto_hash(new Uint8Array([1, 2, 3, 4, 5, 6, 7])), new Uint8Array([140, 31, 40, 252, 47, 72, 194, 113, 214, 196, 152, 240, 242, 73, 205, 222, 54, 92, 84, 197]));
|
3089
|
+
},
|
3090
|
+
async 'reference'() {
|
3091
|
+
const data = new Uint8Array([255, 254, 253]);
|
3092
|
+
$mol_assert_equal($mol_crypto_hash(data), new Uint8Array(await $mol_crypto_native.subtle.digest('SHA-1', data)));
|
3062
3093
|
},
|
3063
3094
|
});
|
3064
3095
|
})($ || ($ = {}));
|