@waku/rln 0.1.1-891ee34 → 0.1.1-9b1e818
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/bundle/assets/rln_wasm_bg-a503e304.wasm +0 -0
- package/bundle/index.js +284 -152
- package/dist/.tsbuildinfo +1 -1
- package/dist/byte_utils.d.ts +7 -0
- package/dist/byte_utils.js +13 -0
- package/dist/byte_utils.js.map +1 -1
- package/dist/codec.d.ts +5 -3
- package/dist/codec.js +8 -2
- package/dist/codec.js.map +1 -1
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +62 -9
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/keystore/keystore.d.ts +4 -3
- package/dist/keystore/keystore.js +16 -5
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/keystore/types.d.ts +5 -5
- package/dist/message.d.ts +1 -1
- package/dist/message.js +1 -1
- package/dist/rln.js +2 -2
- package/dist/rln.js.map +1 -1
- package/dist/rln_contract.d.ts +23 -13
- package/dist/rln_contract.js +65 -28
- package/dist/rln_contract.js.map +1 -1
- package/package.json +6 -6
- package/src/byte_utils.ts +14 -0
- package/src/codec.ts +10 -2
- package/src/constants.ts +63 -9
- package/src/index.ts +7 -2
- package/src/message.ts +1 -1
- package/src/rln.ts +2 -2
- package/src/rln_contract.ts +117 -41
- package/bundle/assets/rln_wasm_bg-6f96f821.wasm +0 -0
package/bundle/index.js
CHANGED
@@ -1871,6 +1871,18 @@ function fromString(string, encoding = 'utf8') {
|
|
1871
1871
|
return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions
|
1872
1872
|
}
|
1873
1873
|
|
1874
|
+
/**
|
1875
|
+
* Convert input to a byte array.
|
1876
|
+
*
|
1877
|
+
* Handles both `0x` prefixed and non-prefixed strings.
|
1878
|
+
*/
|
1879
|
+
function hexToBytes$2(hex) {
|
1880
|
+
if (typeof hex === "string") {
|
1881
|
+
const _hex = hex.replace(/^0x/i, "");
|
1882
|
+
return fromString(_hex.toLowerCase(), "base16");
|
1883
|
+
}
|
1884
|
+
return hex;
|
1885
|
+
}
|
1874
1886
|
/**
|
1875
1887
|
* Encode utf-8 string to byte array.
|
1876
1888
|
*/
|
@@ -1907,7 +1919,7 @@ class RlnMessage {
|
|
1907
1919
|
this.rlnInstance = rlnInstance;
|
1908
1920
|
this.msg = msg;
|
1909
1921
|
this.rateLimitProof = rateLimitProof;
|
1910
|
-
this.
|
1922
|
+
this.pubsubTopic = "";
|
1911
1923
|
}
|
1912
1924
|
verify(roots) {
|
1913
1925
|
return this.rateLimitProof
|
@@ -1973,6 +1985,9 @@ class RLNEncoder {
|
|
1973
1985
|
console.timeEnd("proof_gen_timer");
|
1974
1986
|
return proof;
|
1975
1987
|
}
|
1988
|
+
get pubsubTopic() {
|
1989
|
+
return this.encoder.pubsubTopic;
|
1990
|
+
}
|
1976
1991
|
get contentTopic() {
|
1977
1992
|
return this.encoder.contentTopic;
|
1978
1993
|
}
|
@@ -1985,6 +2000,9 @@ class RLNDecoder {
|
|
1985
2000
|
this.rlnInstance = rlnInstance;
|
1986
2001
|
this.decoder = decoder;
|
1987
2002
|
}
|
2003
|
+
get pubsubTopic() {
|
2004
|
+
return this.decoder.pubsubTopic;
|
2005
|
+
}
|
1988
2006
|
get contentTopic() {
|
1989
2007
|
return this.decoder.contentTopic;
|
1990
2008
|
}
|
@@ -1993,26 +2011,79 @@ class RLNDecoder {
|
|
1993
2011
|
log("Message decoded", protoMessage);
|
1994
2012
|
return Promise.resolve(protoMessage);
|
1995
2013
|
}
|
1996
|
-
async fromProtoObj(
|
1997
|
-
const msg = await this.decoder.fromProtoObj(
|
2014
|
+
async fromProtoObj(pubsubTopic, proto) {
|
2015
|
+
const msg = await this.decoder.fromProtoObj(pubsubTopic, proto);
|
1998
2016
|
if (!msg)
|
1999
2017
|
return;
|
2000
2018
|
return new RlnMessage(this.rlnInstance, msg, proto.rateLimitProof);
|
2001
2019
|
}
|
2002
2020
|
}
|
2003
2021
|
|
2004
|
-
|
2005
|
-
|
2006
|
-
"
|
2007
|
-
"
|
2008
|
-
"
|
2009
|
-
"
|
2022
|
+
// ref https://github.com/waku-org/waku-rln-contract/blob/19fded82bca07e7b535b429dc507cfb83f10dfcf/deployments/sepolia/WakuRlnRegistry_Implementation.json#L3
|
2023
|
+
const RLN_REGISTRY_ABI = [
|
2024
|
+
"error IncompatibleStorage()",
|
2025
|
+
"error IncompatibleStorageIndex()",
|
2026
|
+
"error NoStorageContractAvailable()",
|
2027
|
+
"error StorageAlreadyExists(address storageAddress)",
|
2028
|
+
"event AdminChanged(address previousAdmin, address newAdmin)",
|
2029
|
+
"event BeaconUpgraded(address indexed beacon)",
|
2030
|
+
"event Initialized(uint8 version)",
|
2031
|
+
"event NewStorageContract(uint16 index, address storageAddress)",
|
2032
|
+
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
|
2033
|
+
"event Upgraded(address indexed implementation)",
|
2034
|
+
"function forceProgress()",
|
2035
|
+
"function initialize(address _poseidonHasher)",
|
2036
|
+
"function newStorage()",
|
2037
|
+
"function nextStorageIndex() view returns (uint16)",
|
2038
|
+
"function owner() view returns (address)",
|
2039
|
+
"function poseidonHasher() view returns (address)",
|
2040
|
+
"function proxiableUUID() view returns (bytes32)",
|
2041
|
+
"function register(uint16 storageIndex, uint256 commitment)",
|
2042
|
+
"function register(uint256[] commitments)",
|
2043
|
+
"function register(uint16 storageIndex, uint256[] commitments)",
|
2044
|
+
"function registerStorage(address storageAddress)",
|
2045
|
+
"function renounceOwnership()",
|
2046
|
+
"function storages(uint16) view returns (address)",
|
2047
|
+
"function transferOwnership(address newOwner)",
|
2048
|
+
"function upgradeTo(address newImplementation)",
|
2049
|
+
"function upgradeToAndCall(address newImplementation, bytes data) payable",
|
2050
|
+
"function usingStorageIndex() view returns (uint16)",
|
2051
|
+
];
|
2052
|
+
// ref https://github.com/waku-org/waku-rln-contract/blob/19fded82bca07e7b535b429dc507cfb83f10dfcf/deployments/sepolia/WakuRlnStorage_0.json#L3
|
2053
|
+
const RLN_STORAGE_ABI = [
|
2054
|
+
"constructor(address _poseidonHasher, uint16 _contractIndex)",
|
2055
|
+
"error DuplicateIdCommitment()",
|
2056
|
+
"error FullTree()",
|
2057
|
+
"error InvalidIdCommitment(uint256 idCommitment)",
|
2058
|
+
"error NotImplemented()",
|
2059
|
+
"event MemberRegistered(uint256 idCommitment, uint256 index)",
|
2060
|
+
"event MemberWithdrawn(uint256 idCommitment, uint256 index)",
|
2061
|
+
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
|
2062
|
+
"function DEPTH() view returns (uint256)",
|
2063
|
+
"function MEMBERSHIP_DEPOSIT() view returns (uint256)",
|
2064
|
+
"function SET_SIZE() view returns (uint256)",
|
2065
|
+
"function contractIndex() view returns (uint16)",
|
2066
|
+
"function deployedBlockNumber() view returns (uint32)",
|
2067
|
+
"function idCommitmentIndex() view returns (uint256)",
|
2068
|
+
"function isValidCommitment(uint256 idCommitment) view returns (bool)",
|
2069
|
+
"function memberExists(uint256) view returns (bool)",
|
2070
|
+
"function members(uint256) view returns (uint256)",
|
2071
|
+
"function owner() view returns (address)",
|
2072
|
+
"function poseidonHasher() view returns (address)",
|
2073
|
+
"function register(uint256[] idCommitments)",
|
2074
|
+
"function register(uint256 idCommitment) payable",
|
2075
|
+
"function renounceOwnership()",
|
2076
|
+
"function slash(uint256 idCommitment, address receiver, uint256[8] proof) pure",
|
2077
|
+
"function stakedAmounts(uint256) view returns (uint256)",
|
2078
|
+
"function transferOwnership(address newOwner)",
|
2079
|
+
"function verifier() view returns (address)",
|
2080
|
+
"function withdraw() pure",
|
2081
|
+
"function withdrawalBalance(address) view returns (uint256)",
|
2010
2082
|
];
|
2011
2083
|
const SEPOLIA_CONTRACT = {
|
2012
2084
|
chainId: 11155111,
|
2013
|
-
|
2014
|
-
|
2015
|
-
abi: RLN_ABI,
|
2085
|
+
address: "0xF471d71E9b1455bBF4b85d475afb9BB0954A29c4",
|
2086
|
+
abi: RLN_REGISTRY_ABI,
|
2016
2087
|
};
|
2017
2088
|
|
2018
2089
|
var lib = {};
|
@@ -23851,6 +23922,19 @@ function buildBigIntFromUint8Array(array) {
|
|
23851
23922
|
const dataView = new DataView(array.buffer);
|
23852
23923
|
return dataView.getBigUint64(0, true);
|
23853
23924
|
}
|
23925
|
+
/**
|
23926
|
+
* Fills with zeros to set length
|
23927
|
+
* @param array little endian Uint8Array
|
23928
|
+
* @param length amount to pad
|
23929
|
+
* @returns little endian Uint8Array padded with zeros to set length
|
23930
|
+
*/
|
23931
|
+
function zeroPadLE(array, length) {
|
23932
|
+
const result = new Uint8Array(length);
|
23933
|
+
for (let i = 0; i < length; i++) {
|
23934
|
+
result[i] = array[i] || 0;
|
23935
|
+
}
|
23936
|
+
return result;
|
23937
|
+
}
|
23854
23938
|
|
23855
23939
|
const U32_MASK64 = BigInt(2 ** 32 - 1);
|
23856
23940
|
const _32n = BigInt(32);
|
@@ -24475,11 +24559,11 @@ class Keystore {
|
|
24475
24559
|
// TODO: add runtime validation of nwaku credentials
|
24476
24560
|
return {
|
24477
24561
|
identity: {
|
24478
|
-
IDCommitment: _.get(obj, "identityCredential.idCommitment"),
|
24479
|
-
IDTrapdoor: _.get(obj, "identityCredential.idTrapdoor"),
|
24480
|
-
IDNullifier: _.get(obj, "identityCredential.idNullifier"),
|
24481
|
-
IDCommitmentBigInt: buildBigIntFromUint8Array(
|
24482
|
-
IDSecretHash: _.get(obj, "identityCredential.idSecretHash"),
|
24562
|
+
IDCommitment: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idCommitment", [])),
|
24563
|
+
IDTrapdoor: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idTrapdoor", [])),
|
24564
|
+
IDNullifier: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idNullifier", [])),
|
24565
|
+
IDCommitmentBigInt: buildBigIntFromUint8Array(Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idCommitment", []))),
|
24566
|
+
IDSecretHash: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idSecretHash", [])),
|
24483
24567
|
},
|
24484
24568
|
membership: {
|
24485
24569
|
treeIndex: _.get(obj, "treeIndex"),
|
@@ -24493,6 +24577,17 @@ class Keystore {
|
|
24493
24577
|
return null;
|
24494
24578
|
}
|
24495
24579
|
}
|
24580
|
+
static fromArraylikeToBytes(obj) {
|
24581
|
+
const bytes = [];
|
24582
|
+
let index = 0;
|
24583
|
+
let lastElement = obj[index];
|
24584
|
+
while (lastElement !== undefined) {
|
24585
|
+
bytes.push(lastElement);
|
24586
|
+
index += 1;
|
24587
|
+
lastElement = obj[index];
|
24588
|
+
}
|
24589
|
+
return new Uint8Array(bytes);
|
24590
|
+
}
|
24496
24591
|
// follows nwaku implementation
|
24497
24592
|
// https://github.com/waku-org/nwaku/blob/f05528d4be3d3c876a8b07f9bb7dfaae8aa8ec6e/waku/waku_keystore/protocol_types.nim#L111
|
24498
24593
|
static computeMembershipHash(info) {
|
@@ -24525,10 +24620,23 @@ heap.push(undefined, null, true, false);
|
|
24525
24620
|
|
24526
24621
|
function getObject(idx) { return heap[idx]; }
|
24527
24622
|
|
24528
|
-
|
24623
|
+
let heap_next = heap.length;
|
24624
|
+
|
24625
|
+
function dropObject(idx) {
|
24626
|
+
if (idx < 132) return;
|
24627
|
+
heap[idx] = heap_next;
|
24628
|
+
heap_next = idx;
|
24629
|
+
}
|
24630
|
+
|
24631
|
+
function takeObject(idx) {
|
24632
|
+
const ret = getObject(idx);
|
24633
|
+
dropObject(idx);
|
24634
|
+
return ret;
|
24635
|
+
}
|
24529
24636
|
|
24530
|
-
cachedTextDecoder
|
24637
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
24531
24638
|
|
24639
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
|
24532
24640
|
let cachedUint8Memory0 = null;
|
24533
24641
|
|
24534
24642
|
function getUint8Memory0() {
|
@@ -24539,11 +24647,10 @@ function getUint8Memory0() {
|
|
24539
24647
|
}
|
24540
24648
|
|
24541
24649
|
function getStringFromWasm0(ptr, len) {
|
24650
|
+
ptr = ptr >>> 0;
|
24542
24651
|
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
24543
24652
|
}
|
24544
24653
|
|
24545
|
-
let heap_next = heap.length;
|
24546
|
-
|
24547
24654
|
function addHeapObject(obj) {
|
24548
24655
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
24549
24656
|
const idx = heap_next;
|
@@ -24553,21 +24660,9 @@ function addHeapObject(obj) {
|
|
24553
24660
|
return idx;
|
24554
24661
|
}
|
24555
24662
|
|
24556
|
-
function dropObject(idx) {
|
24557
|
-
if (idx < 132) return;
|
24558
|
-
heap[idx] = heap_next;
|
24559
|
-
heap_next = idx;
|
24560
|
-
}
|
24561
|
-
|
24562
|
-
function takeObject(idx) {
|
24563
|
-
const ret = getObject(idx);
|
24564
|
-
dropObject(idx);
|
24565
|
-
return ret;
|
24566
|
-
}
|
24567
|
-
|
24568
24663
|
let WASM_VECTOR_LEN = 0;
|
24569
24664
|
|
24570
|
-
const cachedTextEncoder = new TextEncoder('utf-8');
|
24665
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
24571
24666
|
|
24572
24667
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
24573
24668
|
? function (arg, view) {
|
@@ -24586,14 +24681,14 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
24586
24681
|
|
24587
24682
|
if (realloc === undefined) {
|
24588
24683
|
const buf = cachedTextEncoder.encode(arg);
|
24589
|
-
const ptr = malloc(buf.length);
|
24684
|
+
const ptr = malloc(buf.length) >>> 0;
|
24590
24685
|
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
24591
24686
|
WASM_VECTOR_LEN = buf.length;
|
24592
24687
|
return ptr;
|
24593
24688
|
}
|
24594
24689
|
|
24595
24690
|
let len = arg.length;
|
24596
|
-
let ptr = malloc(len);
|
24691
|
+
let ptr = malloc(len) >>> 0;
|
24597
24692
|
|
24598
24693
|
const mem = getUint8Memory0();
|
24599
24694
|
|
@@ -24609,7 +24704,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
24609
24704
|
if (offset !== 0) {
|
24610
24705
|
arg = arg.slice(offset);
|
24611
24706
|
}
|
24612
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
24707
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
|
24613
24708
|
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
24614
24709
|
const ret = encodeString(arg, view);
|
24615
24710
|
|
@@ -24832,7 +24927,7 @@ function getUint32Memory0() {
|
|
24832
24927
|
}
|
24833
24928
|
|
24834
24929
|
function passArrayJsValueToWasm0(array, malloc) {
|
24835
|
-
const ptr = malloc(array.length * 4);
|
24930
|
+
const ptr = malloc(array.length * 4) >>> 0;
|
24836
24931
|
const mem = getUint32Memory0();
|
24837
24932
|
for (let i = 0; i < array.length; i++) {
|
24838
24933
|
mem[ptr / 4 + i] = addHeapObject(array[i]);
|
@@ -25016,11 +25111,7 @@ function handleError(f, args) {
|
|
25016
25111
|
}
|
25017
25112
|
}
|
25018
25113
|
|
25019
|
-
function
|
25020
|
-
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
25021
|
-
}
|
25022
|
-
|
25023
|
-
async function load(module, imports) {
|
25114
|
+
async function __wbg_load(module, imports) {
|
25024
25115
|
if (typeof Response === 'function' && module instanceof Response) {
|
25025
25116
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
25026
25117
|
try {
|
@@ -25051,17 +25142,9 @@ async function load(module, imports) {
|
|
25051
25142
|
}
|
25052
25143
|
}
|
25053
25144
|
|
25054
|
-
function
|
25145
|
+
function __wbg_get_imports() {
|
25055
25146
|
const imports = {};
|
25056
25147
|
imports.wbg = {};
|
25057
|
-
imports.wbg.__wbindgen_is_string = function(arg0) {
|
25058
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
25059
|
-
return ret;
|
25060
|
-
};
|
25061
|
-
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
25062
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
25063
|
-
return addHeapObject(ret);
|
25064
|
-
};
|
25065
25148
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
25066
25149
|
takeObject(arg0);
|
25067
25150
|
};
|
@@ -25072,33 +25155,46 @@ function getImports() {
|
|
25072
25155
|
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
25073
25156
|
const obj = getObject(arg1);
|
25074
25157
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
25075
|
-
var
|
25076
|
-
var
|
25077
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
25078
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
25158
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
25159
|
+
var len1 = WASM_VECTOR_LEN;
|
25160
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
25161
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
25079
25162
|
};
|
25080
|
-
imports.wbg.
|
25081
|
-
const ret = arg0;
|
25082
|
-
return addHeapObject(ret);
|
25083
|
-
};
|
25084
|
-
imports.wbg.__wbindgen_number_new = function(arg0) {
|
25085
|
-
const ret = arg0;
|
25163
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
25164
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
25086
25165
|
return addHeapObject(ret);
|
25087
25166
|
};
|
25088
|
-
imports.wbg.
|
25089
|
-
const ret =
|
25090
|
-
return
|
25167
|
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
25168
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
25169
|
+
return ret;
|
25091
25170
|
};
|
25092
25171
|
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
25093
25172
|
const ret = getObject(arg0);
|
25094
25173
|
return addHeapObject(ret);
|
25095
25174
|
};
|
25175
|
+
imports.wbg.__wbindgen_is_object = function(arg0) {
|
25176
|
+
const val = getObject(arg0);
|
25177
|
+
const ret = typeof(val) === 'object' && val !== null;
|
25178
|
+
return ret;
|
25179
|
+
};
|
25096
25180
|
imports.wbg.__wbg_String_91fba7ded13ba54c = function(arg0, arg1) {
|
25097
25181
|
const ret = String(getObject(arg1));
|
25098
|
-
const
|
25099
|
-
const
|
25100
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
25101
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
25182
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
25183
|
+
const len1 = WASM_VECTOR_LEN;
|
25184
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
25185
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
25186
|
+
};
|
25187
|
+
imports.wbg.__wbindgen_number_new = function(arg0) {
|
25188
|
+
const ret = arg0;
|
25189
|
+
return addHeapObject(ret);
|
25190
|
+
};
|
25191
|
+
imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
|
25192
|
+
const ret = arg0;
|
25193
|
+
return addHeapObject(ret);
|
25194
|
+
};
|
25195
|
+
imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
|
25196
|
+
const ret = BigInt.asUintN(64, arg0);
|
25197
|
+
return addHeapObject(ret);
|
25102
25198
|
};
|
25103
25199
|
imports.wbg.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) {
|
25104
25200
|
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
@@ -25109,54 +25205,47 @@ function getImports() {
|
|
25109
25205
|
};
|
25110
25206
|
imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
25111
25207
|
const ret = getObject(arg1).stack;
|
25112
|
-
const
|
25113
|
-
const
|
25114
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
25115
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
25208
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
25209
|
+
const len1 = WASM_VECTOR_LEN;
|
25210
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
25211
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
25116
25212
|
};
|
25117
25213
|
imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
25214
|
+
let deferred0_0;
|
25215
|
+
let deferred0_1;
|
25118
25216
|
try {
|
25217
|
+
deferred0_0 = arg0;
|
25218
|
+
deferred0_1 = arg1;
|
25119
25219
|
console.error(getStringFromWasm0(arg0, arg1));
|
25120
25220
|
} finally {
|
25121
|
-
wasm.__wbindgen_free(
|
25221
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1);
|
25122
25222
|
}
|
25123
25223
|
};
|
25124
25224
|
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
25125
25225
|
const ret = getObject(arg0) === undefined;
|
25126
25226
|
return ret;
|
25127
25227
|
};
|
25128
|
-
imports.wbg.
|
25129
|
-
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
|
25130
|
-
}, arguments) };
|
25131
|
-
imports.wbg.__wbg_getRandomValues_805f1c3d65988a5a = function() { return handleError(function (arg0, arg1) {
|
25132
|
-
getObject(arg0).getRandomValues(getObject(arg1));
|
25133
|
-
}, arguments) };
|
25134
|
-
imports.wbg.__wbg_crypto_e1d53a1d73fb10b8 = function(arg0) {
|
25228
|
+
imports.wbg.__wbg_crypto_70a96de3b6b73dac = function(arg0) {
|
25135
25229
|
const ret = getObject(arg0).crypto;
|
25136
25230
|
return addHeapObject(ret);
|
25137
25231
|
};
|
25138
|
-
imports.wbg.
|
25139
|
-
const val = getObject(arg0);
|
25140
|
-
const ret = typeof(val) === 'object' && val !== null;
|
25141
|
-
return ret;
|
25142
|
-
};
|
25143
|
-
imports.wbg.__wbg_process_038c26bf42b093f8 = function(arg0) {
|
25232
|
+
imports.wbg.__wbg_process_dd1577445152112e = function(arg0) {
|
25144
25233
|
const ret = getObject(arg0).process;
|
25145
25234
|
return addHeapObject(ret);
|
25146
25235
|
};
|
25147
|
-
imports.wbg.
|
25236
|
+
imports.wbg.__wbg_versions_58036bec3add9e6f = function(arg0) {
|
25148
25237
|
const ret = getObject(arg0).versions;
|
25149
25238
|
return addHeapObject(ret);
|
25150
25239
|
};
|
25151
|
-
imports.wbg.
|
25240
|
+
imports.wbg.__wbg_node_6a9d28205ed5b0d8 = function(arg0) {
|
25152
25241
|
const ret = getObject(arg0).node;
|
25153
25242
|
return addHeapObject(ret);
|
25154
25243
|
};
|
25155
|
-
imports.wbg.
|
25244
|
+
imports.wbg.__wbg_msCrypto_adbc770ec9eca9c7 = function(arg0) {
|
25156
25245
|
const ret = getObject(arg0).msCrypto;
|
25157
25246
|
return addHeapObject(ret);
|
25158
25247
|
};
|
25159
|
-
imports.wbg.
|
25248
|
+
imports.wbg.__wbg_require_f05d779769764e82 = function() { return handleError(function () {
|
25160
25249
|
const ret = module.require;
|
25161
25250
|
return addHeapObject(ret);
|
25162
25251
|
}, arguments) };
|
@@ -25164,94 +25253,100 @@ function getImports() {
|
|
25164
25253
|
const ret = typeof(getObject(arg0)) === 'function';
|
25165
25254
|
return ret;
|
25166
25255
|
};
|
25167
|
-
imports.wbg.
|
25256
|
+
imports.wbg.__wbg_getRandomValues_3774744e221a22ad = function() { return handleError(function (arg0, arg1) {
|
25257
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
25258
|
+
}, arguments) };
|
25259
|
+
imports.wbg.__wbg_randomFillSync_e950366c42764a07 = function() { return handleError(function (arg0, arg1) {
|
25260
|
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
25261
|
+
}, arguments) };
|
25262
|
+
imports.wbg.__wbg_new_18bc2084e9a3e1ff = function() {
|
25168
25263
|
const ret = new Array();
|
25169
25264
|
return addHeapObject(ret);
|
25170
25265
|
};
|
25171
|
-
imports.wbg.
|
25266
|
+
imports.wbg.__wbg_newnoargs_e643855c6572a4a8 = function(arg0, arg1) {
|
25172
25267
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
25173
25268
|
return addHeapObject(ret);
|
25174
25269
|
};
|
25175
|
-
imports.wbg.
|
25270
|
+
imports.wbg.__wbg_new_b6fd0149e79ffce8 = function() {
|
25176
25271
|
const ret = new Map();
|
25177
25272
|
return addHeapObject(ret);
|
25178
25273
|
};
|
25179
|
-
imports.wbg.
|
25274
|
+
imports.wbg.__wbg_call_f96b398515635514 = function() { return handleError(function (arg0, arg1) {
|
25180
25275
|
const ret = getObject(arg0).call(getObject(arg1));
|
25181
25276
|
return addHeapObject(ret);
|
25182
25277
|
}, arguments) };
|
25183
|
-
imports.wbg.
|
25278
|
+
imports.wbg.__wbg_new_7befa02319b36069 = function() {
|
25184
25279
|
const ret = new Object();
|
25185
25280
|
return addHeapObject(ret);
|
25186
25281
|
};
|
25187
|
-
imports.wbg.
|
25282
|
+
imports.wbg.__wbg_self_b9aad7f1c618bfaf = function() { return handleError(function () {
|
25188
25283
|
const ret = self.self;
|
25189
25284
|
return addHeapObject(ret);
|
25190
25285
|
}, arguments) };
|
25191
|
-
imports.wbg.
|
25286
|
+
imports.wbg.__wbg_window_55e469842c98b086 = function() { return handleError(function () {
|
25192
25287
|
const ret = window.window;
|
25193
25288
|
return addHeapObject(ret);
|
25194
25289
|
}, arguments) };
|
25195
|
-
imports.wbg.
|
25290
|
+
imports.wbg.__wbg_globalThis_d0957e302752547e = function() { return handleError(function () {
|
25196
25291
|
const ret = globalThis.globalThis;
|
25197
25292
|
return addHeapObject(ret);
|
25198
25293
|
}, arguments) };
|
25199
|
-
imports.wbg.
|
25294
|
+
imports.wbg.__wbg_global_ae2f87312b8987fb = function() { return handleError(function () {
|
25200
25295
|
const ret = global.global;
|
25201
25296
|
return addHeapObject(ret);
|
25202
25297
|
}, arguments) };
|
25203
|
-
imports.wbg.
|
25298
|
+
imports.wbg.__wbg_set_aee8682c7ee9ac44 = function(arg0, arg1, arg2) {
|
25204
25299
|
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
25205
25300
|
};
|
25206
|
-
imports.wbg.
|
25301
|
+
imports.wbg.__wbg_toString_27ba0397f8cf84a6 = function() { return handleError(function (arg0, arg1) {
|
25207
25302
|
const ret = getObject(arg0).toString(arg1);
|
25208
25303
|
return addHeapObject(ret);
|
25209
25304
|
}, arguments) };
|
25210
|
-
imports.wbg.
|
25305
|
+
imports.wbg.__wbg_call_35782e9a1aa5e091 = function() { return handleError(function (arg0, arg1, arg2) {
|
25211
25306
|
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
25212
25307
|
return addHeapObject(ret);
|
25213
25308
|
}, arguments) };
|
25214
|
-
imports.wbg.
|
25309
|
+
imports.wbg.__wbg_set_6c1b2b7b73337778 = function(arg0, arg1, arg2) {
|
25215
25310
|
const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
|
25216
25311
|
return addHeapObject(ret);
|
25217
25312
|
};
|
25218
|
-
imports.wbg.
|
25313
|
+
imports.wbg.__wbg_fromEntries_10a57760b5d7d9b8 = function() { return handleError(function (arg0) {
|
25219
25314
|
const ret = Object.fromEntries(getObject(arg0));
|
25220
25315
|
return addHeapObject(ret);
|
25221
25316
|
}, arguments) };
|
25222
|
-
imports.wbg.
|
25317
|
+
imports.wbg.__wbg_buffer_fcbfb6d88b2732e9 = function(arg0) {
|
25223
25318
|
const ret = getObject(arg0).buffer;
|
25224
25319
|
return addHeapObject(ret);
|
25225
25320
|
};
|
25226
|
-
imports.wbg.
|
25321
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_92c251989c485785 = function(arg0, arg1, arg2) {
|
25227
25322
|
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
25228
25323
|
return addHeapObject(ret);
|
25229
25324
|
};
|
25230
|
-
imports.wbg.
|
25325
|
+
imports.wbg.__wbg_new_bc5d9aad3f9ac80e = function(arg0) {
|
25231
25326
|
const ret = new Uint8Array(getObject(arg0));
|
25232
25327
|
return addHeapObject(ret);
|
25233
25328
|
};
|
25234
|
-
imports.wbg.
|
25329
|
+
imports.wbg.__wbg_set_4b3aa8445ac1e91c = function(arg0, arg1, arg2) {
|
25235
25330
|
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
25236
25331
|
};
|
25237
|
-
imports.wbg.
|
25332
|
+
imports.wbg.__wbg_length_d9c4ded7e708c6a1 = function(arg0) {
|
25238
25333
|
const ret = getObject(arg0).length;
|
25239
25334
|
return ret;
|
25240
25335
|
};
|
25241
|
-
imports.wbg.
|
25336
|
+
imports.wbg.__wbg_newwithlength_89eca18f2603a999 = function(arg0) {
|
25242
25337
|
const ret = new Uint8Array(arg0 >>> 0);
|
25243
25338
|
return addHeapObject(ret);
|
25244
25339
|
};
|
25245
|
-
imports.wbg.
|
25340
|
+
imports.wbg.__wbg_subarray_7649d027b2b141b3 = function(arg0, arg1, arg2) {
|
25246
25341
|
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
25247
25342
|
return addHeapObject(ret);
|
25248
25343
|
};
|
25249
25344
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
25250
25345
|
const ret = debugString(getObject(arg1));
|
25251
|
-
const
|
25252
|
-
const
|
25253
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
25254
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
25346
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
25347
|
+
const len1 = WASM_VECTOR_LEN;
|
25348
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
25349
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
25255
25350
|
};
|
25256
25351
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
25257
25352
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
@@ -25264,9 +25359,9 @@ function getImports() {
|
|
25264
25359
|
return imports;
|
25265
25360
|
}
|
25266
25361
|
|
25267
|
-
function
|
25362
|
+
function __wbg_finalize_init(instance, module) {
|
25268
25363
|
wasm = instance.exports;
|
25269
|
-
|
25364
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
25270
25365
|
cachedInt32Memory0 = null;
|
25271
25366
|
cachedUint32Memory0 = null;
|
25272
25367
|
cachedUint8Memory0 = null;
|
@@ -25275,19 +25370,21 @@ function finalizeInit(instance, module) {
|
|
25275
25370
|
return wasm;
|
25276
25371
|
}
|
25277
25372
|
|
25278
|
-
async function
|
25373
|
+
async function __wbg_init(input) {
|
25374
|
+
if (wasm !== undefined) return wasm;
|
25375
|
+
|
25279
25376
|
if (typeof input === 'undefined') {
|
25280
|
-
input = new URL(new URL('assets/rln_wasm_bg-
|
25377
|
+
input = new URL(new URL('assets/rln_wasm_bg-a503e304.wasm', import.meta.url).href, import.meta.url);
|
25281
25378
|
}
|
25282
|
-
const imports =
|
25379
|
+
const imports = __wbg_get_imports();
|
25283
25380
|
|
25284
25381
|
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
25285
25382
|
input = fetch(input);
|
25286
25383
|
}
|
25287
25384
|
|
25288
|
-
const { instance, module } = await
|
25385
|
+
const { instance, module } = await __wbg_load(await input, imports);
|
25289
25386
|
|
25290
|
-
return
|
25387
|
+
return __wbg_finalize_init(instance, module);
|
25291
25388
|
}
|
25292
25389
|
|
25293
25390
|
const verificationKey = {
|
@@ -25726,7 +25823,7 @@ async function loadZkey() {
|
|
25726
25823
|
* @returns RLNInstance
|
25727
25824
|
*/
|
25728
25825
|
async function create$1() {
|
25729
|
-
await
|
25826
|
+
await __wbg_init?.();
|
25730
25827
|
init_panic_hook();
|
25731
25828
|
const witnessCalculator = await loadWitnessCalculator();
|
25732
25829
|
const zkey = await loadZkey();
|
@@ -49692,27 +49789,51 @@ class MerkleRootTracker {
|
|
49692
49789
|
}
|
49693
49790
|
|
49694
49791
|
class RLNContract {
|
49695
|
-
constructor(rlnInstance, { address, provider }) {
|
49696
|
-
this._members = [];
|
49697
|
-
const initialRoot = rlnInstance.getMerkleRoot();
|
49698
|
-
this._contract = new Contract(address, RLN_ABI, provider);
|
49699
|
-
this.merkleRootTracker = new MerkleRootTracker(5, initialRoot);
|
49700
|
-
this.membersFilter = this.contract.filters.MemberRegistered();
|
49701
|
-
}
|
49702
49792
|
static async init(rlnInstance, options) {
|
49703
49793
|
const rlnContract = new RLNContract(rlnInstance, options);
|
49794
|
+
await rlnContract.initStorageContract(options.provider);
|
49704
49795
|
await rlnContract.fetchMembers(rlnInstance);
|
49705
49796
|
rlnContract.subscribeToMembers(rlnInstance);
|
49706
49797
|
return rlnContract;
|
49707
49798
|
}
|
49799
|
+
constructor(rlnInstance, { registryAddress, provider }) {
|
49800
|
+
this._members = new Map();
|
49801
|
+
const initialRoot = rlnInstance.getMerkleRoot();
|
49802
|
+
this.registryContract = new Contract(registryAddress, RLN_REGISTRY_ABI, provider);
|
49803
|
+
this.merkleRootTracker = new MerkleRootTracker(5, initialRoot);
|
49804
|
+
}
|
49805
|
+
async initStorageContract(provider, options = {}) {
|
49806
|
+
const storageIndex = options?.storageIndex
|
49807
|
+
? options.storageIndex
|
49808
|
+
: await this.registryContract.usingStorageIndex();
|
49809
|
+
const storageAddress = await this.registryContract.storages(storageIndex);
|
49810
|
+
if (!storageAddress || storageAddress === AddressZero) {
|
49811
|
+
throw Error("No RLN Storage initialized on registry contract.");
|
49812
|
+
}
|
49813
|
+
this.storageIndex = storageIndex;
|
49814
|
+
this.storageContract = new Contract(storageAddress, RLN_STORAGE_ABI, provider);
|
49815
|
+
this._membersFilter = this.storageContract.filters.MemberRegistered();
|
49816
|
+
this.deployBlock = await this.storageContract.deployedBlockNumber();
|
49817
|
+
}
|
49708
49818
|
get contract() {
|
49709
|
-
|
49819
|
+
if (!this.storageContract) {
|
49820
|
+
throw Error("Storage contract was not initialized");
|
49821
|
+
}
|
49822
|
+
return this.storageContract;
|
49710
49823
|
}
|
49711
49824
|
get members() {
|
49712
|
-
|
49825
|
+
const sortedMembers = Array.from(this._members.values()).sort((left, right) => left.index.toNumber() - right.index.toNumber());
|
49826
|
+
return sortedMembers;
|
49827
|
+
}
|
49828
|
+
get membersFilter() {
|
49829
|
+
if (!this._membersFilter) {
|
49830
|
+
throw Error("Members filter was not initialized.");
|
49831
|
+
}
|
49832
|
+
return this._membersFilter;
|
49713
49833
|
}
|
49714
49834
|
async fetchMembers(rlnInstance, options = {}) {
|
49715
49835
|
const registeredMemberEvents = await queryFilter(this.contract, {
|
49836
|
+
fromBlock: this.deployBlock,
|
49716
49837
|
...options,
|
49717
49838
|
membersFilter: this.membersFilter,
|
49718
49839
|
});
|
@@ -49729,11 +49850,11 @@ class RLNContract {
|
|
49729
49850
|
const index = evt.args.index;
|
49730
49851
|
const toRemoveVal = toRemoveTable.get(evt.blockNumber);
|
49731
49852
|
if (toRemoveVal != undefined) {
|
49732
|
-
toRemoveVal.push(index);
|
49853
|
+
toRemoveVal.push(index.toNumber());
|
49733
49854
|
toRemoveTable.set(evt.blockNumber, toRemoveVal);
|
49734
49855
|
}
|
49735
49856
|
else {
|
49736
|
-
toRemoveTable.set(evt.blockNumber, [index]);
|
49857
|
+
toRemoveTable.set(evt.blockNumber, [index.toNumber()]);
|
49737
49858
|
}
|
49738
49859
|
}
|
49739
49860
|
else {
|
@@ -49744,21 +49865,24 @@ class RLNContract {
|
|
49744
49865
|
eventsPerBlock.push(evt);
|
49745
49866
|
toInsertTable.set(evt.blockNumber, eventsPerBlock);
|
49746
49867
|
}
|
49747
|
-
this.removeMembers(rlnInstance, toRemoveTable);
|
49748
|
-
this.insertMembers(rlnInstance, toInsertTable);
|
49749
49868
|
});
|
49869
|
+
this.removeMembers(rlnInstance, toRemoveTable);
|
49870
|
+
this.insertMembers(rlnInstance, toInsertTable);
|
49750
49871
|
}
|
49751
49872
|
insertMembers(rlnInstance, toInsert) {
|
49752
49873
|
toInsert.forEach((events, blockNumber) => {
|
49753
49874
|
events.forEach((evt) => {
|
49754
|
-
|
49875
|
+
const _idCommitment = evt?.args?.idCommitment;
|
49876
|
+
const index = evt?.args?.index;
|
49877
|
+
if (!_idCommitment || !index) {
|
49755
49878
|
return;
|
49756
49879
|
}
|
49757
|
-
const
|
49758
|
-
const index = evt.args.index;
|
49759
|
-
const idCommitment = zeroPad(arrayify(pubkey), 32);
|
49880
|
+
const idCommitment = zeroPadLE(hexToBytes$2(_idCommitment?._hex), 32);
|
49760
49881
|
rlnInstance.insertMember(idCommitment);
|
49761
|
-
this.
|
49882
|
+
this._members.set(index.toNumber(), {
|
49883
|
+
index,
|
49884
|
+
idCommitment: _idCommitment?._hex,
|
49885
|
+
});
|
49762
49886
|
});
|
49763
49887
|
const currentRoot = rlnInstance.getMerkleRoot();
|
49764
49888
|
this.merkleRootTracker.pushRoot(blockNumber, currentRoot);
|
@@ -49768,9 +49892,8 @@ class RLNContract {
|
|
49768
49892
|
const removeDescending = new Map([...toRemove].sort().reverse());
|
49769
49893
|
removeDescending.forEach((indexes, blockNumber) => {
|
49770
49894
|
indexes.forEach((index) => {
|
49771
|
-
|
49772
|
-
|
49773
|
-
this.members.splice(idx, 1);
|
49895
|
+
if (this._members.has(index)) {
|
49896
|
+
this._members.delete(index);
|
49774
49897
|
}
|
49775
49898
|
rlnInstance.deleteMember(index);
|
49776
49899
|
});
|
@@ -49778,19 +49901,28 @@ class RLNContract {
|
|
49778
49901
|
});
|
49779
49902
|
}
|
49780
49903
|
subscribeToMembers(rlnInstance) {
|
49781
|
-
this.contract.on(this.membersFilter, (_pubkey, _index, event) => this.processEvents(rlnInstance, event));
|
49904
|
+
this.contract.on(this.membersFilter, (_pubkey, _index, event) => this.processEvents(rlnInstance, [event]));
|
49782
49905
|
}
|
49783
49906
|
async registerWithSignature(rlnInstance, signature) {
|
49784
49907
|
const identityCredential = await rlnInstance.generateSeededIdentityCredential(signature);
|
49785
49908
|
return this.registerWithKey(identityCredential);
|
49786
49909
|
}
|
49787
49910
|
async registerWithKey(credential) {
|
49788
|
-
|
49789
|
-
|
49790
|
-
|
49791
|
-
});
|
49911
|
+
if (this.storageIndex === undefined) {
|
49912
|
+
throw Error("Cannot register credential, no storage contract index found.");
|
49913
|
+
}
|
49914
|
+
const txRegisterResponse = await this.registryContract["register(uint16,uint256)"](this.storageIndex, credential.IDCommitmentBigInt, { gasLimit: 100000 });
|
49792
49915
|
const txRegisterReceipt = await txRegisterResponse.wait();
|
49793
|
-
|
49916
|
+
// assumption: register(uint16,uint256) emits one event
|
49917
|
+
const memberRegistered = txRegisterReceipt?.events?.[0];
|
49918
|
+
if (!memberRegistered) {
|
49919
|
+
return undefined;
|
49920
|
+
}
|
49921
|
+
const decodedData = this.contract.interface.decodeEventLog("MemberRegistered", memberRegistered.data);
|
49922
|
+
return {
|
49923
|
+
idCommitment: decodedData.idCommitment,
|
49924
|
+
index: decodedData.index,
|
49925
|
+
};
|
49794
49926
|
}
|
49795
49927
|
roots() {
|
49796
49928
|
return this.merkleRootTracker.roots();
|
@@ -49856,4 +49988,4 @@ async function create() {
|
|
49856
49988
|
return await rlnModule.create();
|
49857
49989
|
}
|
49858
49990
|
|
49859
|
-
export { IdentityCredential, Keystore, MerkleRootTracker, Proof, ProofMetadata, RLNContract, RLNDecoder, RLNEncoder, RLNInstance,
|
49991
|
+
export { IdentityCredential, Keystore, MerkleRootTracker, Proof, ProofMetadata, RLNContract, RLNDecoder, RLNEncoder, RLNInstance, RLN_REGISTRY_ABI, RLN_STORAGE_ABI, SEPOLIA_CONTRACT, create };
|