Skip to content

Commit b9292ba

Browse files
committed
Add KVAC
Signed-off-by: lovesh <lovesh.bond@gmail.com>
1 parent c2bff4d commit b9292ba

File tree

112 files changed

+3586
-1976
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+3586
-1976
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
},
88
plugins: [
99
'@typescript-eslint',
10+
'unused-imports'
1011
],
1112
extends: [
1213
'eslint:recommended',

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@docknetwork/crypto-wasm-ts",
3-
"version": "0.50.0",
3+
"version": "0.52.0",
44
"description": "Typescript abstractions over Dock's Rust crypto library's WASM wrapper",
55
"homepage": "https://github.com/docknetwork/crypto-wasm-ts",
66
"main": "lib/index.js",
@@ -16,7 +16,8 @@
1616
"test-bbs": "TEST_SIGNATURE_SCHEME=BBS yarn jest",
1717
"test-bbs+": "TEST_SIGNATURE_SCHEME=BBS+ yarn jest",
1818
"test-ps": "TEST_SIGNATURE_SCHEME=PS yarn jest",
19-
"test-all": "TEST_SIGNATURE_SCHEME=BBS yarn jest; TEST_SIGNATURE_SCHEME=BBS+ yarn jest; TEST_SIGNATURE_SCHEME=PS yarn jest"
19+
"test-bddt16": "TEST_SIGNATURE_SCHEME=BDDT16 yarn jest",
20+
"test-all": "TEST_SIGNATURE_SCHEME=BBS yarn jest; TEST_SIGNATURE_SCHEME=BBS+ yarn jest; TEST_SIGNATURE_SCHEME=PS yarn jest; TEST_SIGNATURE_SCHEME=BDDT16 yarn jest"
2021
},
2122
"license": "Apache-2.0",
2223
"private": false,
@@ -27,10 +28,11 @@
2728
"lib": "lib"
2829
},
2930
"dependencies": {
30-
"@docknetwork/crypto-wasm": "0.23.0",
3131
"@types/flat": "^5.0.2",
3232
"@types/lodash": "^4.14.195",
3333
"bs58": "5.0.0",
34+
"crypto-wasm-new": "npm:@docknetwork/crypto-wasm@0.24.0",
35+
"crypto-wasm-old": "npm:@docknetwork/crypto-wasm@0.23.0",
3436
"flat": "^5.0.2",
3537
"json-pointer": "^0.6.2",
3638
"json-stringify-deterministic": "^1.0.11",
@@ -48,6 +50,7 @@
4850
"eslint": "^8.42.0",
4951
"eslint-config-prettier": "^8.8.0",
5052
"eslint-plugin-import": "^2.27.5",
53+
"eslint-plugin-unused-imports": "^3.1.0",
5154
"husky": "^7.0.4",
5255
"jest": "^29.1.0",
5356
"jsonld": "6.0.0",
@@ -56,6 +59,6 @@
5659
"r1csfile": "^0.0.41",
5760
"ts-jest": "^29.1.0",
5861
"ts-node": "^10.9.1",
59-
"typescript": "5.1.3"
62+
"typescript": "5.3.3"
6063
}
6164
}

src/Pseudonym.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { pedersenCommitmentG1, generateRandomG1Element } from '@docknetwork/crypto-wasm';
1+
import { pedersenCommitmentG1, generateRandomG1Element } from 'crypto-wasm-new';
22
import { BytearrayWrapper } from './bytearray-wrapper';
33
import { base58ToBytearray, bytearrayToBase58 } from './util';
44

src/accumulator/accumulator.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import {
2929
universalAccumulatorRemoveBatch,
3030
universalAccumulatorVerifyMembership,
3131
universalAccumulatorVerifyNonMembership
32-
} from '@docknetwork/crypto-wasm';
33-
import { MembershipWitness, NonMembershipWitness } from './accumulatorWitness';
32+
} from 'crypto-wasm-new';
33+
import { VBMembershipWitness, VBNonMembershipWitness } from './accumulatorWitness';
3434
import { getUint8ArraysFromObject } from '../util';
3535
import { IAccumulatorState, IUniversalAccumulatorState } from './IAccumulatorState';
3636
import { IInitialElementsStore } from './IInitialElementsStore';
@@ -261,7 +261,7 @@ export abstract class Accumulator {
261261
element: Uint8Array,
262262
secretKey?: AccumulatorSecretKey,
263263
state?: IAccumulatorState
264-
): Promise<MembershipWitness>;
264+
): Promise<VBMembershipWitness>;
265265

