Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

372 move bls signature verification to pubkey lib #465

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move bls aggregated signature verification to pubkey submodule #372
  • Loading branch information
CblPOK-git committed Jan 19, 2024
commit b2de25ece16733640344188d9ec9ffe56b3c05aa
31 changes: 2 additions & 29 deletions examples/cpp/bls12_381_signature_verification_aggregated.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <nil/crypto3/algebra/fields/bls12/base_field.hpp>
#include <nil/crypto3/algebra/curves/bls12.hpp>
#include <nil/crypto3/algebra/algorithms/pair.hpp>
#include <nil/crypto3/pubkey/detail/bls/bls_basic_functions.hpp>


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

// __builtin_assigner_exit_check(__builtin_assigner_is_in_g1_check(aggregated_signature));


typename algebra::curves::bls12<381>::template g2_type<>::value_type g2_group_generator = algebra::curves::bls12<381>::template g2_type<>::one();
typename algebra::curves::bls12<381>::gt_type::value_type pairing1 =
algebra::pair<algebra::curves::bls12<381>>(aggregated_signature, g2_group_generator);

typename algebra::curves::bls12<381>::template g1_type<>::value_type msg_point = __builtin_assigner_hash_to_curve(hashed_msg);

// __builtin_assigner_exit_check(__builtin_assigner_is_in_g2_check(pubkeys[0]));
typename algebra::curves::bls12<381>::gt_type::value_type pairing2 =
algebra::pair<algebra::curves::bls12<381>>(msg_point, pubkeys[0]);

typename algebra::curves::bls12<381>::gt_type::value_type current_pairing;

for (std::size_t i = 1; i < validators_amount; i++) {
// __builtin_assigner_exit_check(__builtin_assigner_is_in_g2_check(pubkeys[i]));
current_pairing = algebra::pair<algebra::curves::bls12<381>>(msg_point, pubkeys[i]);
pairing2 = __builtin_assigner_gt_multiplication(pairing2, current_pairing);
}

bool are_equal = 0;
for (std::size_t i = 0; i < 12; i++) {
are_equal = are_equal && (pairing1[i] == pairing2[i]);
}
// __builtin_assigner_exit_check(are_equal);

return are_equal;
return nil::crypto3::pubkey::detail::bls_basic_functions::aggregate_verify<validators_amount>(hashed_msg, pubkeys, aggregated_signature);
}