Skip to content

Commit 66c13b1

Browse files
committed
Handle invalid witness length
1 parent 126f5bb commit 66c13b1

File tree

7 files changed

+23
-15
lines changed

7 files changed

+23
-15
lines changed

.github/workflows/build.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ jobs:
3030
depends/gmp-6.2.1.tar.xz
3131
key: ${{ runner.os }}-gmp-${{ hashFiles('build_gmp.sh') }}-2
3232

33-
- name: build gmp android arm64
33+
- name: build gmp for Android arm64
3434
run: if [[ ! -d "depends/gmp/package_android_arm64" ]]; then ./build_gmp.sh android; fi
3535

36-
- name: build gmp android x86_64
36+
- name: build gmp for Android x86_64
3737
run: if [[ ! -d "depends/gmp/package_android_x86_64" ]]; then ./build_gmp.sh android_x86_64; fi
3838

39-
- name: build gmp android x86_64
39+
- name: build gmp for Linux x86_64
4040
run: if [[ ! -d "depends/gmp/package" ]]; then ./build_gmp.sh host; fi
4141

4242
- name: Build prover Android ARM64
@@ -209,7 +209,7 @@ jobs:
209209
GH_TOKEN: ${{ github.token }}
210210
run: |
211211
set -x
212-
mkdir rapidsnark-macos-x86_64-${{ github.ref_name }}
213-
cp -r package_macos_x86_64/* rapidsnark-macos-x86_64-${{ github.ref_name }}/
214-
zip -r rapidsnark-macos-x86_64-${{ github.ref_name }}.zip rapidsnark-macos-x86_64-${{ github.ref_name }}
215-
gh release upload ${{ github.event.release.tag_name }} rapidsnark-macos-x86_64-${{ github.ref_name }}.zip
212+
mkdir rapidsnark-macOS-x86_64-${{ github.ref_name }}
213+
cp -r package_macos_x86_64/* rapidsnark-macOS-x86_64-${{ github.ref_name }}/
214+
zip -r rapidsnark-macOS-x86_64-${{ github.ref_name }}.zip rapidsnark-macOS-x86_64-${{ github.ref_name }}
215+
gh release upload ${{ github.event.release.tag_name }} rapidsnark-macOS-x86_64-${{ github.ref_name }}.zip

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
url = https://github.com/nlohmann/json.git
77
[submodule "depends/ffiasm"]
88
path = depends/ffiasm
9-
url = https://github.com/0xPolygonID/ffiasm
9+
url = https://github.com/iden3/ffiasm
1010
branch = master
1111
[submodule "depends/circom_runtime"]
1212
path = depends/circom_runtime

depends/ffiasm

Submodule ffiasm updated 1 file

src/binfile_utils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ BinFile::BinFile(const void *fileData, size_t fileSize, std::string _type, uint3
1919

2020
if (type != _type) {
2121
free(addr);
22-
throw new std::invalid_argument("Invalid file type. It should be " + _type + " and it us " + type);
22+
throw new std::invalid_argument("Invalid file type. It should be " + _type + " and it is " + type);
2323
}
2424

2525
version = readU32LE();
2626
if (version > maxVersion) {
2727
free(addr);
28-
throw new std::invalid_argument("Invalid version. It should be <=" + std::to_string(maxVersion) + " and it us " + std::to_string(version));
28+
throw new std::invalid_argument("Invalid version. It should be <=" + std::to_string(maxVersion) + " and it is " + std::to_string(version));
2929
}
3030

3131
u_int32_t nSections = readU32LE();

src/main_prover.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
do { perror(msg); exit(EXIT_FAILURE); } while (0)
1010

1111

12-
const size_t BufferSize = 16384;
12+
const size_t BufferSize = 32768;
1313

1414

1515
int main(int argc, char **argv)

src/prover.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ groth16_prover(const void *zkey_buffer, unsigned long zkey_size,
6868
BinFileUtils::BinFile wtns(wtns_buffer, wtns_size, "wtns", 2);
6969
auto wtnsHeader = WtnsUtils::loadHeader(&wtns);
7070

71+
if (zkeyHeader->nVars != wtnsHeader->nVars) {
72+
snprintf(error_msg, error_msg_maxsize,
73+
"Invalid witness length. Circuit: %u, witness: %u",
74+
zkeyHeader->nVars, wtnsHeader->nVars);
75+
return PPROVER_INVALID_WITNESS_LENGTH;
76+
}
77+
7178
size_t proofMinSize = ProofBufferMinSize();
7279
size_t publicMinSize = PublicBufferMinSize(zkeyHeader->nPublic);
7380

src/prover.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ extern "C" {
66
#endif
77

88
//Error codes returned by the functions.
9-
#define PRPOVER_OK 0x0
10-
#define PPROVER_ERROR 0x1
11-
#define PPROVER_ERROR_SHORT_BUFFER 0x2
9+
#define PRPOVER_OK 0x0
10+
#define PPROVER_ERROR 0x1
11+
#define PPROVER_ERROR_SHORT_BUFFER 0x2
12+
#define PPROVER_INVALID_WITNESS_LENGTH 0x3
1213

1314

1415
/**

0 commit comments

Comments
 (0)