266266
/**
267267
* Calculate the membership witnesses for the given batch of elements
@@ -273,7 +273,7 @@ export abstract class Accumulator {
273273
elements: Uint8Array[],
274274
secretKey?: AccumulatorSecretKey,
275275
state?: IAccumulatorState
276-
): Promise<MembershipWitness[]>;
276+
): Promise<VBMembershipWitness[]>;
277277

278278
/**
279279
* Verify the membership witness.
@@ -284,7 +284,7 @@ export abstract class Accumulator {
284284
*/
285285
abstract verifyMembershipWitness(
286286
member: Uint8Array,
287-
witness: MembershipWitness,
287+
witness: VBMembershipWitness,
288288
pk: AccumulatorPublicKey,
289289
params?: AccumulatorParams
290290
): boolean;
@@ -508,11 +508,11 @@ export class PositiveAccumulator extends Accumulator {
508508
member: Uint8Array,
509509
secretKey?: AccumulatorSecretKey,
510510
state?: IAccumulatorState
511-
): Promise<MembershipWitness> {
511+
): Promise<VBMembershipWitness> {
512512
await this.ensurePresence(member, state);
513513
const sk = this.getSecretKey(secretKey);
514514
const wit = positiveAccumulatorMembershipWitness(this.value, member, sk.value);
515-
return new MembershipWitness(wit);
515+
return new VBMembershipWitness(wit);
516516
}
517517

