Skip to content

Commit

Permalink
add private input test #205
Browse files Browse the repository at this point in the history
  • Loading branch information
CblPOK-git committed Oct 16, 2023
1 parent a9bac5a commit 615f62f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ add_zkllvm_unit_test("algebra/fields/pallas_arithmetics/loop")
add_zkllvm_unit_test("algebra/fields/pallas_arithmetics/mul")
add_zkllvm_unit_test("algebra/fields/pallas_arithmetics/sub")

add_zkllvm_unit_test("algebra/fields/pallas_arithmetics/private_input_add")


# int tests
add_zkllvm_unit_test("algebra/integers/division/udiv")
Expand Down
40 changes: 40 additions & 0 deletions tests/cpp/algebra/fields/pallas_arithmetics/private_input_add.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef __ZKLLVM__
#include "../../../read_boost_json.hpp"
#include <fstream>
#endif

#include <nil/crypto3/algebra/curves/pallas.hpp>

using namespace nil::crypto3::algebra::curves;

[[circuit]] typename pallas::base_field_type::value_type
pallas_field_add([[private_input]] typename pallas::base_field_type::value_type a,
[[private_input]] typename pallas::base_field_type::value_type b) {

typename pallas::base_field_type::value_type c = a + b;

#ifndef __ZKLLVM__
std::cout << c.data <<std::endl;
#endif

return c;
}

#ifndef __ZKLLVM__

int main (int argc, char *argv[]){
if (argc != 2) {
std::cerr << "one command line argument must be provided\n";
std::abort();
}

boost::json::value input_json = read_boost_json(std::string(argv[1]));

using BlueprintFieldType = typename pallas::base_field_type;
typename BlueprintFieldType::value_type a = read_field <BlueprintFieldType>(input_json, 0);
typename BlueprintFieldType::value_type b = read_field <BlueprintFieldType>(input_json, 1);

pallas_field_add(a, b);
return 0;
}
#endif

0 comments on commit 615f62f

Please sign in to comment.