Skip to content

Commit

Permalink
Add groth16_test_env()
Browse files Browse the repository at this point in the history
  • Loading branch information
nixw committed Mar 12, 2024
1 parent c69a98a commit 28abd14
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string>
#include <cstring>
#include <stdexcept>
#include <sstream>
#include <alt_bn128.hpp>
#include <nlohmann/json.hpp>

Expand Down Expand Up @@ -222,3 +223,33 @@ groth16_prover_zkey_file(const char *zkey_file_path,
public_buffer, public_size,
error_msg, error_msg_maxsize);
}

int
groth16_test_env(char *buffer, unsigned long buffer_maxsize)
{
std::ostringstream stream;

#ifdef USE_ASM
#if defined(ARCH_X86_64)
stream << "ASM: x86_64" << std::endl;
#elif defined(ARCH_ARM64)
stream << "ASM: arm64" << std::endl;
#endif
#else
stream << "ASM is disabled" << std::endl;
#endif

#ifdef USE_OPENMP
stream << "OpenMP max threads: " << omp_get_max_threads() << std::endl;
#else
stream << "OpenMP is disabled" << std::endl;
#endif

if (buffer_maxsize < stream.str().size() + 1) {
return PROVER_ERROR_SHORT_BUFFER;
}

strncpy(buffer, stream.str().c_str(), buffer_maxsize);

return PROVER_OK;
}
10 changes: 10 additions & 0 deletions src/prover.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ groth16_prover_zkey_file(const char *zkey_file_path,
char *public_buffer, unsigned long *public_size,
char *error_msg, unsigned long error_msg_maxsize);

/**
* groth16_test_env
* @return error code:
* PROVER_OK - in case of success
* PROVER_ERROR_SHORT_BUFFER - in case of a short buffer error
*/
int
groth16_test_env(char *buffer, unsigned long buffer_maxsize);


#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 28abd14

Please sign in to comment.