Skip to content

Commit

Permalink
c reproducer
Browse files Browse the repository at this point in the history
  • Loading branch information
wjblanke committed Oct 10, 2024
1 parent 25005a8 commit 1fbc0fb
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/verifier_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "verifier.h"
#include "create_discriminant.h"
#include "c_bindings/c_wrapper.h"
#include "prover_slow.h"

void assertm(bool expr, std::string msg, bool verbose=false) {
if (expr && verbose) {
Expand All @@ -22,8 +24,37 @@ std::vector<uint8_t> HexToBytes(const char *hex_proof) {
return result;
}

ByteArray prove_wrapper(const uint8_t* challenge_hash, size_t challenge_size, const uint8_t* x_s, size_t x_s_size, size_t discriminant_size_bits, uint64_t num_iterations) {
try {
std::vector<uint8_t> challenge_hash_bytes(challenge_hash, challenge_hash + challenge_size);
integer discriminant = CreateDiscriminant(challenge_hash_bytes, discriminant_size_bits);
form x = DeserializeForm(discriminant, x_s, x_s_size);
std::vector<uint8_t> result = ProveSlow(discriminant, x, num_iterations, "");

// Allocate memory for the result and copy data
uint8_t* resultData = new uint8_t[result.size()];
std::copy(result.begin(), result.end(), resultData);

return ByteArray { resultData, result.size() };
} catch (...) {
return ByteArray { nullptr, 0 };
}
}

int main()
{

std::vector<uint8_t> challenge_hash=HexToBytes("a6c42558174fb1eedc64");
std::vector<uint8_t> x_s=HexToBytes("0300aca4849458af5c557710c80f21519f196907764d2d55c9b70581a90d49ca7b3201ad6a9da836429e6592c200e965434f0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");

ByteArray ba=prove_wrapper(challenge_hash.data(), challenge_hash.size(), x_s.data(), x_s.size(), 512, 90909);

for (size_t i = 0; i < ba.length; i++)
printf( "%02x", ba.data[i]);

printf("\n");


uint8_t arr[10000];
std::vector<uint8_t> result=HexToBytes("003f360be667de706fe886f766fe20240de04fe2c2f91207f1bbdddf20c554ab8d168b2ce9664d75f4613375a0ab12bf8158983574c9f5cd61c6b8a905fd3fa6bbffc5401b4ccedbe093b560293263a226e46302e720726586251116bc689ef09dc70d99e0a090c4409f928e218e85032fdbee02fedd563073be555b75a70a2d6a430033bc7a4926e3504e87698a0ace0dee6364cced2e9142b4e4cbe55a6371aab41e501ceed21d79d3a0dbbd82ce913c5de40b13eb7c59b1b52b6ef270ee603bd5e7fffcc9f5fae6dbd5aeec394181af130c0fdd195b22be745449b7a584ac80fc75ed49acfdb4d650f5cd344f86377ebbbaef5b19a0af3ae08101d1697f5656a52193000000000071c6f40024c342868a0c2a201b1b26a5d52c5d2f92a106c19ff926deb3fba1e74a444ecee3f8f507c062b949a2eaadd442b049417f82e8811526fa83c6d099d75323e068ffeca9dcd163761000c65d21dede72787ac350f25bdd3d29db6e9cb0e22c8124c724db33660c88784e2871b62ecf816846db7b469c71cad9a5dcfc5548ed2dd781006fa15b968facf4d79219646267eb187a670306d1ff1a59fc28ae00d36bb5a1cba659f48aa64a9022711a66105ef14401ff3948add265240aaad329ee76ba4c2300496746b86bcccacff5947c3fcb956cde2cffae10435960d7097f989aac742cf1047887f11584d20297958385e1715fe0f9b69141750c20d8134420eafec68fd10000000001555540006958aabfe4cc5d870e61fef82bcf1f2c3859e2bd8b1177e8a8872376b5cabace5dcb59b6fecada7e522d05f6f0e352939a6bfdf8c454fbe822cfa5ce97d17be0ffde44a4812cde9d04ec5c08dce6f9146586fdc8e081e05ec690b7effe24ea756f3d300f361203b61e1a39220c6eafa7852842674e317dcae5549c78c7144296ff004a6d0d2854c55e4c1de2f17dc4480b81652cfec37124ef41560a28c853482732434d1c006763b2e341528ae0bcc29fb76f1a4dafd99ade4fd75ec9cc9ca3f3d7001bcb6eb71e43eb22169ab721637551a8ec93838eb0825e9ecba9175297a00b146e9fdd244c5b722f29d3c46ec38840ba18f1f06ddec3dea844867386c2e1ac95");
std::copy(result.begin(), result.end(), arr);
Expand Down

0 comments on commit 1fbc0fb

Please sign in to comment.