Skip to content

Commit

Permalink
Added hardhat-circom and update indent size to be 2 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmychu0807 authored Aug 14, 2024
1 parent 2fde49a commit e770b13
Show file tree
Hide file tree
Showing 48 changed files with 2,628 additions and 1,289 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
indent_size = 4
indent_size = 2

[*.md]
trim_trailing_whitespace = false
14 changes: 7 additions & 7 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

<!-- Please check if the PR fulfills these requirements. -->

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] My changes generate no new warnings
- [ ] I have run `yarn format` and `yarn lint` without getting any errors
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] My changes generate no new warnings
- [ ] I have run `yarn format` and `yarn lint` without getting any errors
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
32 changes: 16 additions & 16 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: style

on:
pull_request:
push:
branches: ["main"]
pull_request:
push:
branches: ["main"]

jobs:
style:
runs-on: ubuntu-latest
style:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: yarn
- name: Install dependencies
run: yarn

- name: Run Prettier
run: yarn prettier
- name: Run Prettier
run: yarn prettier
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@ node_modules/
!.yarn/sdks
!.yarn/versions

# Circuit artifacts
circuits/artifacts

# own misc notes
project-todo.md
6 changes: 3 additions & 3 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"semi": true,
"arrowParens": "always",
"trailingComma": "none"
"semi": true,
"arrowParens": "always",
"trailingComma": "none"
}
2 changes: 1 addition & 1 deletion apps/contracts/.solhint.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "solhint:default"
"extends": "solhint:default"
}
24 changes: 24 additions & 0 deletions apps/contracts/circuits/lib.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pragma circom 2.1.6;

include "../../../node_modules/circomlib/circuits/babyjub.circom";

template AddNumOnEllipticCurve () {
signal input x1;
signal input y1;
signal input x2;
signal input y2;

signal input xout;
signal input yout;

component babyAdd = BabyAdd();
babyAdd.x1 <== x1;
babyAdd.y1 <== y1;
babyAdd.x2 <== x2;
babyAdd.y2 <== y2;

xout === babyAdd.xout;
yout === babyAdd.yout;
}

component main = AddNumOnEllipticCurve();
8 changes: 8 additions & 0 deletions apps/contracts/circuits/lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"x1": "17777552123799933955779906779655732241715742912184938656739573121738514868268",
"y1": "2626589144620713026669568689430873010625803728049924121243784502389097019475",
"x2": "17777552123799933955779906779655732241715742912184938656739573121738514868268",
"y2": "2626589144620713026669568689430873010625803728049924121243784502389097019475",
"xout": "6890855772600357754907169075114257697580319025794532037257385534741338397365",
"yout": "4338620300185947561074059802482547481416142213883829469920100239455078257889"
}
64 changes: 32 additions & 32 deletions apps/contracts/contracts/Feedback.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ pragma solidity ^0.8.23;
import "@semaphore-protocol/contracts/interfaces/ISemaphore.sol";

contract Feedback {
ISemaphore public semaphore;

uint256 public groupId;

constructor(address semaphoreAddress) {
semaphore = ISemaphore(semaphoreAddress);

groupId = semaphore.createGroup(address(this));
}

function joinGroup(uint256 identityCommitment) external {
semaphore.addMember(groupId, identityCommitment);
}

function sendFeedback(
uint256 merkleTreeDepth,
uint256 merkleTreeRoot,
uint256 nullifier,
uint256 feedback,
uint256[8] calldata points
) external {
ISemaphore.SemaphoreProof memory proof = ISemaphore.SemaphoreProof(
merkleTreeDepth,
merkleTreeRoot,
nullifier,
feedback,
groupId,
points
);

semaphore.validateProof(groupId, proof);
}
ISemaphore public semaphore;

uint256 public groupId;

constructor(address semaphoreAddress) {
semaphore = ISemaphore(semaphoreAddress);

groupId = semaphore.createGroup(address(this));
}

function joinGroup(uint256 identityCommitment) external {
semaphore.addMember(groupId, identityCommitment);
}

function sendFeedback(
uint256 merkleTreeDepth,
uint256 merkleTreeRoot,
uint256 nullifier,
uint256 feedback,
uint256[8] calldata points
) external {
ISemaphore.SemaphoreProof memory proof = ISemaphore.SemaphoreProof(
merkleTreeDepth,
merkleTreeRoot,
nullifier,
feedback,
groupId,
points
);

semaphore.validateProof(groupId, proof);
}
}
Loading

0 comments on commit e770b13

Please sign in to comment.