|
30 | 30 | (eq! (shift misc/MMU_FLAG 1) (precompile-processing---common---OOB-extract-call-data)) |
31 | 31 | )) |
32 | 32 |
|
33 | | -(defconstraint precompile-processing---common---setting-OOB-instruction (:guard (precompile-processing---common---precondition)) |
| 33 | +(defconstraint precompile-processing---common---setting-OOB-instruction |
| 34 | + (:guard (precompile-processing---common---precondition)) |
| 35 | + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
34 | 36 | (set-OOB-instruction---common precompile-processing---common---1st-misc-row---row-offset ;; offset |
35 | 37 | (precompile-processing---common---OOB-instruction) ;; relevant OOB instruction |
36 | 38 | (precompile-processing---dup-call-gas) ;; call gas i.e. gas provided to the precompile |
|
71 | 73 | (defun (precompile-processing---common---OOB-empty-call-data) (shift [misc/OOB_DATA 7] precompile-processing---common---1st-misc-row---row-offset)) |
72 | 74 | (defun (precompile-processing---common---OOB-r@c-nonzero) (shift [misc/OOB_DATA 8] precompile-processing---common---1st-misc-row---row-offset)) ;; "" |
73 | 75 |
|
74 | | -(defproperty precompile-processing---common---sanity-checks-for-BLS-precompiles-and-P256-verify |
75 | | - (if-not-zero (precompile-processing---common---precondition) |
76 | | - (if-not-zero (force-bin (+ (scenario-shorthand---PRC---common-BLS-address-bit-sum) scenario/PRC_P256_VERIFY)) |
77 | | - (begin |
78 | | - (eq! (precompile-processing---common---OOB-extract-call-data) |
79 | | - (precompile-processing---common---OOB-hub-success)) |
80 | | - (eq! (precompile-processing---common---OOB-empty-call-data) |
81 | | - 0))))) |
82 | 76 |
|
83 | | -(defconstraint precompile-processing---common---setting-MMU-instruction (:guard (precompile-processing---common---precondition)) |
| 77 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 78 | +;; OOB shorthands formal properties and sanity checks ;; |
| 79 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 80 | + |
| 81 | +(defproperty precompile-processing---common---sanity-checks---binarities |
| 82 | + (begin |
| 83 | + (is-binary (precompile-processing---common---OOB-hub-success) ) |
| 84 | + (is-binary (precompile-processing---common---OOB-extract-call-data) ) |
| 85 | + (is-binary (precompile-processing---common---OOB-empty-call-data) ) |
| 86 | + (is-binary (precompile-processing---common---OOB-r@c-nonzero) ) |
| 87 | + )) |
| 88 | + |
| 89 | +(defproperty precompile-processing---common---sanity-checks---unconditional-extract-empty-exclusivity |
| 90 | + (vanishes! (* (precompile-processing---common---OOB-extract-call-data) |
| 91 | + (precompile-processing---common---OOB-empty-call-data) |
| 92 | + ))) |
| 93 | + |
| 94 | +(defproperty precompile-processing---common---sanity-checks---the-empty-call-data-bit-must-vanish-starting-with-Cancun |
| 95 | + (if-not-zero (+ (scenario-shorthand---PRC---common-Cancun-address-bit-sum) |
| 96 | + (scenario-shorthand---PRC---common-Prague-address-bit-sum) |
| 97 | + (scenario-shorthand---PRC---common-Osaka-address-bit-sum)) |
| 98 | + (vanishes! (precompile-processing---common---OOB-empty-call-data)) |
| 99 | + )) |
| 100 | + |
| 101 | +(defproperty precompile-processing---common---sanity-checks---neat-splitting-of-hub-success-bit-prior-to-Osaka |
| 102 | + (if-not-zero (+ (scenario-shorthand---PRC---common-London-address-bit-sum) |
| 103 | + (scenario-shorthand---PRC---common-Cancun-address-bit-sum) |
| 104 | + (scenario-shorthand---PRC---common-Prague-address-bit-sum)) |
| 105 | + (eq! (precompile-processing---common---OOB-hub-success) |
| 106 | + (+ (precompile-processing---common---OOB-extract-call-data) |
| 107 | + (precompile-processing---common---OOB-empty-call-data) |
| 108 | + )))) |
| 109 | + |
| 110 | +;; we verify empirically that 0 ≤ extract_call_data ≤ hub_success (≤ 1) |
| 111 | +(defproperty precompile-processing---common---sanity-checks---not-so-neat-splitting-of-hub-success-for-Osaka |
| 112 | + (if-not-zero (scenario-shorthand---PRC---common-Osaka-address-bit-sum) |
| 113 | + (if-not-zero (precompile-processing---common---OOB-extract-call-data) |
| 114 | + (eq! (precompile-processing---common---OOB-hub-success) |
| 115 | + 1 |
| 116 | + )))) |
| 117 | + |
| 118 | +(defconstraint precompile-processing---common---setting-MMU-instruction |
| 119 | + (:guard (precompile-processing---common---precondition)) |
| 120 | + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
84 | 121 | (if-not-zero (shift misc/MMU_FLAG precompile-processing---common---1st-misc-row---row-offset) |
85 | 122 | (begin |
86 | 123 | (if-not-zero scenario/PRC_IDENTITY |
|
131 | 168 | (* 96 scenario/PRC_ECMUL ) |
132 | 169 | (* (precompile-processing---dup-cds) scenario/PRC_ECPAIRING ) |
133 | 170 | (* (precompile-processing---dup-cds) (scenario-shorthand---PRC---common-BLS-address-bit-sum) ) |
134 | | - (* 160 scenario/PRC_P256_VERIFY ) |
| 171 | + (* (precompile-processing---dup-cds) scenario/PRC_P256_VERIFY ) |
135 | 172 | )) |
136 | 173 |
|
137 | 174 | (defun (precompile-processing---common---MMU-exo-sum) |
138 | | - (+ (* EXO_SUM_WEIGHT_ECDATA scenario/PRC_ECRECOVER ) |
139 | | - (* EXO_SUM_WEIGHT_RIPSHA scenario/PRC_SHA2-256 ) |
140 | | - (* EXO_SUM_WEIGHT_RIPSHA scenario/PRC_RIPEMD-160 ) |
141 | | - (* EXO_SUM_WEIGHT_ECDATA scenario/PRC_ECADD ) |
142 | | - (* EXO_SUM_WEIGHT_ECDATA scenario/PRC_ECMUL ) |
143 | | - (* EXO_SUM_WEIGHT_ECDATA scenario/PRC_ECPAIRING ) |
144 | | - (* EXO_SUM_WEIGHT_BLSDATA (scenario-shorthand---PRC---common-BLS-address-bit-sum) ) |
145 | | - (* EXO_SUM_WEIGHT_ECDATA scenario/PRC_P256_VERIFY ) |
| 175 | + (+ (* EXO_SUM_WEIGHT_ECDATA scenario/PRC_ECRECOVER ) |
| 176 | + (* EXO_SUM_WEIGHT_RIPSHA scenario/PRC_SHA2-256 ) |
| 177 | + (* EXO_SUM_WEIGHT_RIPSHA scenario/PRC_RIPEMD-160 ) |
| 178 | + (* EXO_SUM_WEIGHT_ECDATA scenario/PRC_ECADD ) |
| 179 | + (* EXO_SUM_WEIGHT_ECDATA scenario/PRC_ECMUL ) |
| 180 | + (* EXO_SUM_WEIGHT_ECDATA scenario/PRC_ECPAIRING ) |
| 181 | + (* EXO_SUM_WEIGHT_BLSDATA (scenario-shorthand---PRC---common-BLS-address-bit-sum) ) |
| 182 | + (* EXO_SUM_WEIGHT_ECDATA scenario/PRC_P256_VERIFY ) |
146 | 183 | )) |
147 | 184 |
|
148 | 185 | (defun (precompile-processing---common---MMU-phase) |
|
163 | 200 | (* PHASE_P256_VERIFY_DATA scenario/PRC_P256_VERIFY ) |
164 | 201 | )) |
165 | 202 |
|
166 | | -;; ECRECOVER related shorthands |
167 | | -(defun (precompile-processing---common---address-recovery-failure) |
168 | | - (+ (precompile-processing---common---OOB-empty-call-data) |
169 | | - (* (precompile-processing---common---OOB-extract-call-data) |
170 | | - (- 1 (precompile-processing---common---MMU-success-bit))))) |
171 | | -(defun (precompile-processing---common---address-recovery-success) |
172 | | - (* (precompile-processing---common---OOB-extract-call-data) |
173 | | - (precompile-processing---common---MMU-success-bit))) |
| 203 | +;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;; |
| 204 | +;; ECRECOVER related shorthands ;; |
| 205 | +;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;; |
| 206 | + |
| 207 | +(defun (precompile-processing---common---address-recovery-failure) (+ (precompile-processing---common---OOB-empty-call-data) |
| 208 | + (* (precompile-processing---common---OOB-extract-call-data) |
| 209 | + (- 1 (precompile-processing---common---MMU-success-bit))) |
| 210 | + )) |
| 211 | +(defun (precompile-processing---common---address-recovery-success) (* (precompile-processing---common---OOB-extract-call-data) |
| 212 | + (precompile-processing---common---MMU-success-bit) |
| 213 | + )) |
| 214 | + |
| 215 | +;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;; |
| 216 | +;; ECRECOVER related shorthands sanity checks ;; |
| 217 | +;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;; |
| 218 | + |
| 219 | +(defproperty precompile-processing---common---address-recovery-success-shorthands-sanity-checks |
| 220 | + (begin |
| 221 | + (is-binary (precompile-processing---common---address-recovery-failure)) |
| 222 | + (is-binary (precompile-processing---common---address-recovery-success)) |
| 223 | + (eq! (precompile-processing---common---OOB-hub-success) |
| 224 | + (+ (precompile-processing---common---address-recovery-failure) |
| 225 | + (precompile-processing---common---address-recovery-success) |
| 226 | + )))) |
| 227 | + |
| 228 | + |
| 229 | +;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;; |
| 230 | +;; ECADD, ECMUL, ECPAIRING and BLS related shorthands ;; |
| 231 | +;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;; |
174 | 232 |
|
175 | | -;; ECADD, ECMUL and ECPAIRING related shorthands |
176 | 233 | (defun (precompile-processing---common---malformed-data) (* (precompile-processing---common---OOB-extract-call-data) |
177 | 234 | (- 1 (precompile-processing---common---MMU-success-bit)))) |
178 | 235 | (defun (precompile-processing---common---wellformed-data) (+ (precompile-processing---common---OOB-empty-call-data) |
179 | 236 | (* (precompile-processing---common---OOB-extract-call-data) |
180 | 237 | (precompile-processing---common---MMU-success-bit)))) |
181 | 238 |
|
| 239 | +;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;; |
| 240 | +;; ECADD, ECMUL, ECPAIRING and BLS related shorthands sanity checks ;; |
| 241 | +;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;; |
| 242 | + |
| 243 | +(defproperty precompile-processing---common---well-and-mal-formed-data-shorthands-sanity-checks |
| 244 | + (begin |
| 245 | + (is-binary (precompile-processing---common---malformed-data)) |
| 246 | + (is-binary (precompile-processing---common---wellformed-data)) |
| 247 | + (eq! (precompile-processing---common---OOB-hub-success) |
| 248 | + (+ (precompile-processing---common---malformed-data) |
| 249 | + (precompile-processing---common---wellformed-data) |
| 250 | + )))) |
| 251 | + |
| 252 | +;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;; |
| 253 | +;; P256_VERIFY related shorthands ;; |
| 254 | +;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;; |
| 255 | + |
| 256 | +(defun (precompile-processing---common---p256-sufficient-gas-wrong-cds) (- (precompile-processing---common---OOB-hub-success) |
| 257 | + (precompile-processing---common---OOB-extract-call-data) |
| 258 | + )) |
| 259 | +(defun (precompile-processing---common---p256-sig-verification-failure) (* (precompile-processing---common---OOB-extract-call-data) |
| 260 | + (- 1 (precompile-processing---common---MMU-success-bit)) |
| 261 | + )) |
| 262 | +(defun (precompile-processing---common---p256-sig-verification-success) (* (precompile-processing---common---OOB-extract-call-data) |
| 263 | + (precompile-processing---common---MMU-success-bit) |
| 264 | + )) |
182 | 265 |
|
183 | | -;; (defconstraint precompile-processing---common---debug-constraints-for-address-recovery (:guard (precompile-processing---common---precondition))) |
184 | | -;; (defconstraint precompile-processing---common---debug-constraints-for-data-integrity (:guard (precompile-processing---common---precondition))) |
185 | | -;; (defconstraint precompile-processing---common---debug-constraints-for-automatic-success-bit-vanishing (:guard (precompile-processing---common---precondition))) |
| 266 | +;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;; |
| 267 | +;; P256_VERIFY related shorthands sanity checks ;; |
| 268 | +;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;; |
186 | 269 |
|
187 | | -(defconstraint precompile-processing---common---justifying-success-scenario (:guard (precompile-processing---common---precondition)) |
| 270 | +(defproperty precompile-processing---common---address-recovery-success-shorthands-sanity-checks |
| 271 | + (begin |
| 272 | + (is-binary (precompile-processing---common---p256-sufficient-gas-wrong-cds)) |
| 273 | + (is-binary (precompile-processing---common---p256-sig-verification-failure)) |
| 274 | + (is-binary (precompile-processing---common---p256-sig-verification-success)) |
| 275 | + (eq! (precompile-processing---common---OOB-hub-success) |
| 276 | + (+ (precompile-processing---common---p256-sufficient-gas-wrong-cds) |
| 277 | + (precompile-processing---common---p256-sig-verification-failure) |
| 278 | + (precompile-processing---common---p256-sig-verification-success) |
| 279 | + )))) |
| 280 | + |
| 281 | + |
| 282 | + |
| 283 | +(defconstraint precompile-processing---common---justifying-success-scenario |
| 284 | + (:guard (precompile-processing---common---precondition)) |
| 285 | + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
188 | 286 | (eq! (scenario-shorthand---PRC---success) |
189 | 287 | (+ (* (precompile-processing---common---OOB-hub-success) |
190 | 288 | (+ scenario/PRC_ECRECOVER |
191 | 289 | scenario/PRC_SHA2-256 |
192 | 290 | scenario/PRC_RIPEMD-160 |
193 | 291 | scenario/PRC_IDENTITY |
| 292 | + scenario/PRC_P256_VERIFY |
194 | 293 | )) |
195 | 294 | (* (precompile-processing---common---wellformed-data) |
196 | 295 | (+ scenario/PRC_ECADD |
197 | 296 | scenario/PRC_ECMUL |
198 | 297 | scenario/PRC_ECPAIRING |
199 | 298 | (scenario-shorthand---PRC---common-BLS-address-bit-sum) |
200 | | - scenario/PRC_P256_VERIFY |
201 | 299 | )) |
202 | 300 | ))) |
203 | 301 |
|
|
212 | 310 | scenario/PRC_ECMUL |
213 | 311 | scenario/PRC_ECPAIRING |
214 | 312 | (scenario-shorthand---PRC---common-BLS-address-bit-sum) |
215 | | - scenario/PRC_P256_VERIFY |
216 | 313 | )))) |
217 | 314 |
|
218 | 315 | (defconstraint precompile-processing---common---justifying-return-gas-prediction (:guard (precompile-processing---common---precondition)) |
|
0 commit comments