shogun-core 6.2.3 → 6.3.0
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/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js +93 -341
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js.map +1 -1
- package/dist/browser/shogun-core.js +138850 -146638
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/{core.js → src/core.js} +167 -107
- package/dist/src/crypto/asymmetric.js +168 -0
- package/dist/src/crypto/double-ratchet.js +908 -0
- package/dist/src/crypto/file-encryption.js +352 -0
- package/dist/src/crypto/hashing.js +160 -0
- package/dist/src/crypto/index.js +18 -0
- package/dist/{crypto → src/crypto}/mls-codec.js +24 -34
- package/dist/src/crypto/mls.js +734 -0
- package/dist/src/crypto/pgp.js +619 -0
- package/dist/{crypto → src/crypto}/random-generation.js +125 -103
- package/dist/src/crypto/sframe.js +466 -0
- package/dist/src/crypto/signal-protocol.js +943 -0
- package/dist/src/crypto/symmetric.js +165 -0
- package/dist/src/crypto/utils.js +220 -0
- package/dist/src/examples/auth-test.js +535 -0
- package/dist/src/examples/crypto-identity-example.js +294 -0
- package/dist/src/examples/crypto-working-test.js +149 -0
- package/dist/src/examples/double-ratchet-test.js +240 -0
- package/dist/src/examples/mls-3-member-test.js +183 -0
- package/dist/src/examples/mls-multi-member.js +439 -0
- package/dist/src/examples/mls-sframe-test.js +491 -0
- package/dist/src/examples/mls-simple-test.js +122 -0
- package/dist/src/examples/pgp-example.js +354 -0
- package/dist/src/examples/random-generation-test.js +191 -0
- package/dist/src/examples/shogun-core-example.js +204 -0
- package/dist/src/examples/signal-protocol-test.js +82 -0
- package/dist/src/examples/zkproof-credentials-example.js +357 -0
- package/dist/src/examples/zkproof-example.js +357 -0
- package/dist/src/gundb/crypto.js +420 -0
- package/dist/src/gundb/db.js +728 -0
- package/dist/src/gundb/derive.js +327 -0
- package/dist/src/gundb/errors.js +115 -0
- package/dist/src/gundb/gun-es.js +8 -0
- package/dist/src/gundb/index.js +5 -0
- package/dist/{gundb → src/gundb}/rxjs.js +147 -111
- package/dist/{gundb → src/gundb}/types.js +1 -2
- package/dist/src/index.js +19 -0
- package/dist/src/interfaces/events.js +57 -0
- package/dist/{interfaces → src/interfaces}/shogun.js +4 -7
- package/dist/src/managers/AuthManager.js +301 -0
- package/dist/src/managers/CoreInitializer.js +304 -0
- package/dist/src/managers/CryptoIdentityManager.js +230 -0
- package/dist/{managers → src/managers}/EventManager.js +19 -21
- package/dist/{managers → src/managers}/PluginManager.js +123 -89
- package/dist/src/plugins/base.js +90 -0
- package/dist/src/plugins/index.js +17 -0
- package/dist/src/plugins/nostr/index.js +4 -0
- package/dist/src/plugins/nostr/nostrConnector.js +539 -0
- package/dist/src/plugins/nostr/nostrConnectorPlugin.js +663 -0
- package/dist/src/plugins/nostr/nostrSigner.js +414 -0
- package/dist/src/plugins/smartwallet/index.js +2 -0
- package/dist/src/plugins/smartwallet/smartWalletPlugin.js +824 -0
- package/dist/src/plugins/web3/index.js +4 -0
- package/dist/src/plugins/web3/types.js +1 -0
- package/dist/src/plugins/web3/web3Connector.js +738 -0
- package/dist/src/plugins/web3/web3ConnectorPlugin.js +639 -0
- package/dist/src/plugins/web3/web3Signer.js +432 -0
- package/dist/src/plugins/webauthn/index.js +3 -0
- package/dist/{plugins → src/plugins}/webauthn/types.js +2 -5
- package/dist/src/plugins/webauthn/webauthn.js +647 -0
- package/dist/src/plugins/webauthn/webauthnPlugin.js +689 -0
- package/dist/src/plugins/webauthn/webauthnSigner.js +419 -0
- package/dist/{plugins → src/plugins}/zkproof/index.js +3 -10
- package/dist/src/plugins/zkproof/types.js +1 -0
- package/dist/src/plugins/zkproof/zkCredentials.js +287 -0
- package/dist/src/plugins/zkproof/zkProofConnector.js +267 -0
- package/dist/src/plugins/zkproof/zkProofPlugin.js +405 -0
- package/dist/src/storage/storage.js +189 -0
- package/dist/src/utils/errorHandler.js +339 -0
- package/dist/{utils → src/utils}/eventEmitter.js +26 -26
- package/dist/{utils → src/utils}/seedPhrase.js +23 -32
- package/dist/{utils → src/utils}/validation.js +14 -21
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/{crypto → src/crypto}/double-ratchet.d.ts +1 -1
- package/dist/types/{crypto → src/crypto}/signal-protocol.d.ts +25 -0
- package/dist/types/{crypto → src/crypto}/types.d.ts +3 -1
- package/dist/types/src/examples/crypto-working-test.d.ts +1 -0
- package/dist/types/src/examples/double-ratchet-test.d.ts +1 -0
- package/dist/types/src/examples/mls-sframe-test.d.ts +1 -0
- package/dist/types/src/examples/random-generation-test.d.ts +1 -0
- package/dist/types/src/examples/signal-protocol-test.d.ts +1 -0
- package/dist/types/{gundb → src/gundb}/db.d.ts +14 -1
- package/dist/types/src/gundb/gun-es.d.ts +8 -0
- package/dist/types/src/gundb/min.d.ts +3 -0
- package/dist/types/{index.d.ts → src/index.d.ts} +1 -0
- package/package.json +14 -11
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js +0 -1651
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js.map +0 -1
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js +0 -1608
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js.map +0 -1
- package/dist/crypto/asymmetric.js +0 -99
- package/dist/crypto/double-ratchet.js +0 -370
- package/dist/crypto/file-encryption.js +0 -213
- package/dist/crypto/hashing.js +0 -87
- package/dist/crypto/index.js +0 -34
- package/dist/crypto/mls.js +0 -569
- package/dist/crypto/pgp.js +0 -390
- package/dist/crypto/sframe.js +0 -352
- package/dist/crypto/signal-protocol.js +0 -456
- package/dist/crypto/symmetric.js +0 -91
- package/dist/crypto/types.js +0 -2
- package/dist/crypto/utils.js +0 -140
- package/dist/examples/auth-test.js +0 -453
- package/dist/examples/crypto-identity-example.js +0 -196
- package/dist/examples/crypto-working-test.js +0 -83
- package/dist/examples/double-ratchet-test.js +0 -155
- package/dist/examples/mls-3-member-test.js +0 -97
- package/dist/examples/mls-multi-member.js +0 -153
- package/dist/examples/mls-sframe-test.js +0 -307
- package/dist/examples/mls-simple-test.js +0 -58
- package/dist/examples/pgp-example.js +0 -200
- package/dist/examples/random-generation-test.js +0 -151
- package/dist/examples/shogun-core-example.js +0 -150
- package/dist/examples/signal-protocol-test.js +0 -38
- package/dist/examples/zkproof-credentials-example.js +0 -217
- package/dist/examples/zkproof-example.js +0 -242
- package/dist/gundb/crypto.js +0 -306
- package/dist/gundb/db.js +0 -485
- package/dist/gundb/derive.js +0 -232
- package/dist/gundb/errors.js +0 -76
- package/dist/gundb/gun-es.js +0 -12
- package/dist/gundb/index.js +0 -21
- package/dist/gundb/min.js +0 -10
- package/dist/index.esm.js +0 -22
- package/dist/index.js +0 -47
- package/dist/interfaces/common.js +0 -2
- package/dist/interfaces/events.js +0 -40
- package/dist/interfaces/plugin.js +0 -2
- package/dist/managers/AuthManager.js +0 -226
- package/dist/managers/CoreInitializer.js +0 -250
- package/dist/managers/CryptoIdentityManager.js +0 -138
- package/dist/plugins/base.js +0 -50
- package/dist/plugins/index.js +0 -32
- package/dist/plugins/nostr/index.js +0 -20
- package/dist/plugins/nostr/nostrConnector.js +0 -419
- package/dist/plugins/nostr/nostrConnectorPlugin.js +0 -453
- package/dist/plugins/nostr/nostrSigner.js +0 -319
- package/dist/plugins/nostr/types.js +0 -2
- package/dist/plugins/smartwallet/index.js +0 -18
- package/dist/plugins/smartwallet/smartWalletPlugin.js +0 -511
- package/dist/plugins/smartwallet/types.js +0 -2
- package/dist/plugins/web3/index.js +0 -20
- package/dist/plugins/web3/types.js +0 -2
- package/dist/plugins/web3/web3Connector.js +0 -533
- package/dist/plugins/web3/web3ConnectorPlugin.js +0 -455
- package/dist/plugins/web3/web3Signer.js +0 -314
- package/dist/plugins/webauthn/index.js +0 -19
- package/dist/plugins/webauthn/webauthn.js +0 -496
- package/dist/plugins/webauthn/webauthnPlugin.js +0 -490
- package/dist/plugins/webauthn/webauthnSigner.js +0 -310
- package/dist/plugins/zkproof/types.js +0 -2
- package/dist/plugins/zkproof/zkCredentials.js +0 -216
- package/dist/plugins/zkproof/zkProofConnector.js +0 -198
- package/dist/plugins/zkproof/zkProofPlugin.js +0 -272
- package/dist/storage/storage.js +0 -145
- package/dist/types/gundb/gun-es.d.ts +0 -8
- package/dist/utils/errorHandler.js +0 -246
- /package/dist/{types/examples/crypto-working-test.d.ts → src/crypto/types.js} +0 -0
- /package/dist/{types/gundb/min.d.ts → src/gundb/min.js} +0 -0
- /package/dist/{types/examples/double-ratchet-test.d.ts → src/interfaces/common.js} +0 -0
- /package/dist/{types/examples/mls-sframe-test.d.ts → src/interfaces/plugin.js} +0 -0
- /package/dist/{types/examples/random-generation-test.d.ts → src/plugins/nostr/types.js} +0 -0
- /package/dist/{types/examples/signal-protocol-test.d.ts → src/plugins/smartwallet/types.js} +0 -0
- /package/dist/types/{core.d.ts → src/core.d.ts} +0 -0
- /package/dist/types/{crypto → src/crypto}/asymmetric.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/file-encryption.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/hashing.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/index.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/mls-codec.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/mls.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/pgp.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/random-generation.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/sframe.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/symmetric.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/utils.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/auth-test.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/crypto-identity-example.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/mls-3-member-test.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/mls-multi-member.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/mls-simple-test.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/pgp-example.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/shogun-core-example.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/zkproof-credentials-example.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/zkproof-example.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/crypto.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/derive.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/errors.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/index.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/rxjs.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/types.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/common.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/events.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/plugin.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/shogun.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/AuthManager.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/CoreInitializer.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/CryptoIdentityManager.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/EventManager.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/PluginManager.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/base.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/nostrConnector.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/nostrConnectorPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/nostrSigner.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/smartwallet/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/smartwallet/smartWalletPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/smartwallet/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/web3Connector.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/web3ConnectorPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/web3Signer.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/webauthn.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/webauthnPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/webauthnSigner.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/zkproof/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/zkproof/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/zkproof/zkCredentials.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/zkproof/zkProofConnector.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/zkproof/zkProofPlugin.d.ts +0 -0
- /package/dist/types/{storage → src/storage}/storage.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/errorHandler.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/eventEmitter.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/seedPhrase.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/validation.d.ts +0 -0
|
@@ -2,285 +2,37 @@
|
|
|
2
2
|
(this["webpackChunkShogunCore"] = this["webpackChunkShogunCore"] || []).push([["defaultVendors-node_modules_noble_curves_esm_ed448_js"],{
|
|
3
3
|
|
|
4
4
|
/***/ "./node_modules/@noble/curves/esm/ed448.js":
|
|
5
|
-
|
|
6
|
-
!*** ./node_modules/@noble/curves/esm/ed448.js
|
|
7
|
-
|
|
5
|
+
/*!*************************************************!*\
|
|
6
|
+
!*** ./node_modules/@noble/curves/esm/ed448.js ***!
|
|
7
|
+
\*************************************************/
|
|
8
8
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
9
9
|
|
|
10
|
-
// ESM COMPAT FLAG
|
|
11
10
|
__webpack_require__.r(__webpack_exports__);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* SHA3 (keccak) hash function, based on a new "Sponge function" design.
|
|
39
|
-
* Different from older hashes, the internal state is bigger than output size.
|
|
40
|
-
*
|
|
41
|
-
* Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf),
|
|
42
|
-
* [Website](https://keccak.team/keccak.html),
|
|
43
|
-
* [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub).
|
|
44
|
-
*
|
|
45
|
-
* Check out `sha3-addons` module for cSHAKE, k12, and others.
|
|
46
|
-
* @module
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
// prettier-ignore
|
|
50
|
-
|
|
51
|
-
// No __PURE__ annotations in sha3 header:
|
|
52
|
-
// EVERYTHING is in fact used on every export.
|
|
53
|
-
// Various per round constants calculations
|
|
54
|
-
const _0n = BigInt(0);
|
|
55
|
-
const _1n = BigInt(1);
|
|
56
|
-
const _2n = BigInt(2);
|
|
57
|
-
const _7n = BigInt(7);
|
|
58
|
-
const _256n = BigInt(256);
|
|
59
|
-
const _0x71n = BigInt(0x71);
|
|
60
|
-
const SHA3_PI = [];
|
|
61
|
-
const SHA3_ROTL = [];
|
|
62
|
-
const _SHA3_IOTA = [];
|
|
63
|
-
for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
|
|
64
|
-
// Pi
|
|
65
|
-
[x, y] = [y, (2 * x + 3 * y) % 5];
|
|
66
|
-
SHA3_PI.push(2 * (5 * y + x));
|
|
67
|
-
// Rotational
|
|
68
|
-
SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);
|
|
69
|
-
// Iota
|
|
70
|
-
let t = _0n;
|
|
71
|
-
for (let j = 0; j < 7; j++) {
|
|
72
|
-
R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;
|
|
73
|
-
if (R & _2n)
|
|
74
|
-
t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);
|
|
75
|
-
}
|
|
76
|
-
_SHA3_IOTA.push(t);
|
|
77
|
-
}
|
|
78
|
-
const IOTAS = (0,_u64.split)(_SHA3_IOTA, true);
|
|
79
|
-
const SHA3_IOTA_H = IOTAS[0];
|
|
80
|
-
const SHA3_IOTA_L = IOTAS[1];
|
|
81
|
-
// Left rotation (without 0, 32, 64)
|
|
82
|
-
const rotlH = (h, l, s) => (s > 32 ? (0,_u64.rotlBH)(h, l, s) : (0,_u64.rotlSH)(h, l, s));
|
|
83
|
-
const rotlL = (h, l, s) => (s > 32 ? (0,_u64.rotlBL)(h, l, s) : (0,_u64.rotlSL)(h, l, s));
|
|
84
|
-
/** `keccakf1600` internal function, additionally allows to adjust round count. */
|
|
85
|
-
function keccakP(s, rounds = 24) {
|
|
86
|
-
const B = new Uint32Array(5 * 2);
|
|
87
|
-
// NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)
|
|
88
|
-
for (let round = 24 - rounds; round < 24; round++) {
|
|
89
|
-
// Theta θ
|
|
90
|
-
for (let x = 0; x < 10; x++)
|
|
91
|
-
B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
|
|
92
|
-
for (let x = 0; x < 10; x += 2) {
|
|
93
|
-
const idx1 = (x + 8) % 10;
|
|
94
|
-
const idx0 = (x + 2) % 10;
|
|
95
|
-
const B0 = B[idx0];
|
|
96
|
-
const B1 = B[idx0 + 1];
|
|
97
|
-
const Th = rotlH(B0, B1, 1) ^ B[idx1];
|
|
98
|
-
const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
|
|
99
|
-
for (let y = 0; y < 50; y += 10) {
|
|
100
|
-
s[x + y] ^= Th;
|
|
101
|
-
s[x + y + 1] ^= Tl;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
// Rho (ρ) and Pi (π)
|
|
105
|
-
let curH = s[2];
|
|
106
|
-
let curL = s[3];
|
|
107
|
-
for (let t = 0; t < 24; t++) {
|
|
108
|
-
const shift = SHA3_ROTL[t];
|
|
109
|
-
const Th = rotlH(curH, curL, shift);
|
|
110
|
-
const Tl = rotlL(curH, curL, shift);
|
|
111
|
-
const PI = SHA3_PI[t];
|
|
112
|
-
curH = s[PI];
|
|
113
|
-
curL = s[PI + 1];
|
|
114
|
-
s[PI] = Th;
|
|
115
|
-
s[PI + 1] = Tl;
|
|
116
|
-
}
|
|
117
|
-
// Chi (χ)
|
|
118
|
-
for (let y = 0; y < 50; y += 10) {
|
|
119
|
-
for (let x = 0; x < 10; x++)
|
|
120
|
-
B[x] = s[y + x];
|
|
121
|
-
for (let x = 0; x < 10; x++)
|
|
122
|
-
s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
|
|
123
|
-
}
|
|
124
|
-
// Iota (ι)
|
|
125
|
-
s[0] ^= SHA3_IOTA_H[round];
|
|
126
|
-
s[1] ^= SHA3_IOTA_L[round];
|
|
127
|
-
}
|
|
128
|
-
(0,utils.clean)(B);
|
|
129
|
-
}
|
|
130
|
-
/** Keccak sponge function. */
|
|
131
|
-
class Keccak extends utils.Hash {
|
|
132
|
-
// NOTE: we accept arguments in bytes instead of bits here.
|
|
133
|
-
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
134
|
-
super();
|
|
135
|
-
this.pos = 0;
|
|
136
|
-
this.posOut = 0;
|
|
137
|
-
this.finished = false;
|
|
138
|
-
this.destroyed = false;
|
|
139
|
-
this.enableXOF = false;
|
|
140
|
-
this.blockLen = blockLen;
|
|
141
|
-
this.suffix = suffix;
|
|
142
|
-
this.outputLen = outputLen;
|
|
143
|
-
this.enableXOF = enableXOF;
|
|
144
|
-
this.rounds = rounds;
|
|
145
|
-
// Can be passed from user as dkLen
|
|
146
|
-
(0,utils.anumber)(outputLen);
|
|
147
|
-
// 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
|
|
148
|
-
// 0 < blockLen < 200
|
|
149
|
-
if (!(0 < blockLen && blockLen < 200))
|
|
150
|
-
throw new Error('only keccak-f1600 function is supported');
|
|
151
|
-
this.state = new Uint8Array(200);
|
|
152
|
-
this.state32 = (0,utils.u32)(this.state);
|
|
153
|
-
}
|
|
154
|
-
clone() {
|
|
155
|
-
return this._cloneInto();
|
|
156
|
-
}
|
|
157
|
-
keccak() {
|
|
158
|
-
(0,utils.swap32IfBE)(this.state32);
|
|
159
|
-
keccakP(this.state32, this.rounds);
|
|
160
|
-
(0,utils.swap32IfBE)(this.state32);
|
|
161
|
-
this.posOut = 0;
|
|
162
|
-
this.pos = 0;
|
|
163
|
-
}
|
|
164
|
-
update(data) {
|
|
165
|
-
(0,utils.aexists)(this);
|
|
166
|
-
data = (0,utils.toBytes)(data);
|
|
167
|
-
(0,utils.abytes)(data);
|
|
168
|
-
const { blockLen, state } = this;
|
|
169
|
-
const len = data.length;
|
|
170
|
-
for (let pos = 0; pos < len;) {
|
|
171
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
172
|
-
for (let i = 0; i < take; i++)
|
|
173
|
-
state[this.pos++] ^= data[pos++];
|
|
174
|
-
if (this.pos === blockLen)
|
|
175
|
-
this.keccak();
|
|
176
|
-
}
|
|
177
|
-
return this;
|
|
178
|
-
}
|
|
179
|
-
finish() {
|
|
180
|
-
if (this.finished)
|
|
181
|
-
return;
|
|
182
|
-
this.finished = true;
|
|
183
|
-
const { state, suffix, pos, blockLen } = this;
|
|
184
|
-
// Do the padding
|
|
185
|
-
state[pos] ^= suffix;
|
|
186
|
-
if ((suffix & 0x80) !== 0 && pos === blockLen - 1)
|
|
187
|
-
this.keccak();
|
|
188
|
-
state[blockLen - 1] ^= 0x80;
|
|
189
|
-
this.keccak();
|
|
190
|
-
}
|
|
191
|
-
writeInto(out) {
|
|
192
|
-
(0,utils.aexists)(this, false);
|
|
193
|
-
(0,utils.abytes)(out);
|
|
194
|
-
this.finish();
|
|
195
|
-
const bufferOut = this.state;
|
|
196
|
-
const { blockLen } = this;
|
|
197
|
-
for (let pos = 0, len = out.length; pos < len;) {
|
|
198
|
-
if (this.posOut >= blockLen)
|
|
199
|
-
this.keccak();
|
|
200
|
-
const take = Math.min(blockLen - this.posOut, len - pos);
|
|
201
|
-
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
|
|
202
|
-
this.posOut += take;
|
|
203
|
-
pos += take;
|
|
204
|
-
}
|
|
205
|
-
return out;
|
|
206
|
-
}
|
|
207
|
-
xofInto(out) {
|
|
208
|
-
// Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF
|
|
209
|
-
if (!this.enableXOF)
|
|
210
|
-
throw new Error('XOF is not possible for this instance');
|
|
211
|
-
return this.writeInto(out);
|
|
212
|
-
}
|
|
213
|
-
xof(bytes) {
|
|
214
|
-
(0,utils.anumber)(bytes);
|
|
215
|
-
return this.xofInto(new Uint8Array(bytes));
|
|
216
|
-
}
|
|
217
|
-
digestInto(out) {
|
|
218
|
-
(0,utils.aoutput)(out, this);
|
|
219
|
-
if (this.finished)
|
|
220
|
-
throw new Error('digest() was already called');
|
|
221
|
-
this.writeInto(out);
|
|
222
|
-
this.destroy();
|
|
223
|
-
return out;
|
|
224
|
-
}
|
|
225
|
-
digest() {
|
|
226
|
-
return this.digestInto(new Uint8Array(this.outputLen));
|
|
227
|
-
}
|
|
228
|
-
destroy() {
|
|
229
|
-
this.destroyed = true;
|
|
230
|
-
(0,utils.clean)(this.state);
|
|
231
|
-
}
|
|
232
|
-
_cloneInto(to) {
|
|
233
|
-
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
234
|
-
to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
|
|
235
|
-
to.state32.set(this.state32);
|
|
236
|
-
to.pos = this.pos;
|
|
237
|
-
to.posOut = this.posOut;
|
|
238
|
-
to.finished = this.finished;
|
|
239
|
-
to.rounds = rounds;
|
|
240
|
-
// Suffix can change in cSHAKE
|
|
241
|
-
to.suffix = suffix;
|
|
242
|
-
to.outputLen = outputLen;
|
|
243
|
-
to.enableXOF = enableXOF;
|
|
244
|
-
to.destroyed = this.destroyed;
|
|
245
|
-
return to;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
const gen = (suffix, blockLen, outputLen) => (0,utils.createHasher)(() => new Keccak(blockLen, suffix, outputLen));
|
|
249
|
-
/** SHA3-224 hash function. */
|
|
250
|
-
const sha3_224 = /* @__PURE__ */ (() => gen(0x06, 144, 224 / 8))();
|
|
251
|
-
/** SHA3-256 hash function. Different from keccak-256. */
|
|
252
|
-
const sha3_256 = /* @__PURE__ */ (() => gen(0x06, 136, 256 / 8))();
|
|
253
|
-
/** SHA3-384 hash function. */
|
|
254
|
-
const sha3_384 = /* @__PURE__ */ (() => gen(0x06, 104, 384 / 8))();
|
|
255
|
-
/** SHA3-512 hash function. */
|
|
256
|
-
const sha3_512 = /* @__PURE__ */ (() => gen(0x06, 72, 512 / 8))();
|
|
257
|
-
/** keccak-224 hash function. */
|
|
258
|
-
const keccak_224 = /* @__PURE__ */ (() => gen(0x01, 144, 224 / 8))();
|
|
259
|
-
/** keccak-256 hash function. Different from SHA3-256. */
|
|
260
|
-
const keccak_256 = /* @__PURE__ */ (() => gen(0x01, 136, 256 / 8))();
|
|
261
|
-
/** keccak-384 hash function. */
|
|
262
|
-
const keccak_384 = /* @__PURE__ */ (() => gen(0x01, 104, 384 / 8))();
|
|
263
|
-
/** keccak-512 hash function. */
|
|
264
|
-
const keccak_512 = /* @__PURE__ */ (() => gen(0x01, 72, 512 / 8))();
|
|
265
|
-
const genShake = (suffix, blockLen, outputLen) => (0,utils.createXOFer)((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));
|
|
266
|
-
/** SHAKE128 XOF with 128-bit security. */
|
|
267
|
-
const shake128 = /* @__PURE__ */ (() => genShake(0x1f, 168, 128 / 8))();
|
|
268
|
-
/** SHAKE256 XOF with 256-bit security. */
|
|
269
|
-
const shake256 = /* @__PURE__ */ (() => genShake(0x1f, 136, 256 / 8))();
|
|
270
|
-
//# sourceMappingURL=sha3.js.map
|
|
271
|
-
// EXTERNAL MODULE: ./node_modules/@noble/curves/esm/abstract/curve.js
|
|
272
|
-
var curve = __webpack_require__("./node_modules/@noble/curves/esm/abstract/curve.js");
|
|
273
|
-
// EXTERNAL MODULE: ./node_modules/@noble/curves/esm/abstract/edwards.js
|
|
274
|
-
var edwards = __webpack_require__("./node_modules/@noble/curves/esm/abstract/edwards.js");
|
|
275
|
-
// EXTERNAL MODULE: ./node_modules/@noble/curves/esm/abstract/hash-to-curve.js
|
|
276
|
-
var hash_to_curve = __webpack_require__("./node_modules/@noble/curves/esm/abstract/hash-to-curve.js");
|
|
277
|
-
// EXTERNAL MODULE: ./node_modules/@noble/curves/esm/abstract/modular.js
|
|
278
|
-
var modular = __webpack_require__("./node_modules/@noble/curves/esm/abstract/modular.js");
|
|
279
|
-
// EXTERNAL MODULE: ./node_modules/@noble/curves/esm/abstract/montgomery.js
|
|
280
|
-
var montgomery = __webpack_require__("./node_modules/@noble/curves/esm/abstract/montgomery.js");
|
|
281
|
-
// EXTERNAL MODULE: ./node_modules/@noble/curves/esm/utils.js
|
|
282
|
-
var esm_utils = __webpack_require__("./node_modules/@noble/curves/esm/utils.js");
|
|
283
|
-
;// ./node_modules/@noble/curves/esm/ed448.js
|
|
11
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
12
|
+
/* harmony export */ DecafPoint: () => (/* binding */ DecafPoint),
|
|
13
|
+
/* harmony export */ E448: () => (/* binding */ E448),
|
|
14
|
+
/* harmony export */ ED448_TORSION_SUBGROUP: () => (/* binding */ ED448_TORSION_SUBGROUP),
|
|
15
|
+
/* harmony export */ decaf448: () => (/* binding */ decaf448),
|
|
16
|
+
/* harmony export */ decaf448_hasher: () => (/* binding */ decaf448_hasher),
|
|
17
|
+
/* harmony export */ ed448: () => (/* binding */ ed448),
|
|
18
|
+
/* harmony export */ ed448_hasher: () => (/* binding */ ed448_hasher),
|
|
19
|
+
/* harmony export */ ed448ph: () => (/* binding */ ed448ph),
|
|
20
|
+
/* harmony export */ edwardsToMontgomery: () => (/* binding */ edwardsToMontgomery),
|
|
21
|
+
/* harmony export */ edwardsToMontgomeryPub: () => (/* binding */ edwardsToMontgomeryPub),
|
|
22
|
+
/* harmony export */ encodeToCurve: () => (/* binding */ encodeToCurve),
|
|
23
|
+
/* harmony export */ hashToCurve: () => (/* binding */ hashToCurve),
|
|
24
|
+
/* harmony export */ hashToDecaf448: () => (/* binding */ hashToDecaf448),
|
|
25
|
+
/* harmony export */ hash_to_decaf448: () => (/* binding */ hash_to_decaf448),
|
|
26
|
+
/* harmony export */ x448: () => (/* binding */ x448)
|
|
27
|
+
/* harmony export */ });
|
|
28
|
+
/* harmony import */ var _noble_hashes_sha3_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @noble/hashes/sha3.js */ "./node_modules/@noble/hashes/esm/sha3.js");
|
|
29
|
+
/* harmony import */ var _noble_hashes_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @noble/hashes/utils.js */ "./node_modules/@noble/hashes/esm/utils.js");
|
|
30
|
+
/* harmony import */ var _abstract_curve_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstract/curve.js */ "./node_modules/@noble/curves/esm/abstract/curve.js");
|
|
31
|
+
/* harmony import */ var _abstract_edwards_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./abstract/edwards.js */ "./node_modules/@noble/curves/esm/abstract/edwards.js");
|
|
32
|
+
/* harmony import */ var _abstract_hash_to_curve_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./abstract/hash-to-curve.js */ "./node_modules/@noble/curves/esm/abstract/hash-to-curve.js");
|
|
33
|
+
/* harmony import */ var _abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./abstract/modular.js */ "./node_modules/@noble/curves/esm/abstract/modular.js");
|
|
34
|
+
/* harmony import */ var _abstract_montgomery_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./abstract/montgomery.js */ "./node_modules/@noble/curves/esm/abstract/montgomery.js");
|
|
35
|
+
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@noble/curves/esm/utils.js");
|
|
284
36
|
/**
|
|
285
37
|
* Edwards448 (not Ed448-Goldilocks) curve with following addons:
|
|
286
38
|
* - X448 ECDH
|
|
@@ -321,10 +73,10 @@ const E448_CURVE = Object.assign({}, ed448_CURVE, {
|
|
|
321
73
|
Gx: BigInt('0x79a70b2b70400553ae7c9df416c792c61128751ac92969240c25a07d728bdc93e21f7787ed6972249de732f38496cd11698713093e9c04fc'),
|
|
322
74
|
Gy: BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000000000000000000000000000000000000000000001'),
|
|
323
75
|
});
|
|
324
|
-
const shake256_114 = /* @__PURE__ */ (0,
|
|
325
|
-
const shake256_64 = /* @__PURE__ */ (0,
|
|
76
|
+
const shake256_114 = /* @__PURE__ */ (0,_noble_hashes_utils_js__WEBPACK_IMPORTED_MODULE_1__.createHasher)(() => _noble_hashes_sha3_js__WEBPACK_IMPORTED_MODULE_0__.shake256.create({ dkLen: 114 }));
|
|
77
|
+
const shake256_64 = /* @__PURE__ */ (0,_noble_hashes_utils_js__WEBPACK_IMPORTED_MODULE_1__.createHasher)(() => _noble_hashes_sha3_js__WEBPACK_IMPORTED_MODULE_0__.shake256.create({ dkLen: 64 }));
|
|
326
78
|
// prettier-ignore
|
|
327
|
-
const
|
|
79
|
+
const _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _4n = BigInt(4), _11n = BigInt(11);
|
|
328
80
|
// prettier-ignore
|
|
329
81
|
const _22n = BigInt(22), _44n = BigInt(44), _88n = BigInt(88), _223n = BigInt(223);
|
|
330
82
|
// powPminus3div4 calculates z = x^k mod p, where k = (p-3)/4.
|
|
@@ -334,17 +86,17 @@ function ed448_pow_Pminus3div4(x) {
|
|
|
334
86
|
const P = ed448_CURVE.p;
|
|
335
87
|
const b2 = (x * x * x) % P;
|
|
336
88
|
const b3 = (b2 * b2 * x) % P;
|
|
337
|
-
const b6 = ((0,
|
|
338
|
-
const b9 = ((0,
|
|
339
|
-
const b11 = ((0,
|
|
340
|
-
const b22 = ((0,
|
|
341
|
-
const b44 = ((0,
|
|
342
|
-
const b88 = ((0,
|
|
343
|
-
const b176 = ((0,
|
|
344
|
-
const b220 = ((0,
|
|
345
|
-
const b222 = ((0,
|
|
346
|
-
const b223 = ((0,
|
|
347
|
-
return ((0,
|
|
89
|
+
const b6 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.pow2)(b3, _3n, P) * b3) % P;
|
|
90
|
+
const b9 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.pow2)(b6, _3n, P) * b3) % P;
|
|
91
|
+
const b11 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.pow2)(b9, _2n, P) * b2) % P;
|
|
92
|
+
const b22 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.pow2)(b11, _11n, P) * b11) % P;
|
|
93
|
+
const b44 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.pow2)(b22, _22n, P) * b22) % P;
|
|
94
|
+
const b88 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.pow2)(b44, _44n, P) * b44) % P;
|
|
95
|
+
const b176 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.pow2)(b88, _88n, P) * b88) % P;
|
|
96
|
+
const b220 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.pow2)(b176, _44n, P) * b44) % P;
|
|
97
|
+
const b222 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.pow2)(b220, _2n, P) * b2) % P;
|
|
98
|
+
const b223 = ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.pow2)(b222, _1n, P) * x) % P;
|
|
99
|
+
return ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.pow2)(b223, _223n, P) * b222) % P;
|
|
348
100
|
}
|
|
349
101
|
function adjustScalarBytes(bytes) {
|
|
350
102
|
// Section 5: Likewise, for X448, set the two least significant bits of the first byte to 0,
|
|
@@ -365,31 +117,31 @@ function uvRatio(u, v) {
|
|
|
365
117
|
// following trick, to use a single modular powering for both the
|
|
366
118
|
// inversion of v and the square root:
|
|
367
119
|
// x = (u/v)^((p+1)/4) = u³v(u⁵v³)^((p-3)/4) (mod p)
|
|
368
|
-
const u2v = (0,
|
|
369
|
-
const u3v = (0,
|
|
370
|
-
const u5v3 = (0,
|
|
120
|
+
const u2v = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.mod)(u * u * v, P); // u²v
|
|
121
|
+
const u3v = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.mod)(u2v * u, P); // u³v
|
|
122
|
+
const u5v3 = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.mod)(u3v * u2v * v, P); // u⁵v³
|
|
371
123
|
const root = ed448_pow_Pminus3div4(u5v3);
|
|
372
|
-
const x = (0,
|
|
124
|
+
const x = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.mod)(u3v * root, P);
|
|
373
125
|
// Verify that root is exists
|
|
374
|
-
const x2 = (0,
|
|
126
|
+
const x2 = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.mod)(x * x, P); // x²
|
|
375
127
|
// If vx² = u, the recovered x-coordinate is x. Otherwise, no
|
|
376
128
|
// square root exists, and the decoding fails.
|
|
377
|
-
return { isValid: (0,
|
|
129
|
+
return { isValid: (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.mod)(x2 * v, P) === u, value: x };
|
|
378
130
|
}
|
|
379
131
|
// Finite field 2n**448n - 2n**224n - 1n
|
|
380
132
|
// The value fits in 448 bits, but we use 456-bit (57-byte) elements because of bitflags.
|
|
381
133
|
// - ed25519 fits in 255 bits, allowing using last 1 byte for specifying bit flag of point negation.
|
|
382
134
|
// - ed448 fits in 448 bits. We can't use last 1 byte: we can only use a bit 224 in the middle.
|
|
383
|
-
const Fp = /* @__PURE__ */ (() => (0,
|
|
384
|
-
const Fn = /* @__PURE__ */ (() => (0,
|
|
135
|
+
const Fp = /* @__PURE__ */ (() => (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.Field)(ed448_CURVE.p, { BITS: 456, isLE: true }))();
|
|
136
|
+
const Fn = /* @__PURE__ */ (() => (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.Field)(ed448_CURVE.n, { BITS: 456, isLE: true }))();
|
|
385
137
|
// decaf448 uses 448-bit (56-byte) keys
|
|
386
|
-
const Fp448 = /* @__PURE__ */ (() => (0,
|
|
387
|
-
const Fn448 = /* @__PURE__ */ (() => (0,
|
|
138
|
+
const Fp448 = /* @__PURE__ */ (() => (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.Field)(ed448_CURVE.p, { BITS: 448, isLE: true }))();
|
|
139
|
+
const Fn448 = /* @__PURE__ */ (() => (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.Field)(ed448_CURVE.n, { BITS: 448, isLE: true }))();
|
|
388
140
|
// SHAKE256(dom4(phflag,context)||x, 114)
|
|
389
141
|
function dom4(data, ctx, phflag) {
|
|
390
142
|
if (ctx.length > 255)
|
|
391
143
|
throw new Error('context must be smaller than 255, got: ' + ctx.length);
|
|
392
|
-
return (0,
|
|
144
|
+
return (0,_noble_hashes_utils_js__WEBPACK_IMPORTED_MODULE_1__.concatBytes)((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.asciiToBytes)('SigEd448'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
|
|
393
145
|
}
|
|
394
146
|
// const ed448_eddsa_opts = { adjustScalarBytes, domain: dom4 };
|
|
395
147
|
// const ed448_Point = edwards(ed448_CURVE, { Fp, Fn, uvRatio });
|
|
@@ -412,10 +164,10 @@ const ED448_DEF = /* @__PURE__ */ (() => ({
|
|
|
412
164
|
* const sig = ed448.sign(msg, secretKey);
|
|
413
165
|
* const isValid = ed448.verify(sig, msg, publicKey);
|
|
414
166
|
*/
|
|
415
|
-
const ed448 = (0,
|
|
167
|
+
const ed448 = (0,_abstract_edwards_js__WEBPACK_IMPORTED_MODULE_3__.twistedEdwards)(ED448_DEF);
|
|
416
168
|
// There is no ed448ctx, since ed448 supports ctx by default
|
|
417
169
|
/** Prehashed version of ed448. Accepts already-hashed messages in sign() and verify(). */
|
|
418
|
-
const ed448ph = /* @__PURE__ */ (() => (0,
|
|
170
|
+
const ed448ph = /* @__PURE__ */ (() => (0,_abstract_edwards_js__WEBPACK_IMPORTED_MODULE_3__.twistedEdwards)({
|
|
419
171
|
...ED448_DEF,
|
|
420
172
|
prehash: shake256_64,
|
|
421
173
|
}))();
|
|
@@ -424,7 +176,7 @@ const ed448ph = /* @__PURE__ */ (() => (0,edwards.twistedEdwards)({
|
|
|
424
176
|
* E448 != edwards448 used in ed448.
|
|
425
177
|
* E448 is birationally equivalent to edwards448.
|
|
426
178
|
*/
|
|
427
|
-
const E448 = (0,
|
|
179
|
+
const E448 = (0,_abstract_edwards_js__WEBPACK_IMPORTED_MODULE_3__.edwards)(E448_CURVE);
|
|
428
180
|
/**
|
|
429
181
|
* ECDH using curve448 aka x448.
|
|
430
182
|
* x448 has 56-byte keys as per RFC 7748, while
|
|
@@ -432,13 +184,13 @@ const E448 = (0,edwards.edwards)(E448_CURVE);
|
|
|
432
184
|
*/
|
|
433
185
|
const x448 = /* @__PURE__ */ (() => {
|
|
434
186
|
const P = ed448_CURVE.p;
|
|
435
|
-
return (0,
|
|
187
|
+
return (0,_abstract_montgomery_js__WEBPACK_IMPORTED_MODULE_6__.montgomery)({
|
|
436
188
|
P,
|
|
437
189
|
type: 'x448',
|
|
438
190
|
powPminus2: (x) => {
|
|
439
191
|
const Pminus3div4 = ed448_pow_Pminus3div4(x);
|
|
440
|
-
const Pminus3 = (0,
|
|
441
|
-
return (0,
|
|
192
|
+
const Pminus3 = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.pow2)(Pminus3div4, _2n, P);
|
|
193
|
+
return (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.mod)(Pminus3 * x, P); // Pminus3 * x = Pminus2
|
|
442
194
|
},
|
|
443
195
|
adjustScalarBytes,
|
|
444
196
|
});
|
|
@@ -513,18 +265,18 @@ function map_to_curve_elligator2_edwards448(u) {
|
|
|
513
265
|
xEd = Fp.cmov(xEd, Fp.ONE, e); // 35. xEd = CMOV(xEd, 1, e)
|
|
514
266
|
yEn = Fp.cmov(yEn, Fp.ONE, e); // 36. yEn = CMOV(yEn, 1, e)
|
|
515
267
|
yEd = Fp.cmov(yEd, Fp.ONE, e); // 37. yEd = CMOV(yEd, 1, e)
|
|
516
|
-
const inv = (0,
|
|
268
|
+
const inv = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.FpInvertBatch)(Fp, [xEd, yEd], true); // batch division
|
|
517
269
|
return { x: Fp.mul(xEn, inv[0]), y: Fp.mul(yEn, inv[1]) }; // 38. return (xEn, xEd, yEn, yEd)
|
|
518
270
|
}
|
|
519
271
|
/** Hashing / encoding to ed448 points / field. RFC 9380 methods. */
|
|
520
|
-
const ed448_hasher = /* @__PURE__ */ (() => (0,
|
|
272
|
+
const ed448_hasher = /* @__PURE__ */ (() => (0,_abstract_hash_to_curve_js__WEBPACK_IMPORTED_MODULE_4__.createHasher)(ed448.Point, (scalars) => map_to_curve_elligator2_edwards448(scalars[0]), {
|
|
521
273
|
DST: 'edwards448_XOF:SHAKE256_ELL2_RO_',
|
|
522
274
|
encodeDST: 'edwards448_XOF:SHAKE256_ELL2_NU_',
|
|
523
275
|
p: Fp.ORDER,
|
|
524
276
|
m: 1,
|
|
525
277
|
k: 224,
|
|
526
278
|
expand: 'xof',
|
|
527
|
-
hash: shake256,
|
|
279
|
+
hash: _noble_hashes_sha3_js__WEBPACK_IMPORTED_MODULE_0__.shake256,
|
|
528
280
|
}))();
|
|
529
281
|
// 1-d
|
|
530
282
|
const ONE_MINUS_D = /* @__PURE__ */ BigInt('39082');
|
|
@@ -535,7 +287,7 @@ const SQRT_MINUS_D = /* @__PURE__ */ BigInt('98944233647732219769177004876929019
|
|
|
535
287
|
// 1 / √(-d)
|
|
536
288
|
const INVSQRT_MINUS_D = /* @__PURE__ */ BigInt('315019913931389607337177038330951043522456072897266928557328499619017160722351061360252776265186336876723201881398623946864393857820716');
|
|
537
289
|
// Calculates 1/√(number)
|
|
538
|
-
const invertSqrt = (number) => uvRatio(
|
|
290
|
+
const invertSqrt = (number) => uvRatio(_1n, number);
|
|
539
291
|
/**
|
|
540
292
|
* Elligator map for hash-to-curve of decaf448.
|
|
541
293
|
* Described in [RFC9380](https://www.rfc-editor.org/rfc/rfc9380#appendix-C)
|
|
@@ -546,28 +298,28 @@ function calcElligatorDecafMap(r0) {
|
|
|
546
298
|
const P = Fp.ORDER;
|
|
547
299
|
const mod = (n) => Fp.create(n);
|
|
548
300
|
const r = mod(-(r0 * r0)); // 1
|
|
549
|
-
const u0 = mod(d * (r -
|
|
550
|
-
const u1 = mod((u0 +
|
|
551
|
-
const { isValid: was_square, value: v } = uvRatio(ONE_MINUS_TWO_D, mod((r +
|
|
301
|
+
const u0 = mod(d * (r - _1n)); // 2
|
|
302
|
+
const u1 = mod((u0 + _1n) * (u0 - r)); // 3
|
|
303
|
+
const { isValid: was_square, value: v } = uvRatio(ONE_MINUS_TWO_D, mod((r + _1n) * u1)); // 4
|
|
552
304
|
let v_prime = v; // 5
|
|
553
305
|
if (!was_square)
|
|
554
306
|
v_prime = mod(r0 * v);
|
|
555
|
-
let sgn =
|
|
307
|
+
let sgn = _1n; // 6
|
|
556
308
|
if (!was_square)
|
|
557
|
-
sgn = mod(-
|
|
558
|
-
const s = mod(v_prime * (r +
|
|
309
|
+
sgn = mod(-_1n);
|
|
310
|
+
const s = mod(v_prime * (r + _1n)); // 7
|
|
559
311
|
let s_abs = s;
|
|
560
|
-
if ((0,
|
|
312
|
+
if ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.isNegativeLE)(s, P))
|
|
561
313
|
s_abs = mod(-s);
|
|
562
314
|
const s2 = s * s;
|
|
563
|
-
const W0 = mod(s_abs *
|
|
564
|
-
const W1 = mod(s2 +
|
|
565
|
-
const W2 = mod(s2 -
|
|
566
|
-
const W3 = mod(v_prime * s * (r -
|
|
315
|
+
const W0 = mod(s_abs * _2n); // 8
|
|
316
|
+
const W1 = mod(s2 + _1n); // 9
|
|
317
|
+
const W2 = mod(s2 - _1n); // 10
|
|
318
|
+
const W3 = mod(v_prime * s * (r - _1n) * ONE_MINUS_TWO_D + sgn); // 11
|
|
567
319
|
return new ed448.Point(mod(W0 * W3), mod(W2 * W1), mod(W1 * W3), mod(W0 * W2));
|
|
568
320
|
}
|
|
569
321
|
function decaf448_map(bytes) {
|
|
570
|
-
(0,
|
|
322
|
+
(0,_noble_hashes_utils_js__WEBPACK_IMPORTED_MODULE_1__.abytes)(bytes, 112);
|
|
571
323
|
const skipValidation = true;
|
|
572
324
|
// Note: Similar to the field element decoding described in
|
|
573
325
|
// [RFC7748], and unlike the field element decoding described in
|
|
@@ -585,7 +337,7 @@ function decaf448_map(bytes) {
|
|
|
585
337
|
* but it should work in its own namespace: do not combine those two.
|
|
586
338
|
* See [RFC9496](https://www.rfc-editor.org/rfc/rfc9496).
|
|
587
339
|
*/
|
|
588
|
-
class _DecafPoint extends
|
|
340
|
+
class _DecafPoint extends _abstract_edwards_js__WEBPACK_IMPORTED_MODULE_3__.PrimeEdwardsPoint {
|
|
589
341
|
constructor(ep) {
|
|
590
342
|
super(ep);
|
|
591
343
|
}
|
|
@@ -601,32 +353,32 @@ class _DecafPoint extends edwards.PrimeEdwardsPoint {
|
|
|
601
353
|
}
|
|
602
354
|
/** @deprecated use `import { decaf448_hasher } from '@noble/curves/ed448.js';` */
|
|
603
355
|
static hashToCurve(hex) {
|
|
604
|
-
return decaf448_map((0,
|
|
356
|
+
return decaf448_map((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.ensureBytes)('decafHash', hex, 112));
|
|
605
357
|
}
|
|
606
358
|
static fromBytes(bytes) {
|
|
607
|
-
(0,
|
|
359
|
+
(0,_noble_hashes_utils_js__WEBPACK_IMPORTED_MODULE_1__.abytes)(bytes, 56);
|
|
608
360
|
const { d } = ed448_CURVE;
|
|
609
361
|
const P = Fp.ORDER;
|
|
610
362
|
const mod = (n) => Fp448.create(n);
|
|
611
363
|
const s = Fp448.fromBytes(bytes);
|
|
612
364
|
// 1. Check that s_bytes is the canonical encoding of a field element, or else abort.
|
|
613
365
|
// 2. Check that s is non-negative, or else abort
|
|
614
|
-
if (!(0,
|
|
366
|
+
if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.equalBytes)(Fn448.toBytes(s), bytes) || (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.isNegativeLE)(s, P))
|
|
615
367
|
throw new Error('invalid decaf448 encoding 1');
|
|
616
368
|
const s2 = mod(s * s); // 1
|
|
617
|
-
const u1 = mod(
|
|
369
|
+
const u1 = mod(_1n + s2); // 2
|
|
618
370
|
const u1sq = mod(u1 * u1);
|
|
619
371
|
const u2 = mod(u1sq - _4n * d * s2); // 3
|
|
620
372
|
const { isValid, value: invsqrt } = invertSqrt(mod(u2 * u1sq)); // 4
|
|
621
373
|
let u3 = mod((s + s) * invsqrt * u1 * SQRT_MINUS_D); // 5
|
|
622
|
-
if ((0,
|
|
374
|
+
if ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.isNegativeLE)(u3, P))
|
|
623
375
|
u3 = mod(-u3);
|
|
624
376
|
const x = mod(u3 * invsqrt * u2 * INVSQRT_MINUS_D); // 6
|
|
625
|
-
const y = mod((
|
|
377
|
+
const y = mod((_1n - s2) * invsqrt * u1); // 7
|
|
626
378
|
const t = mod(x * y); // 8
|
|
627
379
|
if (!isValid)
|
|
628
380
|
throw new Error('invalid decaf448 encoding 2');
|
|
629
|
-
return new _DecafPoint(new ed448.Point(x, y,
|
|
381
|
+
return new _DecafPoint(new ed448.Point(x, y, _1n, t));
|
|
630
382
|
}
|
|
631
383
|
/**
|
|
632
384
|
* Converts decaf-encoded string to decaf point.
|
|
@@ -634,11 +386,11 @@ class _DecafPoint extends edwards.PrimeEdwardsPoint {
|
|
|
634
386
|
* @param hex Decaf-encoded 56 bytes. Not every 56-byte string is valid decaf encoding
|
|
635
387
|
*/
|
|
636
388
|
static fromHex(hex) {
|
|
637
|
-
return _DecafPoint.fromBytes((0,
|
|
389
|
+
return _DecafPoint.fromBytes((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.ensureBytes)('decafHex', hex, 56));
|
|
638
390
|
}
|
|
639
391
|
/** @deprecated use `import { pippenger } from '@noble/curves/abstract/curve.js';` */
|
|
640
392
|
static msm(points, scalars) {
|
|
641
|
-
return (0,
|
|
393
|
+
return (0,_abstract_curve_js__WEBPACK_IMPORTED_MODULE_2__.pippenger)(_DecafPoint, Fn, points, scalars);
|
|
642
394
|
}
|
|
643
395
|
/**
|
|
644
396
|
* Encodes decaf point to Uint8Array.
|
|
@@ -652,11 +404,11 @@ class _DecafPoint extends edwards.PrimeEdwardsPoint {
|
|
|
652
404
|
const x2 = mod(X * X);
|
|
653
405
|
const { value: invsqrt } = invertSqrt(mod(u1 * ONE_MINUS_D * x2)); // 2
|
|
654
406
|
let ratio = mod(invsqrt * u1 * SQRT_MINUS_D); // 3
|
|
655
|
-
if ((0,
|
|
407
|
+
if ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.isNegativeLE)(ratio, P))
|
|
656
408
|
ratio = mod(-ratio);
|
|
657
409
|
const u2 = mod(INVSQRT_MINUS_D * ratio * Z - T); // 4
|
|
658
410
|
let s = mod(ONE_MINUS_D * invsqrt * X * u2); // 5
|
|
659
|
-
if ((0,
|
|
411
|
+
if ((0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_5__.isNegativeLE)(s, P))
|
|
660
412
|
s = mod(-s);
|
|
661
413
|
return Fn448.toBytes(s);
|
|
662
414
|
}
|
|
@@ -678,7 +430,7 @@ class _DecafPoint extends edwards.PrimeEdwardsPoint {
|
|
|
678
430
|
// The following gymnastics is done because typescript strips comments otherwise
|
|
679
431
|
// prettier-ignore
|
|
680
432
|
_DecafPoint.BASE =
|
|
681
|
-
/* @__PURE__ */ (() => new _DecafPoint(ed448.Point.BASE).multiplyUnsafe(
|
|
433
|
+
/* @__PURE__ */ (() => new _DecafPoint(ed448.Point.BASE).multiplyUnsafe(_2n))();
|
|
682
434
|
// prettier-ignore
|
|
683
435
|
_DecafPoint.ZERO =
|
|
684
436
|
/* @__PURE__ */ (() => new _DecafPoint(ed448.Point.ZERO))();
|
|
@@ -693,15 +445,15 @@ const decaf448 = { Point: _DecafPoint };
|
|
|
693
445
|
const decaf448_hasher = {
|
|
694
446
|
hashToCurve(msg, options) {
|
|
695
447
|
const DST = options?.DST || 'decaf448_XOF:SHAKE256_D448MAP_RO_';
|
|
696
|
-
return decaf448_map((0,
|
|
448
|
+
return decaf448_map((0,_abstract_hash_to_curve_js__WEBPACK_IMPORTED_MODULE_4__.expand_message_xof)(msg, DST, 112, 224, _noble_hashes_sha3_js__WEBPACK_IMPORTED_MODULE_0__.shake256));
|
|
697
449
|
},
|
|
698
450
|
// Warning: has big modulo bias of 2^-64.
|
|
699
451
|
// RFC is invalid. RFC says "use 64-byte xof", while for 2^-112 bias
|
|
700
452
|
// it must use 84-byte xof (56+56/2), not 64.
|
|
701
|
-
hashToScalar(msg, options = { DST:
|
|
453
|
+
hashToScalar(msg, options = { DST: _abstract_hash_to_curve_js__WEBPACK_IMPORTED_MODULE_4__._DST_scalar }) {
|
|
702
454
|
// Can't use `Fn448.fromBytes()`. 64-byte input => 56-byte field element
|
|
703
|
-
const xof = (0,
|
|
704
|
-
return Fn448.create((0,
|
|
455
|
+
const xof = (0,_abstract_hash_to_curve_js__WEBPACK_IMPORTED_MODULE_4__.expand_message_xof)(msg, options.DST, 64, 256, _noble_hashes_sha3_js__WEBPACK_IMPORTED_MODULE_0__.shake256);
|
|
456
|
+
return Fn448.create((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.bytesToNumberLE)(xof));
|
|
705
457
|
},
|
|
706
458
|
};
|
|
707
459
|
// export const decaf448_oprf: OPRF = createORPF({
|
|
@@ -735,7 +487,7 @@ const hashToDecaf448 = /* @__PURE__ */ (() => decaf448_hasher.hashToCurve)();
|
|
|
735
487
|
const hash_to_decaf448 = /* @__PURE__ */ (() => decaf448_hasher.hashToCurve)();
|
|
736
488
|
/** @deprecated use `ed448.utils.toMontgomery` */
|
|
737
489
|
function edwardsToMontgomeryPub(edwardsPub) {
|
|
738
|
-
return ed448.utils.toMontgomery((0,
|
|
490
|
+
return ed448.utils.toMontgomery((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.ensureBytes)('pub', edwardsPub));
|
|
739
491
|
}
|
|
740
492
|
/** @deprecated use `ed448.utils.toMontgomery` */
|
|
741
493
|
const edwardsToMontgomery = edwardsToMontgomeryPub;
|