-
Notifications
You must be signed in to change notification settings - Fork 644
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
Split precompile constants out of individual modules #2081 #2085
Merged
rakita
merged 72 commits into
bluealloy:main
from
Ayushdubey86:Split-Precompile-Constants-out-of-Individual-Modules-#2081
Feb 19, 2025
+142
−165
Merged
Changes from 16 commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
17d3350
Update bls12_381.rs
Ayushdubey86 4e3849a
Merge branch 'bluealloy:main' into Split-Precompile-Constants-out-of-…
Ayushdubey86 6723031
Update g1.rs
Ayushdubey86 771feed
Update g1_add.rs
Ayushdubey86 46393d7
Update g1.rs
Ayushdubey86 b3a8830
Update g1_msm.rs
Ayushdubey86 65b91b2
Update g2.rs
Ayushdubey86 06b1abc
Update g2_add.rs
Ayushdubey86 8b440c7
Update g2_msm.rs
Ayushdubey86 45d2b57
Update map_fp_to_g1.rs
Ayushdubey86 2aa936b
Update map_fp2_to_g2.rs
Ayushdubey86 92752f8
Update msm.rs
Ayushdubey86 91e4e49
Update pairing.rs
Ayushdubey86 7170956
Update utils.rs
Ayushdubey86 e14174b
Add files via upload
Ayushdubey86 5ed8fb4
Update bls12_381.rs
Ayushdubey86 49a604e
Merge branch 'bluealloy:main' into Split-Precompile-Constants-out-of-…
Ayushdubey86 7e45d7c
Update bls12_381_const.rs
Ayushdubey86 88eb122
Update g1.rs
Ayushdubey86 fa79045
Update g1_add.rs
Ayushdubey86 5a3f7d1
Update g1_msm.rs
Ayushdubey86 9bf0f5f
Update g2.rs
Ayushdubey86 5f414ea
Update g2_add.rs
Ayushdubey86 96da3a1
Update g2_msm.rs
Ayushdubey86 da24a29
Update map_fp2_to_g2.rs
Ayushdubey86 37adee4
Update map_fp_to_g1.rs
Ayushdubey86 66a8485
Update pairing.rs
Ayushdubey86 31fa51e
Update utils.rs
Ayushdubey86 b804a84
Merge branch 'bluealloy:main' into Split-Precompile-Constants-out-of-…
Ayushdubey86 4090e87
Delete crates/precompile/src/bls12_381/bls12_381_const.rs
Ayushdubey86 f6dc7a5
Update lib.rs
Ayushdubey86 1073fec
Add files via upload
Ayushdubey86 f2bb096
Update utils.rs
Ayushdubey86 cdce5ba
Update pairing.rs
Ayushdubey86 19e7ce6
Update msm.rs
Ayushdubey86 b259b1e
Update map_fp_to_g1.rs
Ayushdubey86 9860c79
Update map_fp2_to_g2.rs
Ayushdubey86 04b32b6
Update g2_msm.rs
Ayushdubey86 0c8aeea
Update g2_add.rs
Ayushdubey86 c828bf9
Update g2.rs
Ayushdubey86 1dc038f
Update g1_msm.rs
Ayushdubey86 2ef3aae
Update g1_add.rs
Ayushdubey86 c3c91c3
Update g1.rs
Ayushdubey86 f5e0d12
Update bls12_381.rs
Ayushdubey86 d5165d5
Merge branch 'bluealloy:main' into Split-Precompile-Constants-out-of-…
Ayushdubey86 0405e7f
Update g1.rs
Ayushdubey86 ba1c27e
Update g1_msm.rs
Ayushdubey86 bc47a3e
Update g2.rs
Ayushdubey86 d1cee00
Update g2.rs
Ayushdubey86 791f2e0
Update g2_msm.rs
Ayushdubey86 e13e418
Update g1_msm.rs
Ayushdubey86 25d447d
Update g2.rs
Ayushdubey86 7547528
Update g1_add.rs
Ayushdubey86 80fbd53
Update g1_add.rs
Ayushdubey86 7af1926
Update g1_msm.rs
Ayushdubey86 708bbc0
Update g1_add.rs
Ayushdubey86 72376e6
Update g2_msm.rs
Ayushdubey86 629b070
Update map_fp2_to_g2.rs
Ayushdubey86 b280c35
Update map_fp_to_g1.rs
Ayushdubey86 ca89ecf
Update utils.rs
Ayushdubey86 a9b0845
Update bls12_381.rs
Ayushdubey86 1149445
Update g1_add.rs
Ayushdubey86 681a35b
Update g1_msm.rs
Ayushdubey86 451581f
Update g2_msm.rs
Ayushdubey86 b4931e5
Update g2_msm.rs
Ayushdubey86 c9b4001
Update g2_msm.rs
Ayushdubey86 2ad5ded
Update bls12_381_const.rs
Ayushdubey86 22f9e48
Update lib.rs
Ayushdubey86 3643dce
Update map_fp2_to_g2.rs
Ayushdubey86 f6a1e80
Update map_fp2_to_g2.rs
Ayushdubey86 6fff639
Update map_fp2_to_g2.rs
Ayushdubey86 ec26a86
Update map_fp2_to_g2.rs
Ayushdubey86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
use crate::PrecompileWithAddress; | ||
|
||
use crate::bls12_381::g1_add; | ||
use crate::bls12_381::g1_msm; | ||
use crate::bls12_381::g2_add; | ||
use crate::bls12_381::g2_msm; | ||
use crate::bls12_381::pairing; | ||
use crate::bls12_381::map_fp_to_g1; | ||
use crate::bls12_381::map_fp2_to_g2; | ||
|
||
pub const G1_ADD_ADDRESS: u64 = 0x0b; | ||
pub const G1_ADD_BASE_GAS_FEE: u64 = 375; | ||
pub const G1_ADD_INPUT_LENGTH: usize = 256; | ||
pub const G1_MSM_ADDRESS: u64=0x0c; | ||
pub const G1_MSM_BASE_GAS_FEE: u64 = 1200; | ||
pub const G1_MSM_INPUT_LENGTH: usize = 160; | ||
pub const G1_OUTPUT_LENGTH: usize = 128; | ||
pub const G1_INPUT_ITEM_LENGTH: usize = 128; | ||
pub const G2_ADD_ADDRESS: u64 = 0x0d; | ||
pub const G2_ADD_BASE_GAS_FEE: u64 = 600; | ||
pub const G2_ADD_INPUT_LENGTH: usize = 512; | ||
pub const G2_MSM_ADDRESS: u64 = 0x0e; | ||
pub const G2_MSM_BASE_GAS_FEE: u64 = 22500; | ||
pub const G2_MSM_INPUT_LENGTH: usize = 288; | ||
pub const G2_OUTPUT_LENGTH: usize = 256; | ||
pub const G2_INPUT_ITEM_LENGTH: usize = 256; | ||
pub const PAIRING_ADDRESS: u64 = 0x0f; | ||
pub const PAIRING_PAIRING_MULTIPLIER_BAS: u64 = 32600; | ||
pub const PAIRING_PAIRING_OFFSET_BASE: u64 = 37700; | ||
pub const PAIRING_INPUT_LENGTH: usize = 384; | ||
pub const MAP_FP_TO_G1_ADDRESS: u64 = 0x10; | ||
pub const MAP_FP_TO_G1_BASE_GAS_FEE: u64 = 5500; | ||
pub const MAP_FP2_TO_G2_ADDRESS: u64 = 0x11; | ||
pub const MAP_FP2_TO_G2_BASE_GAS_FEE: u64 = 0x23800; | ||
pub const MSM_MULTIPLIER: u64 = 1000; | ||
/// Number of bits used in the BLS12-381 curve finite field elements. | ||
pub const UTILS_NBITS: usize = 256; | ||
Ayushdubey86 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// Finite field element input length. | ||
pub const UTILS_FP_LENGTH: usize = 48; | ||
/// Finite field element padded input length. | ||
pub const UTILS_PADDED_FP_LENGTH: usize = 64; | ||
/// Quadratic extension of finite field element input length. | ||
pub const UTILS_PADDED_FP2_LENGTH: usize = 128; | ||
/// Input elements padding length. | ||
pub const UTILS_PADDING_LENGTH: usize = 16; | ||
/// Scalar length. | ||
pub const UTILS_SCALAR_LENGTH: usize = 32; | ||
// Big-endian non-Montgomery form. | ||
pub const UTILS_MODULUS_REPR: [u8; 48] = [ | ||
0x1a, 0x01, 0x11, 0xea, 0x39, 0x7f, 0xe6, 0x9a, 0x4b, 0x1b, 0xa7, 0xb6, 0x43, 0x4b, 0xac, 0xd7, | ||
0x64, 0x77, 0x4b, 0x84, 0xf3, 0x85, 0x12, 0xbf, 0x67, 0x30, 0xd2, 0xa0, 0xf6, 0xb0, 0xf6, 0x24, | ||
0x1e, 0xab, 0xff, 0xfe, 0xb1, 0x53, 0xff, 0xff, 0xb9, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xaa, 0xab, | ||
]; | ||
|
||
#[cfg(feature = "blst")] | ||
pub fn precompiles() -> impl Iterator<Item = PrecompileWithAddress> { | ||
Ayushdubey86 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[ | ||
g1_add::PRECOMPILE, | ||
g1_msm::PRECOMPILE, | ||
g2_add::PRECOMPILE, | ||
g2_msm::PRECOMPILE, | ||
pairing::PRECOMPILE, | ||
map_fp_to_g1::PRECOMPILE, | ||
map_fp2_to_g2::PRECOMPILE, | ||
] | ||
.into_iter() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final thing, move bls12_381_const to
src/
folder and remove all#[cfg(feature = "blst")]
from this file. This would work as the main cfg feature from lib.rs is still active.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just made these changes and pushed! do check it when free!