1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00

revert to default prettier version, run prettier

This commit is contained in:
schaeff 2022-08-29 12:51:16 +02:00
parent e8e943dba9
commit 530991dc16
231 changed files with 10531 additions and 10600 deletions

View file

@ -9,4 +9,4 @@ jobs:
uses: creyD/prettier_action@v4.2 uses: creyD/prettier_action@v4.2
with: with:
dry: True dry: True
prettier_options: "--check" file_pattern: ./**/*.{js,ts,json}

View file

@ -3,12 +3,7 @@
"tests": [ "tests": [
{ {
"input": { "input": {
"values": [ "values": [true, "2", { "a": [false, true], "b": "2" }, ["3", "4"]]
true,
"2",
{ "a": [false, true], "b": "2" },
["3", "4"]
]
}, },
"output": { "output": {
"Ok": { "Ok": {

View file

@ -8,14 +8,7 @@
}, },
"output": { "output": {
"Ok": { "Ok": {
"value": [ "value": [["2"], ["1"], { "a": "2" }, { "a": "1" }, "2", "1"]
["2"],
["1"],
{ "a": "2" },
{ "a": "1" },
"2",
"1"
]
} }
} }
} }

View file

@ -8,12 +8,7 @@
}, },
"output": { "output": {
"Ok": { "Ok": {
"value": [ "value": ["0x0000000000000000", "0x00000000", "0x0000", "0x00"]
"0x0000000000000000",
"0x00000000",
"0x0000",
"0x00"
]
} }
} }
}, },
@ -23,12 +18,7 @@
}, },
"output": { "output": {
"Ok": { "Ok": {
"value": [ "value": ["0xffffffffffffffff", "0xffffffff", "0xffff", "0xff"]
"0xffffffffffffffff",
"0xffffffff",
"0xffff",
"0xff"
]
} }
} }
}, },
@ -38,12 +28,7 @@
}, },
"output": { "output": {
"Ok": { "Ok": {
"value": [ "value": ["0x1234567812345678", "0x12345678", "0x1234", "0x12"]
"0x1234567812345678",
"0x12345678",
"0x1234",
"0x12"
]
} }
} }
} }

View file

