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

sha2 air formulas optimizations #7

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

sha2 air formulas optimizations #7

wants to merge 1 commit into from

Conversation

Okm165
Copy link
Owner

@Okm165 Okm165 commented Nov 6, 2024

Summary

This PR introduces an optimization for the SHA-2 precompile AIR constraints, reducing the size of the SHA-2 columns by 22.

Core Idea

The optimization is based on leveraging equivalent expressions for the SHA-2 ch and maj functions to simplify the constraints:


  • ch optimization:
    ch := (e AND f) XOR (NOT e AND g)  
       = g XOR (e AND (f XOR g))
    

Eliminates single NOT operation.


  • maj optimization:
    maj := (a AND b) XOR (a AND c) XOR (b AND c)  
        = (a AND (b XOR c)) XOR (b AND c)
    

Eliminates single AND operation.

@Okm165 Okm165 changed the base branch from dev to release-plz-2024-07-16T18-07-12Z November 6, 2024 23:10
@Okm165 Okm165 changed the base branch from release-plz-2024-07-16T18-07-12Z to dev November 6, 2024 23:10
@Okm165 Okm165 self-assigned this Nov 6, 2024
@Okm165 Okm165 added the enhancement New feature or request label Nov 6, 2024
@Okm165 Okm165 changed the title sha2 air formulas optimizations sha2 air formulas optimizations Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant