Skip to content

Commit d2d89c2

Browse files
committed
add exit_check_eq_pallas test
1 parent 5c2da23 commit d2d89c2

File tree

5 files changed

+63
-7
lines changed

5 files changed

+63
-7
lines changed

tests/cpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ add_zkllvm_unit_test("algebra/integers/shift/right")
228228

229229
#bool tests
230230
add_zkllvm_unit_test("algebra/bool/assigner_exit_check")
231+
add_zkllvm_unit_test("algebra/bool/assigner_exit_check_eq_pallas")
231232

232233
# bit de/composition tests
233234
add_zkllvm_unit_test("algebra/de_composition/decomposition/msb")

tests/cpp/algebra/bool/assigner_exit_check.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

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

9-
[[circuit]] bool assert_equaluty(uint32_t a, uint32_t b) {
9+
using namespace nil::crypto3::algebra::curves;
10+
11+
[[circuit]] bool assert_equaluty(
12+
typename pallas::base_field_type::value_type a,
13+
typename pallas::base_field_type::value_type b
14+
) {
1015

1116
bool c = a == b;
1217

@@ -34,8 +39,9 @@ int main (int argc, char *argv[]){
3439

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

37-
uint32_t a = read_uint<uint32_t>(input_json, 0);
38-
uint32_t b = read_uint<uint32_t>(input_json, 1);
42+
using BlueprintFieldType = typename pallas::base_field_type;
43+
typename BlueprintFieldType::value_type a = read_field <BlueprintFieldType>(input_json, 0);
44+
typename BlueprintFieldType::value_type b = read_field <BlueprintFieldType>(input_json, 1);
3945

4046
assert_equaluty(a, b);
4147
return 0;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#ifndef __ZKLLVM__
2+
#include "../../read_boost_json.hpp"
3+
#include <cstdint>
4+
#include <fstream>
5+
#endif
6+
7+
#include <nil/crypto3/algebra/curves/pallas.hpp>
8+
9+
using namespace nil::crypto3::algebra::curves;
10+
11+
[[circuit]] bool assert_equaluty(
12+
typename pallas::base_field_type::value_type a,
13+
typename pallas::base_field_type::value_type b
14+
) {
15+
16+
bool c = a == b;
17+
18+
19+
#ifdef __ZKLLVM__
20+
__builtin_assigner_exit_check_eq_pallas(a, b);
21+
#else
22+
assert(c);
23+
#endif
24+
25+
#ifndef __ZKLLVM__
26+
std::cout << c <<std::endl;
27+
#endif
28+
29+
return c;
30+
}
31+
32+
#ifndef __ZKLLVM__
33+
34+
int main (int argc, char *argv[]){
35+
if (argc != 2) {
36+
std::cerr << "one command line argument must be provided\n";
37+
std::abort();
38+
}
39+
40+
boost::json::value input_json = read_boost_json(std::string(argv[1]));
41+
42+
using BlueprintFieldType = typename pallas::base_field_type;
43+
typename BlueprintFieldType::value_type a = read_field <BlueprintFieldType>(input_json, 0);
44+
typename BlueprintFieldType::value_type b = read_field <BlueprintFieldType>(input_json, 1);
45+
46+
assert_equaluty(a, b);
47+
return 0;
48+
}
49+
#endif
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[
2-
{"int": 5},
3-
{"int": 10}
2+
{"field": 5},
3+
{"field": 10}
44
]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[
2-
{"int": 5},
3-
{"int": 5}
2+
{"field": 5},
3+
{"field": 5}
44
]

0 commit comments

Comments
 (0)