Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/bump-version #483

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 9 additions & 36 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: ["14", "16", "18"]
node-version: ["18", "20"]

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

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
check-latest: true
Expand All @@ -40,14 +40,14 @@ jobs:
matrix:
os: [ubuntu-latest]
# Pinning to 18.15 and dropped 20 due to https://github.com/NomicFoundation/hardhat/issues/3877
node-version: ["16", "18.15.0"]
node-version: ["18.15.0", "20"]

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

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
check-latest: true
Expand All @@ -64,33 +64,6 @@ jobs:
working-directory: smart_contract_tests
run: npm test

testv12:
name: Testv12
runs-on: ${{ matrix.os }}
timeout-minutes: 30

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: ["12"]

steps:
- name: Checkout project
uses: actions/checkout@v2

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
check-latest: true
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm run testv12

test-browser:
name: Test browser
Expand All @@ -101,14 +74,14 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
node-version: ["18"]
node-version: ["20"]

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

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
check-latest: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tutorial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install -g circom@latest
Expand Down
10 changes: 5 additions & 5 deletions browser_tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion browser_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"devDependencies": {
"puppeteer": "20.2.0",
"ffjavascript": "^0.2.62",
"ffjavascript": "^0.3.0",
"st": "3.0.0"
}
}
41 changes: 31 additions & 10 deletions build/browser.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3330,6 +3330,13 @@ function flatArray(a) {
}
}

// Ref https://github.com/iden3/circom/commit/ec6388cf6eb62463539cb4c40cc3ceae9826de19
function normalize(n, prime) {
let res = BigInt(n) % prime;
if (res < 0) res += prime;
return res
}

function fnvHash(str) {
const uint64_max = BigInt(2) ** BigInt(64);
let hash = BigInt("0xCBF29CE484222325");
Expand Down Expand Up @@ -3739,7 +3746,7 @@ class WitnessCalculatorCircom2 {
this.n32 = this.instance.exports.getFieldNumLen32();

this.instance.exports.getRawPrime();
const arr = new Array(this.n32);
const arr = new Uint32Array(this.n32);
for (let i=0; i<this.n32; i++) {
arr[this.n32-1-i] = this.instance.exports.readSharedRWMemory(i);
}
Expand All @@ -3764,18 +3771,32 @@ class WitnessCalculatorCircom2 {
const hMSB = parseInt(h.slice(0,8), 16);
const hLSB = parseInt(h.slice(8,16), 16);
const fArr = flatArray(input[k]);
// Slight deviation from https://github.com/iden3/circom/blob/v2.1.6/code_producers/src/wasm_elements/common/witness_calculator.js
// because I don't know when this exported function was added
if (typeof this.instance.exports.getInputSignalSize === 'function') {
let signalSize = this.instance.exports.getInputSignalSize(hMSB, hLSB);
if (signalSize < 0){
throw new Error(`Signal ${k} not found\n`);
}
if (fArr.length < signalSize) {
throw new Error(`Not enough values for input signal ${k}\n`);
}
if (fArr.length > signalSize) {
throw new Error(`Too many values for input signal ${k}\n`);
}
}
for (let i=0; i<fArr.length; i++) {
const arrFr = toArray32(fArr[i],this.n32);
for (let j=0; j<this.n32; j++) {
this.instance.exports.writeSharedRWMemory(j,arrFr[this.n32-1-j]);
}
try {
const arrFr = toArray32(normalize(fArr[i],this.prime),this.n32);
for (let j=0; j<this.n32; j++) {
this.instance.exports.writeSharedRWMemory(j,arrFr[this.n32-1-j]);
}
try {
this.instance.exports.setInputSignal(hMSB, hLSB,i);
input_counter++;
} catch (err) {
// console.log(`After adding signal ${i} of ${k}`)
input_counter++;
} catch (err) {
// console.log(`After adding signal ${i} of ${k}`)
throw new Error(err);
}
}
}

});
Expand Down
Loading