Skip to content

350 basic cleanup of zkevm opcode circuits #361

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ayashunsky
Copy link
Contributor

Moved common power-of-two constants and multiplication-computing functions to util.hpp

@ayashunsky ayashunsky requested a review from mizabrik February 27, 2025 15:58
@ayashunsky ayashunsky linked an issue Feb 27, 2025 that may be closed by this pull request
Copy link

Clang Test Results

  215 files  ±0    215 suites  +1   47m 45s ⏱️ +2s
8 650 tests +1  8 642 ✅ +1   8 💤 ±0  0 ❌ ±0 
8 896 runs  +1  8 884 ✅ +1  12 💤 ±0  0 ❌ ±0 

Results for commit e3c0fd6. ± Comparison against base commit 977dced.

Copy link

Gcc Test Results

  215 files  ±0    215 suites  ±0   44m 34s ⏱️ - 1m 50s
8 650 tests ±0  8 642 ✅ ±0   8 💤 ±0  0 ❌ ±0 
8 896 runs  ±0  8 884 ✅ ±0  12 💤 ±0  0 ❌ ±0 

Results for commit e3c0fd6. ± Comparison against base commit 977dced.

chunks[4 * chunk_idx + 2] * two_32 + chunks[4 * chunk_idx + 3] * two_48;
}

// computes 128-bit chunks of r*b + q - a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we use conventional (?) q*b + r - a?

Comment on lines +108 to +115
static const unsigned int two_15 = 32768;
static const unsigned int two_16 = 65536;
static const nil::crypto3::multiprecision::big_uint<64> two_32 = 4294967296;
static const nil::crypto3::multiprecision::big_uint<64> two_48 = 281474976710656;
static const nil::crypto3::multiprecision::big_uint<92> two_64 = 0x10000000000000000_big_uint92;
static const nil::crypto3::multiprecision::big_uint<130> two_128 = 0x100000000000000000000000000000000_big_uint130;
static const nil::crypto3::multiprecision::big_uint<205>
two_192 = 0x1000000000000000000000000000000000000000000000000_big_uint205;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static const unsigned int two_15 = 32768;
static const unsigned int two_16 = 65536;
static const nil::crypto3::multiprecision::big_uint<64> two_32 = 4294967296;
static const nil::crypto3::multiprecision::big_uint<64> two_48 = 281474976710656;
static const nil::crypto3::multiprecision::big_uint<92> two_64 = 0x10000000000000000_big_uint92;
static const nil::crypto3::multiprecision::big_uint<130> two_128 = 0x100000000000000000000000000000000_big_uint130;
static const nil::crypto3::multiprecision::big_uint<205>
two_192 = 0x1000000000000000000000000000000000000000000000000_big_uint205;
static const uint32_t two_15 = 1 << 15;
static const uint32_t two_16 = 1 << 16;
static const nil::crypto3::multiprecision::big_uint<64> two_32 = 1ull << 32;
static const nil::crypto3::multiprecision::big_uint<64> two_48 = 1ull << 48;
static const nil::crypto3::multiprecision::big_uint<92> two_64 = 1_big_uint92 << 64;
static const nil::crypto3::multiprecision::big_uint<130> two_128 = 1_big_uint130 << 128;
static const nil::crypto3::multiprecision::big_uint<205> two_192 = 1_big_uint205 << 192;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why not uint64_t?

two_192 = 0x1000000000000000000000000000000000000000000000000_big_uint205;

template<typename T, typename V = T>
T chunk_sum_64(const std::vector<V> &chunks, const unsigned char chunk_idx) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have it returning a vector with all the chunks, without specifying chunk_idx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Basic cleanup of zkEVM opcode circuits
2 participants