From 80256475b8e1bc2c9f9c33947d1807826003d165 Mon Sep 17 00:00:00 2001 From: dark64 Date: Mon, 21 Aug 2023 16:05:07 +0200 Subject: [PATCH 1/2] js fmt --- zokrates_js/index.d.ts | 8 ++++---- zokrates_js/index.js | 12 ++++++------ zokrates_js/patch.js | 2 +- zokrates_js/tests/tests.js | 20 ++++++++++---------- zokrates_js/tests/umd/tests.js | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/zokrates_js/index.d.ts b/zokrates_js/index.d.ts index ff7cba246..425a3955a 100644 --- a/zokrates_js/index.d.ts +++ b/zokrates_js/index.d.ts @@ -8,7 +8,7 @@ declare module "zokrates-js" { export type ResolveCallback = ( location: string, - path: string + path: string, ) => ResolverResult; export interface CompileConfig { @@ -78,12 +78,12 @@ declare module "zokrates-js" { withOptions(options: Options): ZoKratesProvider; compile( source: string, - compileOptions?: CompileOptions + compileOptions?: CompileOptions, ): CompilationArtifacts; computeWitness( input: CompilationArtifacts | Uint8Array, args: any[], - options?: ComputeOptions + options?: ComputeOptions, ): ComputationResult; setup(program: Uint8Array, entropy?: string): SetupKeypair; universalSetup(size: number, entropy?: string): Uint8Array; @@ -92,7 +92,7 @@ declare module "zokrates-js" { program: Uint8Array, witness: Uint8Array, provingKey: Uint8Array, - entropy?: string + entropy?: string, ): Proof; verify(verificationKey: VerificationKey, proof: Proof): boolean; exportSolidityVerifier(verificationKey: VerificationKey): string; diff --git a/zokrates_js/index.js b/zokrates_js/index.js index 55a7dbda6..f0ef0a393 100644 --- a/zokrates_js/index.js +++ b/zokrates_js/index.js @@ -22,7 +22,7 @@ const initialize = async () => { location, resolveCallback, config, - curve + curve, ); const result = Object.assign( { @@ -30,7 +30,7 @@ const initialize = async () => { abi: ptr.abi(), constraintCount: ptr.constraint_count(), }, - snarkjs ? { snarkjs: { program: ptr.snarkjs_program() } } : {} + snarkjs ? { snarkjs: { program: ptr.snarkjs_program() } } : {}, ); ptr.free(); return result; @@ -47,7 +47,7 @@ const initialize = async () => { { snarkjs: snarkjs, }, - logCallback + logCallback, ); const result = Object.assign( @@ -61,7 +61,7 @@ const initialize = async () => { witness: ptr.snarkjs_witness(), }, } - : {} + : {}, ); ptr.free(); @@ -94,7 +94,7 @@ const initialize = async () => { witness, provingKey, entropy, - options + options, ); }, verify: (vk, proof, options) => { @@ -132,7 +132,7 @@ const initialize = async () => { witness, provingKey, entropy, - options + options, ), verify: (vk, proof) => defaultProvider.verify(vk, proof, options), exportSolidityVerifier: (vk) => diff --git a/zokrates_js/patch.js b/zokrates_js/patch.js index 4f4c19aa7..72bffba57 100644 --- a/zokrates_js/patch.js +++ b/zokrates_js/patch.js @@ -5,7 +5,7 @@ import pako from "pako"; (async function () { const packageObject = JSON.parse( - await fs.readFile("pkg/package.json", { encoding: "utf-8" }) + await fs.readFile("pkg/package.json", { encoding: "utf-8" }), ); const wasmPath = packageObject.files.find((file) => file.endsWith(".wasm")); const wasm = await fs.readFile(`pkg/${wasmPath}`); diff --git a/zokrates_js/tests/tests.js b/zokrates_js/tests/tests.js index ad43c5dbd..3c6149e74 100644 --- a/zokrates_js/tests/tests.js +++ b/zokrates_js/tests/tests.js @@ -39,7 +39,7 @@ describe("tests", () => { describe("compilation", () => { it("should compile", () => { const artifacts = zokratesProvider.compile( - "def main() -> field { return 42; }" + "def main() -> field { return 42; }", ); assert.ok(artifacts); assert.ok(artifacts.snarkjs === undefined); @@ -49,7 +49,7 @@ describe("tests", () => { it("should compile with snarkjs output", () => { const artifacts = zokratesProvider.compile( "def main() -> field { return 42; }", - { snarkjs: true } + { snarkjs: true }, ); assert.ok(artifacts); assert.ok(artifacts.snarkjs.program !== undefined); @@ -167,7 +167,7 @@ describe("tests", () => { ["337", "113569"], { snarkjs: true, - } + }, ); }); @@ -214,7 +214,7 @@ describe("tests", () => { return snarkjs.zKey.newZKey( r1csPath, "./tests/powersOfTau5_0000.ptau", - zkeyPath + zkeyPath, ); }); }); @@ -231,7 +231,7 @@ describe("tests", () => { proof = provider.generateProof( artifacts.program, computationResult.witness, - keypair.pk + keypair.pk, ); assert.ok(proof !== undefined); assert.equal(proof.inputs.length, 2); @@ -240,7 +240,7 @@ describe("tests", () => { let proof2 = provider.generateProof( artifacts.program, computationResult.witness, - keypair.pk + keypair.pk, ); assert.notDeepEqual(proof, proof2); }); @@ -251,7 +251,7 @@ describe("tests", () => { artifacts.program, computationResult.witness, keypair.pk, - entropy + entropy, ); assert.ok(proof !== undefined); assert.equal(proof.inputs.length, 2); @@ -261,7 +261,7 @@ describe("tests", () => { artifacts.program, computationResult.witness, keypair.pk, - entropy + entropy, ); assert.deepEqual(proof, proof2); }); @@ -333,7 +333,7 @@ describe("tests", () => { const fileSystemResolver = (from, to) => { let parsedPath = path.parse( - path.resolve(path.dirname(path.resolve(from)), to) + path.resolve(path.dirname(path.resolve(from)), to), ); const location = path.format({ ...parsedPath, @@ -368,7 +368,7 @@ describe("tests", () => { try { const result = specializedProvider.computeWitness( input, - t.input.values + t.input.values, ); const value = JSON.parse(result.output); assert.deepEqual({ Ok: { value } }, t.output); diff --git a/zokrates_js/tests/umd/tests.js b/zokrates_js/tests/umd/tests.js index 4bda5f8a6..2f61a60cb 100644 --- a/zokrates_js/tests/umd/tests.js +++ b/zokrates_js/tests/umd/tests.js @@ -11,7 +11,7 @@ describe("umd web tests", () => { const page = await browser.newPage(); let response = await page.goto( - path.dirname(import.meta.url) + "/index.html" + path.dirname(import.meta.url) + "/index.html", ); assert(response.ok()); From 34f444035511e326e86d9661367c7644e35d85c7 Mon Sep 17 00:00:00 2001 From: dark64 Date: Mon, 21 Aug 2023 16:05:57 +0200 Subject: [PATCH 2/2] clippy --- zokrates_analysis/src/boolean_array_comparator.rs | 6 +++--- zokrates_analysis/src/log_ignorer.rs | 2 +- zokrates_analysis/src/out_of_bounds.rs | 2 +- zokrates_ast/src/ir/clean.rs | 2 +- zokrates_core/src/optimizer/mod.rs | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/zokrates_analysis/src/boolean_array_comparator.rs b/zokrates_analysis/src/boolean_array_comparator.rs index 72c158193..e549917be 100644 --- a/zokrates_analysis/src/boolean_array_comparator.rs +++ b/zokrates_analysis/src/boolean_array_comparator.rs @@ -22,7 +22,7 @@ pub struct BooleanArrayComparator; impl BooleanArrayComparator { pub fn simplify(p: TypedProgram) -> TypedProgram { - Self::default().fold_program(p) + Self.fold_program(p) } } @@ -141,7 +141,7 @@ mod tests { ]), )); - let res = BooleanArrayComparator::default().fold_boolean_expression(e); + let res = BooleanArrayComparator.fold_boolean_expression(e); assert_eq!(res, expected); } @@ -171,7 +171,7 @@ mod tests { ]), )); - let res = BooleanArrayComparator::default().fold_boolean_expression(e); + let res = BooleanArrayComparator.fold_boolean_expression(e); assert_eq!(res, expected); } diff --git a/zokrates_analysis/src/log_ignorer.rs b/zokrates_analysis/src/log_ignorer.rs index 2c8aa5a8c..06bd520cb 100644 --- a/zokrates_analysis/src/log_ignorer.rs +++ b/zokrates_analysis/src/log_ignorer.rs @@ -6,7 +6,7 @@ pub struct LogIgnorer; impl LogIgnorer { pub fn ignore(p: TypedProgram) -> TypedProgram { - Self::default().fold_program(p) + Self.fold_program(p) } } diff --git a/zokrates_analysis/src/out_of_bounds.rs b/zokrates_analysis/src/out_of_bounds.rs index 7ed8613a7..e00cf1793 100644 --- a/zokrates_analysis/src/out_of_bounds.rs +++ b/zokrates_analysis/src/out_of_bounds.rs @@ -18,7 +18,7 @@ impl fmt::Display for Error { } impl OutOfBoundsChecker { pub fn check(p: TypedProgram) -> Result, Error> { - Self::default().fold_program(p) + Self.fold_program(p) } } diff --git a/zokrates_ast/src/ir/clean.rs b/zokrates_ast/src/ir/clean.rs index 1c58faff6..ac1bcbd06 100644 --- a/zokrates_ast/src/ir/clean.rs +++ b/zokrates_ast/src/ir/clean.rs @@ -16,7 +16,7 @@ impl<'ast, T: Field, I: IntoIterator>> ProgIterator<'a statements: self .statements .into_iter() - .flat_map(|s| Cleaner::default().fold_statement(s)), + .flat_map(|s| Cleaner.fold_statement(s)), solvers: self.solvers, } } diff --git a/zokrates_core/src/optimizer/mod.rs b/zokrates_core/src/optimizer/mod.rs index 08a6c1b7d..6cd3628e9 100644 --- a/zokrates_core/src/optimizer/mod.rs +++ b/zokrates_core/src/optimizer/mod.rs @@ -27,9 +27,9 @@ pub fn optimize<'ast, T: Field, I: IntoIterator>>( // define all optimizer steps let mut redefinition_optimizer = RedefinitionOptimizer::init(&p); - let mut tautologies_optimizer = TautologyOptimizer::default(); + let mut tautologies_optimizer = TautologyOptimizer; let mut directive_optimizer = DirectiveOptimizer::default(); - let mut canonicalizer = Canonicalizer::default(); + let mut canonicalizer = Canonicalizer; let mut duplicate_optimizer = DuplicateOptimizer::default(); use zokrates_ast::ir::folder::Folder;