Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit fa13bad

Browse files
committed
Replaced masks with bits #288
1 parent 94bcdaf commit fa13bad

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

libs/zk/include/nil/crypto3/zk/commitments/detail/polynomial/proof_of_work.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ namespace nil {
5656
}
5757

5858
static inline OutType generate(transcript_type &transcript, std::size_t GrindingBits = 16) {
59+
BOOST_ASSERT_MSG(GrindingBits < 64, "Grinding parameter should be bits, not mask");
5960
output_type mask = GrindingBits > 0 ? ( 1ULL << GrindingBits ) - 1 : 0;
6061
output_type proof_of_work = std::rand();
6162
output_type result;
@@ -74,6 +75,7 @@ namespace nil {
7475
}
7576

7677
static inline bool verify(transcript_type &transcript, output_type proof_of_work, std::size_t GrindingBits = 16) {
78+
BOOST_ASSERT_MSG(GrindingBits < 64, "Grinding parameter should be bits, not mask");
7779
transcript(int_be(proof_of_work));
7880
output_type result = transcript.template int_challenge<output_type>();
7981
output_type mask = GrindingBits > 0 ? ( 1ULL << GrindingBits ) - 1 : 0;
@@ -93,7 +95,7 @@ namespace nil {
9395
using value_type = typename FieldType::value_type;
9496
using integral_type = typename FieldType::integral_type;
9597

96-
static inline value_type generate(transcript_type &transcript, std::size_t GrindingBits=16) {
98+
static inline value_type generate(transcript_type &transcript, std::size_t GrindingBits = 16) {
9799
static boost::random::random_device dev;
98100
static nil::crypto3::random::algebraic_engine<FieldType> random_engine(dev);
99101
value_type proof_of_work = random_engine();
@@ -117,7 +119,7 @@ namespace nil {
117119
return proof_of_work;
118120
}
119121

120-
static inline bool verify(transcript_type &transcript, value_type proof_of_work, std::size_t GrindingBits=16) {
122+
static inline bool verify(transcript_type &transcript, value_type proof_of_work, std::size_t GrindingBits = 16) {
121123
transcript(proof_of_work);
122124
integral_type mask =
123125
(GrindingBits > 0 ?

libs/zk/test/commitment/fri.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ BOOST_AUTO_TEST_SUITE(fri_test_suite)
116116
2, //expand_factor
117117
lambda,
118118
true,
119-
0xFFFFF
119+
20
120120
);
121121

122122
BOOST_CHECK(D[1]->m == D[0]->m / 2);

libs/zk/test/commitment/lpc.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ BOOST_AUTO_TEST_SUITE(lpc_math_polynomial_suite);
210210
2, //expand_factor
211211
lambda,
212212
true,
213-
0xFFF
213+
12
214214
);
215215

216216
using lpc_scheme_type = nil::crypto3::zk::commitments::lpc_commitment_scheme<lpc_type, math::polynomial<typename FieldType::value_type>>;
@@ -510,7 +510,7 @@ BOOST_AUTO_TEST_SUITE(lpc_params_test_suite)
510510
2, //expand_factor
511511
lambda,
512512
true,
513-
0xFF
513+
8
514514
);
515515

516516
using lpc_scheme_type = nil::crypto3::zk::commitments::lpc_commitment_scheme<lpc_type, math::polynomial<typename FieldType::value_type>>;

0 commit comments

Comments
 (0)