@waku/rln 0.1.5-ff0222a.0 → 0.1.5
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/CHANGELOG.md +22 -0
- package/bundle/index.js +2 -2
- package/bundle/node_modules/@ethersproject/abi/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/address/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/bignumber/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/contracts/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +1 -1
- package/bundle/node_modules/@ethersproject/hash/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/networks/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/networks/lib.esm/index.js +19 -1
- package/bundle/node_modules/@ethersproject/properties/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/providers/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/elliptic.js +58 -10
- package/bundle/node_modules/@ethersproject/strings/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/transactions/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/web/lib.esm/_version.js +1 -1
- package/bundle/packages/proto/dist/generated/sds_message.js +59 -3
- package/bundle/packages/rln/dist/contract/constants.js +1 -1
- package/bundle/packages/rln/dist/contract/{rln_light_contract.js → rln_base_contract.js} +177 -177
- package/bundle/packages/rln/dist/contract/rln_contract.js +9 -419
- package/bundle/packages/rln/dist/contract/types.js +9 -0
- package/bundle/packages/rln/dist/create.js +1 -1
- package/bundle/packages/rln/dist/{rln_light.js → credentials_manager.js} +114 -48
- package/bundle/packages/rln/dist/identity.js +0 -9
- package/bundle/packages/rln/dist/keystore/keystore.js +27 -13
- package/bundle/packages/rln/dist/rln.js +56 -166
- package/bundle/packages/rln/dist/zerokit.js +5 -5
- package/dist/.tsbuildinfo +1 -1
- package/dist/contract/constants.d.ts +1 -1
- package/dist/contract/constants.js +1 -1
- package/dist/contract/constants.js.map +1 -1
- package/dist/contract/{rln_light_contract.d.ts → rln_base_contract.d.ts} +25 -53
- package/dist/contract/{rln_light_contract.js → rln_base_contract.js} +177 -177
- package/dist/contract/rln_base_contract.js.map +1 -0
- package/dist/contract/rln_contract.d.ts +5 -122
- package/dist/contract/rln_contract.js +8 -417
- package/dist/contract/rln_contract.js.map +1 -1
- package/dist/contract/types.d.ts +40 -0
- package/dist/contract/types.js +8 -0
- package/dist/contract/types.js.map +1 -0
- package/dist/create.js +1 -1
- package/dist/create.js.map +1 -1
- package/dist/credentials_manager.d.ts +44 -0
- package/dist/credentials_manager.js +197 -0
- package/dist/credentials_manager.js.map +1 -0
- package/dist/identity.d.ts +0 -1
- package/dist/identity.js +0 -9
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/keystore/keystore.d.ts +1 -0
- package/dist/keystore/keystore.js +27 -13
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/rln.d.ts +9 -52
- package/dist/rln.js +54 -163
- package/dist/rln.js.map +1 -1
- package/dist/types.d.ts +27 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/zerokit.d.ts +3 -3
- package/dist/zerokit.js +5 -5
- package/dist/zerokit.js.map +1 -1
- package/package.json +92 -1
- package/src/contract/constants.ts +1 -1
- package/src/contract/{rln_light_contract.ts → rln_base_contract.ts} +294 -312
- package/src/contract/rln_contract.ts +9 -663
- package/src/contract/types.ts +48 -0
- package/src/create.ts +1 -1
- package/src/credentials_manager.ts +282 -0
- package/src/identity.ts +0 -10
- package/src/index.ts +4 -4
- package/src/keystore/keystore.ts +49 -25
- package/src/rln.ts +67 -258
- package/src/types.ts +31 -0
- package/src/zerokit.ts +3 -3
- package/dist/contract/rln_light_contract.js.map +0 -1
- package/dist/rln_light.d.ts +0 -64
- package/dist/rln_light.js +0 -144
- package/dist/rln_light.js.map +0 -1
- package/src/rln_light.ts +0 -235
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.1.5](https://github.com/waku-org/js-waku/compare/rln-v0.1.4...rln-v0.1.5) (2025-04-23)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* **rln:** Create `CredentialsManager` without Zerokit ([#2295](https://github.com/waku-org/js-waku/issues/2295)) ([4adf870](https://github.com/waku-org/js-waku/commit/4adf8706c3befd99ace8f02dc2a1350428d4a163))
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* **rln:** Update types to match nwaku ([#2339](https://github.com/waku-org/js-waku/issues/2339)) ([28f28d0](https://github.com/waku-org/js-waku/commit/28f28d0d3627d7fdd06c5970c6028ea73031786e))
|
14
|
+
|
15
|
+
|
16
|
+
### Dependencies
|
17
|
+
|
18
|
+
* The following workspace dependencies were updated
|
19
|
+
* dependencies
|
20
|
+
* @waku/core bumped from ^0.0.34 to ^0.0.35
|
21
|
+
* @waku/utils bumped from ^0.0.22 to ^0.0.23
|
22
|
+
* devDependencies
|
23
|
+
* @waku/message-encryption bumped from ^0.0.32 to ^0.0.33
|
24
|
+
|
3
25
|
## [0.1.4](https://github.com/waku-org/js-waku/compare/rln-v0.1.3...rln-v0.1.4) (2025-03-24)
|
4
26
|
|
5
27
|
|
package/bundle/index.js
CHANGED
@@ -2,13 +2,13 @@ export { RLNDecoder, RLNEncoder } from './packages/rln/dist/codec.js';
|
|
2
2
|
export { RLN_ABI } from './packages/rln/dist/contract/abi.js';
|
3
3
|
export { RLNContract } from './packages/rln/dist/contract/rln_contract.js';
|
4
4
|
export { LINEA_CONTRACT } from './packages/rln/dist/contract/constants.js';
|
5
|
-
export {
|
5
|
+
export { RLNBaseContract } from './packages/rln/dist/contract/rln_base_contract.js';
|
6
6
|
export { createRLN } from './packages/rln/dist/create.js';
|
7
|
+
export { RLNCredentialsManager } from './packages/rln/dist/credentials_manager.js';
|
7
8
|
export { IdentityCredential } from './packages/rln/dist/identity.js';
|
8
9
|
export { Keystore } from './packages/rln/dist/keystore/keystore.js';
|
9
10
|
export { Proof } from './packages/rln/dist/proof.js';
|
10
11
|
export { RLNInstance } from './packages/rln/dist/rln.js';
|
11
|
-
export { RLNLightInstance } from './packages/rln/dist/rln_light.js';
|
12
12
|
export { MerkleRootTracker } from './packages/rln/dist/root_tracker.js';
|
13
13
|
export { extractMetaMaskSigner } from './packages/rln/dist/utils/metamask.js';
|
14
14
|
import './packages/rln/dist/utils/epoch.js';
|
@@ -763,7 +763,7 @@ class BaseContract {
|
|
763
763
|
logger.throwError("events require a provider or a signer with a provider", Logger.errors.UNSUPPORTED_OPERATION, { operation: "once" });
|
764
764
|
}
|
765
765
|
runningEvent.addListener(listener, once);
|
766
|
-
// Track this running event and its listeners (may already be there; but no
|
766
|
+
// Track this running event and its listeners (may already be there; but no harm in updating)
|
767
767
|
this._runningEvents[runningEvent.tag] = runningEvent;
|
768
768
|
// If we are not polling the provider, start polling
|
769
769
|
if (!this._wrappedEmits[runningEvent.tag]) {
|
@@ -59,6 +59,12 @@ function ethDefaultProvider(network) {
|
|
59
59
|
}
|
60
60
|
catch (error) { }
|
61
61
|
}
|
62
|
+
if (providers.QuickNodeProvider && options.quicknode !== "-") {
|
63
|
+
try {
|
64
|
+
providerList.push(new providers.QuickNodeProvider(network, options.quicknode));
|
65
|
+
}
|
66
|
+
catch (error) { }
|
67
|
+
}
|
62
68
|
if (providerList.length === 0) {
|
63
69
|
return null;
|
64
70
|
}
|
@@ -136,9 +142,15 @@ const networks = {
|
|
136
142
|
kintsugi: { chainId: 1337702, name: "kintsugi" },
|
137
143
|
sepolia: {
|
138
144
|
chainId: 11155111,
|
145
|
+
ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
|
139
146
|
name: "sepolia",
|
140
147
|
_defaultProvider: ethDefaultProvider("sepolia")
|
141
148
|
},
|
149
|
+
holesky: {
|
150
|
+
chainId: 17000,
|
151
|
+
name: "holesky",
|
152
|
+
_defaultProvider: ethDefaultProvider("holesky")
|
153
|
+
},
|
142
154
|
// ETC (See: #351)
|
143
155
|
classic: {
|
144
156
|
chainId: 61,
|
@@ -159,7 +171,11 @@ const networks = {
|
|
159
171
|
name: "matic",
|
160
172
|
_defaultProvider: ethDefaultProvider("matic")
|
161
173
|
},
|
162
|
-
maticmum: {
|
174
|
+
maticmum: {
|
175
|
+
chainId: 80001,
|
176
|
+
name: "maticmum",
|
177
|
+
_defaultProvider: ethDefaultProvider("maticmum")
|
178
|
+
},
|
163
179
|
optimism: {
|
164
180
|
chainId: 10,
|
165
181
|
name: "optimism",
|
@@ -167,9 +183,11 @@ const networks = {
|
|
167
183
|
},
|
168
184
|
"optimism-kovan": { chainId: 69, name: "optimism-kovan" },
|
169
185
|
"optimism-goerli": { chainId: 420, name: "optimism-goerli" },
|
186
|
+
"optimism-sepolia": { chainId: 11155420, name: "optimism-sepolia" },
|
170
187
|
arbitrum: { chainId: 42161, name: "arbitrum" },
|
171
188
|
"arbitrum-rinkeby": { chainId: 421611, name: "arbitrum-rinkeby" },
|
172
189
|
"arbitrum-goerli": { chainId: 421613, name: "arbitrum-goerli" },
|
190
|
+
"arbitrum-sepolia": { chainId: 421614, name: "arbitrum-sepolia" },
|
173
191
|
bnb: { chainId: 56, name: "bnb" },
|
174
192
|
bnbt: { chainId: 97, name: "bnbt" },
|
175
193
|
};
|
@@ -103,12 +103,15 @@ utils.encode = utils_1.encode;
|
|
103
103
|
// Represent num in a w-NAF form
|
104
104
|
function getNAF(num, w, bits) {
|
105
105
|
var naf = new Array(Math.max(num.bitLength(), bits) + 1);
|
106
|
-
|
106
|
+
var i;
|
107
|
+
for (i = 0; i < naf.length; i += 1) {
|
108
|
+
naf[i] = 0;
|
109
|
+
}
|
107
110
|
|
108
111
|
var ws = 1 << (w + 1);
|
109
112
|
var k = num.clone();
|
110
113
|
|
111
|
-
for (
|
114
|
+
for (i = 0; i < naf.length; i++) {
|
112
115
|
var z;
|
113
116
|
var mod = k.andln(ws - 1);
|
114
117
|
if (k.isOdd()) {
|
@@ -1994,8 +1997,8 @@ KeyPair.prototype.sign = function sign(msg, enc, options) {
|
|
1994
1997
|
return this.ec.sign(msg, this, enc, options);
|
1995
1998
|
};
|
1996
1999
|
|
1997
|
-
KeyPair.prototype.verify = function verify(msg, signature) {
|
1998
|
-
return this.ec.verify(msg, signature, this);
|
2000
|
+
KeyPair.prototype.verify = function verify(msg, signature, options) {
|
2001
|
+
return this.ec.verify(msg, signature, this, undefined, options);
|
1999
2002
|
};
|
2000
2003
|
|
2001
2004
|
KeyPair.prototype.inspect = function inspect() {
|
@@ -2041,6 +2044,10 @@ function getLength(buf, p) {
|
|
2041
2044
|
return false;
|
2042
2045
|
}
|
2043
2046
|
|
2047
|
+
if(buf[p.place] === 0x00) {
|
2048
|
+
return false;
|
2049
|
+
}
|
2050
|
+
|
2044
2051
|
var val = 0;
|
2045
2052
|
for (var i = 0, off = p.place; i < octetLen; i++, off++) {
|
2046
2053
|
val <<= 8;
|
@@ -2089,6 +2096,9 @@ Signature.prototype._importDER = function _importDER(data, enc) {
|
|
2089
2096
|
if (rlen === false) {
|
2090
2097
|
return false;
|
2091
2098
|
}
|
2099
|
+
if ((data[p.place] & 128) !== 0) {
|
2100
|
+
return false;
|
2101
|
+
}
|
2092
2102
|
var r = data.slice(p.place, rlen + p.place);
|
2093
2103
|
p.place += rlen;
|
2094
2104
|
if (data[p.place++] !== 0x02) {
|
@@ -2101,6 +2111,9 @@ Signature.prototype._importDER = function _importDER(data, enc) {
|
|
2101
2111
|
if (data.length !== slen + p.place) {
|
2102
2112
|
return false;
|
2103
2113
|
}
|
2114
|
+
if ((data[p.place] & 128) !== 0) {
|
2115
|
+
return false;
|
2116
|
+
}
|
2104
2117
|
var s = data.slice(p.place, slen + p.place);
|
2105
2118
|
if (r[0] === 0) {
|
2106
2119
|
if (r[1] & 0x80) {
|
@@ -2246,8 +2259,27 @@ EC.prototype.genKeyPair = function genKeyPair(options) {
|
|
2246
2259
|
}
|
2247
2260
|
};
|
2248
2261
|
|
2249
|
-
EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) {
|
2250
|
-
var
|
2262
|
+
EC.prototype._truncateToN = function _truncateToN(msg, truncOnly, bitLength) {
|
2263
|
+
var byteLength;
|
2264
|
+
if (BN.isBN(msg) || typeof msg === 'number') {
|
2265
|
+
msg = new BN(msg, 16);
|
2266
|
+
byteLength = msg.byteLength();
|
2267
|
+
} else if (typeof msg === 'object') {
|
2268
|
+
// BN assumes an array-like input and asserts length
|
2269
|
+
byteLength = msg.length;
|
2270
|
+
msg = new BN(msg, 16);
|
2271
|
+
} else {
|
2272
|
+
// BN converts the value to string
|
2273
|
+
var str = msg.toString();
|
2274
|
+
// HEX encoding
|
2275
|
+
byteLength = (str.length + 1) >>> 1;
|
2276
|
+
msg = new BN(str, 16);
|
2277
|
+
}
|
2278
|
+
// Allow overriding
|
2279
|
+
if (typeof bitLength !== 'number') {
|
2280
|
+
bitLength = byteLength * 8;
|
2281
|
+
}
|
2282
|
+
var delta = bitLength - this.n.bitLength();
|
2251
2283
|
if (delta > 0)
|
2252
2284
|
msg = msg.ushrn(delta);
|
2253
2285
|
if (!truncOnly && msg.cmp(this.n) >= 0)
|
@@ -2264,8 +2296,18 @@ EC.prototype.sign = function sign(msg, key, enc, options) {
|
|
2264
2296
|
if (!options)
|
2265
2297
|
options = {};
|
2266
2298
|
|
2299
|
+
if (typeof msg !== 'string' && typeof msg !== 'number' && !BN.isBN(msg)) {
|
2300
|
+
assert$5(typeof msg === 'object' && msg && typeof msg.length === 'number',
|
2301
|
+
'Expected message to be an array-like, a hex string, or a BN instance');
|
2302
|
+
assert$5((msg.length >>> 0) === msg.length); // non-negative 32-bit integer
|
2303
|
+
for (var i = 0; i < msg.length; i++) assert$5((msg[i] & 255) === msg[i]);
|
2304
|
+
}
|
2305
|
+
|
2267
2306
|
key = this.keyFromPrivate(key, enc);
|
2268
|
-
msg = this._truncateToN(
|
2307
|
+
msg = this._truncateToN(msg, false, options.msgBitLength);
|
2308
|
+
|
2309
|
+
// Would fail further checks, but let's make the error message clear
|
2310
|
+
assert$5(!msg.isNeg(), 'Can not sign a negative message');
|
2269
2311
|
|
2270
2312
|
// Zero-extend key to provide enough entropy
|
2271
2313
|
var bytes = this.n.byteLength();
|
@@ -2274,6 +2316,9 @@ EC.prototype.sign = function sign(msg, key, enc, options) {
|
|
2274
2316
|
// Zero-extend nonce to have the same byte size as N
|
2275
2317
|
var nonce = msg.toArray('be', bytes);
|
2276
2318
|
|
2319
|
+
// Recheck nonce to be bijective to msg
|
2320
|
+
assert$5((new BN(nonce)).eq(msg), 'Can not sign message');
|
2321
|
+
|
2277
2322
|
// Instantiate Hmac_DRBG
|
2278
2323
|
var drbg = new hmacDrbg({
|
2279
2324
|
hash: this.hash,
|
@@ -2321,8 +2366,11 @@ EC.prototype.sign = function sign(msg, key, enc, options) {
|
|
2321
2366
|
}
|
2322
2367
|
};
|
2323
2368
|
|
2324
|
-
EC.prototype.verify = function verify(msg, signature$1, key, enc) {
|
2325
|
-
|
2369
|
+
EC.prototype.verify = function verify(msg, signature$1, key, enc, options) {
|
2370
|
+
if (!options)
|
2371
|
+
options = {};
|
2372
|
+
|
2373
|
+
msg = this._truncateToN(msg, false, options.msgBitLength);
|
2326
2374
|
key = this.keyFromPublic(key, enc);
|
2327
2375
|
signature$1 = new signature(signature$1, 'hex');
|
2328
2376
|
|
@@ -2414,7 +2462,7 @@ var elliptic_1 = createCommonjsModule(function (module, exports) {
|
|
2414
2462
|
|
2415
2463
|
var elliptic = exports;
|
2416
2464
|
|
2417
|
-
elliptic.version = /*RicMoo:ethers*/{ version: "6.
|
2465
|
+
elliptic.version = /*RicMoo:ethers*/{ version: "6.6.1" }.version;
|
2418
2466
|
elliptic.utils = utils_1$1;
|
2419
2467
|
elliptic.rand = /*RicMoo:ethers:require(brorand)*/(function() { throw new Error('unsupported'); });
|
2420
2468
|
elliptic.curve = curve_1;
|
@@ -8,6 +8,60 @@ import { decodeMessage } from '../../../../node_modules/protons-runtime/dist/src
|
|
8
8
|
/* eslint-disable @typescript-eslint/no-namespace */
|
9
9
|
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
10
10
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
11
|
+
var HistoryEntry;
|
12
|
+
(function (HistoryEntry) {
|
13
|
+
let _codec;
|
14
|
+
HistoryEntry.codec = () => {
|
15
|
+
if (_codec == null) {
|
16
|
+
_codec = message((obj, w, opts = {}) => {
|
17
|
+
if (opts.lengthDelimited !== false) {
|
18
|
+
w.fork();
|
19
|
+
}
|
20
|
+
if ((obj.messageId != null && obj.messageId !== '')) {
|
21
|
+
w.uint32(10);
|
22
|
+
w.string(obj.messageId);
|
23
|
+
}
|
24
|
+
if (obj.retrievalHint != null) {
|
25
|
+
w.uint32(18);
|
26
|
+
w.bytes(obj.retrievalHint);
|
27
|
+
}
|
28
|
+
if (opts.lengthDelimited !== false) {
|
29
|
+
w.ldelim();
|
30
|
+
}
|
31
|
+
}, (reader, length, opts = {}) => {
|
32
|
+
const obj = {
|
33
|
+
messageId: ''
|
34
|
+
};
|
35
|
+
const end = length == null ? reader.len : reader.pos + length;
|
36
|
+
while (reader.pos < end) {
|
37
|
+
const tag = reader.uint32();
|
38
|
+
switch (tag >>> 3) {
|
39
|
+
case 1: {
|
40
|
+
obj.messageId = reader.string();
|
41
|
+
break;
|
42
|
+
}
|
43
|
+
case 2: {
|
44
|
+
obj.retrievalHint = reader.bytes();
|
45
|
+
break;
|
46
|
+
}
|
47
|
+
default: {
|
48
|
+
reader.skipType(tag & 7);
|
49
|
+
break;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
return obj;
|
54
|
+
});
|
55
|
+
}
|
56
|
+
return _codec;
|
57
|
+
};
|
58
|
+
HistoryEntry.encode = (obj) => {
|
59
|
+
return encodeMessage(obj, HistoryEntry.codec());
|
60
|
+
};
|
61
|
+
HistoryEntry.decode = (buf, opts) => {
|
62
|
+
return decodeMessage(buf, HistoryEntry.codec(), opts);
|
63
|
+
};
|
64
|
+
})(HistoryEntry || (HistoryEntry = {}));
|
11
65
|
var SdsMessage;
|
12
66
|
(function (SdsMessage) {
|
13
67
|
let _codec;
|
@@ -32,7 +86,7 @@ var SdsMessage;
|
|
32
86
|
if (obj.causalHistory != null) {
|
33
87
|
for (const value of obj.causalHistory) {
|
34
88
|
w.uint32(90);
|
35
|
-
|
89
|
+
HistoryEntry.codec().encode(value, w);
|
36
90
|
}
|
37
91
|
}
|
38
92
|
if (obj.bloomFilter != null) {
|
@@ -72,7 +126,9 @@ var SdsMessage;
|
|
72
126
|
if (opts.limits?.causalHistory != null && obj.causalHistory.length === opts.limits.causalHistory) {
|
73
127
|
throw new MaxLengthError('Decode error - map field "causalHistory" had too many elements');
|
74
128
|
}
|
75
|
-
obj.causalHistory.push(reader.
|
129
|
+
obj.causalHistory.push(HistoryEntry.codec().decode(reader, reader.uint32(), {
|
130
|
+
limits: opts.limits?.causalHistory$
|
131
|
+
}));
|
76
132
|
break;
|
77
133
|
}
|
78
134
|
case 12: {
|
@@ -102,4 +158,4 @@ var SdsMessage;
|
|
102
158
|
};
|
103
159
|
})(SdsMessage || (SdsMessage = {}));
|
104
160
|
|
105
|
-
export { SdsMessage };
|
161
|
+
export { HistoryEntry, SdsMessage };
|