Skip to content

Commit

Permalink
babybear rw circuit
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineCyr committed Mar 5, 2025
1 parent 3f0c093 commit d2c579d
Show file tree
Hide file tree
Showing 5 changed files with 791 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crypto3/libs/blueprint/include/nil/blueprint/zkevm/zkevm_word.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ namespace nil {
return chunks;
}

template<typename BlueprintFieldType>
std::vector<typename BlueprintFieldType::value_type> zkevm_word_to_field_element_flexible(
const zkevm_word_type &word, const std::size_t num_chunks, const std::size_t chunk_size = 16) {
using value_type = typename BlueprintFieldType::value_type;
std::vector<value_type> chunks;
const zkevm_word_type mask = (zkevm_word_type(1) << chunk_size) - 1;
zkevm_word_type word_copy = word;
for (std::size_t i = 0; i < num_chunks; ++i) {
chunks.push_back(word_copy & mask);
word_copy >>= chunk_size;
}
return chunks;
}

template<typename BlueprintFieldType>
std::vector<typename BlueprintFieldType::value_type> chunk_64_to_16(
const typename BlueprintFieldType::value_type &value
Expand Down
Loading

0 comments on commit d2c579d

Please sign in to comment.