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

Handle invalid witness length #2

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ jobs:
depends/gmp-6.2.1.tar.xz
key: ${{ runner.os }}-gmp-${{ hashFiles('build_gmp.sh') }}-2

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

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

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

- name: Build prover Android ARM64
Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir rapidsnark-macos-x86_64-${{ github.ref_name }}
cp -r package_macos_x86_64/* rapidsnark-macos-x86_64-${{ github.ref_name }}/
zip -r rapidsnark-macos-x86_64-${{ github.ref_name }}.zip rapidsnark-macos-x86_64-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-macos-x86_64-${{ github.ref_name }}.zip
mkdir rapidsnark-macOS-x86_64-${{ github.ref_name }}
cp -r package_macos_x86_64/* rapidsnark-macOS-x86_64-${{ github.ref_name }}/
zip -r rapidsnark-macOS-x86_64-${{ github.ref_name }}.zip rapidsnark-macOS-x86_64-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-macOS-x86_64-${{ github.ref_name }}.zip
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
url = https://github.com/nlohmann/json.git
[submodule "depends/ffiasm"]
path = depends/ffiasm
url = https://github.com/0xPolygonID/ffiasm
url = https://github.com/iden3/ffiasm
branch = master
[submodule "depends/circom_runtime"]
path = depends/circom_runtime
Expand Down
2 changes: 1 addition & 1 deletion depends/ffiasm
Submodule ffiasm updated 1 files
+5 −1 README.md
4 changes: 2 additions & 2 deletions src/binfile_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ BinFile::BinFile(const void *fileData, size_t fileSize, std::string _type, uint3

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

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

u_int32_t nSections = readU32LE();
Expand Down
2 changes: 1 addition & 1 deletion src/main_prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
do { perror(msg); exit(EXIT_FAILURE); } while (0)


const size_t BufferSize = 16384;
const size_t BufferSize = 32768;


int main(int argc, char **argv)
Expand Down
7 changes: 7 additions & 0 deletions src/prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ groth16_prover(const void *zkey_buffer, unsigned long zkey_size,
BinFileUtils::BinFile wtns(wtns_buffer, wtns_size, "wtns", 2);
auto wtnsHeader = WtnsUtils::loadHeader(&wtns);

if (zkeyHeader->nVars != wtnsHeader->nVars) {
olomix marked this conversation as resolved.
Show resolved Hide resolved
snprintf(error_msg, error_msg_maxsize,
"Invalid witness length. Circuit: %u, witness: %u",
zkeyHeader->nVars, wtnsHeader->nVars);
return PPROVER_INVALID_WITNESS_LENGTH;
}

size_t proofMinSize = ProofBufferMinSize();
size_t publicMinSize = PublicBufferMinSize(zkeyHeader->nPublic);

Expand Down
7 changes: 4 additions & 3 deletions src/prover.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ extern "C" {
#endif

//Error codes returned by the functions.
#define PRPOVER_OK 0x0
#define PPROVER_ERROR 0x1
#define PPROVER_ERROR_SHORT_BUFFER 0x2
#define PRPOVER_OK 0x0
#define PPROVER_ERROR 0x1
#define PPROVER_ERROR_SHORT_BUFFER 0x2
#define PPROVER_INVALID_WITNESS_LENGTH 0x3


/**
Expand Down