-
Notifications
You must be signed in to change notification settings - Fork 9
/
accumulator.spec.ts
498 lines (407 loc) · 21.8 KB
/
accumulator.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
import { generateRandomFieldElement } from 'crypto-wasm-new';
import {
initializeWasm,
IInitialElementsStore,
Accumulator,
PositiveAccumulator,
UniversalAccumulator,
VBMembershipWitness,
VBWitnessUpdateInfo,
AccumulatorParams,
AccumulatorKeypair, KBUniversalNonMembershipWitnessUpdateInfo, KBUniversalAccumulatorValue, areUint8ArraysEqual
} from '../src';
import {
InMemoryInitialElementsStore, InMemoryKBUniversalState,
InMemoryState,
InMemoryUniversalState
} from '../src/accumulator/in-memory-persistence';
import { KBUniversalMembershipWitness } from '../src';
import { KBUniversalAccumulator } from '../src';
import {
KBUniversalMembershipWitnessUpdateInfo,
KBUniversalWitnessUpdateInfo
} from '../src/accumulator/witness-update-info';
import { stringToBytes } from './utils';
function getAccum(accumulator: any): PositiveAccumulator | UniversalAccumulator | KBUniversalAccumulator {
const accumulated = accumulator.accumulated;
let tempAccumulator;
if (accumulator instanceof PositiveAccumulator) {
tempAccumulator = PositiveAccumulator.fromAccumulated(accumulated);
} else if (accumulator instanceof UniversalAccumulator) {
tempAccumulator = UniversalAccumulator.fromAccumulated(accumulated);
} else {
tempAccumulator = KBUniversalAccumulator.fromAccumulated(accumulated);
}
return tempAccumulator;
}
async function runCommonTestsForMembership(
keypair: AccumulatorKeypair,
params: AccumulatorParams,
accumulator: PositiveAccumulator | UniversalAccumulator | KBUniversalAccumulator,
state: InMemoryState | InMemoryKBUniversalState,
members: Uint8Array[],
store?: IInitialElementsStore
) {
const sk = keypair.sk;
const pk = keypair.pk;
let witClass, witUpdClass;
if (accumulator instanceof PositiveAccumulator) {
witClass = VBMembershipWitness;
witUpdClass = VBWitnessUpdateInfo;
} else if (accumulator instanceof UniversalAccumulator) {
witClass = VBMembershipWitness;
witUpdClass = VBWitnessUpdateInfo;
} else {
witClass = KBUniversalMembershipWitness;
witUpdClass = KBUniversalMembershipWitnessUpdateInfo;
}
const e1 = members.pop() as Uint8Array;
const e2 = members.pop() as Uint8Array;
expect(state.size).toEqual(0);
await expect(state.has(e1)).resolves.toEqual(false);
// @ts-ignore
await accumulator.add(e1, sk, state, store);
expect(state.size).toEqual(1);
await expect(state.has(e1)).resolves.toEqual(true);
// @ts-ignore
await expect(accumulator.add(e1, sk, state, store)).rejects.toThrow();
// @ts-ignore
await expect(accumulator.remove(e2, sk, state)).rejects.toThrow();
// @ts-ignore
await accumulator.add(e2, sk, state, store);
expect(state.size).toEqual(2);
await expect(state.has(e2)).resolves.toEqual(true);
// @ts-ignore
await accumulator.remove(e2, sk, state, store);
expect(state.size).toEqual(1);
await expect(state.has(e2)).resolves.toEqual(false);
const e3 = members.pop() as Uint8Array;
const e4 = members.pop() as Uint8Array;
// @ts-ignore
await accumulator.addBatch([e3, e4], sk, state, store);
expect(state.size).toEqual(3);
await expect(state.has(e3)).resolves.toEqual(true);
await expect(state.has(e4)).resolves.toEqual(true);
// @ts-ignore
await expect(accumulator.addBatch([e3, e4], sk, state, store)).rejects.toThrow();
expect(state.size).toEqual(3);
// @ts-ignore
await accumulator.removeBatch([e3, e4], sk, state, store);
expect(state.size).toEqual(1);
await expect(state.has(e3)).resolves.toEqual(false);
await expect(state.has(e4)).resolves.toEqual(false);
// @ts-ignore
await expect(accumulator.removeBatch([e3, e4], sk, state, store)).rejects.toThrow();
expect(state.size).toEqual(1);
const e5 = members.pop() as Uint8Array;
const e6 = members.pop() as Uint8Array;
// @ts-ignore
await accumulator.addRemoveBatches([e5, e6], [e1], sk, state, store);
expect(state.size).toEqual(2);
await expect(state.has(e5)).resolves.toEqual(true);
await expect(state.has(e6)).resolves.toEqual(true);
await expect(state.has(e1)).resolves.toEqual(false);
const accumulated = accumulator.accumulated;
let tempAccumulator = getAccum(accumulator);
expect(
// @ts-ignore
tempAccumulator.verifyMembershipWitness(e5, await accumulator.membershipWitness(e5, sk, state), pk, params)
).toEqual(true);
expect(
// @ts-ignore
tempAccumulator.verifyMembershipWitness(e6, await accumulator.membershipWitness(e6, sk, state), pk, params)
).toEqual(true);
// @ts-ignore
const wits = await accumulator.membershipWitnessesForBatch([e5, e6], sk, state);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e5, wits[0], pk, params)).toEqual(true);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e6, wits[1], pk, params)).toEqual(true);
const e7 = members.pop() as Uint8Array;
const e8 = members.pop() as Uint8Array;
// @ts-ignore
await accumulator.addBatch([e7, e8], sk, state, store);
// Witness updates by accumulator manager using secret key
// @ts-ignore
const newWits = witClass.updateMultiplePostBatchUpdates(wits, [e5, e6], [e7, e8], [], accumulated, sk);
tempAccumulator = getAccum(accumulator);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e5, newWits[0], pk, params)).toEqual(true);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e6, newWits[1], pk, params)).toEqual(true);
// Witness update info created by accumulator manager
// @ts-ignore
const witnessUpdInfo = witUpdClass.new(accumulated, [e7, e8], [], sk);
// Witness can be updated without secret key using public info
wits[0].updateUsingPublicInfoPostBatchUpdate(e5, [e7, e8], [], witnessUpdInfo);
wits[1].updateUsingPublicInfoPostBatchUpdate(e6, [e7, e8], [], witnessUpdInfo);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e5, wits[0], pk, params)).toEqual(true);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e6, wits[1], pk, params)).toEqual(true);
// @ts-ignore
const e5Wit = await accumulator.membershipWitness(e5, sk, state);
// @ts-ignore
const e6Wit = await accumulator.membershipWitness(e6, sk, state);
let e5WitTemp = new witClass(e5Wit.value);
let e6WitTemp = new witClass(e6Wit.value);
const e9 = members.pop() as Uint8Array;
const e10 = members.pop() as Uint8Array;
const e11 = members.pop() as Uint8Array;
const e12 = members.pop() as Uint8Array;
const e13 = members.pop() as Uint8Array;
const e14 = members.pop() as Uint8Array;
const e15 = members.pop() as Uint8Array;
const additions = [
[e9, e10],
[e11, e12],
[e13, e14, e15]
];
const removals = [[e7, e8], [e9], []];
// @ts-ignore
const witUpd1 = witUpdClass.new(accumulator.accumulated, additions[0], removals[0], sk);
// @ts-ignore
await accumulator.addRemoveBatches(additions[0], removals[0], sk, state);
tempAccumulator = getAccum(accumulator);
e5WitTemp.updateUsingPublicInfoPostBatchUpdate(e5, additions[0], removals[0], witUpd1);
e6WitTemp.updateUsingPublicInfoPostBatchUpdate(e6, additions[0], removals[0], witUpd1);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e5, e5WitTemp, pk, params)).toEqual(true);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e6, e6WitTemp, pk, params)).toEqual(true);
// @ts-ignore
const witUpd2 = witUpdClass.new(accumulator.accumulated, additions[1], removals[1], sk);
// @ts-ignore
await accumulator.addRemoveBatches(additions[1], removals[1], sk, state);
tempAccumulator = getAccum(accumulator);
e5WitTemp.updateUsingPublicInfoPostBatchUpdate(e5, additions[1], removals[1], witUpd2);
e6WitTemp.updateUsingPublicInfoPostBatchUpdate(e6, additions[1], removals[1], witUpd2);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e5, e5WitTemp, pk, params)).toEqual(true);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e6, e6WitTemp, pk, params)).toEqual(true);
// @ts-ignore
const witUpd3 = witUpdClass.new(accumulator.accumulated, additions[2], removals[2], sk);
// @ts-ignore
await accumulator.addRemoveBatches(additions[2], removals[2], sk, state);
tempAccumulator = getAccum(accumulator);
e5WitTemp.updateUsingPublicInfoPostBatchUpdate(e5, additions[2], removals[2], witUpd3);
e6WitTemp.updateUsingPublicInfoPostBatchUpdate(e6, additions[2], removals[2], witUpd3);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e5, e5WitTemp, pk, params)).toEqual(true);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e6, e6WitTemp, pk, params)).toEqual(true);
const witUpds = [witUpd1, witUpd2, witUpd3];
e5Wit.updateUsingPublicInfoPostMultipleBatchUpdates(e5, additions, removals, witUpds);
e6Wit.updateUsingPublicInfoPostMultipleBatchUpdates(e6, additions, removals, witUpds);
tempAccumulator = getAccum(accumulator);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e5, e5Wit, pk, params)).toEqual(true);
// @ts-ignore
expect(tempAccumulator.verifyMembershipWitness(e6, e6Wit, pk, params)).toEqual(true);
}
describe('Accumulators type', () => {
beforeAll(async () => {
await initializeWasm();
});
it('State update', async () => {
const params = PositiveAccumulator.generateParams();
const keypair = PositiveAccumulator.generateKeypair(params);
const posAccumulator = PositiveAccumulator.initialize(params);
const posState = new InMemoryState();
const uniState = new InMemoryKBUniversalState();
const domain = [generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement()];
const uniAccumulator = await KBUniversalAccumulator.initialize(domain, params, keypair.secretKey, uniState);
for (const d of domain) {
expect(await uniState.inDomain(d)).toEqual(true);
}
async function check(accum: PositiveAccumulator | KBUniversalAccumulator, state, members1: Uint8Array[], members2: Uint8Array[]) {
for (let i = 0; i < members1.length; i++) {
expect(await state.has(members1[i])).toEqual(false);
}
await accum.addBatch(members1, keypair.secretKey, state);
for (let i = 0; i < members1.length; i++) {
expect(await state.has(members1[i])).toEqual(true);
}
for (let i = 0; i < members2.length; i++) {
expect(await state.has(members2[i])).toEqual(false);
}
await accum.addRemoveBatches(members2, members1, keypair.secretKey, state);
for (let i = 0; i < members2.length; i++) {
expect(await state.has(members2[i])).toEqual(true);
}
for (let i = 0; i < members1.length; i++) {
expect(await state.has(members1[i])).toEqual(false);
}
}
await check(posAccumulator, posState, [generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement()], [generateRandomFieldElement(), generateRandomFieldElement()]);
await check(uniAccumulator, uniState, domain.slice(0, 3), domain.slice(3));
// Cannot add element not part of the domain
const oldSize = uniState.size;
const newElement = generateRandomFieldElement();
expect(uniAccumulator.add(newElement, keypair.secretKey, uniState)).rejects.toThrow();
expect(await uniState.inDomain(newElement)).toEqual(false);
expect(await uniState.has(newElement)).toEqual(false);
expect(uniState.size).toEqual(oldSize);
// Add to domain
await uniAccumulator.extend([newElement], keypair.secretKey, uniState);
// Now it works
await uniAccumulator.add(newElement, keypair.secretKey, uniState);
expect(await uniState.inDomain(newElement)).toEqual(true);
expect(await uniState.has(newElement)).toEqual(true);
expect(uniState.size).toEqual(oldSize + 1);
// Cannot extend the domain with an existing element
expect(() => uniAccumulator.extend([newElement], keypair.secretKey, uniState)).rejects.toThrow();
const oldVal = uniAccumulator.value;
const newElements = [generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement()];
for (const e of newElements) {
expect(await uniState.inDomain(e)).toEqual(false);
}
await uniAccumulator.extend(newElements, keypair.secretKey, uniState);
for (const e of newElements) {
expect(await uniState.inDomain(e)).toEqual(true);
}
expect(uniAccumulator.value.mem).toEqual(oldVal.mem);
expect(uniAccumulator.value.nonMem).not.toEqual(oldVal.nonMem);
// Cannot extend the domain with existing elements
expect(() => uniAccumulator.extend(newElements, keypair.secretKey, uniState)).rejects.toThrow();
const val = uniAccumulator.value;
const valAsBytes = val.toBytes();
const recons = KBUniversalAccumulatorValue.fromBytes(valAsBytes);
expect(areUint8ArraysEqual(val.mem, recons.mem)).toEqual(true);
expect(areUint8ArraysEqual(val.nonMem, recons.nonMem)).toEqual(true);
});
it('Positive accumulator', async () => {
const label = stringToBytes('Accumulator params');
const params = PositiveAccumulator.generateParams(label);
const keypair = PositiveAccumulator.generateKeypair(params);
const accumulator = PositiveAccumulator.initialize(params);
const state = new InMemoryState();
const domain = Array.from(Array(20).keys()).map((i) => Accumulator.encodePositiveNumberAsAccumulatorMember(100 + i));
await runCommonTestsForMembership(keypair, params, accumulator, state, domain);
});
it('VB universal accumulator', async () => {
const params = UniversalAccumulator.generateParams();
const keypair = UniversalAccumulator.generateKeypair(params);
const store = new InMemoryInitialElementsStore();
const maxSize = 20;
const accumulator1 = await UniversalAccumulator.initialize(maxSize, params, keypair.secretKey, store);
const fixed = UniversalAccumulator.fixedInitialElements();
expect(store.store.size).toEqual(maxSize + fixed.length + 1);
for (const i of fixed) {
await expect(store.has(i)).resolves.toEqual(true);
}
const state1 = new InMemoryUniversalState();
const domain = Array.from(Array(20).keys()).map((i) => Accumulator.encodePositiveNumberAsAccumulatorMember(100 + i));
await runCommonTestsForMembership(keypair, params, accumulator1, state1, domain, store);
const nm1 = Accumulator.encodePositiveNumberAsAccumulatorMember(500);
const nm1Wit = await accumulator1.nonMembershipWitness(nm1, state1, keypair.secretKey, params, store, 2);
let tempAccumulator = getAccum(accumulator1) as UniversalAccumulator;
expect(tempAccumulator.verifyNonMembershipWitness(nm1, nm1Wit, keypair.publicKey, params)).toEqual(true);
const nm2 = Accumulator.encodePositiveNumberAsAccumulatorMember(501);
const nm3 = Accumulator.encodePositiveNumberAsAccumulatorMember(502);
const [nm2Wit, nm3Wit] = await accumulator1.nonMembershipWitnessesForBatch(
[nm2, nm3],
state1,
keypair.secretKey,
params,
store,
3
);
expect(tempAccumulator.verifyNonMembershipWitness(nm2, nm2Wit, keypair.publicKey, params)).toEqual(true);
expect(tempAccumulator.verifyNonMembershipWitness(nm3, nm3Wit, keypair.publicKey, params)).toEqual(true);
});
it('KB universal accumulator', async () => {
function checkWitnessUpdInfoSerz(witUpdMem, witUpdNonMem) {
const t = new KBUniversalWitnessUpdateInfo(witUpdMem, witUpdNonMem);
const b = t.toBytes();
const r = KBUniversalWitnessUpdateInfo.fromBytes(b);
if (witUpdMem !== undefined) {
// @ts-ignore
expect(areUint8ArraysEqual(r.mem.value, t.mem.value)).toEqual(true);
} else {
expect(r.mem).not.toBeDefined();
}
if (witUpdNonMem !== undefined) {
// @ts-ignore
expect(areUint8ArraysEqual(r.nonMem.value, t.nonMem.value)).toEqual(true);
} else {
expect(r.nonMem).not.toBeDefined();
}
}
const label = stringToBytes('Accumulator params');
const params = KBUniversalAccumulator.generateParams(label);
const keypair = KBUniversalAccumulator.generateKeypair(params);
const state = new InMemoryKBUniversalState();
const domain = Array.from(Array(20).keys()).map((i) => Accumulator.encodePositiveNumberAsAccumulatorMember(100 + i));
const accumulator = await KBUniversalAccumulator.initialize(domain, params, keypair.secretKey, state);
await runCommonTestsForMembership(keypair, params, accumulator, state, domain);
async function checkNonMemWit(nonMember: Uint8Array) {
expect(await state.has(nonMember)).toEqual(false);
expect(await state.inDomain(nonMember)).toEqual(true);
const wit = await accumulator.nonMembershipWitness(nonMember, keypair.secretKey, state);
let tempAccumulator = getAccum(accumulator) as KBUniversalAccumulator;
expect(tempAccumulator.verifyNonMembershipWitness(nonMember, wit, keypair.publicKey, params)).toEqual(true);
return wit;
}
const nm1Wit = await checkNonMemWit(domain[0]);
const nm2Wit = await checkNonMemWit(domain[1]);
const nm3Wit = await checkNonMemWit(domain[2]);
const [nm1Wit_, nm2Wit_, nm3Wit_] = await accumulator.nonMembershipWitnessesForBatch(
[domain[0], domain[1], domain[2]],
keypair.secretKey,
state,
);
expect(areUint8ArraysEqual(nm1Wit.value, nm1Wit_.value)).toEqual(true);
expect(areUint8ArraysEqual(nm2Wit.value, nm2Wit_.value)).toEqual(true);
expect(areUint8ArraysEqual(nm3Wit.value, nm3Wit_.value)).toEqual(true);
const newElements = [generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement()];
await accumulator.extend(newElements, keypair.secretKey, state);
await accumulator.addBatch(newElements.slice(0, 3), keypair.secretKey, state);
const member = newElements[3];
await accumulator.add(member, keypair.secretKey, state);
const memWit = await accumulator.membershipWitness(member, keypair.secretKey, state);
expect(accumulator.verifyMembershipWitness(member, memWit, keypair.publicKey, params)).toEqual(true);
const nonMember = domain[0];
const nonMemWit = await accumulator.nonMembershipWitness(nonMember, keypair.secretKey, state);
const additions = [domain[1], domain[2]];
const removals = [newElements[0], newElements[1]];
const witUpdMem = KBUniversalMembershipWitnessUpdateInfo.new(accumulator.accumulated, additions, removals, keypair.secretKey);
const witUpdNonMem = KBUniversalNonMembershipWitnessUpdateInfo.new(accumulator.accumulated, additions, removals, keypair.secretKey);
const [witUpdMem_, witUpdNonMem_] = accumulator.witnessUpdateInfoForBothWitnessTypes(additions, removals, keypair.secretKey)
expect(areUint8ArraysEqual(witUpdMem.value, witUpdMem_.value)).toEqual(true);
expect(areUint8ArraysEqual(witUpdNonMem.value, witUpdNonMem_.value)).toEqual(true);
checkWitnessUpdInfoSerz(witUpdMem, witUpdNonMem);
checkWitnessUpdInfoSerz(witUpdMem, undefined);
checkWitnessUpdInfoSerz(undefined, witUpdNonMem);
await accumulator.addRemoveBatches(additions, removals, keypair.secretKey, state);
memWit.updateUsingPublicInfoPostBatchUpdate(member, additions, removals, witUpdMem);
expect(accumulator.verifyMembershipWitness(member, memWit, keypair.publicKey, params)).toEqual(true);
nonMemWit.updateUsingPublicInfoPostBatchUpdate(nonMember, additions, removals, witUpdNonMem);
expect(accumulator.verifyNonMembershipWitness(nonMember, nonMemWit, keypair.publicKey, params)).toEqual(true);
const newElements1 = [generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement()];
const witUpdNonMem1 = accumulator.witnessUpdateInfoForNonMembershipWitnessAfterDomainExtension(newElements1, keypair.secretKey);
const witUpdNonMem1_ = KBUniversalNonMembershipWitnessUpdateInfo.newAfterDomainExtension(accumulator.accumulated, newElements1, keypair.secretKey);
await accumulator.extend(newElements1, keypair.secretKey, state);
checkWitnessUpdInfoSerz(undefined, witUpdNonMem1);
expect(areUint8ArraysEqual(witUpdNonMem1.value, witUpdNonMem1_.value)).toEqual(true);
expect(accumulator.verifyNonMembershipWitness(nonMember, nonMemWit, keypair.publicKey, params)).toEqual(false);
nonMemWit.updateUsingPublicInfoPostDomainExtension(nonMember, newElements1, witUpdNonMem1);
expect(accumulator.verifyNonMembershipWitness(nonMember, nonMemWit, keypair.publicKey, params)).toEqual(true);
const newElements2 = [generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement()];
const newElements3 = [generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement()];
const witUpdNonMem2 = accumulator.witnessUpdateInfoForNonMembershipWitnessAfterDomainExtension(newElements2, keypair.secretKey);
const witUpdNonMem2_ = KBUniversalNonMembershipWitnessUpdateInfo.newAfterDomainExtension(accumulator.accumulated, newElements2, keypair.secretKey);
expect(areUint8ArraysEqual(witUpdNonMem2.value, witUpdNonMem2_.value)).toEqual(true);
await accumulator.extend(newElements2, keypair.secretKey, state);
checkWitnessUpdInfoSerz(undefined, witUpdNonMem2);
const witUpdNonMem3 = accumulator.witnessUpdateInfoForNonMembershipWitnessAfterDomainExtension(newElements3, keypair.secretKey);
const witUpdNonMem3_ = KBUniversalNonMembershipWitnessUpdateInfo.newAfterDomainExtension(accumulator.accumulated, newElements3, keypair.secretKey);
expect(areUint8ArraysEqual(witUpdNonMem3.value, witUpdNonMem3_.value)).toEqual(true);
await accumulator.extend(newElements3, keypair.secretKey, state);
checkWitnessUpdInfoSerz(undefined, witUpdNonMem3);
expect(accumulator.verifyNonMembershipWitness(nonMember, nonMemWit, keypair.publicKey, params)).toEqual(false);
nonMemWit.updateUsingPublicInfoPostMultipleDomainExtensions(nonMember, [newElements2, newElements3], [witUpdNonMem2, witUpdNonMem3]);
expect(accumulator.verifyNonMembershipWitness(nonMember, nonMemWit, keypair.publicKey, params)).toEqual(true);
});
});