From de0d759315ddb532893d01dc11f7a6b64cf6d4ff Mon Sep 17 00:00:00 2001 From: nixw <> Date: Thu, 25 Apr 2024 01:33:07 +0300 Subject: [PATCH] Add MSM --- depends/ffiasm | 2 +- src/CMakeLists.txt | 2 +- src/groth16.cpp | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/depends/ffiasm b/depends/ffiasm index 6593fed..b0ed35c 160000 --- a/depends/ffiasm +++ b/depends/ffiasm @@ -1 +1 @@ -Subproject commit 6593fedbf183ebbaa62cbb295963ee8765f89fb0 +Subproject commit b0ed35c0db398a3b60188f23f683d2915bbb31c1 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2714cba..bdcd94f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -134,7 +134,7 @@ endif() enable_testing() add_executable(test_public_size test_public_size.c) -target_link_libraries(test_public_size rapidsnarkStaticFrFq) +target_link_libraries(test_public_size rapidsnarkStaticFrFq pthread) add_test(NAME test_public_size COMMAND test_public_size circuit_final.zkey 86 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testdata) diff --git a/src/groth16.cpp b/src/groth16.cpp index e7eda1f..655712e 100644 --- a/src/groth16.cpp +++ b/src/groth16.cpp @@ -50,28 +50,28 @@ std::unique_ptr> Prover::prove(typename Engine::FrElement LOG_TRACE("Start Multiexp A"); uint32_t sW = sizeof(wtns[0]); typename Engine::G1Point pi_a; - E.g1.multiMulByScalar(pi_a, pointsA, (uint8_t *)wtns, sW, nVars); + E.g1.multiMulByScalarMSM(pi_a, pointsA, (uint8_t *)wtns, sW, nVars); std::ostringstream ss2; ss2 << "pi_a: " << E.g1.toString(pi_a); LOG_DEBUG(ss2); LOG_TRACE("Start Multiexp B1"); typename Engine::G1Point pib1; - E.g1.multiMulByScalar(pib1, pointsB1, (uint8_t *)wtns, sW, nVars); + E.g1.multiMulByScalarMSM(pib1, pointsB1, (uint8_t *)wtns, sW, nVars); std::ostringstream ss3; ss3 << "pib1: " << E.g1.toString(pib1); LOG_DEBUG(ss3); LOG_TRACE("Start Multiexp B2"); typename Engine::G2Point pi_b; - E.g2.multiMulByScalar(pi_b, pointsB2, (uint8_t *)wtns, sW, nVars); + E.g2.multiMulByScalarMSM(pi_b, pointsB2, (uint8_t *)wtns, sW, nVars); std::ostringstream ss4; ss4 << "pi_b: " << E.g2.toString(pi_b); LOG_DEBUG(ss4); LOG_TRACE("Start Multiexp C"); typename Engine::G1Point pi_c; - E.g1.multiMulByScalar(pi_c, pointsC, (uint8_t *)((uint64_t)wtns + (nPublic +1)*sW), sW, nVars-nPublic-1); + E.g1.multiMulByScalarMSM(pi_c, pointsC, (uint8_t *)((uint64_t)wtns + (nPublic +1)*sW), sW, nVars-nPublic-1); std::ostringstream ss5; ss5 << "pi_c: " << E.g1.toString(pi_c); LOG_DEBUG(ss5); @@ -80,25 +80,25 @@ std::unique_ptr> Prover::prove(typename Engine::FrElement uint32_t sW = sizeof(wtns[0]); typename Engine::G1Point pi_a; auto pA_future = std::async([&]() { - E.g1.multiMulByScalar(pi_a, pointsA, (uint8_t *)wtns, sW, nVars); + E.g1.multiMulByScalarMSM(pi_a, pointsA, (uint8_t *)wtns, sW, nVars); }); LOG_TRACE("Start Multiexp B1"); typename Engine::G1Point pib1; auto pB1_future = std::async([&]() { - E.g1.multiMulByScalar(pib1, pointsB1, (uint8_t *)wtns, sW, nVars); + E.g1.multiMulByScalarMSM(pib1, pointsB1, (uint8_t *)wtns, sW, nVars); }); LOG_TRACE("Start Multiexp B2"); typename Engine::G2Point pi_b; auto pB2_future = std::async([&]() { - E.g2.multiMulByScalar(pi_b, pointsB2, (uint8_t *)wtns, sW, nVars); + E.g2.multiMulByScalarMSM(pi_b, pointsB2, (uint8_t *)wtns, sW, nVars); }); LOG_TRACE("Start Multiexp C"); typename Engine::G1Point pi_c; auto pC_future = std::async([&]() { - E.g1.multiMulByScalar(pi_c, pointsC, (uint8_t *)((uint64_t)wtns + (nPublic +1)*sW), sW, nVars-nPublic-1); + E.g1.multiMulByScalarMSM(pi_c, pointsC, (uint8_t *)((uint64_t)wtns + (nPublic +1)*sW), sW, nVars-nPublic-1); }); #endif @@ -230,7 +230,7 @@ std::unique_ptr> Prover::prove(typename Engine::FrElement LOG_TRACE("Start Multiexp H"); typename Engine::G1Point pih; - E.g1.multiMulByScalar(pih, pointsH, (uint8_t *)a, sizeof(a[0]), domainSize); + E.g1.multiMulByScalarMSM(pih, pointsH, (uint8_t *)a, sizeof(a[0]), domainSize); std::ostringstream ss1; ss1 << "pih: " << E.g1.toString(pih); LOG_DEBUG(ss1);