Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix types #6

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 64 additions & 54 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solarity/chai-zkit",
"version": "0.2.2",
"version": "0.2.3",
"license": "MIT",
"author": "Distributed Lab",
"readme": "README.md",
Expand Down
29 changes: 16 additions & 13 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,7 @@ declare global {
<T>(val: T, message?: string): Assertion<T>;
}

interface Witness<T = any> {
witnessInputs(inputs: T extends Circuit ? ExtractInputs<T> : never): AsyncAssertion<T>;
witnessOutputs(outputs: T extends Circuit ? Partial<ExtractOutputs<T>> : never): AsyncAssertion<T>;
}

interface Proof<T = any> {
generateProof(inputs: T extends Circuit ? ExtractInputs<T> : never): AsyncAssertion<T>;
verifyProof(proof: T extends Circuit ? ExtractProofType<T> : never): AsyncAssertion<T>;
useSolidityVerifier(verifierContract: any): AsyncAssertion<T>;
}

interface AsyncAssertion<T = any> extends Promise<void>, Witness<T>, Proof<T> {
interface AsyncAssertion<T = any> extends Promise<void> {
not: AsyncAssertion<T>;
strict: AsyncAssertion<T>;
constraints: AsyncAssertion<T>;
Expand All @@ -51,9 +40,16 @@ declare global {
same: AsyncAssertion<T>;
but: AsyncAssertion<T>;
does: AsyncAssertion<T>;

witnessInputs(inputs: T extends Circuit ? ExtractInputs<T> : never): AsyncAssertion<T>;
witnessOutputs(outputs: T extends Circuit ? Partial<ExtractOutputs<T>> : never): AsyncAssertion<T>;

generateProof(inputs: T extends Circuit ? ExtractInputs<T> : never): AsyncAssertion<T>;
verifyProof(proof: T extends Circuit ? ExtractProofType<T> : never): AsyncAssertion<T>;
useSolidityVerifier(verifierContract: any): AsyncAssertion<T>;
}

interface Assertion<T = any> extends Witness<T>, Proof<T> {
interface Assertion<T = any> {
constraints: Assertion<T>;
to: Assertion<T>;
be: Assertion<T>;
Expand All @@ -70,6 +66,13 @@ declare global {
same: Assertion<T>;
but: Assertion<T>;
does: Assertion<T>;

witnessInputs(inputs: T extends Circuit ? ExtractInputs<T> : never): AsyncAssertion<T>;
witnessOutputs(outputs: T extends Circuit ? Partial<ExtractOutputs<T>> : never): AsyncAssertion<T>;

generateProof(inputs: T extends Circuit ? ExtractInputs<T> : never): AsyncAssertion<T>;
verifyProof(proof: T extends Circuit ? ExtractProofType<T> : never): AsyncAssertion<T>;
useSolidityVerifier(verifierContract: any): AsyncAssertion<T>;
}
}
}
Loading