Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
Signed-off-by: lovesh <lovesh.bond@gmail.com>
  • Loading branch information
lovesh committed Apr 12, 2024
1 parent 923d3af commit 6467d51
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ${{matrix.os}}
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v1
- uses: jetli/wasm-pack-action@v0.3.0
- uses: jetli/wasm-pack-action@v0.4.0
with:
# Optional version of wasm-pack to install(eg. 'v0.9.1', 'latest')
version: 'latest'
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ dlmalloc = { version = "0.2.6", features = ["global"], optional = true }
serde_with = { version = "1.10.0", default-features = false, features = ["macros"] }

bbs_plus = { version = "0.19.0", default-features = false }
vb_accumulator = { version = "0.22.0", default-features = false }
vb_accumulator = { version = "0.23.0", default-features = false }
schnorr_pok = { version = "0.17.0", default-features = false }
proof_system = { version = "0.27.0", default-features = false }
proof_system = { version = "0.28.0", default-features = false }
coconut-crypto = { version = "0.8.0", default-features = false }
dock_crypto_utils = { version = "0.17.0", default-features = false }
saver = { version = "0.15.0", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/crypto-wasm",
"version": "0.28.0",
"version": "0.29.0",
"author": "Dock.io",
"license": "Apache-2.0",
"private": false,
Expand All @@ -19,7 +19,7 @@
"lib": "lib"
},
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},
"scripts": {
"install:deps": "./scripts/install-dependencies.sh",
Expand Down
125 changes: 118 additions & 7 deletions tests/js/kb-universal-accumulator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ import {
updateKBUniversalNonMembershipWitnessUsingPublicInfoAfterBatchUpdate,
updateKBUniversalMembershipWitnessUsingPublicInfoAfterMultipleBatchUpdates,
updateKBUniversalNonMembershipWitnessUsingPublicInfoAfterMultipleBatchUpdates,
publicInfoForBothKBUniversalWitnessUpdate, kbUpdateNonMembershipWitnessesPostBatchUpdates,
kbUpdateBothWitnessesPostBatchUpdates
publicInfoForBothKBUniversalWitnessUpdate,
kbUpdateNonMembershipWitnessesPostBatchUpdates,
kbUpdateBothWitnessesPostBatchUpdates,
kbUpdateNonMembershipWitnessesPostDomainExtension,
publicInfoForKBUniversalNonMemWitnessUpdateOnDomainExtension,
updateKBUniversalNonMembershipWitnessUsingPublicInfoAfterDomainExtension,
updateKBUniversalNonMembershipWitnessUsingPublicInfoAfterMultipleDomainExtensions
} from "../../lib";
import {areUint8ArraysEqual, stringToBytes} from "./util";

Expand Down Expand Up @@ -67,17 +72,24 @@ describe("For KB universal accumulator", () => {
newElements.push(generateFieldElementFromNumber(100 + i));
}

accumulator = kbUniversalAccumulatorComputeExtended(accumulator, newElements, sk);
expect(accumulator).toBeInstanceOf(Object);
const accumulator1 = kbUniversalAccumulatorComputeExtended(accumulator, newElements, sk);
expect(accumulator1.mem).toEqual(accumulator.mem);
expect(accumulator1.non_mem).not.toEqual(accumulator.non_mem);

accumulator = accumulator1;
domain.push(...newElements);
});

it("add an element", () => {
let accumulator1 = kbUniversalAccumulatorAdd(accumulator, domain[0], sk);
expect(accumulator1).toBeInstanceOf(Object);
expect(accumulator1.mem).not.toEqual(accumulator.mem);
expect(accumulator1.non_mem).not.toEqual(accumulator.non_mem);

accumulator1 = kbUniversalAccumulatorAdd(accumulator1, domain[1], sk);
expect(accumulator1).toBeInstanceOf(Object);
expect(accumulator1.mem).not.toEqual(accumulator.mem);
expect(accumulator1.non_mem).not.toEqual(accumulator.non_mem);

accumulator = accumulator1;
});

it("membership and non-membership after single element updates", () => {
Expand Down Expand Up @@ -651,6 +663,8 @@ describe("For KB universal accumulator witness update", () => {
params
)
).toBe(true);

accumulator = accumulator2;
});

