Skip to content

Commit 1d6b9fa

Browse files
akokoshnnkaskov
authored andcommitted
Add tests for sha256 and poseidon. Assigner submodule updated.
1 parent 5f2b7a3 commit 1d6b9fa

File tree

7 files changed

+81
-3
lines changed

7 files changed

+81
-3
lines changed

examples/inputs/validate_merkle_path_sha2_256.inp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
},
3232
{
3333
"vector": [
34-
{"field": "86554538938959106637154046931247318302"},
35-
{"field": "250679293405040244372434488049653302086"}
34+
{"field": "35174607401651764532592651957486212894"},
35+
{"field": "140712014106150384775276850496842098004"}
3636
]
3737
}
3838
]

tests/cpp/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,5 +222,9 @@ add_zkllvm_unit_test("libc/strncmp/strncmp")
222222
add_zkllvm_unit_test("libc/strcpy/strcpy")
223223
add_zkllvm_unit_test("libc/strncpy/strncpy")
224224

225+
#hashes
226+
add_zkllvm_unit_test("hashes/sha256/sha2_256")
227+
add_zkllvm_unit_test("hashes/poseidon/poseidon")
228+
225229
add_dependencies(all_for_test_run all_circuit_tests)
226230
add_dependencies(all_for_test_run all_expected_res_tests)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#ifndef __ZKLLVM__
2+
#include "../../read_boost_json.hpp"
3+
#include <cstdint>
4+
#include <fstream>
5+
#endif
6+
7+
#include <nil/crypto3/hash/algorithm/hash.hpp>
8+
#include <nil/crypto3/hash/poseidon.hpp>
9+
10+
#ifdef __ZKLLVM__
11+
12+
using namespace nil::crypto3;
13+
using namespace nil::crypto3::algebra::curves;
14+
15+
[[circuit]] typename pallas::base_field_type::value_type test_func(typename pallas::base_field_type::value_type b,
16+
typename pallas::base_field_type::value_type c) {
17+
typename pallas::base_field_type::value_type hash_result = hash<hashes::poseidon>(b, c);
18+
19+
return hash_result;
20+
}
21+
22+
#endif
23+
24+
#ifndef __ZKLLVM__
25+
26+
int main (int argc, char *argv[]){
27+
if (argc != 2) {
28+
std::cerr << "one command line argument must be provided\n";
29+
std::abort();
30+
}
31+
32+
std::cout << "1090649087601646060577911565538921894952249843885775285625455432992693168204" << std::endl;
33+
34+
return 0;
35+
}
36+
#endif
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#ifndef __ZKLLVM__
2+
#include "../../read_boost_json.hpp"
3+
#include <cstdint>
4+
#include <fstream>
5+
#endif
6+
7+
#include <nil/crypto3/hash/algorithm/hash.hpp>
8+
#include <nil/crypto3/hash/sha2.hpp>
9+
10+
#ifdef __ZKLLVM__
11+
12+
using namespace nil::crypto3;
13+
14+
[[circuit]] typename hashes::sha2<256>::block_type test_func(typename hashes::sha2<256>::block_type first_input_block,
15+
typename hashes::sha2<256>::block_type second_input_block) {
16+
typename hashes::sha2<256>::block_type hash_result = hash<hashes::sha2<256>>(first_input_block, second_input_block);
17+
18+
return hash_result;
19+
}
20+
21+
#endif
22+
23+
#ifndef __ZKLLVM__
24+
25+
int main (int argc, char *argv[]){
26+
if (argc != 2) {
27+
std::cerr << "one command line argument must be provided\n";
28+
std::abort();
29+
}
30+
31+
std::cout << "88644561790884159333416244513756961366 279256413903306112288588927002886743215 " << std::endl;
32+
33+
return 0;
34+
}
35+
#endif
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"field": 0}, {"field": 1}]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[ {"vector": [{"field": "326522724692461750427768532537390503835"},{"field": "89059515727727869117346995944635890507"}]},
2+
{"vector": [{"field": "291547819587797372485177713898460727720"},{"field": "194782098816759892662980765881849306481"}]} ]

0 commit comments

Comments
 (0)