mirror of
https://github.com/erhant/circomkit.git
synced 2026-05-05 03:00:37 -04:00
renames
This commit is contained in:
10
README.md
10
README.md
@@ -48,10 +48,10 @@ Write your circuits under `circuits` folder; the circuit code itself should be t
|
||||
|
||||
```js
|
||||
multiplier3: {
|
||||
file: 'multiplier',
|
||||
template: 'Multiplier',
|
||||
publicInputs: [],
|
||||
templateInputs: [3],
|
||||
template: 'Multiplier', // template to instantiate the main component
|
||||
file: 'multiplier', // file to include for the template
|
||||
publicInputs: [], // array of public inputs
|
||||
templateInputs: [3], // template parameters, order is important
|
||||
}
|
||||
```
|
||||
|
||||
@@ -69,7 +69,7 @@ There are some environment variables that the CLI can make use of, they are writ
|
||||
|
||||
## Testing
|
||||
|
||||
To run tests:
|
||||
To run Mocha tests do the following:
|
||||
|
||||
```bash
|
||||
# run all tests
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// auto-generated by instantiate.js
|
||||
pragma circom 2.0.0;
|
||||
|
||||
include "../../circuits/sudoku.circom";
|
||||
|
||||
// Circuit for 3^2 x 3^2 sudoku
|
||||
component main {public[puzzle]} = Sudoku(3);
|
||||
|
||||
@@ -3,8 +3,10 @@ clean() {
|
||||
echo -e "\n${CLIENV_COLOR_TITLE}=== Cleaning artifacts ===${CLIENV_COLOR_RESET}"
|
||||
local CIRCUIT=$1
|
||||
local CIRCUIT_DIR=./build/$CIRCUIT
|
||||
local TARGET=./circuits/main/$CIRCUIT.circom
|
||||
|
||||
rm -rf $CIRCUIT_DIR
|
||||
rm -f $TARGET
|
||||
|
||||
echo -e "${CLIENV_COLOR_LOG}Deleted $CIRCUIT_DIR${CLIENV_COLOR_RESET}"
|
||||
echo -e "${CLIENV_COLOR_LOG}Deleted $CIRCUIT_DIR and $TARGET${CLIENV_COLOR_RESET}"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {compileCircuit} from '../utils';
|
||||
import {createWasmTester} from '../utils/wasmTester';
|
||||
import {ProofTester} from '../utils/proofTester';
|
||||
import type {CircuitSignals, FullProof} from '../types/circuit';
|
||||
import type {WasmTester} from '../types/wasmTester';
|
||||
@@ -14,15 +14,12 @@ describe(CIRCUIT_NAME, () => {
|
||||
let circuit: WasmTester;
|
||||
|
||||
before(async () => {
|
||||
circuit = await compileCircuit('./circuits/main/' + CIRCUIT_NAME + '.circom');
|
||||
await circuit.loadConstraints();
|
||||
console.log('#constraints:', circuit.constraints!.length);
|
||||
circuit = await createWasmTester('./circuits/main/' + CIRCUIT_NAME + '.circom', true);
|
||||
});
|
||||
|
||||
it('should compute correctly', async () => {
|
||||
// compute witness
|
||||
const witness = await circuit.calculateWitness(INPUT, true);
|
||||
console.log(witness);
|
||||
|
||||
// witness should have valid constraints
|
||||
await circuit.checkConstraints(witness);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {compileCircuit} from '../utils';
|
||||
import {createWasmTester} from '../utils/wasmTester';
|
||||
import type {CircuitSignals, FullProof} from '../types/circuit';
|
||||
import type {WasmTester} from '../types/wasmTester';
|
||||
import {assert, expect} from 'chai';
|
||||
@@ -13,14 +13,12 @@ describe(CIRCUIT_NAME, () => {
|
||||
let circuit: WasmTester;
|
||||
|
||||
before(async () => {
|
||||
circuit = await compileCircuit('./circuits/main/' + CIRCUIT_NAME + '.circom');
|
||||
await circuit.loadConstraints();
|
||||
console.log('#constraints:', circuit.constraints!.length);
|
||||
circuit = await createWasmTester('./circuits/main/' + CIRCUIT_NAME + '.circom', true);
|
||||
});
|
||||
|
||||
it('should compute correctly', async () => {
|
||||
// compute witness
|
||||
const witness = await circuit.calculateWitness(inputfoo, true);
|
||||
const witness = await circuit.calculateWitness(INPUT, true);
|
||||
|
||||
// witness should have valid constraints
|
||||
await circuit.checkConstraints(witness);
|
||||
|
||||
@@ -13,6 +13,7 @@ export type WasmTester = {
|
||||
|
||||
/**
|
||||
* Cleanup directory, should probably be called upon test completion
|
||||
* @deprecated this is buggy right now
|
||||
*/
|
||||
release(): Promise<void>;
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import type {WasmTester} from '../types/wasmTester';
|
||||
const wasm_tester = require('circom_tester').wasm;
|
||||
|
||||
/**
|
||||
* Compiles and reutrns a circuit via `circom_tester`'s `wasm_tester`.
|
||||
* @param circuit name of circuit
|
||||
* @returns a `wasm_tester` object
|
||||
*/
|
||||
export async function compileCircuit(path: string): Promise<WasmTester> {
|
||||
return await wasm_tester(path, {
|
||||
include: 'node_modules', // will link circomlib circuits
|
||||
});
|
||||
}
|
||||
21
utils/wasmTester.ts
Normal file
21
utils/wasmTester.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type {WasmTester} from '../types/wasmTester';
|
||||
const wasm_tester = require('circom_tester').wasm;
|
||||
|
||||
/**
|
||||
* Compiles and reutrns a circuit via `circom_tester`'s `wasm_tester`.
|
||||
* @param circuit name of circuit
|
||||
* @param showNumConstraints print number of constraints, defualts to `false`
|
||||
* @returns a `wasm_tester` object
|
||||
*/
|
||||
export async function createWasmTester(path: string, showNumConstraints: boolean = false): Promise<WasmTester> {
|
||||
const circuit = await wasm_tester(path, {
|
||||
include: 'node_modules', // will link circomlib circuits
|
||||
});
|
||||
|
||||
if (showNumConstraints) {
|
||||
await circuit.loadConstraints();
|
||||
console.log(' number of constraints:', circuit.constraints!.length);
|
||||
}
|
||||
|
||||
return circuit;
|
||||
}
|
||||
Reference in New Issue
Block a user