-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
130 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,29 @@ | ||
import { Circomkit, WitnessTester } from "circomkit"; | ||
import { CircuitParameters, ProgramExecution } from "./types"; | ||
import { Circomkit, type WitnessTester } from "circomkit"; | ||
import { prepareProgramForCircuit } from "./utils"; | ||
import { helloworld } from "./inputs"; | ||
|
||
const circomkit = new Circomkit(); | ||
const circomkit = new Circomkit({ | ||
verbose: false, | ||
}); | ||
|
||
const program: ProgramExecution = { | ||
ticks: 47, | ||
memsize: 0, | ||
opsize: 18, | ||
insize: 1, | ||
outsize: 10, | ||
ops: [0, 0, 0, 0, 0, 0, 0, 5, 3, 3, 3, 3, 3, 16, 4, 6, 13, 0], | ||
inputs: [5], | ||
outputs: [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], | ||
}; | ||
const params: CircuitParameters = { | ||
insize: 2, | ||
outsize: 15, | ||
opsize: 20, | ||
memsize: 10, | ||
ticks: 80, | ||
}; | ||
describe("zkbrainfuck", () => { | ||
let circuit: WitnessTester<["ops", "inputs", "outputs"]>; | ||
const INPUT = prepareProgramForCircuit(program, params); | ||
[helloworld].map(({ program, params, name }) => | ||
describe(`zkBrainfuck (${name})`, () => { | ||
let circuit: WitnessTester<["ops", "inputs", "outputs"]>; | ||
const INPUT = prepareProgramForCircuit(program, params); | ||
|
||
before(async () => { | ||
circuit = await circomkit.WitnessTester("zkbrainfuck", { | ||
file: "brainfuck", | ||
template: "Brainfuck", | ||
params: [params.ticks, params.memsize, params.opsize, params.insize, params.outsize], | ||
before(async () => { | ||
console.time("compiled in"); | ||
circuit = await circomkit.WitnessTester(name, { | ||
file: "brainfuck", | ||
template: "Brainfuck", | ||
params: [params.ticks, params.memsize, params.opsize, params.insize, params.outsize], | ||
}); | ||
console.timeEnd("compiled in"); | ||
console.log("constraints:", await circuit.getConstraintCount()); | ||
}); | ||
|
||
console.log("#constraints:", await circuit.getConstraintCount()); | ||
}); | ||
|
||
it("should execute circuit", async () => { | ||
console.log("executing..."); | ||
await circuit.expectPass(INPUT); | ||
}); | ||
}); | ||
it("should execute circuit", async () => { | ||
await circuit.expectPass(INPUT); | ||
}); | ||
}) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { TestCase } from "../types"; | ||
|
||
export const helloworld: TestCase = { | ||
program: { | ||
ticks: 972, | ||
memsize: 6, | ||
opsize: 138, | ||
insize: 0, | ||
outsize: 13, | ||
ops: [ | ||
0, 0, 0, 0, 0, 0, 0, 30, 5, 6, 12, 6, 10, 5, 6, 6, 5, 5, 5, 3, 5, 4, 5, 2, 1, 5, 27, 26, 6, 6, 7, 3, 3, 3, 3, 3, | ||
3, 3, 3, 79, 1, 3, 3, 3, 3, 64, 1, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 1, 3, 2, 2, 2, 2, 4, 45, 1, 3, 1, 3, 1, 4, 1, 1, | ||
3, 76, 2, 74, 2, 4, 39, 1, 1, 6, 1, 4, 4, 4, 6, 3, 3, 3, 3, 3, 3, 3, 6, 6, 3, 3, 3, 6, 1, 1, 6, 2, 4, 6, 2, 6, 3, | ||
3, 3, 6, 4, 4, 4, 4, 4, 4, 6, 4, 4, 4, 4, 4, 4, 4, 4, 6, 1, 1, 3, 6, 1, 3, 3, 6, 0, | ||
], | ||
inputs: [], | ||
outputs: [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 10], | ||
}, | ||
params: { | ||
insize: 0, | ||
outsize: 15, | ||
opsize: 140, | ||
memsize: 8, | ||
ticks: 1000, | ||
}, | ||
name: "hello-world", | ||
num: false, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { helloworld } from "./helloworld"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1 @@ | ||
{ | ||
"ticks": 972, | ||
"memsize": 6, | ||
"opsize": 138, | ||
"insize": 0, | ||
"outsize": 13, | ||
"ops": [ | ||
0, 0, 0, 0, 0, 0, 0, 30, 5, 6, 12, 6, 10, 5, 6, 6, 5, 5, 5, 3, 5, 4, 5, 2, 1, 5, 27, 26, 6, 6, 7, 3, 3, 3, 3, 3, 3, | ||
3, 3, 79, 1, 3, 3, 3, 3, 64, 1, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 1, 3, 2, 2, 2, 2, 4, 45, 1, 3, 1, 3, 1, 4, 1, 1, 3, | ||
76, 2, 74, 2, 4, 39, 1, 1, 6, 1, 4, 4, 4, 6, 3, 3, 3, 3, 3, 3, 3, 6, 6, 3, 3, 3, 6, 1, 1, 6, 2, 4, 6, 2, 6, 3, 3, 3, | ||
6, 4, 4, 4, 4, 4, 4, 6, 4, 4, 4, 4, 4, 4, 4, 4, 6, 1, 1, 3, 6, 1, 3, 3, 6, 0 | ||
], | ||
"inputs": [], | ||
"outputs": [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 10] | ||
} | ||
{"ticks":972,"memsize":6,"opsize":138,"insize":0,"outsize":13,"ops":[0,0,0,0,0,0,0,30,5,6,12,6,10,5,6,6,5,5,5,3,5,4,5,2,1,5,27,26,6,6,7,3,3,3,3,3,3,3,3,79,1,3,3,3,3,64,1,3,3,1,3,3,3,1,3,3,3,1,3,2,2,2,2,4,45,1,3,1,3,1,4,1,1,3,76,2,74,2,4,39,1,1,6,1,4,4,4,6,3,3,3,3,3,3,3,6,6,3,3,3,6,1,1,6,2,4,6,2,6,3,3,3,6,4,4,4,4,4,4,6,4,4,4,4,4,4,4,4,6,1,1,3,6,1,3,3,6,0],"inputs":[],"outputs":[72,101,108,108,111,32,87,111,114,108,100,33,10]} |
Oops, something went wrong.