revert to default prettier version, run prettier
This commit is contained in:
parent
e8e943dba9
commit
530991dc16
231 changed files with 10531 additions and 10600 deletions
2
.github/workflows/js-format-check.yml
vendored
2
.github/workflows/js-format-check.yml
vendored
|
@ -9,4 +9,4 @@ jobs:
|
|||
uses: creyD/prettier_action@v4.2
|
||||
with:
|
||||
dry: True
|
||||
prettier_options: "--check"
|
||||
file_pattern: ./**/*.{js,ts,json}
|
||||
|
|
|
@ -3,12 +3,7 @@
|
|||
"tests": [
|
||||
{
|
||||
"input": {
|
||||
"values": [
|
||||
true,
|
||||
"2",
|
||||
{ "a": [false, true], "b": "2" },
|
||||
["3", "4"]
|
||||
]
|
||||
"values": [true, "2", { "a": [false, true], "b": "2" }, ["3", "4"]]
|
||||
},
|
||||
"output": {
|
||||
"Ok": {
|
||||
|
|
|
@ -8,14 +8,7 @@
|
|||
},
|
||||
"output": {
|
||||
"Ok": {
|
||||
"value": [
|
||||
["2"],
|
||||
["1"],
|
||||
{ "a": "2" },
|
||||
{ "a": "1" },
|
||||
"2",
|
||||
"1"
|
||||
]
|
||||
"value": [["2"], ["1"], { "a": "2" }, { "a": "1" }, "2", "1"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,7 @@
|
|||
},
|
||||
"output": {
|
||||
"Ok": {
|
||||
"value": [
|
||||
"0x0000000000000000",
|
||||
"0x00000000",
|
||||
"0x0000",
|
||||
"0x00"
|
||||
]
|
||||
"value": ["0x0000000000000000", "0x00000000", "0x0000", "0x00"]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -23,12 +18,7 @@
|
|||
},
|
||||
"output": {
|
||||
"Ok": {
|
||||
"value": [
|
||||
"0xffffffffffffffff",
|
||||
"0xffffffff",
|
||||
"0xffff",
|
||||
"0xff"
|
||||
]
|
||||
"value": ["0xffffffffffffffff", "0xffffffff", "0xffff", "0xff"]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -38,12 +28,7 @@
|
|||
},
|
||||
"output": {
|
||||
"Ok": {
|
||||
"value": [
|
||||
"0x1234567812345678",
|
||||
"0x12345678",
|
||||
"0x1234",
|
||||
"0x12"
|
||||
]
|
||||
"value": ["0x1234567812345678", "0x12345678", "0x1234", "0x12"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,13 +11,7 @@ module.exports = (pkg) => {
|
|||
|
||||
config = { snarkjs, ...config };
|
||||
|
||||
const ptr = pkg.compile(
|
||||
source,
|
||||
location,
|
||||
resolveCallback,
|
||||
config,
|
||||
curve
|
||||
);
|
||||
const ptr = pkg.compile(source, location, resolveCallback, config, curve);
|
||||
const result = Object.assign(
|
||||
{
|
||||
program: ptr.program(),
|
||||
|
@ -30,12 +24,9 @@ module.exports = (pkg) => {
|
|||
},
|
||||
computeWitness: (input, args, computeOptions = {}) => {
|
||||
const { program, abi } =
|
||||
input instanceof Uint8Array
|
||||
? { program: input, abi: null }
|
||||
: input;
|
||||
input instanceof Uint8Array ? { program: input, abi: null } : input;
|
||||
|
||||
const { snarkjs = false, logCallback = console.log } =
|
||||
computeOptions;
|
||||
const { snarkjs = false, logCallback = console.log } = computeOptions;
|
||||
const ptr = pkg.compute_witness(
|
||||
program,
|
||||
abi,
|
||||
|
@ -104,18 +95,12 @@ module.exports = (pkg) => {
|
|||
setupWithSrs: (srs, program) =>
|
||||
defaultProvider.setupWithSrs(srs, program, options),
|
||||
generateProof: (program, witness, provingKey) =>
|
||||
defaultProvider.generateProof(
|
||||
program,
|
||||
witness,
|
||||
provingKey,
|
||||
options
|
||||
),
|
||||
defaultProvider.generateProof(program, witness, provingKey, options),
|
||||
verify: (vk, proof) => defaultProvider.verify(vk, proof, options),
|
||||
exportSolidityVerifier: (vk) =>
|
||||
defaultProvider.exportSolidityVerifier(vk),
|
||||
utils: {
|
||||
formatProof: (proof) =>
|
||||
defaultProvider.utils.formatProof(proof),
|
||||
formatProof: (proof) => defaultProvider.utils.formatProof(proof),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
@ -94,12 +94,9 @@ describe("tests", () => {
|
|||
describe("computation", () => {
|
||||
it("should compute with valid inputs", () => {
|
||||
assert.doesNotThrow(() => {
|
||||
const code =
|
||||
"def main(private field a) -> field { return a * a; }";
|
||||
const code = "def main(private field a) -> field { return a * a; }";
|
||||
const artifacts = zokratesProvider.compile(code);
|
||||
const result = zokratesProvider.computeWitness(artifacts, [
|
||||
"2",
|
||||
]);
|
||||
const result = zokratesProvider.computeWitness(artifacts, ["2"]);
|
||||
const output = JSON.parse(result.output);
|
||||
assert.deepEqual(output, "4");
|
||||
assert.ok(result.snarkjs === undefined);
|
||||
|
@ -108,17 +105,12 @@ describe("tests", () => {
|
|||
|
||||
it("should compute with valid inputs with snarkjs output", () => {
|
||||
assert.doesNotThrow(() => {
|
||||
const code =
|
||||
"def main(private field a) -> field { return a * a; }";
|
||||
const code = "def main(private field a) -> field { return a * a; }";
|
||||
const artifacts = zokratesProvider.compile(code);
|
||||
|
||||
const result = zokratesProvider.computeWitness(
|
||||
artifacts,
|
||||
["2"],
|
||||
{
|
||||
const result = zokratesProvider.computeWitness(artifacts, ["2"], {
|
||||
snarkjs: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
const output = JSON.parse(result.output);
|
||||
assert.deepEqual(output, "4");
|
||||
|
@ -128,8 +120,7 @@ describe("tests", () => {
|
|||
|
||||
it("should throw on invalid input count", () => {
|
||||
assert.throws(() => {
|
||||
const code =
|
||||
"def main(private field a) -> field { return a * a; }";
|
||||
const code = "def main(private field a) -> field { return a * a; }";
|
||||
const artifacts = zokratesProvider.compile(code);
|
||||
zokratesProvider.computeWitness(artifacts, ["1", "2"]);
|
||||
});
|
||||
|
@ -137,8 +128,7 @@ describe("tests", () => {
|
|||
|
||||
it("should throw on invalid input type", () => {
|
||||
assert.throws(() => {
|
||||
const code =
|
||||
"def main(private field a) -> field { return a * a; }";
|
||||
const code = "def main(private field a) -> field { return a * a; }";
|
||||
const artifacts = zokratesProvider.compile(code);
|
||||
zokratesProvider.computeWitness(artifacts, [true]);
|
||||
});
|
||||
|
@ -146,8 +136,7 @@ describe("tests", () => {
|
|||
|
||||
it("should log in debug", () => {
|
||||
assert.doesNotThrow(() => {
|
||||
const code =
|
||||
'def main() { log("{}", 1f); log("{}", 2f); return; }';
|
||||
const code = 'def main() { log("{}", 1f); log("{}", 2f); return; }';
|
||||
const artifacts = zokratesProvider.compile(code, {
|
||||
config: { debug: true },
|
||||
});
|
||||
|
@ -183,13 +172,9 @@ describe("tests", () => {
|
|||
|
||||
it("compute witness", () => {
|
||||
assert.doesNotThrow(() => {
|
||||
computationResult = provider.computeWitness(
|
||||
artifacts,
|
||||
["2", "4"],
|
||||
{
|
||||
computationResult = provider.computeWitness(artifacts, ["2", "4"], {
|
||||
snarkjs: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -213,20 +198,13 @@ describe("tests", () => {
|
|||
.writeFile(r1csPath, artifacts.snarkjs.program)
|
||||
.then(() => {
|
||||
return snarkjs.zKey
|
||||
.newZKey(
|
||||
r1csPath,
|
||||
"./tests/powersOfTau5_0000.ptau",
|
||||
zkeyPath
|
||||
)
|
||||
.newZKey(r1csPath, "./tests/powersOfTau5_0000.ptau", zkeyPath)
|
||||
.then(() => {});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
options.curve === "bn128" &&
|
||||
["g16", "gm17"].includes(options.scheme)
|
||||
) {
|
||||
if (options.curve === "bn128" && ["g16", "gm17"].includes(options.scheme)) {
|
||||
it("export verifier", () => {
|
||||
assert.doesNotThrow(() => {
|
||||
let verifier = provider.exportSolidityVerifier(keypair.vk);
|
||||
|
@ -283,9 +261,7 @@ describe("tests", () => {
|
|||
for (const scheme of combinations[backend].schemes) {
|
||||
describe(scheme, () => {
|
||||
for (const curve of combinations[backend].curves) {
|
||||
describe(curve, () =>
|
||||
runWithOptions({ backend, scheme, curve })
|
||||
);
|
||||
describe(curve, () => runWithOptions({ backend, scheme, curve }));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -336,11 +312,8 @@ describe("tests", () => {
|
|||
|
||||
let artifacts = specializedProvider.compile(source, options);
|
||||
for (const t of tests) {
|
||||
const withAbiOverride =
|
||||
typeof t.abi === "boolean" ? t.abi : withAbi;
|
||||
const input = withAbiOverride
|
||||
? artifacts
|
||||
: artifacts.program;
|
||||
const withAbiOverride = typeof t.abi === "boolean" ? t.abi : withAbi;
|
||||
const input = withAbiOverride ? artifacts : artifacts.program;
|
||||
|
||||
try {
|
||||
const result = specializedProvider.computeWitness(
|
||||
|
|
Loading…
Reference in a new issue