Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/aienux/allen/vendor/cert-p256.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / aienux / allen / vendor / cert-p256.om` 447 lines ยท 9762 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note Modified 2026-10-25: public verification subset of aien-dev/spark-rsi-mv om/p256/p256.om. 3 note Source commit `bba3877510daeb8a0e070a781a689bcf1952b6f6`, SHA256 4 note `92da68007af091ccfbe01aa845be779502130e02bf57e9550332d669905db958`. 5 note Names prefixed cp2/C2, digest supplied by caller; signing, HMAC, nonce and private-key APIs removed. 6 note Public ECDSA inputs only. 32-bit-limb Montgomery arithmetic and complete a=-3 point addition. 7 note Renes-Costello-Batina 2015 algorithm 4; SEC2 v2 section 2.4.2 parameters. 8 note Byte buffer: key3072 (65 bytes), raw signature3200 (64), prehash3296 (32). 9 note No secret-key or constant-time compiler claim. Apache license in CERT-APACHE-LICENSE. 10 11 const C2MP ulong 0 12 const C2MN ulong 48 13 const C2ONE1 ulong 96 14 const C2BM ulong 104 15 const C2GX ulong 120 16 const C2W1 ulong 160 17 const C2W2 ulong 168 18 const C2XX ulong 176 19 const C2YY ulong 184 20 const C2ZZ ulong 192 21 const C2XY ulong 200 22 const C2YZ ulong 208 23 const C2XZ ulong 216 24 const C2U ulong 224 25 const C2V ulong 232 26 const C2YM ulong 240 27 const C2YP ulong 248 28 const C2BX3 ulong 256 29 const C2XX3 ulong 264 30 const C2ZZ3 ulong 272 31 const C2RX ulong 280 32 const C2ACC ulong 304 33 const C2TMP ulong 328 34 const C2BASE ulong 352 35 const C2ZI ulong 376 36 const C2Z ulong 528 37 const C2R ulong 536 38 const C2S ulong 544 39 const C2U1 ulong 552 40 const C2U2 ulong 560 41 const C2T1 ulong 576 42 const C2T2 ulong 584 43 const C2T3 ulong 592 44 const C2X ulong 608 45 const C2Y ulong 616 46 const C2Q ulong 640 47 const C2P1 ulong 664 48 const C2P2 ulong 688 49 const C2BPUB ulong 3072 50 const C2BSIG ulong 3200 51 const C2BDIG ulong 3296 52 53 fn cp2cpy w edit ulong 1024 o ulong a ulong to void 54 for i ulong 8 55 put w add o i get w add a i 56 end 57 end 58 59 fn cp2pcpy w edit ulong 1024 o ulong a ulong to void 60 for i ulong 24 61 put w add o i get w add a i 62 end 63 end 64 65 fn cp2set w edit ulong 1024 o ulong v ulong to void 66 put w o v 67 for i ulong 7 68 put w add o add i 1 0 69 end 70 end 71 72 fn cp2red w edit ulong 1024 o ulong t view ulong 10 m ulong to void 73 u = new ulong 8 0 74 bw = ulong 0 75 x = ulong 0 76 for i ulong 8 77 x = sub sub get t i get w add m i bw 78 put u i and x `4294967295` 79 bw = shr x 63 80 end 81 sel = or get t 8 xor bw 1 82 mk = sub 0 sel 83 for j ulong 8 84 y = and get u j mk 85 put w add o j or y and get t j not mk 86 end 87 end 88 89 fn cp2mrow t edit ulong 10 w edit ulong 1024 a ulong bi ulong to void 90 c = ulong 0 91 x = ulong 0 92 for j ulong 8 93 x = add add get t j mul get w add a j bi c 94 put t j and x `4294967295` 95 c = shr x 32 96 end 97 x = add get t 8 c 98 put t 8 and x `4294967295` 99 put t 9 shr x 32 100 end 101 102 fn cp2mred t edit ulong 10 w edit ulong 1024 m ulong to void 103 q = and mul get t 0 get w add m 8 `4294967295` 104 x = add get t 0 mul q get w m 105 c = shr x 32 106 j1 = ulong 0 107 for k ulong 7 108 j1 = add k 1 109 x = add add get t j1 mul q get w add m j1 c 110 put t k and x `4294967295` 111 c = shr x 32 112 end 113 x = add get t 8 c 114 put t 7 and x `4294967295` 115 put t 8 add get t 9 shr x 32 116 end 117 118 fn cp2mul w edit ulong 1024 o ulong a ulong b ulong m ulong to void 119 t = new ulong 10 0 120 for i ulong 8 121 cp2mrow t w a get w add b i 122 cp2mred t w m 123 end 124 cp2red w o t m 125 end 126 127 fn cp2add w edit ulong 1024 o ulong a ulong b ulong m ulong to void 128 t = new ulong 10 0 129 c = ulong 0 130 x = ulong 0 131 for i ulong 8 132 x = add add get w add a i get w add b i c 133 put t i and x `4294967295` 134 c = shr x 32 135 end 136 put t 8 c 137 cp2red w o t m 138 end 139 140 fn cp2sub w edit ulong 1024 o ulong a ulong b ulong m ulong to void 141 t = new ulong 8 0 142 bw = ulong 0 143 x = ulong 0 144 for i ulong 8 145 x = sub sub get w add a i get w add b i bw 146 put t i and x `4294967295` 147 bw = shr x 63 148 end 149 mk = sub 0 bw 150 c = ulong 0 151 for j ulong 8 152 x = add add get t j and get w add m j mk c 153 put w add o j and x `4294967295` 154 c = shr x 32 155 end 156 end 157 158 fn cp2modr w edit ulong 1024 o ulong m ulong to void 159 t = new ulong 10 0 160 for i ulong 8 161 put t i get w add o i 162 end 163 cp2red w o t m 164 end 165 166 fn cp2lt w edit ulong 1024 a ulong m ulong to bool 167 bw = ulong 0 168 x = ulong 0 169 for i ulong 8 170 x = sub sub get w add a i get w add m i bw 171 bw = shr x 63 172 end 173 ret eq bw 1 174 end 175 176 fn cp2isz w edit ulong 1024 a ulong to bool 177 v = ulong 0 178 for i ulong 8 179 v = or v get w add a i 180 end 181 ret eq v 0 182 end 183 184 fn cp2eqv w edit ulong 1024 a ulong b ulong to bool 185 v = ulong 0 186 for i ulong 8 187 v = or v xor get w add a i get w add b i 188 end 189 ret eq v 0 190 end 191 192 fn cp2rng w edit ulong 1024 a ulong to bool 193 ret and not cp2isz w a cp2lt w a C2MN 194 end 195 196 fn cp2pow w edit ulong 1024 o ulong a ulong e ulong m ulong to void 197 cp2cpy w C2W2 a 198 cp2cpy w C2W1 add m 24 199 i = ulong 0 200 bit = ulong 0 201 for j ulong 256 202 i = sub 255 j 203 cp2mul w C2W1 C2W1 C2W1 m 204 bit = and shr get w add e shr i 5 and i 31 1 205 if eq bit 1 206 cp2mul w C2W1 C2W1 C2W2 m 207 end 208 end 209 cp2cpy w o C2W1 210 end 211 212 fn cp2inv w edit ulong 1024 o ulong a ulong m ulong to void 213 cp2pow w o a add m 32 m 214 end 215 216 fn cp2tom w edit ulong 1024 o ulong a ulong m ulong to void 217 cp2mul w o a add m 16 m 218 end 219 220 fn cp2frm w edit ulong 1024 o ulong a ulong m ulong to void 221 cp2mul w o a C2ONE1 m 222 end 223 224 fn cp2mod w edit ulong 1024 m ulong to void 225 m0 = get w m 226 x = m0 227 for i ulong 5 228 x = mul x sub 2 mul m0 x 229 end 230 put w add m 8 and sub 0 x `4294967295` 231 cp2set w add m 16 1 232 for j ulong 512 233 cp2add w add m 16 add m 16 add m 16 m 234 end 235 cp2mul w add m 24 C2ONE1 add m 16 m 236 cp2cpy w add m 32 m 237 put w add m 32 sub get w add m 32 2 238 end 239 240 fn cp2init w edit ulong 1024 to void 241 for i ulong 1024 242 put w i 0 243 end 244 put w 0 `4294967295` 245 put w 1 `4294967295` 246 put w 2 `4294967295` 247 put w 6 1 248 put w 7 `4294967295` 249 put w 48 `4234356049` 250 put w 49 `4089039554` 251 put w 50 `2803342980` 252 put w 51 `3169254061` 253 put w 52 `4294967295` 254 put w 53 `4294967295` 255 put w 55 `4294967295` 256 put w C2ONE1 1 257 cp2mod w C2MP 258 cp2mod w C2MN 259 put w C2T1 `668098635` 260 put w 577 `1003371582` 261 put w 578 `3428036854` 262 put w 579 `1696401072` 263 put w 580 `1989707452` 264 put w 581 `3018571093` 265 put w 582 `2855965671` 266 put w 583 `1522939352` 267 cp2tom w C2BM C2T1 C2MP 268 put w C2T1 `3633889942` 269 put w 577 `4104206661` 270 put w 578 `770388896` 271 put w 579 `1996717441` 272 put w 580 `1671708914` 273 put w 581 `4173129445` 274 put w 582 `3777774151` 275 put w 583 `1796723186` 276 cp2tom w C2GX C2T1 C2MP 277 put w C2T1 `935285237` 278 put w 577 `3417718888` 279 put w 578 `1798397646` 280 put w 579 `734933847` 281 put w 580 `2081398294` 282 put w 581 `2397563722` 283 put w 582 `4263149467` 284 put w 583 `1340293858` 285 cp2tom w add C2GX 8 C2T1 C2MP 286 cp2cpy w add C2GX 16 add C2MP 24 287 cp2set w C2T1 0 288 end 289 290 fn cp2padd w edit ulong 1024 o ulong a ulong q ulong to void 291 cp2mul w C2XX a q C2MP 292 cp2mul w C2YY add a 8 add q 8 C2MP 293 cp2mul w C2ZZ add a 16 add q 16 C2MP 294 cp2add w C2U a add a 8 C2MP 295 cp2add w C2V q add q 8 C2MP 296 cp2mul w C2XY C2U C2V C2MP 297 cp2add w C2U C2XX C2YY C2MP 298 cp2sub w C2XY C2XY C2U C2MP 299 cp2add w C2U add a 8 add a 16 C2MP 300 cp2add w C2V add q 8 add q 16 C2MP 301 cp2mul w C2YZ C2U C2V C2MP 302 cp2add w C2U C2YY C2ZZ C2MP 303 cp2sub w C2YZ C2YZ C2U C2MP 304 cp2add w C2U a add a 16 C2MP 305 cp2add w C2V q add q 16 C2MP 306 cp2mul w C2XZ C2U C2V C2MP 307 cp2add w C2U C2XX C2ZZ C2MP 308 cp2sub w C2XZ C2XZ C2U C2MP 309 note bzz3 = 3 (xz - b zz); ym = yy - bzz3; yp = yy + bzz3 310 cp2mul w C2U C2BM C2ZZ C2MP 311 cp2sub w C2U C2XZ C2U C2MP 312 cp2add w C2V C2U C2U C2MP 313 cp2add w C2U C2V C2U C2MP 314 cp2sub w C2YM C2YY C2U C2MP 315 cp2add w C2YP C2YY C2U C2MP 316 note zz3 = 3 zz; bxz3 = 3 (b xz - (zz3 + xx)); xx3 = 3 xx - zz3 317 cp2add w C2ZZ3 C2ZZ C2ZZ C2MP 318 cp2add w C2ZZ3 C2ZZ3 C2ZZ C2MP 319 cp2mul w C2U C2BM C2XZ C2MP 320 cp2add w C2V C2ZZ3 C2XX C2MP 321 cp2sub w C2U C2U C2V C2MP 322 cp2add w C2V C2U C2U C2MP 323 cp2add w C2BX3 C2V C2U C2MP 324 cp2add w C2V C2XX C2XX C2MP 325 cp2add w C2V C2V C2XX C2MP 326 cp2sub w C2XX3 C2V C2ZZ3 C2MP 327 note X3 = yp xy - yz bxz3; Y3 = yp ym + xx3 bxz3; Z3 = ym yz + xy xx3 328 cp2mul w C2U C2YP C2XY C2MP 329 cp2mul w C2V C2YZ C2BX3 C2MP 330 cp2sub w C2RX C2U C2V C2MP 331 cp2mul w C2U C2YP C2YM C2MP 332 cp2mul w C2V C2XX3 C2BX3 C2MP 333 cp2add w add C2RX 8 C2U C2V C2MP 334 cp2mul w C2U C2YM C2YZ C2MP 335 cp2mul w C2V C2XY C2XX3 C2MP 336 cp2add w add C2RX 16 C2U C2V C2MP 337 cp2pcpy w o C2RX 338 end 339 340 fn cp2psel w edit ulong 1024 bit ulong to void 341 mk = sub 0 bit 342 nm = not mk 343 for c ulong 24 344 y = and get w add C2TMP c mk 345 put w add C2ACC c or y and get w add C2ACC c nm 346 end 347 end 348 349 fn cp2smul w edit ulong 1024 o ulong k ulong p ulong to void 350 cp2pcpy w C2BASE p 351 cp2set w C2ACC 0 352 cp2cpy w add C2ACC 8 add C2MP 24 353 cp2set w add C2ACC 16 0 354 i = ulong 0 355 for j ulong 256 356 i = sub 255 j 357 cp2padd w C2ACC C2ACC C2ACC 358 cp2padd w C2TMP C2ACC C2BASE 359 cp2psel w and shr get w add k shr i 5 and i 31 1 360 end 361 cp2pcpy w o C2ACC 362 end 363 364 fn cp2aff w edit ulong 1024 x ulong y ulong p ulong to void 365 cp2inv w C2ZI add p 16 C2MP 366 cp2mul w x p C2ZI C2MP 367 cp2frm w x x C2MP 368 cp2mul w y add p 8 C2ZI C2MP 369 cp2frm w y y C2MP 370 end 371 372 fn cp2ld w edit ulong 1024 o ulong b edit uchar 4096 off ulong to void 373 q = ulong 0 374 v = ulong 0 375 for i ulong 8 376 q = add off sub 28 mul i 4 377 v = ulong get b q 378 v = or shl v 8 ulong get b add q 1 379 v = or shl v 8 ulong get b add q 2 380 v = or shl v 8 ulong get b add q 3 381 put w add o i v 382 end 383 end 384 385 fn cp2oncv w edit ulong 1024 to bool 386 if not cp2lt w C2X C2MP 387 ret false 388 end 389 if not cp2lt w C2Y C2MP 390 ret false 391 end 392 cp2tom w C2T1 C2X C2MP 393 cp2tom w C2T2 C2Y C2MP 394 cp2mul w C2T3 C2T2 C2T2 C2MP 395 cp2mul w C2T2 C2T1 C2T1 C2MP 396 cp2mul w C2T2 C2T2 C2T1 C2MP 397 cp2sub w C2T2 C2T2 C2T1 C2MP 398 cp2sub w C2T2 C2T2 C2T1 C2MP 399 cp2sub w C2T2 C2T2 C2T1 C2MP 400 cp2add w C2T2 C2T2 C2BM C2MP 401 ret cp2eqv w C2T2 C2T3 402 end 403 404 fn cp2vrfy w edit ulong 1024 b edit uchar 4096 to ulong 405 if ne get b C2BPUB 4 406 ret 0 407 end 408 cp2ld w C2X b add C2BPUB 1 409 cp2ld w C2Y b add C2BPUB 33 410 if not cp2oncv w 411 ret 0 412 end 413 cp2ld w C2R b C2BSIG 414 cp2ld w C2S b add C2BSIG 32 415 if not cp2rng w C2R 416 ret 0 417 end 418 if not cp2rng w C2S 419 ret 0 420 end 421 cp2ld w C2Z b C2BDIG 422 cp2modr w C2Z C2MN 423 cp2tom w C2T1 C2S C2MN 424 cp2inv w C2T1 C2T1 C2MN 425 cp2tom w C2T2 C2Z C2MN 426 cp2mul w C2U1 C2T2 C2T1 C2MN 427 cp2frm w C2U1 C2U1 C2MN 428 cp2tom w C2T2 C2R C2MN 429 cp2mul w C2U2 C2T2 C2T1 C2MN 430 cp2frm w C2U2 C2U2 C2MN 431 cp2tom w C2Q C2X C2MP 432 cp2tom w add C2Q 8 C2Y C2MP 433 cp2cpy w add C2Q 16 add C2MP 24 434 cp2smul w C2P1 C2U1 C2GX 435 cp2smul w C2P2 C2U2 C2Q 436 cp2padd w C2P1 C2P1 C2P2 437 if cp2isz w add C2P1 16 438 ret 0 439 end 440 cp2aff w C2X C2Y C2P1 441 cp2modr w C2X C2MN 442 if cp2eqv w C2X C2R 443 ret 1 444 end 445 ret 0 446 end 447