-
Notifications
You must be signed in to change notification settings - Fork 232
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
Fix ALT_BN128_MULTIPLICATION_INPUT_LEN constant #3686
base: master
Are you sure you want to change the base?
Conversation
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.
Sorry for the delay on this and thanks for the contribution! This is indeed something that I missed.
Unfortunately, this change will technically incur a breaking change to the behavior of the runtime, which can lead to break in consensus. These type of changes will generally need to be feature gated (example) Unfortunately, the functions in the bn254 module itself do not have access to the invoke context, which contains information about which feature gates that are activated. This makes the required changes slightly more involved:
- Define two versions of the
alt_bn128_multiplication
functions: one withALT_BN128_MULTIPLICATION_INPUT_LEN = 128
and the other withALT_BN128_MULTIPLICATION_INPUT_LEN = 96
. - Define a new feature gate in the feature-set crate.
- In this line, we should update the function to be either of the two multiplication functions defined above depending on whether the new feature gate is active or not.
Since the changes are somewhat involved, if you are okay with it, then I can commit the changes outlined above. If you are willing to take a shot, then that is fine as well, so please let me know!
More so than this, changes to runtime behavior need to go through a SIMD so other client teams (Firedancer, etc) can be aware of changes and implement corresponding changes as well |
I want to try to do it, but I have some questions about naming:
About SIMD. I don't know, how to do it. Firedancer also checks for 128: https://github.com/firedancer-io/firedancer/blob/513e3250c6154390c070920d0d76ef6876154820/src/ballet/bn254/fd_bn254.c#L192-L194 |
For this, how about we create a non-public function Then, let's make Technically, we are making a breaking change to |
Let's name it For the SIMD, I'll go ahead and create it.
Usually, one of the core contributors generate a keypair and use the corresponding public key. For this, let's use |
The Firedancer team maintains a line-for-line reimplementation of the |
I've added the feature. Please check |
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.
Looks great! Just some minor comments below. Let me create a SIMD and let you know.
@@ -1110,6 +1114,7 @@ lazy_static! { | |||
(accounts_lt_hash::id(), "enables lattice-based accounts hash #3333"), | |||
(enable_secp256r1_precompile::id(), "Enable secp256r1 precompile SIMD-0075"), | |||
(migrate_stake_program_to_core_bpf::id(), "Migrate Stake program to Core BPF SIMD-0196 #3655"), | |||
(fix_alt_bn128_multiplication_input_length::id(), "fix alt_bn128 multiplication input length #3686"), |
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.
Let me work on the SIMD. Once the SIMD is merged, let's plug the SIMD number in here.
Co-authored-by: samkim-crypto <[email protected]>
Problem
Input for
alt_bn128_multiplication
(Scalar multiplication in G1) consist of 1 point in G1 (64 bytes), 1 scalar (BigInteger256 - 32 bytes). So 96 bytes in total, not 128.Summary of Changes
Changed ALT_BN128_MULTIPLICATION_INPUT_LEN to 96