@li0ard/dstu 0.1.4 → 0.1.6
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/README.md +4 -1
- package/dstu4145/const.d.ts +2 -0
- package/dstu4145/const.js +17 -0
- package/dstu4145/ec/expand.js +3 -4
- package/dstu4145/ec/index.d.ts +12 -27
- package/dstu4145/ec/index.js +91 -40
- package/dstu4145/ec/math.d.ts +3 -0
- package/dstu4145/ec/math.js +21 -13
- package/dstu4145/ec/onb.js +6 -6
- package/dstu4145/ec/wnaf.js +1 -1
- package/dstu4145/index.d.ts +11 -0
- package/dstu4145/index.js +15 -1
- package/dstu9041/curve.d.ts +431 -0
- package/dstu9041/curve.js +132 -0
- package/dstu9041/index.d.ts +21 -0
- package/dstu9041/index.js +98 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/kupyna/index.js +2 -1
- package/kupyna/kmac.js +2 -1
- package/modes/cbc.js +6 -8
- package/modes/cfb.js +24 -31
- package/modes/ctr.js +2 -2
- package/modes/ecb.js +2 -2
- package/modes/gcm.js +14 -16
- package/modes/index.d.ts +2 -0
- package/modes/index.js +2 -0
- package/modes/kw.d.ts +7 -0
- package/modes/kw.js +79 -0
- package/modes/mac.js +55 -59
- package/modes/ofb.js +3 -4
- package/modes/xts.d.ts +7 -0
- package/modes/xts.js +82 -0
- package/package.json +3 -1
- package/strumok/index.d.ts +4 -3
- package/strumok/index.js +42 -277
- package/utils.d.ts +1 -7
- package/utils.js +1 -23
package/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bytesToNumberBE, bytesToNumberLE, numberToBytesBE, numberToBytesLE } from "@noble/curves/utils.js";
|
|
2
2
|
export const xorBytes = (a, b) => {
|
|
3
3
|
const mlen = Math.min(a.length, b.length);
|
|
4
4
|
const result = new Uint8Array(mlen);
|
|
@@ -32,20 +32,6 @@ export const uint64sToBytesLE = (w) => {
|
|
|
32
32
|
result.set(numberToBytesLE(w[i], 8), i * 8);
|
|
33
33
|
return result;
|
|
34
34
|
};
|
|
35
|
-
export const hexToNumber = (hex) => {
|
|
36
|
-
if (typeof hex !== 'string')
|
|
37
|
-
throw new Error('hex string expected, got ' + typeof hex);
|
|
38
|
-
return hex === '' ? 0n : BigInt('0x' + hex);
|
|
39
|
-
};
|
|
40
|
-
export const bytesToNumberBE = (bytes) => hexToNumber(bytesToHex(bytes));
|
|
41
|
-
export const numberToBytesBE = (n, len) => {
|
|
42
|
-
let num = n.toString(16).padStart(len * 2, '0');
|
|
43
|
-
while (num.length % 2 != 0)
|
|
44
|
-
num = "0" + num;
|
|
45
|
-
return hexToBytes(num);
|
|
46
|
-
};
|
|
47
|
-
export const bytesToNumberLE = (bytes) => hexToNumber(bytesToHex(copyBytes(bytes).reverse()));
|
|
48
|
-
export const numberToBytesLE = (n, len) => numberToBytesBE(n, len).reverse();
|
|
49
35
|
export const byte = (a) => Number(a & 0xffn);
|
|
50
36
|
export const gf2mMul = (blockSize, a, b) => {
|
|
51
37
|
const temp = new Uint8Array(a);
|
|
@@ -71,11 +57,3 @@ export const gf2mMul = (blockSize, a, b) => {
|
|
|
71
57
|
}
|
|
72
58
|
return result;
|
|
73
59
|
};
|
|
74
|
-
export const equalBytes = (a, b) => {
|
|
75
|
-
if (a.length !== b.length)
|
|
76
|
-
return false;
|
|
77
|
-
let diff = 0;
|
|
78
|
-
for (let i = 0; i < a.length; i++)
|
|
79
|
-
diff |= a[i] ^ b[i];
|
|
80
|
-
return diff === 0;
|
|
81
|
-
};
|