Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yash25198 authored Aug 24, 2024
0 parents commit db73e75
Show file tree
Hide file tree
Showing 16 changed files with 1,376 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: tests

on:
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --yes \
build-essential \
libgmp-dev \
libsodium-dev \
nasm \
nlohmann-json3-dev
- name: Download Circom Binary v2.1.5
run: |
wget -qO /home/runner/work/circom https://github.com/iden3/circom/releases/download/v2.1.5/circom-linux-amd64
chmod +x /home/runner/work/circom
sudo mv /home/runner/work/circom /bin/circom
- name: Print Circom version
run: circom --version

- name: Install dependencies
run: yarn

- name: Run tests
run: yarn test
122 changes: 122 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# builds
build
dist

# circuit-specific powers of tau are ignored
*.ptau
# universal ptaus not ignored
!ptau/*
# temporary ptaus are ignored
tmp.ptau

# is this still a thing lol
.DS_Store

# ignore auto generated test circuits
circuits/test
ptau
7 changes: 7 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extension": ["ts"],
"require": "ts-node/register",
"spec": "tests/**/*.test.ts",
"timeout": 100000,
"exit": true
}
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
printWidth: 120,
};
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["iden3.circom"]
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Circomkit template
5 changes: 5 additions & 0 deletions circomkit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": "2.1.2",
"proofSystem": "groth16",
"curve": "bn128"
}
6 changes: 6 additions & 0 deletions circuits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"add": {
"file": "add",
"template": "Add"
}
}
10 changes: 10 additions & 0 deletions circuits/add.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pragma circom 2.1.5;

template Add() {
signal input a;
signal input b;
signal output out;

out <== a + b;
}

4 changes: 4 additions & 0 deletions inputs/add/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"a": 1,
"b": 2
}
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"description": "Circomkit Template",
"scripts": {
"start": "npx ts-node ./src/index.ts",
"test": "npx mocha",
"compile:test": "npx circomkit compile add && npx circomkit prove add default && npx circomkit verify add default"
},
"dependencies": {
"circomkit": "^0.0.22",
"circomlib": "^2.0.5"
},
"devDependencies": {
"@types/mocha": "^10.0.1",
"@types/node": "^20.3.0",
"mocha": "^10.2.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.3"
}
}
Empty file added src/index.ts
Empty file.
20 changes: 20 additions & 0 deletions tests/add.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { WitnessTester } from "circomkit";
import { circomkit } from "./common";

describe("Add", () => {
let circuit: WitnessTester<["a", "b"], ["out"]>;

describe("Add", () => {
before(async () => {
circuit = await circomkit.WitnessTester(`Add`, {
file: "add",
template: "Add",
});
console.log("#constraints:", await circuit.getConstraintCount());
});

it("should add two numbers", async () => {
await circuit.expectPass({ a: 1, b: 2 }, { out: 3 });
});
});
});
5 changes: 5 additions & 0 deletions tests/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Circomkit } from "circomkit";

export const circomkit = new Circomkit({
verbose: false,
});
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"types": ["mocha", "node"],
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true
}
}
Loading

0 comments on commit db73e75

Please sign in to comment.