Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrom131 committed Aug 28, 2024
1 parent da1ba5b commit fae788b
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 66 deletions.
114 changes: 62 additions & 52 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>;
}
}
}

0 comments on commit fae788b

Please sign in to comment.