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

Modular arithmetic operation #248

Open
6 tasks done
hecmas opened this issue Feb 8, 2024 · 0 comments
Open
6 tasks done

Modular arithmetic operation #248

hecmas opened this issue Feb 8, 2024 · 0 comments
Assignees
Milestone

Comments

@hecmas
Copy link
Contributor

hecmas commented Feb 8, 2024

We introduce the modular arithmetic operation, i.e., the check that:

A*B + C = op (mod D)

as a new instruction on the arithmetic state machine. Note that the E register is not necessary and it is considered to be "free" when checking this instruction.

Numbers

  • For ecrecover, we have gone from:

    ; RESOURCES:
    ;   PATH without root:                   [steps: 4601, bin: 8,  arith: 1010]
    ;   PATH with root:                      [steps: 6383, bin: 17, arith: 527, keccak: 1]
    ;   PATH with result of dbl is infinity: [steps: 6368, bin: 16, arith: 527]
    ; --------------------------------------------------------------------------------------
    ;  worst case:                           [steps: 6383, bin: 17, arith: 1010]
    

    to

    ; RESOURCES:
    ;   PATH without root:                   [steps: 3073, bin: 8, arith: 505]
    ;   PATH with root:                      [steps: 6343, bin: 13, arith: 520, keccak: 1]
    ;   PATH with result of dbl is infinity: [steps: 6332, bin: 12, arith: 520]
    ; --------------------------------------------------------------------------------------
    ;  worst case:                           [steps: 6343, bin: 13, arith: 520, keccak: 1]
    
  • For polEvalFrBLS12381 we have gone from:

     {
      cntArith: 409948n,
      cntBinary: 205010n,
      cntSteps: 2796040
    }
    

    to

    {
      cntArith: 164004n,
      cntBinary: 124544n,
      cntSteps: 1692140
    }
    
@hecmas hecmas self-assigned this Feb 8, 2024
@hecmas hecmas modified the milestone: fork.6 Feb 8, 2024
@hecmas hecmas added this to the fork-feijoa milestone Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant