Skip to content

Commit

Permalink
Minor fixes related to circuit build.
Browse files Browse the repository at this point in the history
  • Loading branch information
HristoStaykov committed Feb 16, 2024
1 parent b302ce1 commit acab843
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 37 deletions.
2 changes: 1 addition & 1 deletion vendor/zkllvm-metacraft-circuits/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ cd $REPO_ROOT/zkllvm-template
COPY_SOURCE_FILES=0
scripts/run.sh $@
cd $SCRIPT_DIR/..
rm -r $REPO_ROOT/zkllvm-template/src
rm -rf $REPO_ROOT/zkllvm-template/src
mv $REPO_ROOT/src~ $REPO_ROOT/zkllvm-template/src
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace circuit_byte_utils {
return bytes;
}

template<typename T, typename iterator_type, size_t SIZE = sizeof(T), bool LittleEndian = true>
template<typename T, typename iterator_type, size_t SIZE, bool LittleEndian>
T bytes_to_int(iterator_type first_element, iterator_type last_element) {
static_assert(std::is_integral_v<typename std::remove_reference_t<T>>, "T must be integral");
assert_in_executable(first_element + sizeof(T) <= last_element);
Expand All @@ -120,7 +120,7 @@ namespace circuit_byte_utils {

template<typename T, size_t SIZE = sizeof(T), bool LittleEndian = true>
T bytes_to_int(const static_vector<Byte, SIZE>& bytes) {
return bytes_to_int<T>(bytes.begin(), bytes.end());
return bytes_to_int<T, decltype(bytes.begin()), SIZE, LittleEndian>(bytes.begin(), bytes.end());
}

template<typename... Args>
Expand Down Expand Up @@ -236,7 +236,7 @@ namespace circuit_byte_utils {

using namespace nil::crypto3;
using namespace nil::crypto3::algebra::curves;
sha256_t bytes_to_hash_type(const static_vector<unsigned char, 32>& bytes) {
sha256_t bytes_to_hash_type(const Bytes32& bytes) {

sha256_t converted;
// MSB first
Expand Down
6 changes: 6 additions & 0 deletions vendor/zkllvm-metacraft-circuits/src/circuits/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ add_example(weigh_justification_and_finalization SOURCES weigh_justification_and

add_dependencies(template compute_shuffled_index)
add_dependencies(template weigh_justification_and_finalization)

add_custom_command(TARGET compute_shuffled_index POST_BUILD
COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/compute_shuffled_index.json ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS compile_commands.json
VERBATIM ON
)
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
[
{"int": 0},
{"int": 33},
{
"array": [
[
"166209954665300884822717121800188038799",
"144783094885247872016525034474730739405"
],
[
"316532530640111588187217404778232020911",
"26724093998456942932372011149134879307"
],
[
"129016131943024881685044309516733708576",
"301035858936827583230771718648958481107"
],
[
"38435942355081927355841277555582070467",
"236468793428173394040239098346085887776"
],
[
"155672546387712744663901139927960865151",
"130337062174399240196487120660567896561"
]
{"int": 38},
{"int": 101},
{"int": 90},
{"int": 171},
{"int": 88},
{"int": 193},
{"int": 139},
{"int": 102},
{"int": 135},
{"int": 15},
{"int": 80},
{"int": 161},
{"int": 51},
{"int": 23},
{"int": 28},
{"int": 133},
{"int": 217},
{"int": 165},
{"int": 174},
{"int": 157},
{"int": 222},
{"int": 85},
{"int": 192},
{"int": 202},
{"int": 4},
{"int": 148},
{"int": 145},
{"int": 162},
{"int": 127},
{"int": 79},
{"int": 99},
{"int": 231}
]
},
{
"vector": [
"166209954665300884822717121800188038799",
"144783094885247872016525034474730739405"
]
},
{
"vector": [
"24758149039370610683683259915413762872",
"275362252495473570680232529690834658303"
]
}
{"int": 90}
]
2 changes: 1 addition & 1 deletion vendor/zkllvm-metacraft-circuits/src/utils/byte_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace byte_utils {
JustificationBitsVariable hexToBitsVariable(std::string hex) {
JustificationBitsVariable retval {};
auto bits = hexToBytes<1>(hex);
for (int64_t i = 0; i < (int64_t)retval.bits.size(); ++i) {
for (uint64_t i = 0; i < (uint64_t)retval.bits.size(); ++i) {
retval.bits[i] = (bits[0] % 2);
bits[0] /= 2;
}
Expand Down

0 comments on commit acab843

Please sign in to comment.