Skip to content

Commit

Permalink
add contract tests
Browse files Browse the repository at this point in the history
  • Loading branch information
motemotech committed Dec 12, 2023
1 parent ca3b577 commit f0a0ece
Show file tree
Hide file tree
Showing 12 changed files with 283 additions and 142 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/contracts-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Contracts CI

on:
pull_request:
paths:
- 'packages/contracts/**/*.sol'

jobs:
format:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/contracts
steps:
- name: Checkout repository code
uses: actions/checkout@v3

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Check Solidity formatting
id: format
run: make format_check
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules/
target/
packages/certs/secret*
packages/certs/der*
packages/certs/myna_new_cert.pem
packages/certs/*.json
3 changes: 0 additions & 3 deletions packages/circom-circuit/src/helpers/rsa.circom
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ template FpPow65537Mod(n, k) {
doublers[i].p[j] <== modulus[j];
}
}
var cnt = 1;
for (var j = 0; j < k; j++) {
doublers[0].a[j] <== base[j];
doublers[0].b[j] <== base[j];
Expand Down Expand Up @@ -152,8 +151,6 @@ template RSAVerify65537(n, k) {
// By construction of the padding, the padded message is necessarily
// smaller than the modulus. Thus, we don't have to check that bigPow is fully reduced.
for (var i = 0; i < k; i++) {
// log(bigPow.out[i]);
// log(padder.padded_message[i]);
bigPow.out[i] === padder.padded_message[i];
}
}
14 changes: 14 additions & 0 deletions packages/circom-circuit/src/test.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pragma circom 2.1.5;

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

template hashTbs() {
signal input tbsInBits[10448];
signal output hashedTbs[256];

component sha256 = Sha256(10448);
sha256.in <== tbsInBits;
hashedTbs <== sha256.out;
}

component main = hashTbs();
13 changes: 12 additions & 1 deletion packages/contracts/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

.PHONY: format
format:
forge fmt --root $(ROOT_DIR)

.PHONY: format_check
format_check:
forge fmt --check --root $(ROOT_DIR)


setup:
node ./script/circom-verifier-setup.js
node ./script/circom-verifier-setup.js
1 change: 0 additions & 1 deletion packages/contracts/src/auth/OwnerAuth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ import "@libraries/Errors.sol";
/// @author a42x
/// @notice You can use this contract for owner auth
abstract contract OwnerAuth {

function _isOwner(bytes memory modulus) internal view virtual returns (bool);
}
Loading

0 comments on commit f0a0ece

Please sign in to comment.