Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
b9e321f
added bls columns
lorenzogentile404 May 19, 2025
7090124
added constants
lorenzogentile404 May 19, 2025
cd3f2fe
added shorthands
lorenzogentile404 May 20, 2025
e7ee3db
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Jun 2, 2025
daa8482
make constraints compile again
lorenzogentile404 Jun 2, 2025
ce811cb
updated columns
lorenzogentile404 Jun 2, 2025
8520d20
added aliases
lorenzogentile404 Jun 2, 2025
904b6f3
updated aliases
lorenzogentile404 Jun 2, 2025
5665eb0
added constraints for flag sum
lorenzogentile404 Jun 2, 2025
faf559c
added shorthands
lorenzogentile404 Jun 2, 2025
0594616
added constraints for bls stamp
lorenzogentile404 Jun 2, 2025
4d9c2d8
added legal transitions wip
lorenzogentile404 Jun 2, 2025
500e917
fixed legal transition constraints and address sum constraints
lorenzogentile404 Jun 3, 2025
b8a2037
added phase sum
lorenzogentile404 Jun 3, 2025
b6bca60
added phase constants
lorenzogentile404 Jun 4, 2025
fb150f5
added ct max, index and index max sections
lorenzogentile404 Jun 8, 2025
e205c38
added ct constraints
lorenzogentile404 Jun 8, 2025
087c7c3
added is first input and is second input constraints
lorenzogentile404 Jun 8, 2025
1a30d20
added id increment constraints
lorenzogentile404 Jun 8, 2025
be5ff11
added acc inputs constraints
lorenzogentile404 Jun 8, 2025
eff8f39
re-organized files into folders
lorenzogentile404 Jun 8, 2025
80e6961
added generalities for mint, mext, wtrv, wnon
lorenzogentile404 Jun 9, 2025
804b23b
added top level flags, utilities and lookup
lorenzogentile404 Jun 10, 2025
294b7bc
added utilities
lorenzogentile404 Jun 11, 2025
76ce538
added specialized shorthands and point evaluation constraints
lorenzogentile404 Jun 11, 2025
3536cfe
added specialized constraints for g1 and g2 add and msm
lorenzogentile404 Jun 11, 2025
d59669b
added pairing check specialized constraints
lorenzogentile404 Jun 11, 2025
904e98c
added maps specialized constraints
lorenzogentile404 Jun 11, 2025
1dd63c9
added circuit selectors constraints
lorenzogentile404 Jun 11, 2025
120f4a2
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Jun 11, 2025
5c5acda
moved BLS to Cancun
lorenzogentile404 Jun 11, 2025
654d10c
added circuit selector for point evaluation in the failing case
lorenzogentile404 Jun 12, 2025
8df322b
fixed cs name
lorenzogentile404 Jun 12, 2025
89895f9
updated zkevm
lorenzogentile404 Jun 13, 2025
0db1dc5
added constraints for total size
lorenzogentile404 Jun 17, 2025
af82fb1
crated folder for bls cancun
lorenzogentile404 Jun 21, 2025
c86ac7e
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Jun 21, 2025
6cd657e
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Jun 26, 2025
2e9d3e5
updated zkevm
lorenzogentile404 Jun 26, 2025
e3d1b2b
updated zkevm
lorenzogentile404 Jun 26, 2025
a9aecb8
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Jun 26, 2025
518196f
removed zkevm
lorenzogentile404 Jun 26, 2025
48264db
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Jul 14, 2025
ea09b7d
Update circuit_selectors.lisp
OlivierBBB Jul 25, 2025
83ae1fe
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Jul 28, 2025
e971d08
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Jul 30, 2025
44bfc7d
added bls constants and columns
lorenzogentile404 Jul 30, 2025
33028f7
added bls pairing check constants
lorenzogentile404 Jul 31, 2025
bf36325
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Aug 1, 2025
f35df1e
added bls ref table
lorenzogentile404 Aug 4, 2025
3691d7b
added bls shorthands
lorenzogentile404 Aug 5, 2025
4dd773b
added bls wght sums
lorenzogentile404 Aug 5, 2025
cc80016
added bls ct max
lorenzogentile404 Aug 5, 2025
dbde21f
added lookup flag sums
lorenzogentile404 Aug 5, 2025
3bf88fb
added call to blr ref table
lorenzogentile404 Aug 5, 2025
a9cefde
added todo
lorenzogentile404 Aug 5, 2025
ded61c4
updated phase constants for BLS
lorenzogentile404 Aug 5, 2025
37123a7
added bls fixed size fixed cost and pairing check constraints
lorenzogentile404 Aug 6, 2025
31b09db
formatting
lorenzogentile404 Aug 6, 2025
d88226f
added msm specialized constraints
lorenzogentile404 Aug 7, 2025
769cdb2
fixed typo and added cancun constraint
lorenzogentile404 Aug 7, 2025
1d6d3ee
fixed legal transitions
lorenzogentile404 Aug 7, 2025
0b36770
added back constraints accidentally overwritten and fixed naming
lorenzogentile404 Aug 7, 2025
ba6a8c5
fixed naming
lorenzogentile404 Aug 7, 2025
8551dd5
fixed naming
lorenzogentile404 Aug 7, 2025
f36412b
fixed naming
lorenzogentile404 Aug 7, 2025
273a832
fixed naming GX_ADD, GX_MSM
lorenzogentile404 Aug 7, 2025
dfac96b
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Aug 7, 2025
b2ef050
added max prc addresses for every fork
lorenzogentile404 Aug 8, 2025
e26ebc0
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Aug 8, 2025
ee359b0
fixed naming
lorenzogentile404 Aug 8, 2025
e67d5bd
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Aug 13, 2025
75b2902
defined circuit selector columns using defcomputedcolumn
lorenzogentile404 Aug 14, 2025
03fdcf7
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Aug 21, 2025
80ea858
added BLS_CANCUN to Makefil
lorenzogentile404 Aug 21, 2025
747b45e
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Aug 21, 2025
5cf8cf4
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Aug 25, 2025
b415730
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Aug 26, 2025
4eaf601
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Aug 27, 2025
510aa79
manged oob and bls versions for Cancun and Prague
lorenzogentile404 Aug 28, 2025
5742adc
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Sep 1, 2025
4db65e8
fixed transition to data and transition to result shorthands
lorenzogentile404 Sep 2, 2025
df3356d
phase is index constant
lorenzogentile404 Sep 2, 2025
3efd23f
fixed legal transitions constraint
lorenzogentile404 Sep 2, 2025
f5f3f6a
updated mmio with bls stuff
lorenzogentile404 Sep 4, 2025
f9cdd87
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Sep 8, 2025
c85a2de
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Sep 9, 2025
d0f6cb9
fixed POINT_EVALUATION_PRIME_LO
lorenzogentile404 Sep 10, 2025
227ebd7
renamed bls to blsdata
lorenzogentile404 Sep 10, 2025
3fa2dd4
Merge branch 'master' into eip-2537-precompile-for-bls12-381-curve-op…
lorenzogentile404 Sep 11, 2025
87360af
added unchecked in lookups towars blsdata and blsreftable
lorenzogentile404 Sep 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ BLOCKDATA := $(wildcard blockdata/*.lisp) \

BLOCKHASH := blockhash

BLS := bls

Copy link

Choose a reason for hiding this comment

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

Bug: Duplicate Variable Overwrites Build Configuration

The BLS_CANCUN variable is defined twice in the Makefile. The second definition overwrites the first, unintentionally excluding specific files like bls/cancun/generalities/cancun_restriction.lisp from the build. This results in missing constraint files.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

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

Bug: Duplicate Variable Overwrites Build Configuration

The BLS_CANCUN variable is defined twice in the Makefile. The second definition overwrites the first, causing cancun_restriction.lisp (present in the initial definition) to be excluded from the build. This could result in missing functionality.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

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

Bug: Variable Redefinition Causes Build Failures

The BLS_CANCUN variable is defined twice. The second definition overwrites the first, which unintentionally excludes cancun_restriction.lisp from the Cancun build. This also leaves BLS_PRAGUE undefined, causing build failures for the Prague target, as the second definition's content seems intended for BLS_PRAGUE.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

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

Bug: Duplicate Variable Definition Causes Module Exclusion

The BLS_CANCUN variable is defined twice. The second definition overwrites the first, unintentionally excluding cancun_restriction.lisp from the BLS_CANCUN module. This appears to be a copy-paste error, possibly intended for the undefined BLS_PRAGUE variable.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

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

Bug: Variable Redefinition and Undefined References

The BLS_CANCUN variable is defined twice; the second definition overwrites the first and omits cancun_restriction.lisp, which was present initially. This means cancun_restriction.lisp will be missing from Cancun builds. Additionally, BLS_PRAGUE is referenced in ZKEVM_MODULES_PRAGUE but is never defined, leading to no BLS files being included for Prague builds.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

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

Bug: Duplicate Variable Definition Causes Build Exclusions

The BLS_CANCUN variable is defined twice in the Makefile. The second definition overwrites the first, which means files like bls/cancun/generalities/cancun_restriction.lisp are unintentionally excluded from the Cancun build. This could lead to unexpected behavior or build failures.

Fix in Cursor Fix in Web

CONSTANTS := constants/constants.lisp

EC_DATA := ecdata
Expand Down Expand Up @@ -101,6 +103,7 @@ ZKEVM_MODULES_COMMON := ${CONSTANTS} \
${BLAKE2f_MODEXP_DATA} \
${BLOCKDATA} \
${BLOCKHASH} \
${BLS} \
${EC_DATA} \
${EUC} \
${EXP} \
Expand Down
100 changes: 100 additions & 0 deletions bls/columns.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
(module bls)

(defcolumns
(STAMP :i32)
(ID :i32)
(TOTAL_SIZE :i16)
(INDEX :i16)
(INDEX_MAX :i16)
(LIMB :i128)
(PHASE :i16)
(SUCCESS_BIT :binary@prove)

(CT :i4)
(CT_MAX :i4)

(DATA_POINT_EVALUATION_FLAG :binary@prove)
(DATA_G1_ADD_FLAG :binary@prove)
(DATA_G1_MSM_FLAG :binary@prove)
(DATA_G2_ADD_FLAG :binary@prove)
(DATA_G2_MSM_FLAG :binary@prove)
(DATA_PAIRING_CHECK_FLAG :binary@prove)
(DATA_MAP_FP_TO_G1_FLAG :binary@prove)
(DATA_MAP_FP2_TO_G2_FLAG :binary@prove)

(RSLT_POINT_EVALUATION_FLAG :binary@prove)
(RSLT_G1_ADD_FLAG :binary@prove)
(RSLT_G1_MSM_FLAG :binary@prove)
(RSLT_G2_ADD_FLAG :binary@prove)
(RSLT_G2_MSM_FLAG :binary@prove)
(RSLT_PAIRING_CHECK_FLAG :binary@prove)
(RSLT_MAP_FP_TO_G1_FLAG :binary@prove)
(RSLT_MAP_FP2_TO_G2_FLAG :binary@prove)

(ACC_INPUTS :i16)
(BYTE_DELTA :byte@prove)

(MALFORMED_DATA_INTERNAL_BIT :binary@prove)
(MALFORMED_DATA_INTERNAL_ACC :binary@prove)
(MALFORMED_DATA_INTERNAL_ACC_TOT :binary@prove)
(MALFORMED_DATA_EXTERNAL_BIT :binary@prove)
(MALFORMED_DATA_EXTERNAL_ACC :binary@prove)
(MALFORMED_DATA_EXTERNAL_ACC_TOT :binary@prove)
(WELLFORMED_DATA_TRIVIAL :binary@prove)
(WELLFORMED_DATA_NONTRIVIAL :binary@prove)

(IS_FIRST_INPUT :binary@prove)
(IS_SECOND_INPUT :binary@prove)
(IS_INFINITY :binary@prove)
(NONTRIVIAL_PAIR_OF_POINTS_BIT :binary@prove)
(NONTRIVIAL_PAIR_OF_POINTS_ACC :binary@prove)

(CIRCUIT_SELECTOR_POINT_EVALUATION :binary@prove)
(CIRCUIT_SELECTOR_C1_MEMBERSHIP :binary@prove)
(CIRCUIT_SELECTOR_G1_MEMBERSHIP :binary@prove)
(CIRCUIT_SELECTOR_C2_MEMBERSHIP :binary@prove)
(CIRCUIT_SELECTOR_G2_MEMBERSHIP :binary@prove)
(CIRCUIT_SELECTOR_PAIRING :binary@prove)
(CIRCUIT_SELECTOR_G1_ADD :binary@prove)
(CIRCUIT_SELECTOR_G2_ADD :binary@prove)
(CIRCUIT_SELECTOR_G1_MSM :binary@prove)
(CIRCUIT_SELECTOR_G2_MSM :binary@prove)
(CIRCUIT_SELECTOR_MAP_FP_TO_G1 :binary@prove)
(CIRCUIT_SELECTOR_MAP_FP2_TO_G2 :binary@prove)

(WCP_FLAG :binary@prove)
(WCP_ARG1_HI :i128)
(WCP_ARG1_LO :i128)
(WCP_ARG2_HI :i128)
(WCP_ARG2_LO :i128)
(WCP_RES :binary)
(WCP_INST :byte :display :opcode)
)

;; aliases
(defalias
MINT_BIT MALFORMED_DATA_INTERNAL_BIT
MINT_ACC MALFORMED_DATA_INTERNAL_ACC
MINT MALFORMED_DATA_INTERNAL_ACC_TOT
MEXT_BIT MALFORMED_DATA_EXTERNAL_BIT
MEXT_ACC MALFORMED_DATA_EXTERNAL_ACC
MEXT MALFORMED_DATA_EXTERNAL_ACC_TOT
WTRV WELLFORMED_DATA_TRIVIAL
WNON WELLFORMED_DATA_NONTRIVIAL
NONTRIVIAL_POP_BIT NONTRIVIAL_PAIR_OF_POINTS_BIT
NONTRIVIAL_POP_ACC NONTRIVIAL_PAIR_OF_POINTS_ACC
CS_POINT_EVALUATION CIRCUIT_SELECTOR_POINT_EVALUATION
CS_C1_MEMBERSHIP CIRCUIT_SELECTOR_C1_MEMBERSHIP
CS_G1_MEMBERSHIP CIRCUIT_SELECTOR_G1_MEMBERSHIP
CS_C2_MEMBERSHIP CIRCUIT_SELECTOR_C2_MEMBERSHIP
CS_G2_MEMBERSHIP CIRCUIT_SELECTOR_G2_MEMBERSHIP
CS_PAIRING CIRCUIT_SELECTOR_PAIRING
CS_G1_ADD CIRCUIT_SELECTOR_G1_ADD
CS_G2_ADD CIRCUIT_SELECTOR_G2_ADD
CS_G1_MSM CIRCUIT_SELECTOR_G1_MSM
CS_G2_MSM CIRCUIT_SELECTOR_G2_MSM
CS_MAP_FP_TO_G1 CIRCUIT_SELECTOR_MAP_FP_TO_G1
CS_MAP_FP2_TO_G2 CIRCUIT_SELECTOR_MAP_FP2_TO_G2
)


36 changes: 36 additions & 0 deletions bls/constants.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(module bls)

(defconst
POINT_EVALUATION_PRIME_HI 0x73eda753299d7d483339d80809a1d805
POINT_EVALUATION_PRIME_LO 0x1b4d2c3f4b6a0c7e8f3f5a0e9d1b2c3f
BLS_PRIME_3 0x00000000000000000000000000000000
BLS_PRIME_2 0x1a0111ea397fe69a4b1ba7b6434bacd7
BLS_PRIME_1 0x64774b84f38512bf6730d2a0f6b0f624
BLS_PRIME_0 0x1eabfffeb153ffffb9feffffffffaaab

INDEX_MAX_DATA_POINT_EVALUATION 11
INDEX_MAX_RSLT_POINT_EVALUATION 3
INDEX_MAX_DATA_G1_ADD 15
INDEX_MAX_RSLT_G1_ADD 7
INDEX_MAX_DATA_G1_MSM_MIN 9
INDEX_MAX_RSLT_G1_MSM 7
INDEX_MAX_DATA_G2_ADD 31
INDEX_MAX_RSLT_G2_ADD 15
INDEX_MAX_DATA_G2_MSM_MIN 17
INDEX_MAX_RSLT_G2_MSM 15
INDEX_MAX_DATA_PAIRING_CHECK_MIN 23
INDEX_MAX_RSLT_PAIRING_CHECK 1
INDEX_MAX_DATA_MAP_FP_TO_G1 3
INDEX_MAX_RSLT_MAP_FP_TO_G1 7
INDEX_MAX_DATA_MAP_FP2_TO_G2 7
INDEX_MAX_RSLT_MAP_FP2_TO_G2 15

CT_MAX_POINT_EVALUATION 11
CT_MAX_SMALL_POINT 7
CT_MAX_LARGE_POINT 15
CT_MAX_SCALAR 1
CT_MAX_MAP_FP_TO_G1 3
CT_MAX_MAP_FP2_TO_G2 7
)


24 changes: 24 additions & 0 deletions bls/generalities/constancy_conditions.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(module bls)

(defconstraint stamp-constancy ()
(begin (stamp-constancy STAMP ID)
(stamp-constancy STAMP SUCCESS_BIT)
(stamp-constancy STAMP MINT)
(stamp-constancy STAMP MEXT)
(stamp-constancy STAMP WTRV)
(stamp-constancy STAMP WNON)))

(defconstraint counter-constancy ()
(begin (counter-constancy INDEX PHASE) ;; NOTE: PHASE and INDEX_MAX are said to be index-constant
(counter-constancy INDEX INDEX_MAX)
(counter-constancy CT CT_MAX)
(counter-constancy CT IS_INFINITY)
(counter-constancy CT ACC_INPUTS)
(counter-constancy CT NONTRIVIAL_POP_ACC)
(counter-constancy CT MEXT_BIT)
(counter-constancy CT MEXT_ACC)))

(defconstraint pair-of-inputs-constancy ()
(if-not-zero ACC_INPUTS
(if (will-remain-constant! ACC_INPUTS)
(will-remain-constant! NONTRIVIAL_POP_BIT))))
14 changes: 14 additions & 0 deletions bls/generalities/constraining_address_sum.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(module bls)

(defun (address_sum)
(+ (* 10 (is_point_evaluation))
(* 11 (is_g1_add))
(* 12 (is_g1_msm))
(* 13 (is_g2_add))
(* 14 (is_g2_msm))
(* 15 (is_pairing_check))
(* 16 (is_map_fp_to_g1))
(* 17 (is_map_fp2_to_g2))))

(defconstraint stamp-constancy ()
(stamp-constancy STAMP (address_sum)))
47 changes: 47 additions & 0 deletions bls/generalities/constraining_flag_sum.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
(module bls)

(defun (is_point_evaluation)
(+ DATA_POINT_EVALUATION_FLAG RSLT_POINT_EVALUATION_FLAG))

(defun (is_g1_add)
(+ DATA_G1_ADD_FLAG RSLT_G1_ADD_FLAG))

(defun (is_g1_msm)
(+ DATA_G1_MSM_FLAG RSLT_G1_MSM_FLAG))

(defun (is_g2_add)
(+ DATA_G2_ADD_FLAG RSLT_G2_ADD_FLAG))

(defun (is_g2_msm)
(+ DATA_G2_MSM_FLAG RSLT_G2_MSM_FLAG))

(defun (is_pairing_check)
(+ DATA_PAIRING_CHECK_FLAG RSLT_PAIRING_CHECK_FLAG))

(defun (is_map_fp_to_g1)
(+ DATA_MAP_FP_TO_G1_FLAG RSLT_MAP_FP_TO_G1_FLAG))

(defun (is_map_fp2_to_g2)
(+ DATA_MAP_FP2_TO_G2_FLAG RSLT_MAP_FP2_TO_G2_FLAG))

(defun (flag_sum)
(+ (is_point_evaluation)
(is_g1_add)
(is_g1_msm)
(is_g2_add)
(is_g2_msm)
(is_pairing_check)
(is_map_fp_to_g1)
(is_map_fp2_to_g2)))

(defconstraint first-row-sanity-check (:domain {0})
(debug (vanishes! (flag_sum))))

(defconstraint non-decreasing-sanity-check ()
(debug (if-not-zero (flag_sum) (next (eq! (flag_sum) 1)))))

(defconstraint flag-sum-when-stamp-is-zero ()
(if-zero STAMP (vanishes! (flag_sum))))

(defconstraint flag-sum-when-stamp-is-not-zero ()
(if-not-zero STAMP (eq! (flag_sum) 1)))
11 changes: 11 additions & 0 deletions bls/generalities/constraints_for_bls_stamp.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(module bls)

(defconstraint first-row (:domain {0})
(vanishes! STAMP))

(defconstraint stamp-increment-sanity-check ()
(begin
(debug (or! (will-remain-constant! STAMP) (will-inc! STAMP 1))))) ;; implied by the constraint below

(defconstraint stamp-increment ()
(eq! (next STAMP) (+ STAMP (transition_to_data))))
12 changes: 12 additions & 0 deletions bls/generalities/constraints_for_ct.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(module bls)

(defconstraint vanishing-values ()
(if-zero (flag_sum)
(begin (vanishes! CT_MAX)
(vanishes! CT)
(debug (vanishes! (next CT))))))

(defconstraint ct-increment ()
(if-eq-else CT CT_MAX
(vanishes! (next CT))
(eq! (next CT) (+ 1 CT))))
11 changes: 11 additions & 0 deletions bls/generalities/id_increment_constraints.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(module bls)

(defconstraint id-increment ()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why we don't do like with other modules and just call WCP to check the id increment ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We used this same approach in ecdata, too. Is there any advantage in doing this with wcp lookups?

Copy link
Collaborator

Choose a reason for hiding this comment

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

simplicity, we do like this with SHAKIRA, BLAKEMODEXP, less columns, we had a failing edgecase with the manual byte decomposition with EcDAta on mainnet few months ago

Copy link
Collaborator

Choose a reason for hiding this comment

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

we even have a spec issue to delete it from EcData : https://github.com/Consensys/linea-specification-internal/issues/482

(if-not-zero (- (next STAMP) STAMP)
(eq! (next ID)
(+ ID
1
(+ (* 256 256 256 (next BYTE_DELTA))
(* 256 256 (shift BYTE_DELTA 2))
(* 256 (shift BYTE_DELTA 3))
(shift BYTE_DELTA 4))))))
37 changes: 37 additions & 0 deletions bls/generalities/legal_transition_constraints.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(module bls)

(defun (same_data_to_data)
(+ (* DATA_POINT_EVALUATION_FLAG (next DATA_POINT_EVALUATION_FLAG))
(* DATA_G1_ADD_FLAG (next DATA_G1_ADD_FLAG))
(* DATA_G1_MSM_FLAG (next DATA_G1_MSM_FLAG))
(* DATA_G2_ADD_FLAG (next DATA_G2_ADD_FLAG))
(* DATA_G1_MSM_FLAG (next DATA_G2_ADD_FLAG))
(* DATA_PAIRING_CHECK_FLAG (next DATA_PAIRING_CHECK_FLAG))
(* DATA_MAP_FP_TO_G1_FLAG (next DATA_MAP_FP_TO_G1_FLAG))
(* DATA_MAP_FP2_TO_G2_FLAG (next DATA_MAP_FP2_TO_G2_FLAG))))

(defun (same_data_to_result)
(+ (* DATA_POINT_EVALUATION_FLAG (next RSLT_POINT_EVALUATION_FLAG))
(* DATA_G1_ADD_FLAG (next RSLT_G1_ADD_FLAG))
(* DATA_G1_MSM_FLAG (next RSLT_G1_MSM_FLAG))
(* DATA_G2_ADD_FLAG (next RSLT_G2_ADD_FLAG))
(* DATA_G1_MSM_FLAG (next RSLT_G2_ADD_FLAG))
(* DATA_PAIRING_CHECK_FLAG (next RSLT_PAIRING_CHECK_FLAG))
(* DATA_MAP_FP_TO_G1_FLAG (next RSLT_MAP_FP_TO_G1_FLAG))
(* DATA_MAP_FP2_TO_G2_FLAG (next RSLT_MAP_FP2_TO_G2_FLAG))))

(defun (same_result_to_result)
(+ (* RSLT_POINT_EVALUATION_FLAG (next RSLT_POINT_EVALUATION_FLAG))
(* RSLT_G1_ADD_FLAG (next RSLT_G1_ADD_FLAG))
(* RSLT_G1_MSM_FLAG (next RSLT_G1_MSM_FLAG))
(* RSLT_G2_ADD_FLAG (next RSLT_G2_ADD_FLAG))
(* RSLT_G1_MSM_FLAG (next RSLT_G2_ADD_FLAG))
(* RSLT_PAIRING_CHECK_FLAG (next RSLT_PAIRING_CHECK_FLAG))
(* RSLT_MAP_FP_TO_G1_FLAG (next RSLT_MAP_FP_TO_G1_FLAG))
(* RSLT_MAP_FP2_TO_G2_FLAG (next RSLT_MAP_FP2_TO_G2_FLAG))))

(defconstraint legal-transitions ()
(eq! (+ (same_data_to_data)
(same_data_to_result)
(same_result_to_result)
(transition_to_data)) 1))
20 changes: 20 additions & 0 deletions bls/generalities/setting_acc_inputs.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(module bls)

(defun (is_variable_size_data)
(+ DATA_G1_MSM_FLAG
DATA_G2_MSM_FLAG
DATA_PAIRING_CHECK_FLAG))

(defconstraint acc-inputs-init ()
(if-zero (is_variable_size_data)
(begin (vanishes! ACC_INPUTS)
(eq! (next ACC_INPUTS) (next (is_variable_size_data))))))

(defconstraint acc-inputs-increment ()
(if-not-zero (is_variable_size_data)
(if-eq-else (next (is_variable_size_data)) 0
(vanishes! (next ACC_INPUTS))
(eq! (next ACC_INPUTS)
(+ ACC_INPUTS
1
(will_switch_from_second_to_first))))))
24 changes: 24 additions & 0 deletions bls/generalities/setting_ct_max.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(module bls)

(defun (ct_max_first_input)
(+ (* CT_MAX_POINT_EVALUATION DATA_POINT_EVALUATION_FLAG)
(* CT_MAX_SMALL_POINT DATA_G1_ADD_FLAG)
(* CT_MAX_SMALL_POINT DATA_G1_MSM_FLAG)
(* CT_MAX_LARGE_POINT DATA_G2_ADD_FLAG)
(* CT_MAX_LARGE_POINT DATA_G2_MSM_FLAG)
(* CT_MAX_SMALL_POINT DATA_PAIRING_CHECK_FLAG)
(* CT_MAX_MAP_FP_TO_G1 DATA_MAP_FP_TO_G1_FLAG)
(* CT_MAX_MAP_FP2_TO_G2 DATA_MAP_FP2_TO_G2_FLAG)))

(defun (ct_max_second_input)
(+ (* CT_MAX_SMALL_POINT RSLT_G1_ADD_FLAG)
(* CT_MAX_SCALAR RSLT_G1_MSM_FLAG)
(* CT_MAX_LARGE_POINT RSLT_G2_ADD_FLAG)
(* CT_MAX_SCALAR RSLT_G2_MSM_FLAG)
(* CT_MAX_LARGE_POINT RSLT_PAIRING_CHECK_FLAG)))

(defconstraint set-ct-max ()
(eq! CT_MAX
(+ (* (ct_max_first_input) IS_FIRST_INPUT)
(* (ct_max_second_input) IS_SECOND_INPUT)
(* INDEX_MAX (is_result)))))
22 changes: 22 additions & 0 deletions bls/generalities/setting_index.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(module bls)

(defconstraint vanishing-values ()
(if-zero (flag_sum)
(begin (vanishes! INDEX_MAX)
(vanishes! INDEX)
(vanishes! ID))))

(defconstraint index-reset ()
(if-not-zero (transition_bit)
(vanishes! (next INDEX))))

(defconstraint index-increment ()
(if-not-zero (flag_sum)
(if-eq-else INDEX INDEX_MAX
(eq! (transition_bit) 1)
(eq! (next INDEX) (+ 1 INDEX)))))

(defconstraint final-row (:domain {-1})
(if-not-zero (flag_sum)
(begin (eq! (is_result) 1)
(eq! INDEX INDEX_MAX))))
Loading
Loading