-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(root): Cbinds for root rollup (#132)
* intial root * feat: pass on snaphots * fix: update naming for consistency + extend root rollup logic * feat: serialization debug utility (#126) * feat: serialize canary * bump bb * feat: pass along asan settings * Revert "bump bb" This reverts commit 514682d. * feat: pass build type to cmake * initial commit with root cbinds * root rollup cbind working * fix root test --------- Co-authored-by: LHerskind <[email protected]> Co-authored-by: ludamad <[email protected]>
- Loading branch information
1 parent
eeb1381
commit 055f5f5
Showing
5 changed files
with
172 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include "index.hpp" | ||
#include "init.hpp" | ||
#include "c_bind.h" | ||
|
||
#include <aztec3/constants.hpp> | ||
#include <aztec3/utils/types/native_types.hpp> | ||
#include "aztec3/circuits/abis/signed_tx_request.hpp" | ||
#include "aztec3/circuits/abis/private_kernel/private_call_data.hpp" | ||
#include <aztec3/circuits/abis/private_kernel/private_inputs.hpp> | ||
#include <aztec3/circuits/abis/private_kernel/public_inputs.hpp> | ||
#include <aztec3/circuits/mock/mock_kernel_circuit.hpp> | ||
|
||
#include "barretenberg/srs/reference_string/env_reference_string.hpp" | ||
|
||
#include "barretenberg/common/serialize.hpp" | ||
#include "barretenberg/plonk/composer/turbo_composer.hpp" | ||
|
||
namespace { | ||
using NT = aztec3::utils::types::NativeTypes; | ||
using aztec3::circuits::rollup::native_root_rollup::root_rollup_circuit; | ||
using aztec3::circuits::rollup::native_root_rollup::RootRollupInputs; | ||
using aztec3::circuits::rollup::native_root_rollup::RootRollupPublicInputs; | ||
|
||
using plonk::TurboComposer; | ||
using namespace plonk::stdlib::types; | ||
} // namespace | ||
|
||
#define WASM_EXPORT __attribute__((visibility("default"))) | ||
// WASM Cbinds | ||
extern "C" { | ||
|
||
WASM_EXPORT size_t root_rollup__init_proving_key(uint8_t const** pk_buf) | ||
{ | ||
std::vector<uint8_t> pk_vec(42, 0); | ||
|
||
auto raw_buf = (uint8_t*)malloc(pk_vec.size()); | ||
memcpy(raw_buf, (void*)pk_vec.data(), pk_vec.size()); | ||
*pk_buf = raw_buf; | ||
|
||
return pk_vec.size(); | ||
} | ||
|
||
WASM_EXPORT size_t root_rollup__init_verification_key(uint8_t const* pk_buf, uint8_t const** vk_buf) | ||
{ | ||
std::vector<uint8_t> vk_vec(42, 0); | ||
// TODO remove when proving key is used | ||
(void)pk_buf; // unused | ||
|
||
auto raw_buf = (uint8_t*)malloc(vk_vec.size()); | ||
memcpy(raw_buf, (void*)vk_vec.data(), vk_vec.size()); | ||
*vk_buf = raw_buf; | ||
|
||
return vk_vec.size(); | ||
} | ||
|
||
WASM_EXPORT size_t root_rollup__sim(uint8_t const* root_rollup_inputs_buf, | ||
uint8_t const** root_rollup_public_inputs_buf) | ||
{ | ||
RootRollupInputs root_rollup_inputs; | ||
read(root_rollup_inputs_buf, root_rollup_inputs); | ||
|
||
RootRollupPublicInputs public_inputs = root_rollup_circuit(root_rollup_inputs); | ||
|
||
// serialize public inputs to bytes vec | ||
std::vector<uint8_t> public_inputs_vec; | ||
write(public_inputs_vec, public_inputs); | ||
// copy public inputs to output buffer | ||
auto raw_public_inputs_buf = (uint8_t*)malloc(public_inputs_vec.size()); | ||
memcpy(raw_public_inputs_buf, (void*)public_inputs_vec.data(), public_inputs_vec.size()); | ||
*root_rollup_public_inputs_buf = raw_public_inputs_buf; | ||
|
||
return public_inputs_vec.size(); | ||
} | ||
|
||
WASM_EXPORT size_t root_rollup__verify_proof(uint8_t const* vk_buf, uint8_t const* proof, uint32_t length) | ||
{ | ||
(void)vk_buf; // unused | ||
(void)proof; // unused | ||
(void)length; // unused | ||
return true; | ||
} | ||
|
||
} // extern "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <cstdint> | ||
#include <cstddef> | ||
|
||
#define WASM_EXPORT __attribute__((visibility("default"))) | ||
|
||
extern "C" { | ||
|
||
WASM_EXPORT size_t root_rollup__init_proving_key(uint8_t const** pk_buf); | ||
WASM_EXPORT size_t root_rollup__init_verification_key(uint8_t const* pk_buf, uint8_t const** vk_buf); | ||
WASM_EXPORT size_t root_rollup__sim(uint8_t const* root_rollup_inputs_buf, | ||
uint8_t const** root_rollup_public_inputs_buf); | ||
WASM_EXPORT size_t root_rollup__verify_proof(uint8_t const* vk_buf, | ||
uint8_t const* proof, | ||
uint32_t length); | ||
|
||
} |