-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [x] Update typescript - [x] Add linter deps and configs - [x] Run prettier - [x] Lint fixes for project - [x] Apply new lint rules for `crypto` package - [x] Update dev deps - [x] Add lint, prettier checks for ci
- Loading branch information
Showing
145 changed files
with
47,703 additions
and
35,589 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
module.exports = { | ||
root: true, | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["@typescript-eslint"], | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier", | ||
], | ||
rules: { | ||
"no-console": "off", | ||
"no-debugger": "off", | ||
"no-prototype-builtins": "off", | ||
"no-constant-condition": ["error", { checkLoops: false }], | ||
"no-empty": ["error", { allowEmptyCatch: true }], | ||
"@typescript-eslint/no-var-requires": "off", | ||
"@typescript-eslint/interface-name-prefix": "off", | ||
"@typescript-eslint/ban-ts-ignore": "off", | ||
"@typescript-eslint/no-use-before-define": "off", | ||
"@typescript-eslint/camelcase": "off", | ||
"@typescript-eslint/explicit-function-return-type": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
}, | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["@typescript-eslint"], | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier", | ||
], | ||
rules: { | ||
"no-console": "off", | ||
"no-debugger": "off", | ||
"no-prototype-builtins": "off", | ||
"no-constant-condition": ["error", { checkLoops: false }], | ||
"no-empty": ["error", { allowEmptyCatch: true }], | ||
"@typescript-eslint/no-var-requires": "off", | ||
"@typescript-eslint/interface-name-prefix": "off", | ||
"@typescript-eslint/ban-ts-ignore": "off", | ||
"@typescript-eslint/no-use-before-define": "off", | ||
"@typescript-eslint/camelcase": "off", | ||
"@typescript-eslint/explicit-function-return-type": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
}, | ||
}; |
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,40 @@ | ||
name: Checks | ||
|
||
on: | ||
push: | ||
branches: [master, dev] | ||
pull_request: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
check: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
command: ["prettier", "lint"] | ||
|
||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: "npm" | ||
|
||
- name: Update npm to latest version | ||
run: npm install --global npm@latest | ||
|
||
- name: Build | ||
run: | | ||
npm install | ||
npm run bootstrap | ||
npm run build | ||
- name: ${{ matrix.command }} | ||
run: npm run ${{ matrix.command }} |
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,4 +1,4 @@ | ||
{ | ||
"**/*.ts": ["prettier --ignore-unknown --write", "eslint --fix"], | ||
"**/*.{yaml, yml}": "prettier --ignore-unknown --write" | ||
"**/*.{sol, yaml, yml, md}": ["prettier --ignore-unknown --write"] | ||
} |
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,10 @@ | ||
build/ | ||
node_modules/ | ||
coverage/ | ||
tmp/ | ||
artifacts/ | ||
cache/ | ||
package-lock.json | ||
**/package-lock.json | ||
CHANGELOG.md | ||
.eslintignore |
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,20 @@ | ||
{ | ||
"arrowParens": "always", | ||
"bracketSpacing": true, | ||
"endOfLine": "lf", | ||
"printWidth": 120, | ||
"singleQuote": false, | ||
"semi": true, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"trailingComma": "all", | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"printWidth": 120, | ||
"semi": true | ||
} | ||
} | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,34 +1,30 @@ | ||
import { getSignal } from "./utils"; | ||
import * as path from "path"; | ||
import path from "path"; | ||
const tester = require("circom_tester").wasm; | ||
import { expect } from "chai"; | ||
|
||
describe("CalculateTotal circuit", () => { | ||
const circuitPath = path.join( | ||
__dirname, | ||
"../../circom/test", | ||
`calculateTotal_test.circom` | ||
); | ||
let circuit: any; | ||
const circuitPath = path.join(__dirname, "../../circom/test", `calculateTotal_test.circom`); | ||
let circuit: any; | ||
|
||
before(async () => { | ||
circuit = await tester(circuitPath); | ||
}); | ||
before(async () => { | ||
circuit = await tester(circuitPath); | ||
}); | ||
|
||
it("should correctly sum a list of values", async () => { | ||
const nums: number[] = []; | ||
for (let i = 0; i < 6; i++) { | ||
nums.push(Math.floor(Math.random() * 100)); | ||
} | ||
const sum = nums.reduce((a, b) => a + b, 0); | ||
it("should correctly sum a list of values", async () => { | ||
const nums: number[] = []; | ||
for (let i = 0; i < 6; i++) { | ||
nums.push(Math.floor(Math.random() * 100)); | ||
} | ||
const sum = nums.reduce((a, b) => a + b, 0); | ||
|
||
const circuitInputs = { | ||
nums, | ||
}; | ||
const circuitInputs = { | ||
nums, | ||
}; | ||
|
||
const witness = await circuit.calculateWitness(circuitInputs, true); | ||
await circuit.checkConstraints(witness); | ||
const result = await getSignal(circuit, witness, "sum"); | ||
expect(result.toString()).to.be.eq(sum.toString()); | ||
}); | ||
const witness = await circuit.calculateWitness(circuitInputs, true); | ||
await circuit.checkConstraints(witness); | ||
const result = await getSignal(circuit, witness, "sum"); | ||
expect(result.toString()).to.be.eq(sum.toString()); | ||
}); | ||
}); |
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,54 +1,35 @@ | ||
import { stringifyBigInts } from "maci-crypto"; | ||
import { Keypair } from "maci-domainobjs"; | ||
import * as path from "path"; | ||
import path from "path"; | ||
const tester = require("circom_tester").wasm; | ||
import { getSignal } from "./utils"; | ||
import { expect } from "chai"; | ||
|
||
describe("Public key derivation circuit", () => { | ||
const circuitPath = path.join( | ||
__dirname, | ||
"../../circom/test", | ||
`ecdh_test.circom` | ||
); | ||
let circuit: any; | ||
const circuitPath = path.join(__dirname, "../../circom/test", `ecdh_test.circom`); | ||
let circuit: any; | ||
|
||
before(async () => { | ||
circuit = await tester(circuitPath); | ||
}); | ||
before(async () => { | ||
circuit = await tester(circuitPath); | ||
}); | ||
|
||
it("correctly computes a public key", async () => { | ||
const keypair = new Keypair(); | ||
const keypair2 = new Keypair(); | ||
it("correctly computes a public key", async () => { | ||
const keypair = new Keypair(); | ||
const keypair2 = new Keypair(); | ||
|
||
const ecdhSharedKey = Keypair.genEcdhSharedKey( | ||
keypair.privKey, | ||
keypair2.pubKey | ||
); | ||
const ecdhSharedKey = Keypair.genEcdhSharedKey(keypair.privKey, keypair2.pubKey); | ||
|
||
const circuitInputs = stringifyBigInts({ | ||
privKey: keypair.privKey.asCircuitInputs(), | ||
pubKey: keypair2.pubKey.asCircuitInputs(), | ||
}); | ||
const circuitInputs = stringifyBigInts({ | ||
privKey: keypair.privKey.asCircuitInputs(), | ||
pubKey: keypair2.pubKey.asCircuitInputs(), | ||
}); | ||
|
||
const witness = await circuit.calculateWitness(circuitInputs, true); | ||
await circuit.checkConstraints(witness); | ||
const witness = await circuit.calculateWitness(circuitInputs, true); | ||
await circuit.checkConstraints(witness); | ||
|
||
const circuitEcdhSharedKey0 = await getSignal( | ||
circuit, | ||
witness, | ||
"sharedKey[0]" | ||
); | ||
const circuitEcdhSharedKey1 = await getSignal( | ||
circuit, | ||
witness, | ||
"sharedKey[1]" | ||
); | ||
expect(circuitEcdhSharedKey0.toString()).to.be.eq( | ||
ecdhSharedKey[0].toString() | ||
); | ||
expect(circuitEcdhSharedKey1.toString()).to.be.eq( | ||
ecdhSharedKey[1].toString() | ||
); | ||
}); | ||
const circuitEcdhSharedKey0 = await getSignal(circuit, witness, "sharedKey[0]"); | ||
const circuitEcdhSharedKey1 = await getSignal(circuit, witness, "sharedKey[1]"); | ||
expect(circuitEcdhSharedKey0.toString()).to.be.eq(ecdhSharedKey[0].toString()); | ||
expect(circuitEcdhSharedKey1.toString()).to.be.eq(ecdhSharedKey[1].toString()); | ||
}); | ||
}); |
Oops, something went wrong.