@ocap/mcrypto 1.27.16 → 1.28.1
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/esm/crypter/aes-legacy.d.ts +8 -6
- package/esm/crypter/aes-legacy.js +27 -24
- package/esm/crypter/aes.d.ts +9 -7
- package/esm/crypter/aes.js +27 -25
- package/esm/crypter/rsa-browserify.d.ts +7 -6
- package/esm/crypter/rsa-browserify.js +34 -31
- package/esm/crypter/rsa.d.ts +11 -9
- package/esm/crypter/rsa.js +31 -28
- package/esm/encode.d.ts +12 -8
- package/esm/encode.js +13 -18
- package/esm/hasher/keccak.d.ts +8 -5
- package/esm/hasher/keccak.js +37 -36
- package/esm/hasher/sha2.d.ts +8 -5
- package/esm/hasher/sha2.js +42 -40
- package/esm/hasher/sha3.d.ts +8 -5
- package/esm/hasher/sha3.js +37 -36
- package/esm/index.d.ts +148 -143
- package/esm/index.js +172 -209
- package/esm/protocols/crypter.d.ts +3 -1
- package/esm/protocols/crypter.js +7 -4
- package/esm/protocols/hasher.d.ts +3 -1
- package/esm/protocols/hasher.js +7 -4
- package/esm/protocols/signer.d.ts +3 -1
- package/esm/protocols/signer.js +7 -4
- package/esm/signer/ed25519.d.ts +49 -46
- package/esm/signer/ed25519.js +80 -80
- package/esm/signer/ethereum.d.ts +11 -8
- package/esm/signer/ethereum.js +34 -34
- package/esm/signer/passkey.d.ts +21 -18
- package/esm/signer/passkey.js +49 -58
- package/esm/signer/secp256k1.d.ts +35 -32
- package/esm/signer/secp256k1.js +80 -93
- package/lib/_virtual/rolldown_runtime.js +29 -0
- package/lib/crypter/aes-legacy.d.ts +8 -6
- package/lib/crypter/aes-legacy.js +35 -52
- package/lib/crypter/aes.d.ts +9 -7
- package/lib/crypter/aes.js +29 -29
- package/lib/crypter/rsa-browserify.d.ts +7 -6
- package/lib/crypter/rsa-browserify.js +36 -33
- package/lib/crypter/rsa.d.ts +11 -9
- package/lib/crypter/rsa.js +33 -32
- package/lib/encode.d.ts +12 -8
- package/lib/encode.js +14 -21
- package/lib/hasher/keccak.d.ts +8 -5
- package/lib/hasher/keccak.js +40 -41
- package/lib/hasher/sha2.d.ts +8 -5
- package/lib/hasher/sha2.js +43 -42
- package/lib/hasher/sha3.d.ts +8 -5
- package/lib/hasher/sha3.js +40 -41
- package/lib/index.d.ts +148 -143
- package/lib/index.js +177 -216
- package/lib/protocols/crypter.d.ts +3 -1
- package/lib/protocols/crypter.js +10 -9
- package/lib/protocols/hasher.d.ts +3 -1
- package/lib/protocols/hasher.js +10 -9
- package/lib/protocols/signer.d.ts +3 -1
- package/lib/protocols/signer.js +10 -9
- package/lib/signer/ed25519.d.ts +49 -46
- package/lib/signer/ed25519.js +85 -86
- package/lib/signer/ethereum.d.ts +11 -8
- package/lib/signer/ethereum.js +38 -39
- package/lib/signer/passkey.d.ts +21 -18
- package/lib/signer/passkey.js +51 -63
- package/lib/signer/secp256k1.d.ts +35 -32
- package/lib/signer/secp256k1.js +85 -99
- package/package.json +21 -10
package/lib/hasher/keccak.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { BytesType, EncodingType } from
|
|
1
|
+
import { BytesType, EncodingType } from "@ocap/util";
|
|
2
|
+
|
|
3
|
+
//#region src/hasher/keccak.d.ts
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
6
|
* Keccak support with different hash length
|
|
4
7
|
*
|
|
5
8
|
* @class KeccakHasher
|
|
6
9
|
*/
|
|
7
10
|
declare class KeccakHasher {
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
[x: string]: (data: BytesType, round?: number, encoding?: EncodingType) => BytesType;
|
|
12
|
+
constructor();
|
|
10
13
|
}
|
|
11
14
|
declare const _default: KeccakHasher;
|
|
12
|
-
|
|
13
|
-
export { KeccakHasher };
|
|
15
|
+
//#endregion
|
|
16
|
+
export { KeccakHasher, _default as default };
|
package/lib/hasher/keccak.js
CHANGED
|
@@ -1,43 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const util_1 = require("@ocap/util");
|
|
10
|
-
const encode_1 = require("../encode");
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
3
|
+
const require_encode = require('../encode.js');
|
|
4
|
+
let _ocap_util = require("@ocap/util");
|
|
5
|
+
let js_sha3 = require("js-sha3");
|
|
6
|
+
js_sha3 = require_rolldown_runtime.__toESM(js_sha3);
|
|
7
|
+
|
|
8
|
+
//#region src/hasher/keccak.ts
|
|
11
9
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
10
|
+
* Keccak support with different hash length
|
|
11
|
+
*
|
|
12
|
+
* @class KeccakHasher
|
|
13
|
+
*/
|
|
14
|
+
var KeccakHasher = class {
|
|
15
|
+
constructor() {
|
|
16
|
+
[
|
|
17
|
+
224,
|
|
18
|
+
256,
|
|
19
|
+
384,
|
|
20
|
+
512
|
|
21
|
+
].forEach((x) => {
|
|
22
|
+
const name = `hash${x}`;
|
|
23
|
+
const hasher = (data) => js_sha3.default[`keccak${x}`](data);
|
|
24
|
+
const hashFn = (input, round) => {
|
|
25
|
+
if (round === 1) return hasher(input);
|
|
26
|
+
return hashFn(hasher(input), round - 1);
|
|
27
|
+
};
|
|
28
|
+
this[name] = (data, round = 1, encoding = "hex") => {
|
|
29
|
+
let input = data;
|
|
30
|
+
try {
|
|
31
|
+
input = (0, _ocap_util.toUint8Array)(data);
|
|
32
|
+
} catch (err) {}
|
|
33
|
+
return require_encode.encode(`0x${hashFn(input, round)}`, encoding);
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var keccak_default = new KeccakHasher();
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
42
41
|
exports.KeccakHasher = KeccakHasher;
|
|
43
|
-
exports.default =
|
|
42
|
+
exports.default = keccak_default;
|
package/lib/hasher/sha2.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { BytesType, EncodingType } from
|
|
1
|
+
import { BytesType, EncodingType } from "@ocap/util";
|
|
2
|
+
|
|
3
|
+
//#region src/hasher/sha2.d.ts
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
6
|
* Sha2 support with different hash length
|
|
4
7
|
*
|
|
5
8
|
* @class
|
|
6
9
|
*/
|
|
7
10
|
declare class Sha2Hasher {
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
[x: string]: (data: BytesType, round?: number, encoding?: EncodingType) => BytesType;
|
|
12
|
+
constructor();
|
|
10
13
|
}
|
|
11
14
|
declare const _default: Sha2Hasher;
|
|
12
|
-
|
|
13
|
-
export { Sha2Hasher };
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Sha2Hasher, _default as default };
|
package/lib/hasher/sha2.js
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
3
|
+
const require_encode = require('../encode.js');
|
|
4
|
+
let _ocap_util = require("@ocap/util");
|
|
5
|
+
let hash_js = require("hash.js");
|
|
6
|
+
|
|
7
|
+
//#region src/hasher/sha2.ts
|
|
8
8
|
const hashFns = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
sha224: hash_js.sha224,
|
|
10
|
+
sha256: hash_js.sha256,
|
|
11
|
+
sha384: hash_js.sha384,
|
|
12
|
+
sha512: hash_js.sha512
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
15
|
+
* Sha2 support with different hash length
|
|
16
|
+
*
|
|
17
|
+
* @class
|
|
18
|
+
*/
|
|
19
|
+
var Sha2Hasher = class {
|
|
20
|
+
constructor() {
|
|
21
|
+
[
|
|
22
|
+
224,
|
|
23
|
+
256,
|
|
24
|
+
384,
|
|
25
|
+
512
|
|
26
|
+
].forEach((x) => {
|
|
27
|
+
const name = `hash${x}`;
|
|
28
|
+
const hasher = hashFns[`sha${x}`];
|
|
29
|
+
const hashFn = (input, round) => {
|
|
30
|
+
let inputBytes = input;
|
|
31
|
+
try {
|
|
32
|
+
inputBytes = (0, _ocap_util.toUint8Array)(input);
|
|
33
|
+
} catch (err) {}
|
|
34
|
+
if (round === 1) return `0x${hasher().update(inputBytes).digest("hex")}`;
|
|
35
|
+
return hashFn(hashFn(inputBytes, 1), round - 1);
|
|
36
|
+
};
|
|
37
|
+
this[name] = (data, round = 2, encoding = "hex") => {
|
|
38
|
+
return require_encode.encode(hashFn(data, round), encoding);
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var sha2_default = new Sha2Hasher();
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
45
46
|
exports.Sha2Hasher = Sha2Hasher;
|
|
46
|
-
exports.default =
|
|
47
|
+
exports.default = sha2_default;
|
package/lib/hasher/sha3.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { BytesType, EncodingType } from
|
|
1
|
+
import { BytesType, EncodingType } from "@ocap/util";
|
|
2
|
+
|
|
3
|
+
//#region src/hasher/sha3.d.ts
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
6
|
* Sha3 support with different hash length
|
|
4
7
|
*
|
|
5
8
|
* @class Sha3Hasher
|
|
6
9
|
*/
|
|
7
10
|
declare class Sha3Hasher {
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
[x: string]: (data: BytesType, round?: number, encoding?: EncodingType) => BytesType;
|
|
12
|
+
constructor();
|
|
10
13
|
}
|
|
11
14
|
declare const _default: Sha3Hasher;
|
|
12
|
-
|
|
13
|
-
export { Sha3Hasher };
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Sha3Hasher, _default as default };
|
package/lib/hasher/sha3.js
CHANGED
|
@@ -1,43 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const encode_1 = require("../encode");
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
3
|
+
const require_encode = require('../encode.js');
|
|
4
|
+
let _ocap_util = require("@ocap/util");
|
|
5
|
+
let js_sha3 = require("js-sha3");
|
|
6
|
+
js_sha3 = require_rolldown_runtime.__toESM(js_sha3);
|
|
7
|
+
|
|
8
|
+
//#region src/hasher/sha3.ts
|
|
10
9
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
10
|
+
* Sha3 support with different hash length
|
|
11
|
+
*
|
|
12
|
+
* @class Sha3Hasher
|
|
13
|
+
*/
|
|
14
|
+
var Sha3Hasher = class {
|
|
15
|
+
constructor() {
|
|
16
|
+
[
|
|
17
|
+
224,
|
|
18
|
+
256,
|
|
19
|
+
384,
|
|
20
|
+
512
|
|
21
|
+
].forEach((x) => {
|
|
22
|
+
const name = `hash${x}`;
|
|
23
|
+
const hasher = js_sha3.default[`sha3_${x}`];
|
|
24
|
+
const hashFn = (input, round) => {
|
|
25
|
+
if (round === 1) return hasher(input);
|
|
26
|
+
return hashFn(hasher(input), round - 1);
|
|
27
|
+
};
|
|
28
|
+
this[name] = (data, round = 1, encoding = "hex") => {
|
|
29
|
+
let input = data;
|
|
30
|
+
try {
|
|
31
|
+
input = (0, _ocap_util.toUint8Array)(data);
|
|
32
|
+
} catch (err) {}
|
|
33
|
+
return require_encode.encode(`0x${hashFn(input, round)}`, encoding);
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var sha3_default = new Sha3Hasher();
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
42
41
|
exports.Sha3Hasher = Sha3Hasher;
|
|
43
|
-
exports.default =
|
|
42
|
+
exports.default = sha3_default;
|