518518
/**
@@ -526,11 +526,11 @@ export class PositiveAccumulator extends Accumulator {
526526
members: Uint8Array[],
527527
secretKey?: AccumulatorSecretKey,
528528
state?: IAccumulatorState
529-
): Promise<MembershipWitness[]> {
529+
): Promise<VBMembershipWitness[]> {
530530
await this.ensurePresenceOfBatch(members, state);
531531
const sk = this.getSecretKey(secretKey);
532532
return positiveAccumulatorMembershipWitnessesForBatch(this.value, members, sk.value).map(
533-
(m) => new MembershipWitness(m)
533+
(m) => new VBMembershipWitness(m)
534534
);
535535
}
536536

@@ -544,7 +544,7 @@ export class PositiveAccumulator extends Accumulator {
544544
*/
545545
verifyMembershipWitness(
546546
member: Uint8Array,
547-
witness: MembershipWitness,
547+
witness: VBMembershipWitness,
548548
publicKey: AccumulatorPublicKey,
549549
params?: AccumulatorParams
550550
): boolean {
@@ -750,25 +750,25 @@ export class UniversalAccumulator extends Accumulator {
750750
secretKey?: AccumulatorSecretKey,
751751
state?: IAccumulatorState,
752752
initialElementsStore?: IInitialElementsStore
753-
): Promise<MembershipWitness> {
753+
): Promise<VBMembershipWitness> {
754754
await this.checkElementAcceptable(member, initialElementsStore);
755755
await this.ensurePresence(member, state);
756756
const sk = this.getSecretKey(secretKey);
757757
const wit = universalAccumulatorMembershipWitness(this.value, member, sk.value);
758-
return new MembershipWitness(wit);
758+
return new VBMembershipWitness(wit);
759759
}
760760

761761
async membershipWitnessesForBatch(
762762
members: Uint8Array[],
763763
secretKey?: AccumulatorSecretKey,
764764
state?: IAccumulatorState,
765765
initialElementsStore?: IInitialElementsStore
766-
): Promise<MembershipWitness[]> {
766+
): Promise<VBMembershipWitness[]> {
767767
await this.checkElementBatchAcceptable(members, initialElementsStore);
768768
await this.ensurePresenceOfBatch(members, state);
769769
const sk = this.getSecretKey(secretKey);
770770
return universalAccumulatorMembershipWitnessesForBatch(this.value, members, sk.value).map(
771-
(m) => new MembershipWitness(m)
771+
(m) => new VBMembershipWitness(m)
772772
);
773773
}
774774

@@ -790,7 +790,7 @@ export class UniversalAccumulator extends Accumulator {
790790
params?: AccumulatorParams,
791791
initialElementsStore?: IInitialElementsStore,
792792
batchSize = 100
793-
): Promise<NonMembershipWitness> {
793+
): Promise<VBNonMembershipWitness> {
794794
await this.checkElementAcceptable(nonMember, initialElementsStore);
795795
await this.ensureAbsence(nonMember, state);
796796
const sk = this.getSecretKey(secretKey);
@@ -810,7 +810,7 @@ export class UniversalAccumulator extends Accumulator {
810810
}
811811
const d = universalAccumulatorCombineMultipleD(ds);
812812
const wit = universalAccumulatorNonMembershipWitness(this.value, d, nonMember, sk.value, params_.value);
813-
return new NonMembershipWitness(wit);
813+
return new VBNonMembershipWitness(wit);
814814
}
815815

816816
/**
@@ -830,13 +830,13 @@ export class UniversalAccumulator extends Accumulator {
830830
params?: AccumulatorParams,
831831
state?: IUniversalAccumulatorState,
832832
initialElementsStore?: IInitialElementsStore
833-
): Promise<NonMembershipWitness> {
833+
): Promise<VBNonMembershipWitness> {
834834
await this.checkElementAcceptable(nonMember, initialElementsStore);
835835
await this.ensureAbsence(nonMember, state);
836836
const sk = this.getSecretKey(secretKey);
837837
const params_ = this.getParams(params);
838838
const wit = universalAccumulatorNonMembershipWitness(this.value, d, nonMember, sk.value, params_.value);
839-
return new NonMembershipWitness(wit);
839+
return new VBNonMembershipWitness(wit);
840840
}
841841

842842
/**
@@ -856,7 +856,7 @@ export class UniversalAccumulator extends Accumulator {
856856
params?: AccumulatorParams,
857857
initialElementsStore?: IInitialElementsStore,
858858
batchSize = 100
859-
): Promise<NonMembershipWitness[]> {
859+
): Promise<VBNonMembershipWitness[]> {
860860
await this.checkElementBatchAcceptable(nonMembers, initialElementsStore);
861861
await this.ensureAbsenceOfBatch(nonMembers, state);
862862
const sk = this.getSecretKey(secretKey);
@@ -894,7 +894,7 @@ export class UniversalAccumulator extends Accumulator {
894894
ds[i] = universalAccumulatorCombineMultipleD(dsForAll[i]);
895895
}
896896
return universalAccumulatorNonMembershipWitnessesForBatch(this.value, ds, nonMembers, sk.value, params_.value).map(
897-
(m) => new NonMembershipWitness(m)
897+
(m) => new VBNonMembershipWitness(m)
898898
);
899899
}
900900

@@ -915,19 +915,19 @@ export class UniversalAccumulator extends Accumulator {
915915
params?: AccumulatorParams,
916916
state?: IUniversalAccumulatorState,
917917
initialElementsStore?: IInitialElementsStore
918-
): Promise<NonMembershipWitness[]> {
918+
): Promise<VBNonMembershipWitness[]> {
919919
await this.checkElementBatchAcceptable(nonMembers, initialElementsStore);
920920
await this.ensureAbsenceOfBatch(nonMembers, state);
921921
const sk = this.getSecretKey(secretKey);
922922
const params_ = this.getParams(params);
923923
return universalAccumulatorNonMembershipWitnessesForBatch(this.value, d, nonMembers, sk.value, params_.value).map(
924-
(m) => new NonMembershipWitness(m)
924+
(m) => new VBNonMembershipWitness(m)
925925
);
926926
}
927927

928928
verifyMembershipWitness(
929929
member: Uint8Array,
930-
witness: MembershipWitness,
930+
witness: VBMembershipWitness,
931931
pk: AccumulatorPublicKey,
932932
params?: AccumulatorParams
933933
): boolean {
@@ -937,7 +937,7 @@ export class UniversalAccumulator extends Accumulator {
937937

938938
verifyNonMembershipWitness(
939939
nonMember: Uint8Array,
940-
witness: NonMembershipWitness,
940+
witness: VBNonMembershipWitness,
941941
pk: AccumulatorPublicKey,
942942
params?: AccumulatorParams
943943
): boolean {

0 commit comments

Comments
 (0)