@ -11,13 +11,7 @@ module.exports = (pkg) => {
config = { snarkjs, ...config }; config = { snarkjs, ...config };
const ptr = pkg.compile( const ptr = pkg.compile(source, location, resolveCallback, config, curve);
source,
location,
resolveCallback,
config,
curve
);
const result = Object.assign( const result = Object.assign(
{ {
program: ptr.program(), program: ptr.program(),
@ -30,12 +24,9 @@ module.exports = (pkg) => {
}, },
computeWitness: (input, args, computeOptions = {}) => { computeWitness: (input, args, computeOptions = {}) => {
const { program, abi } = const { program, abi } =
input instanceof Uint8Array input instanceof Uint8Array ? { program: input, abi: null } : input;
? { program: input, abi: null }
: input;
const { snarkjs = false, logCallback = console.log } = const { snarkjs = false, logCallback = console.log } = computeOptions;
computeOptions;
const ptr = pkg.compute_witness( const ptr = pkg.compute_witness(
program, program,
abi, abi,
@ -104,18 +95,12 @@ module.exports = (pkg) => {
setupWithSrs: (srs, program) => setupWithSrs: (srs, program) =>
defaultProvider.setupWithSrs(srs, program, options), defaultProvider.setupWithSrs(srs, program, options),
generateProof: (program, witness, provingKey) => generateProof: (program, witness, provingKey) =>
defaultProvider.generateProof( defaultProvider.generateProof(program, witness, provingKey, options),
program,
witness,
provingKey,
options
),
verify: (vk, proof) => defaultProvider.verify(vk, proof, options), verify: (vk, proof) => defaultProvider.verify(vk, proof, options),
exportSolidityVerifier: (vk) => exportSolidityVerifier: (vk) =>
defaultProvider.exportSolidityVerifier(vk), defaultProvider.exportSolidityVerifier(vk),
utils: { utils: {
formatProof: (proof) => formatProof: (proof) => defaultProvider.utils.formatProof(proof),
defaultProvider.utils.formatProof(proof),
}, },
}; };
}; };

View file

@ -94,12 +94,9 @@ describe("tests", () => {
describe("computation", () => { describe("computation", () => {
it("should compute with valid inputs", () => { it("should compute with valid inputs", () => {
assert.doesNotThrow(() => { assert.doesNotThrow(() => {
const code = const code = "def main(private field a) -> field { return a * a; }";
"def main(private field a) -> field { return a * a; }";
const artifacts = zokratesProvider.compile(code); const artifacts = zokratesProvider.compile(code);
const result = zokratesProvider.computeWitness(artifacts, [ const result = zokratesProvider.computeWitness(artifacts, ["2"]);
"2",
]);
const output = JSON.parse(result.output); const output = JSON.parse(result.output);
assert.deepEqual(output, "4"); assert.deepEqual(output, "4");
assert.ok(result.snarkjs === undefined); assert.ok(result.snarkjs === undefined);
@ -108,17 +105,12 @@ describe("tests", () => {
it("should compute with valid inputs with snarkjs output", () => { it("should compute with valid inputs with snarkjs output", () => {
assert.doesNotThrow(() => { assert.doesNotThrow(() => {
const code = const code = "def main(private field a) -> field { return a * a; }";
"def main(private field a) -> field { return a * a; }";
const artifacts = zokratesProvider.compile(code); const artifacts = zokratesProvider.compile(code);
const result = zokratesProvider.computeWitness( const result = zokratesProvider.computeWitness(artifacts, ["2"], {
artifacts,
["2"],
{
snarkjs: true, snarkjs: true,
} });
);
const output = JSON.parse(result.output); const output = JSON.parse(result.output);
assert.deepEqual(output, "4"); assert.deepEqual(output, "4");
@ -128,8 +120,7 @@ describe("tests", () => {
it("should throw on invalid input count", () => { it("should throw on invalid input count", () => {
assert.throws(() => { assert.throws(() => {
const code = const code = "def main(private field a) -> field { return a * a; }";
"def main(private field a) -> field { return a * a; }";
const artifacts = zokratesProvider.compile(code); const artifacts = zokratesProvider.compile(code);
zokratesProvider.computeWitness(artifacts, ["1", "2"]); zokratesProvider.computeWitness(artifacts, ["1", "2"]);
}); });
@ -137,8 +128,7 @@ describe("tests", () => {
it("should throw on invalid input type", () => { it("should throw on invalid input type", () => {
assert.throws(() => { assert.throws(() => {
const code = const code = "def main(private field a) -> field { return a * a; }";
"def main(private field a) -> field { return a * a; }";
const artifacts = zokratesProvider.compile(code); const artifacts = zokratesProvider.compile(code);
zokratesProvider.computeWitness(artifacts, [true]); zokratesProvider.computeWitness(artifacts, [true]);
}); });
@ -146,8 +136,7 @@ describe("tests", () => {
it("should log in debug", () => { it("should log in debug", () => {
assert.doesNotThrow(() => { assert.doesNotThrow(() => {
const code = const code = 'def main() { log("{}", 1f); log("{}", 2f); return; }';
'def main() { log("{}", 1f); log("{}", 2f); return; }';
const artifacts = zokratesProvider.compile(code, { const artifacts = zokratesProvider.compile(code, {
config: { debug: true }, config: { debug: true },
}); });
@ -183,13 +172,9 @@ describe("tests", () => {
it("compute witness", () => { it("compute witness", () => {
assert.doesNotThrow(() => { assert.doesNotThrow(() => {
computationResult = provider.computeWitness( computationResult = provider.computeWitness(artifacts, ["2", "4"], {
artifacts,
["2", "4"],
{
snarkjs: true, snarkjs: true,
} });
);
}); });
}); });
@ -213,20 +198,13 @@ describe("tests", () => {
.writeFile(r1csPath, artifacts.snarkjs.program) .writeFile(r1csPath, artifacts.snarkjs.program)
.then(() => { .then(() => {
return snarkjs.zKey return snarkjs.zKey
.newZKey( .newZKey(r1csPath, "./tests/powersOfTau5_0000.ptau", zkeyPath)
r1csPath,
"./tests/powersOfTau5_0000.ptau",
zkeyPath
)
.then(() => {}); .then(() => {});
}); });
}); });
} }
if ( if (options.curve === "bn128" && ["g16", "gm17"].includes(options.scheme)) {
options.curve === "bn128" &&
["g16", "gm17"].includes(options.scheme)
) {
it("export verifier", () => { it("export verifier", () => {
assert.doesNotThrow(() => { assert.doesNotThrow(() => {
let verifier = provider.exportSolidityVerifier(keypair.vk); let verifier = provider.exportSolidityVerifier(keypair.vk);
@ -283,9 +261,7 @@ describe("tests", () => {
for (const scheme of combinations[backend].schemes) { for (const scheme of combinations[backend].schemes) {
describe(scheme, () => { describe(scheme, () => {
for (const curve of combinations[backend].curves) { for (const curve of combinations[backend].curves) {
describe(curve, () => describe(curve, () => runWithOptions({ backend, scheme, curve }));
runWithOptions({ backend, scheme, curve })
);
} }
}); });
} }
@ -336,11 +312,8 @@ describe("tests", () => {
let artifacts = specializedProvider.compile(source, options); let artifacts = specializedProvider.compile(source, options);
for (const t of tests) { for (const t of tests) {
const withAbiOverride = const withAbiOverride = typeof t.abi === "boolean" ? t.abi : withAbi;
typeof t.abi === "boolean" ? t.abi : withAbi; const input = withAbiOverride ? artifacts : artifacts.program;
const input = withAbiOverride
? artifacts
: artifacts.program;
try { try {
const result = specializedProvider.computeWitness( const result = specializedProvider.computeWitness(