Skip to content

Commit

Permalink
initialize empty rlc_challenge for copy circuit
Browse files Browse the repository at this point in the history
  • Loading branch information
oclaw committed Dec 5, 2024
1 parent c510089 commit 68f9e85
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
5 changes: 3 additions & 2 deletions crypto3/libs/blueprint/include/nil/blueprint/bbf/generic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,10 @@ namespace nil {
template<typename FieldType, GenerationStage stage>
class generic_component {
public:
using TYPE = typename std::conditional<static_cast<bool>(stage),
using TYPE = std::conditional_t<static_cast<bool>(stage),
crypto3::zk::snark::plonk_constraint<FieldType>,
typename FieldType::value_type>::type;
typename FieldType::value_type
>;
using context_type = context<FieldType, stage>;
using plonk_copy_constraint = crypto3::zk::snark::plonk_copy_constraint<FieldType>;

Expand Down
18 changes: 14 additions & 4 deletions crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
//---------------------------------------------------------------------------//
#pragma once

#include <cstddef>
#include <nil/blueprint/zkevm_bbf/subcomponents/keccak_table.hpp>
#include <nil/blueprint/zkevm_bbf/subcomponents/bytecode_table.hpp>
#include <nil/blueprint/zkevm_bbf/subcomponents/rw_table.hpp>
#include <nil/blueprint/zkevm_bbf/subcomponents/copy_table.hpp>
#include <stdexcept>
#include <type_traits>

namespace nil {
namespace blueprint {
Expand All @@ -45,10 +48,14 @@ namespace nil {

struct input_type{
TYPE rlc_challenge;
typename std::conditional<stage == GenerationStage::ASSIGNMENT, zkevm_keccak_buffers, std::nullptr_t>::type bytecodes;
typename std::conditional<stage == GenerationStage::ASSIGNMENT, zkevm_keccak_buffers, std::nullptr_t>::type keccak_buffers;
typename std::conditional<stage==GenerationStage::ASSIGNMENT, rw_operations_vector, std::nullptr_t>::type rw_operations;
typename std::conditional<stage==GenerationStage::ASSIGNMENT, std::vector<copy_event>, std::nullptr_t>::type copy_events;

template <bool condition, typename T>
using type_or_none = typename std::conditional_t<condition, T, std::nullptr_t>;

type_or_none<stage == GenerationStage::ASSIGNMENT, zkevm_keccak_buffers> bytecodes;
type_or_none<stage == GenerationStage::ASSIGNMENT, zkevm_keccak_buffers> keccak_buffers;
type_or_none<stage == GenerationStage::ASSIGNMENT, rw_operations_vector> rw_operations;
type_or_none<stage == GenerationStage::ASSIGNMENT, std::vector<copy_event>> copy_events;
};
public:
using BytecodeTable = bytecode_table<FieldType, stage>;
Expand Down Expand Up @@ -86,6 +93,9 @@ namespace nil {
} else {
std::cout << "Copy circuit" << std::endl;
}
if (input.rlc_challenge == 0) {
throw std::invalid_argument("RLC challenge should be non-zero");
}

std::cout << "Copy assignment and circuit construction" << std::endl;
std::size_t current_column = copy_advice_amount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace nil {
typename nil::blueprint::bbf::context<BlueprintFieldType, nil::blueprint::bbf::GenerationStage::ASSIGNMENT> context_object(assignment_table, limits::max_rows);

typename ComponentType::input_type input;
input.rlc_challenge = limits::RLC_CHALLENGE;

auto copy_events = deserialize_copy_events_from_file(trace_file_path);
if (!copy_events) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ namespace nil {

nil::blueprint::circuit<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>> circuit;
typename ComponentType::input_type input;
input.rlc_challenge = limits::RLC_CHALLENGE;

blueprint::components::generate_circuit(
wrapper,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <cstdint>
#include "nil/proof-generator/preset/preset.hpp"

namespace nil {
namespace proof_generator {
Expand All @@ -14,6 +15,8 @@ namespace nil {
const std::size_t max_mpt_size = 30;
const std::size_t max_zkevm_rows = 10000;

const std::size_t RLC_CHALLENGE = 7;

} // limits
} // proof_generator
} // nil

0 comments on commit 68f9e85

Please sign in to comment.