-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure not to generate non-PODName list names (#26)
- Loading branch information
Showing
24 changed files
with
209 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "test-app", | ||
"version": "1.0.19", | ||
"version": "1.0.20", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import path from "path"; | ||
|
||
export const GPC_NPM_ARTIFACTS_PATH = path.join( | ||
__dirname, | ||
"../node_modules/@pcd/proto-pod-gpc-artifacts" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { | ||
type GPCBoundConfig, | ||
boundConfigToJSON, | ||
gpcProve, | ||
podMembershipListsToJSON, | ||
proofConfigToJSON, | ||
revealedClaimsToJSON | ||
} from "@pcd/gpc"; | ||
import { POD } from "@pcd/pod"; | ||
import { describe, expect, it } from "vitest"; | ||
import * as p from "../src/index.js"; | ||
import { GPC_NPM_ARTIFACTS_PATH } from "./constants.js"; | ||
import { generateKeyPair } from "./utils.js"; | ||
|
||
describe("should be able to serialize outputs", function () { | ||
it("should serialize proof request outputs", async function () { | ||
const { publicKey, privateKey } = generateKeyPair(); | ||
|
||
const pod1 = p.pod({ | ||
entries: { | ||
foo: { type: "string" }, | ||
bar: { | ||
type: "int", | ||
inRange: { min: 0n, max: 10n } | ||
} | ||
}, | ||
signerPublicKey: { | ||
isMemberOf: [publicKey] | ||
}, | ||
tuples: [ | ||
{ | ||
entries: ["$signerPublicKey", "foo", "bar"], | ||
isMemberOf: [ | ||
[ | ||
{ type: "eddsa_pubkey", value: publicKey }, | ||
{ type: "string", value: "test" }, | ||
{ type: "int", value: 5n } | ||
] | ||
] | ||
} | ||
] | ||
}); | ||
const prs = p.proofRequest({ | ||
pods: { | ||
pod1: pod1.proofConfig({ revealed: { foo: true, bar: true } }) | ||
}, | ||
watermark: { type: "string", value: "1" }, | ||
externalNullifier: { type: "string", value: "1" } | ||
}); | ||
|
||
const pr = prs.getProofRequest(); | ||
console.dir(pr, { depth: null }); | ||
|
||
expect(() => proofConfigToJSON(pr.proofConfig)).to.not.throw; | ||
expect(() => podMembershipListsToJSON(pr.membershipLists)).to.not.throw; | ||
|
||
const pod = POD.sign( | ||
{ | ||
foo: { type: "string", value: "test" }, | ||
bar: { type: "int", value: 5n } | ||
}, | ||
privateKey | ||
); | ||
|
||
const proof = await gpcProve( | ||
pr.proofConfig, | ||
{ | ||
membershipLists: pr.membershipLists, | ||
pods: { pod1: pod } | ||
}, | ||
GPC_NPM_ARTIFACTS_PATH | ||
); | ||
|
||
pr.proofConfig.circuitIdentifier = proof.boundConfig.circuitIdentifier; | ||
const boundConfig: GPCBoundConfig = { | ||
...pr.proofConfig, | ||
circuitIdentifier: proof.boundConfig.circuitIdentifier | ||
}; | ||
|
||
expect(() => boundConfigToJSON(boundConfig)).to.not.throw; | ||
expect(() => revealedClaimsToJSON(proof.revealedClaims)).to.not.throw; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.