Skip to content

Commit c30430e

Browse files
committed
move bls aggregated signature verification to pubkey submodule #372
1 parent 7218963 commit c30430e

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed
Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <nil/crypto3/algebra/fields/bls12/base_field.hpp>
22
#include <nil/crypto3/algebra/curves/bls12.hpp>
3-
#include <nil/crypto3/algebra/algorithms/pair.hpp>
3+
#include <nil/crypto3/pubkey/detail/bls/bls_basic_functions.hpp>
44

55

66
using namespace nil::crypto3;
@@ -13,32 +13,5 @@ constexpr const std::size_t validators_amount = 5;
1313
typename algebra::curves::bls12<381>::template g1_type<>::value_type aggregated_signature
1414
) {
1515

16-
// __builtin_assigner_exit_check(__builtin_assigner_is_in_g1_check(aggregated_signature));
17-
18-
19-
typename algebra::curves::bls12<381>::template g2_type<>::value_type g2_group_generator = algebra::curves::bls12<381>::template g2_type<>::one();
20-
typename algebra::curves::bls12<381>::gt_type::value_type pairing1 =
21-
algebra::pair<algebra::curves::bls12<381>>(aggregated_signature, g2_group_generator);
22-
23-
typename algebra::curves::bls12<381>::template g1_type<>::value_type msg_point = __builtin_assigner_hash_to_curve(hashed_msg);
24-
25-
// __builtin_assigner_exit_check(__builtin_assigner_is_in_g2_check(pubkeys[0]));
26-
typename algebra::curves::bls12<381>::gt_type::value_type pairing2 =
27-
algebra::pair<algebra::curves::bls12<381>>(msg_point, pubkeys[0]);
28-
29-
typename algebra::curves::bls12<381>::gt_type::value_type current_pairing;
30-
31-
for (std::size_t i = 1; i < validators_amount; i++) {
32-
// __builtin_assigner_exit_check(__builtin_assigner_is_in_g2_check(pubkeys[i]));
33-
current_pairing = algebra::pair<algebra::curves::bls12<381>>(msg_point, pubkeys[i]);
34-
pairing2 = __builtin_assigner_gt_multiplication(pairing2, current_pairing);
35-
}
36-
37-
bool are_equal = 0;
38-
for (std::size_t i = 0; i < 12; i++) {
39-
are_equal = are_equal && (pairing1[i] == pairing2[i]);
40-
}
41-
// __builtin_assigner_exit_check(are_equal);
42-
43-
return are_equal;
16+
return nil::crypto3::pubkey::detail::bls_basic_functions::aggregate_verify<validators_amount>(hashed_msg, pubkeys, aggregated_signature);
4417
}

0 commit comments

Comments
 (0)