it("by manager after batch updates", () => {
Expand Down Expand Up @@ -748,7 +762,48 @@ describe("For KB universal accumulator witness update", () => {
expect(areUint8ArraysEqual(newNonMemWits[i], newNonMemWits_[i])).toEqual(true);
}

accumulator = accumulator1;
const newElements = [generateFieldElementFromNumber(200 + 1), generateFieldElementFromNumber(200 + 2), generateFieldElementFromNumber(200 + 3)];
const newerNonMemWits = kbUpdateNonMembershipWitnessesPostDomainExtension(newNonMemWits, [nonMember1, nonMember2], newElements, accumulator1, sk);
const accumulator2 = kbUniversalAccumulatorComputeExtended(accumulator1, newElements, sk);
expect(
kbUniversalAccumulatorVerifyNonMembership(
accumulator2,
nonMember1,
newNonMemWits[0],
pk,
params
)
).toBe(false);
expect(
kbUniversalAccumulatorVerifyNonMembership(
accumulator2,
nonMember2,
newNonMemWits[1],
pk,
params
)
).toBe(false);

expect(
kbUniversalAccumulatorVerifyNonMembership(
accumulator2,
nonMember1,
newerNonMemWits[0],
pk,
params
)
).toBe(true);
expect(
kbUniversalAccumulatorVerifyNonMembership(
accumulator2,
nonMember2,
newerNonMemWits[1],
pk,
params
)
).toBe(true);

accumulator = accumulator2;
});

it("after batch updates", () => {
Expand Down Expand Up @@ -1017,5 +1072,61 @@ describe("For KB universal accumulator witness update", () => {
params
)
).toBe(true);

const newElements1 = [generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement()];
const publicInfo1 = publicInfoForKBUniversalNonMemWitnessUpdateOnDomainExtension(accumulator, newElements1, sk);
const accumulator1 = kbUniversalAccumulatorComputeExtended(accumulator, newElements1, sk);

expect(
kbUniversalAccumulatorVerifyNonMembership(
accumulator1,
nonMember,
nonMemWit,
pk,
params
)
).toBe(false);
nonMemWit = updateKBUniversalNonMembershipWitnessUsingPublicInfoAfterDomainExtension(nonMemWit, nonMember, newElements1, publicInfo1);
expect(
kbUniversalAccumulatorVerifyNonMembership(
accumulator1,
nonMember,
nonMemWit,
pk,
params
)
).toBe(true);

const newElements2 = [generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement()];
const publicInfo2 = publicInfoForKBUniversalNonMemWitnessUpdateOnDomainExtension(accumulator1, newElements2, sk);
const accumulator2 = kbUniversalAccumulatorComputeExtended(accumulator1, newElements2, sk);

const newElements3 = [generateRandomFieldElement(), generateRandomFieldElement()];
const publicInfo3 = publicInfoForKBUniversalNonMemWitnessUpdateOnDomainExtension(accumulator2, newElements3, sk);
const accumulator3 = kbUniversalAccumulatorComputeExtended(accumulator2, newElements3, sk);

const newElements4 = [generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement(), generateRandomFieldElement()];
const publicInfo4 = publicInfoForKBUniversalNonMemWitnessUpdateOnDomainExtension(accumulator3, newElements4, sk);
const accumulator4 = kbUniversalAccumulatorComputeExtended(accumulator3, newElements4, sk);

expect(
kbUniversalAccumulatorVerifyNonMembership(
accumulator4,
nonMember,
nonMemWit,
pk,
params
)
).toBe(false);
nonMemWit = updateKBUniversalNonMembershipWitnessUsingPublicInfoAfterMultipleDomainExtensions(nonMemWit, nonMember, [newElements2, newElements3, newElements4], [publicInfo2, publicInfo3, publicInfo4]);
expect(
kbUniversalAccumulatorVerifyNonMembership(
accumulator4,
nonMember,
nonMemWit,
pk,
params
)
).toBe(true);
});
});

0 comments on commit 6467d51

Please sign in to comment.