/* Autogenerated: src/ExtractionOCaml/word_by_word_montgomery --static secp256k1 '2^256 - 2^32 - 977' 64 mul square add sub opp from_montgomery nonzero selectznz to_bytes from_bytes */ /* curve description: secp256k1 */ /* requested operations: mul, square, add, sub, opp, from_montgomery, nonzero, selectznz, to_bytes, from_bytes */ /* m = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f (from "2^256 - 2^32 - 977") */ /* machine_wordsize = 64 (from "64") */ /* */ /* NOTE: In addition to the bounds specified above each function, all */ /* functions synthesized for this Montgomery arithmetic require the */ /* input to be strictly less than the prime modulus (m), and also */ /* require the input to be in the unique saturated representation. */ /* All functions also ensure that these two properties are true of */ /* return values. */ #include typedef unsigned char fiat_secp256k1_uint1; typedef signed char fiat_secp256k1_int1; typedef signed __int128 fiat_secp256k1_int128; typedef unsigned __int128 fiat_secp256k1_uint128; #if (-1 & 3) != 3 #error "This code only works on a two's complement system" #endif /* * The function fiat_secp256k1_addcarryx_u64 is an addition with carry. * Postconditions: * out1 = (arg1 + arg2 + arg3) mod 2^64 * out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [0x0 ~> 0xffffffffffffffff] * arg3: [0x0 ~> 0xffffffffffffffff] * Output Bounds: * out1: [0x0 ~> 0xffffffffffffffff] * out2: [0x0 ~> 0x1] */ static void fiat_secp256k1_addcarryx_u64(uint64_t* out1, fiat_secp256k1_uint1* out2, fiat_secp256k1_uint1 arg1, uint64_t arg2, uint64_t arg3) { fiat_secp256k1_uint128 x1 = ((arg1 + (fiat_secp256k1_uint128)arg2) + arg3); uint64_t x2 = (uint64_t)(x1 & UINT64_C(0xffffffffffffffff)); fiat_secp256k1_uint1 x3 = (fiat_secp256k1_uint1)(x1 >> 64); *out1 = x2; *out2 = x3; } /* * The function fiat_secp256k1_subborrowx_u64 is a subtraction with borrow. * Postconditions: * out1 = (-arg1 + arg2 + -arg3) mod 2^64 * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋ * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [0x0 ~> 0xffffffffffffffff] * arg3: [0x0 ~> 0xffffffffffffffff] * Output Bounds: * out1: [0x0 ~> 0xffffffffffffffff] * out2: [0x0 ~> 0x1] */ static void fiat_secp256k1_subborrowx_u64(uint64_t* out1, fiat_secp256k1_uint1* out2, fiat_secp256k1_uint1 arg1, uint64_t arg2, uint64_t arg3) { fiat_secp256k1_int128 x1 = ((arg2 - (fiat_secp256k1_int128)arg1) - arg3); fiat_secp256k1_int1 x2 = (fiat_secp256k1_int1)(x1 >> 64); uint64_t x3 = (uint64_t)(x1 & UINT64_C(0xffffffffffffffff)); *out1 = x3; *out2 = (fiat_secp256k1_uint1)(0x0 - x2); } /* * The function fiat_secp256k1_mulx_u64 is a multiplication, returning the full double-width result. * Postconditions: * out1 = (arg1 * arg2) mod 2^64 * out2 = ⌊arg1 * arg2 / 2^64⌋ * * Input Bounds: * arg1: [0x0 ~> 0xffffffffffffffff] * arg2: [0x0 ~> 0xffffffffffffffff] * Output Bounds: * out1: [0x0 ~> 0xffffffffffffffff] * out2: [0x0 ~> 0xffffffffffffffff] */ static void fiat_secp256k1_mulx_u64(uint64_t* out1, uint64_t* out2, uint64_t arg1, uint64_t arg2) { fiat_secp256k1_uint128 x1 = ((fiat_secp256k1_uint128)arg1 * arg2); uint64_t x2 = (uint64_t)(x1 & UINT64_C(0xffffffffffffffff)); uint64_t x3 = (uint64_t)(x1 >> 64); *out1 = x2; *out2 = x3; } /* * The function fiat_secp256k1_cmovznz_u64 is a single-word conditional move. * Postconditions: * out1 = (if arg1 = 0 then arg2 else arg3) * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [0x0 ~> 0xffffffffffffffff] * arg3: [0x0 ~> 0xffffffffffffffff] * Output Bounds: * out1: [0x0 ~> 0xffffffffffffffff] */ static void fiat_secp256k1_cmovznz_u64(uint64_t* out1, fiat_secp256k1_uint1 arg1, uint64_t arg2, uint64_t arg3) { fiat_secp256k1_uint1 x1 = (!(!arg1)); uint64_t x2 = ((fiat_secp256k1_int1)(0x0 - x1) & UINT64_C(0xffffffffffffffff)); uint64_t x3 = ((x2 & arg3) | ((~x2) & arg2)); *out1 = x3; } /* * The function fiat_secp256k1_mul multiplies two field elements in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * 0 ≤ eval arg2 < m * Postconditions: * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_secp256k1_mul(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) { uint64_t x1 = (arg1[1]); uint64_t x2 = (arg1[2]); uint64_t x3 = (arg1[3]); uint64_t x4 = (arg1[0]); uint64_t x5; uint64_t x6; fiat_secp256k1_mulx_u64(&x5, &x6, x4, (arg2[3])); uint64_t x7; uint64_t x8; fiat_secp256k1_mulx_u64(&x7, &x8, x4, (arg2[2])); uint64_t x9; uint64_t x10; fiat_secp256k1_mulx_u64(&x9, &x10, x4, (arg2[1])); uint64_t x11; uint64_t x12; fiat_secp256k1_mulx_u64(&x11, &x12, x4, (arg2[0])); uint64_t x13; fiat_secp256k1_uint1 x14; fiat_secp256k1_addcarryx_u64(&x13, &x14, 0x0, x12, x9); uint64_t x15; fiat_secp256k1_uint1 x16; fiat_secp256k1_addcarryx_u64(&x15, &x16, x14, x10, x7); uint64_t x17; fiat_secp256k1_uint1 x18; fiat_secp256k1_addcarryx_u64(&x17, &x18, x16, x8, x5); uint64_t x19 = (x18 + x6); uint64_t x20; uint64_t x21; fiat_secp256k1_mulx_u64(&x20, &x21, x11, UINT64_C(0xd838091dd2253531)); uint64_t x22; uint64_t x23; fiat_secp256k1_mulx_u64(&x22, &x23, x20, UINT64_C(0xffffffffffffffff)); uint64_t x24; uint64_t x25; fiat_secp256k1_mulx_u64(&x24, &x25, x20, UINT64_C(0xffffffffffffffff)); uint64_t x26; uint64_t x27; fiat_secp256k1_mulx_u64(&x26, &x27, x20, UINT64_C(0xffffffffffffffff)); uint64_t x28; uint64_t x29; fiat_secp256k1_mulx_u64(&x28, &x29, x20, UINT64_C(0xfffffffefffffc2f)); uint64_t x30; fiat_secp256k1_uint1 x31; fiat_secp256k1_addcarryx_u64(&x30, &x31, 0x0, x29, x26); uint64_t x32; fiat_secp256k1_uint1 x33; fiat_secp256k1_addcarryx_u64(&x32, &x33, x31, x27, x24); uint64_t x34; fiat_secp256k1_uint1 x35; fiat_secp256k1_addcarryx_u64(&x34, &x35, x33, x25, x22); uint64_t x36 = (x35 + x23); uint64_t x37; fiat_secp256k1_uint1 x38; fiat_secp256k1_addcarryx_u64(&x37, &x38, 0x0, x11, x28); uint64_t x39; fiat_secp256k1_uint1 x40; fiat_secp256k1_addcarryx_u64(&x39, &x40, x38, x13, x30); uint64_t x41; fiat_secp256k1_uint1 x42; fiat_secp256k1_addcarryx_u64(&x41, &x42, x40, x15, x32); uint64_t x43; fiat_secp256k1_uint1 x44; fiat_secp256k1_addcarryx_u64(&x43, &x44, x42, x17, x34); uint64_t x45; fiat_secp256k1_uint1 x46; fiat_secp256k1_addcarryx_u64(&x45, &x46, x44, x19, x36); uint64_t x47; uint64_t x48; fiat_secp256k1_mulx_u64(&x47, &x48, x1, (arg2[3])); uint64_t x49; uint64_t x50; fiat_secp256k1_mulx_u64(&x49, &x50, x1, (arg2[2])); uint64_t x51; uint64_t x52; fiat_secp256k1_mulx_u64(&x51, &x52, x1, (arg2[1])); uint64_t x53; uint64_t x54; fiat_secp256k1_mulx_u64(&x53, &x54, x1, (arg2[0])); uint64_t x55; fiat_secp256k1_uint1 x56; fiat_secp256k1_addcarryx_u64(&x55, &x56, 0x0, x54, x51); uint64_t x57; fiat_secp256k1_uint1 x58; fiat_secp256k1_addcarryx_u64(&x57, &x58, x56, x52, x49); uint64_t x59; fiat_secp256k1_uint1 x60; fiat_secp256k1_addcarryx_u64(&x59, &x60, x58, x50, x47); uint64_t x61 = (x60 + x48); uint64_t x62; fiat_secp256k1_uint1 x63; fiat_secp256k1_addcarryx_u64(&x62, &x63, 0x0, x39, x53); uint64_t x64; fiat_secp256k1_uint1 x65; fiat_secp256k1_addcarryx_u64(&x64, &x65, x63, x41, x55); uint64_t x66; fiat_secp256k1_uint1 x67; fiat_secp256k1_addcarryx_u64(&x66, &x67, x65, x43, x57); uint64_t x68; fiat_secp256k1_uint1 x69; fiat_secp256k1_addcarryx_u64(&x68, &x69, x67, x45, x59); uint64_t x70; fiat_secp256k1_uint1 x71; fiat_secp256k1_addcarryx_u64(&x70, &x71, x69, x46, x61); uint64_t x72; uint64_t x73; fiat_secp256k1_mulx_u64(&x72, &x73, x62, UINT64_C(0xd838091dd2253531)); uint64_t x74; uint64_t x75; fiat_secp256k1_mulx_u64(&x74, &x75, x72, UINT64_C(0xffffffffffffffff)); uint64_t x76; uint64_t x77; fiat_secp256k1_mulx_u64(&x76, &x77, x72, UINT64_C(0xffffffffffffffff)); uint64_t x78; uint64_t x79; fiat_secp256k1_mulx_u64(&x78, &x79, x72, UINT64_C(0xffffffffffffffff)); uint64_t x80; uint64_t x81; fiat_secp256k1_mulx_u64(&x80, &x81, x72, UINT64_C(0xfffffffefffffc2f)); uint64_t x82; fiat_secp256k1_uint1 x83; fiat_secp256k1_addcarryx_u64(&x82, &x83, 0x0, x81, x78); uint64_t x84; fiat_secp256k1_uint1 x85; fiat_secp256k1_addcarryx_u64(&x84, &x85, x83, x79, x76); uint64_t x86; fiat_secp256k1_uint1 x87; fiat_secp256k1_addcarryx_u64(&x86, &x87, x85, x77, x74); uint64_t x88 = (x87 + x75); uint64_t x89; fiat_secp256k1_uint1 x90; fiat_secp256k1_addcarryx_u64(&x89, &x90, 0x0, x62, x80); uint64_t x91; fiat_secp256k1_uint1 x92; fiat_secp256k1_addcarryx_u64(&x91, &x92, x90, x64, x82); uint64_t x93; fiat_secp256k1_uint1 x94; fiat_secp256k1_addcarryx_u64(&x93, &x94, x92, x66, x84); uint64_t x95; fiat_secp256k1_uint1 x96; fiat_secp256k1_addcarryx_u64(&x95, &x96, x94, x68, x86); uint64_t x97; fiat_secp256k1_uint1 x98; fiat_secp256k1_addcarryx_u64(&x97, &x98, x96, x70, x88); uint64_t x99 = ((uint64_t)x98 + x71); uint64_t x100; uint64_t x101; fiat_secp256k1_mulx_u64(&x100, &x101, x2, (arg2[3])); uint64_t x102; uint64_t x103; fiat_secp256k1_mulx_u64(&x102, &x103, x2, (arg2[2])); uint64_t x104; uint64_t x105; fiat_secp256k1_mulx_u64(&x104, &x105, x2, (arg2[1])); uint64_t x106; uint64_t x107; fiat_secp256k1_mulx_u64(&x106, &x107, x2, (arg2[0])); uint64_t x108; fiat_secp256k1_uint1 x109; fiat_secp256k1_addcarryx_u64(&x108, &x109, 0x0, x107, x104); uint64_t x110; fiat_secp256k1_uint1 x111; fiat_secp256k1_addcarryx_u64(&x110, &x111, x109, x105, x102); uint64_t x112; fiat_secp256k1_uint1 x113; fiat_secp256k1_addcarryx_u64(&x112, &x113, x111, x103, x100); uint64_t x114 = (x113 + x101); uint64_t x115; fiat_secp256k1_uint1 x116; fiat_secp256k1_addcarryx_u64(&x115, &x116, 0x0, x91, x106); uint64_t x117; fiat_secp256k1_uint1 x118; fiat_secp256k1_addcarryx_u64(&x117, &x118, x116, x93, x108); uint64_t x119; fiat_secp256k1_uint1 x120; fiat_secp256k1_addcarryx_u64(&x119, &x120, x118, x95, x110); uint64_t x121; fiat_secp256k1_uint1 x122; fiat_secp256k1_addcarryx_u64(&x121, &x122, x120, x97, x112); uint64_t x123; fiat_secp256k1_uint1 x124; fiat_secp256k1_addcarryx_u64(&x123, &x124, x122, x99, x114); uint64_t x125; uint64_t x126; fiat_secp256k1_mulx_u64(&x125, &x126, x115, UINT64_C(0xd838091dd2253531)); uint64_t x127; uint64_t x128; fiat_secp256k1_mulx_u64(&x127, &x128, x125, UINT64_C(0xffffffffffffffff)); uint64_t x129; uint64_t x130; fiat_secp256k1_mulx_u64(&x129, &x130, x125, UINT64_C(0xffffffffffffffff)); uint64_t x131; uint64_t x132; fiat_secp256k1_mulx_u64(&x131, &x132, x125, UINT64_C(0xffffffffffffffff)); uint64_t x133; uint64_t x134; fiat_secp256k1_mulx_u64(&x133, &x134, x125, UINT64_C(0xfffffffefffffc2f)); uint64_t x135; fiat_secp256k1_uint1 x136; fiat_secp256k1_addcarryx_u64(&x135, &x136, 0x0, x134, x131); uint64_t x137; fiat_secp256k1_uint1 x138; fiat_secp256k1_addcarryx_u64(&x137, &x138, x136, x132, x129); uint64_t x139; fiat_secp256k1_uint1 x140; fiat_secp256k1_addcarryx_u64(&x139, &x140, x138, x130, x127); uint64_t x141 = (x140 + x128); uint64_t x142; fiat_secp256k1_uint1 x143; fiat_secp256k1_addcarryx_u64(&x142, &x143, 0x0, x115, x133); uint64_t x144; fiat_secp256k1_uint1 x145; fiat_secp256k1_addcarryx_u64(&x144, &x145, x143, x117, x135); uint64_t x146; fiat_secp256k1_uint1 x147; fiat_secp256k1_addcarryx_u64(&x146, &x147, x145, x119, x137); uint64_t x148; fiat_secp256k1_uint1 x149; fiat_secp256k1_addcarryx_u64(&x148, &x149, x147, x121, x139); uint64_t x150; fiat_secp256k1_uint1 x151; fiat_secp256k1_addcarryx_u64(&x150, &x151, x149, x123, x141); uint64_t x152 = ((uint64_t)x151 + x124); uint64_t x153; uint64_t x154; fiat_secp256k1_mulx_u64(&x153, &x154, x3, (arg2[3])); uint64_t x155; uint64_t x156; fiat_secp256k1_mulx_u64(&x155, &x156, x3, (arg2[2])); uint64_t x157; uint64_t x158; fiat_secp256k1_mulx_u64(&x157, &x158, x3, (arg2[1])); uint64_t x159; uint64_t x160; fiat_secp256k1_mulx_u64(&x159, &x160, x3, (arg2[0])); uint64_t x161; fiat_secp256k1_uint1 x162; fiat_secp256k1_addcarryx_u64(&x161, &x162, 0x0, x160, x157); uint64_t x163; fiat_secp256k1_uint1 x164; fiat_secp256k1_addcarryx_u64(&x163, &x164, x162, x158, x155); uint64_t x165; fiat_secp256k1_uint1 x166; fiat_secp256k1_addcarryx_u64(&x165, &x166, x164, x156, x153); uint64_t x167 = (x166 + x154); uint64_t x168; fiat_secp256k1_uint1 x169; fiat_secp256k1_addcarryx_u64(&x168, &x169, 0x0, x144, x159); uint64_t x170; fiat_secp256k1_uint1 x171; fiat_secp256k1_addcarryx_u64(&x170, &x171, x169, x146, x161); uint64_t x172; fiat_secp256k1_uint1 x173; fiat_secp256k1_addcarryx_u64(&x172, &x173, x171, x148, x163); uint64_t x174; fiat_secp256k1_uint1 x175; fiat_secp256k1_addcarryx_u64(&x174, &x175, x173, x150, x165); uint64_t x176; fiat_secp256k1_uint1 x177; fiat_secp256k1_addcarryx_u64(&x176, &x177, x175, x152, x167); uint64_t x178; uint64_t x179; fiat_secp256k1_mulx_u64(&x178, &x179, x168, UINT64_C(0xd838091dd2253531)); uint64_t x180; uint64_t x181; fiat_secp256k1_mulx_u64(&x180, &x181, x178, UINT64_C(0xffffffffffffffff)); uint64_t x182; uint64_t x183; fiat_secp256k1_mulx_u64(&x182, &x183, x178, UINT64_C(0xffffffffffffffff)); uint64_t x184; uint64_t x185; fiat_secp256k1_mulx_u64(&x184, &x185, x178, UINT64_C(0xffffffffffffffff)); uint64_t x186; uint64_t x187; fiat_secp256k1_mulx_u64(&x186, &x187, x178, UINT64_C(0xfffffffefffffc2f)); uint64_t x188; fiat_secp256k1_uint1 x189; fiat_secp256k1_addcarryx_u64(&x188, &x189, 0x0, x187, x184); uint64_t x190; fiat_secp256k1_uint1 x191; fiat_secp256k1_addcarryx_u64(&x190, &x191, x189, x185, x182); uint64_t x192; fiat_secp256k1_uint1 x193; fiat_secp256k1_addcarryx_u64(&x192, &x193, x191, x183, x180); uint64_t x194 = (x193 + x181); uint64_t x195; fiat_secp256k1_uint1 x196; fiat_secp256k1_addcarryx_u64(&x195, &x196, 0x0, x168, x186); uint64_t x197; fiat_secp256k1_uint1 x198; fiat_secp256k1_addcarryx_u64(&x197, &x198, x196, x170, x188); uint64_t x199; fiat_secp256k1_uint1 x200; fiat_secp256k1_addcarryx_u64(&x199, &x200, x198, x172, x190); uint64_t x201; fiat_secp256k1_uint1 x202; fiat_secp256k1_addcarryx_u64(&x201, &x202, x200, x174, x192); uint64_t x203; fiat_secp256k1_uint1 x204; fiat_secp256k1_addcarryx_u64(&x203, &x204, x202, x176, x194); uint64_t x205 = ((uint64_t)x204 + x177); uint64_t x206; fiat_secp256k1_uint1 x207; fiat_secp256k1_subborrowx_u64(&x206, &x207, 0x0, x197, UINT64_C(0xfffffffefffffc2f)); uint64_t x208; fiat_secp256k1_uint1 x209; fiat_secp256k1_subborrowx_u64(&x208, &x209, x207, x199, UINT64_C(0xffffffffffffffff)); uint64_t x210; fiat_secp256k1_uint1 x211; fiat_secp256k1_subborrowx_u64(&x210, &x211, x209, x201, UINT64_C(0xffffffffffffffff)); uint64_t x212; fiat_secp256k1_uint1 x213; fiat_secp256k1_subborrowx_u64(&x212, &x213, x211, x203, UINT64_C(0xffffffffffffffff)); uint64_t x214; fiat_secp256k1_uint1 x215; fiat_secp256k1_subborrowx_u64(&x214, &x215, x213, x205, 0x0); uint64_t x216; fiat_secp256k1_cmovznz_u64(&x216, x215, x206, x197); uint64_t x217; fiat_secp256k1_cmovznz_u64(&x217, x215, x208, x199); uint64_t x218; fiat_secp256k1_cmovznz_u64(&x218, x215, x210, x201); uint64_t x219; fiat_secp256k1_cmovznz_u64(&x219, x215, x212, x203); out1[0] = x216; out1[1] = x217; out1[2] = x218; out1[3] = x219; } /* * The function fiat_secp256k1_square squares a field element in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_secp256k1_square(uint64_t out1[4], const uint64_t arg1[4]) { uint64_t x1 = (arg1[1]); uint64_t x2 = (arg1[2]); uint64_t x3 = (arg1[3]); uint64_t x4 = (arg1[0]); uint64_t x5; uint64_t x6; fiat_secp256k1_mulx_u64(&x5, &x6, x4, (arg1[3])); uint64_t x7; uint64_t x8; fiat_secp256k1_mulx_u64(&x7, &x8, x4, (arg1[2])); uint64_t x9; uint64_t x10; fiat_secp256k1_mulx_u64(&x9, &x10, x4, (arg1[1])); uint64_t x11; uint64_t x12; fiat_secp256k1_mulx_u64(&x11, &x12, x4, (arg1[0])); uint64_t x13; fiat_secp256k1_uint1 x14; fiat_secp256k1_addcarryx_u64(&x13, &x14, 0x0, x12, x9); uint64_t x15; fiat_secp256k1_uint1 x16; fiat_secp256k1_addcarryx_u64(&x15, &x16, x14, x10, x7); uint64_t x17; fiat_secp256k1_uint1 x18; fiat_secp256k1_addcarryx_u64(&x17, &x18, x16, x8, x5); uint64_t x19 = (x18 + x6); uint64_t x20; uint64_t x21; fiat_secp256k1_mulx_u64(&x20, &x21, x11, UINT64_C(0xd838091dd2253531)); uint64_t x22; uint64_t x23; fiat_secp256k1_mulx_u64(&x22, &x23, x20, UINT64_C(0xffffffffffffffff)); uint64_t x24; uint64_t x25; fiat_secp256k1_mulx_u64(&x24, &x25, x20, UINT64_C(0xffffffffffffffff)); uint64_t x26; uint64_t x27; fiat_secp256k1_mulx_u64(&x26, &x27, x20, UINT64_C(0xffffffffffffffff)); uint64_t x28; uint64_t x29; fiat_secp256k1_mulx_u64(&x28, &x29, x20, UINT64_C(0xfffffffefffffc2f)); uint64_t x30; fiat_secp256k1_uint1 x31; fiat_secp256k1_addcarryx_u64(&x30, &x31, 0x0, x29, x26); uint64_t x32; fiat_secp256k1_uint1 x33; fiat_secp256k1_addcarryx_u64(&x32, &x33, x31, x27, x24); uint64_t x34; fiat_secp256k1_uint1 x35; fiat_secp256k1_addcarryx_u64(&x34, &x35, x33, x25, x22); uint64_t x36 = (x35 + x23); uint64_t x37; fiat_secp256k1_uint1 x38; fiat_secp256k1_addcarryx_u64(&x37, &x38, 0x0, x11, x28); uint64_t x39; fiat_secp256k1_uint1 x40; fiat_secp256k1_addcarryx_u64(&x39, &x40, x38, x13, x30); uint64_t x41; fiat_secp256k1_uint1 x42; fiat_secp256k1_addcarryx_u64(&x41, &x42, x40, x15, x32); uint64_t x43; fiat_secp256k1_uint1 x44; fiat_secp256k1_addcarryx_u64(&x43, &x44, x42, x17, x34); uint64_t x45; fiat_secp256k1_uint1 x46; fiat_secp256k1_addcarryx_u64(&x45, &x46, x44, x19, x36); uint64_t x47; uint64_t x48; fiat_secp256k1_mulx_u64(&x47, &x48, x1, (arg1[3])); uint64_t x49; uint64_t x50; fiat_secp256k1_mulx_u64(&x49, &x50, x1, (arg1[2])); uint64_t x51; uint64_t x52; fiat_secp256k1_mulx_u64(&x51, &x52, x1, (arg1[1])); uint64_t x53; uint64_t x54; fiat_secp256k1_mulx_u64(&x53, &x54, x1, (arg1[0])); uint64_t x55; fiat_secp256k1_uint1 x56; fiat_secp256k1_addcarryx_u64(&x55, &x56, 0x0, x54, x51); uint64_t x57; fiat_secp256k1_uint1 x58; fiat_secp256k1_addcarryx_u64(&x57, &x58, x56, x52, x49); uint64_t x59; fiat_secp256k1_uint1 x60; fiat_secp256k1_addcarryx_u64(&x59, &x60, x58, x50, x47); uint64_t x61 = (x60 + x48); uint64_t x62; fiat_secp256k1_uint1 x63; fiat_secp256k1_addcarryx_u64(&x62, &x63, 0x0, x39, x53); uint64_t x64; fiat_secp256k1_uint1 x65; fiat_secp256k1_addcarryx_u64(&x64, &x65, x63, x41, x55); uint64_t x66; fiat_secp256k1_uint1 x67; fiat_secp256k1_addcarryx_u64(&x66, &x67, x65, x43, x57); uint64_t x68; fiat_secp256k1_uint1 x69; fiat_secp256k1_addcarryx_u64(&x68, &x69, x67, x45, x59); uint64_t x70; fiat_secp256k1_uint1 x71; fiat_secp256k1_addcarryx_u64(&x70, &x71, x69, x46, x61); uint64_t x72; uint64_t x73; fiat_secp256k1_mulx_u64(&x72, &x73, x62, UINT64_C(0xd838091dd2253531)); uint64_t x74; uint64_t x75; fiat_secp256k1_mulx_u64(&x74, &x75, x72, UINT64_C(0xffffffffffffffff)); uint64_t x76; uint64_t x77; fiat_secp256k1_mulx_u64(&x76, &x77, x72, UINT64_C(0xffffffffffffffff)); uint64_t x78; uint64_t x79; fiat_secp256k1_mulx_u64(&x78, &x79, x72, UINT64_C(0xffffffffffffffff)); uint64_t x80; uint64_t x81; fiat_secp256k1_mulx_u64(&x80, &x81, x72, UINT64_C(0xfffffffefffffc2f)); uint64_t x82; fiat_secp256k1_uint1 x83; fiat_secp256k1_addcarryx_u64(&x82, &x83, 0x0, x81, x78); uint64_t x84; fiat_secp256k1_uint1 x85; fiat_secp256k1_addcarryx_u64(&x84, &x85, x83, x79, x76); uint64_t x86; fiat_secp256k1_uint1 x87; fiat_secp256k1_addcarryx_u64(&x86, &x87, x85, x77, x74); uint64_t x88 = (x87 + x75); uint64_t x89; fiat_secp256k1_uint1 x90; fiat_secp256k1_addcarryx_u64(&x89, &x90, 0x0, x62, x80); uint64_t x91; fiat_secp256k1_uint1 x92; fiat_secp256k1_addcarryx_u64(&x91, &x92, x90, x64, x82); uint64_t x93; fiat_secp256k1_uint1 x94; fiat_secp256k1_addcarryx_u64(&x93, &x94, x92, x66, x84); uint64_t x95; fiat_secp256k1_uint1 x96; fiat_secp256k1_addcarryx_u64(&x95, &x96, x94, x68, x86); uint64_t x97; fiat_secp256k1_uint1 x98; fiat_secp256k1_addcarryx_u64(&x97, &x98, x96, x70, x88); uint64_t x99 = ((uint64_t)x98 + x71); uint64_t x100; uint64_t x101; fiat_secp256k1_mulx_u64(&x100, &x101, x2, (arg1[3])); uint64_t x102; uint64_t x103; fiat_secp256k1_mulx_u64(&x102, &x103, x2, (arg1[2])); uint64_t x104; uint64_t x105; fiat_secp256k1_mulx_u64(&x104, &x105, x2, (arg1[1])); uint64_t x106; uint64_t x107; fiat_secp256k1_mulx_u64(&x106, &x107, x2, (arg1[0])); uint64_t x108; fiat_secp256k1_uint1 x109; fiat_secp256k1_addcarryx_u64(&x108, &x109, 0x0, x107, x104); uint64_t x110; fiat_secp256k1_uint1 x111; fiat_secp256k1_addcarryx_u64(&x110, &x111, x109, x105, x102); uint64_t x112; fiat_secp256k1_uint1 x113; fiat_secp256k1_addcarryx_u64(&x112, &x113, x111, x103, x100); uint64_t x114 = (x113 + x101); uint64_t x115; fiat_secp256k1_uint1 x116; fiat_secp256k1_addcarryx_u64(&x115, &x116, 0x0, x91, x106); uint64_t x117; fiat_secp256k1_uint1 x118; fiat_secp256k1_addcarryx_u64(&x117, &x118, x116, x93, x108); uint64_t x119; fiat_secp256k1_uint1 x120; fiat_secp256k1_addcarryx_u64(&x119, &x120, x118, x95, x110); uint64_t x121; fiat_secp256k1_uint1 x122; fiat_secp256k1_addcarryx_u64(&x121, &x122, x120, x97, x112); uint64_t x123; fiat_secp256k1_uint1 x124; fiat_secp256k1_addcarryx_u64(&x123, &x124, x122, x99, x114); uint64_t x125; uint64_t x126; fiat_secp256k1_mulx_u64(&x125, &x126, x115, UINT64_C(0xd838091dd2253531)); uint64_t x127; uint64_t x128; fiat_secp256k1_mulx_u64(&x127, &x128, x125, UINT64_C(0xffffffffffffffff)); uint64_t x129; uint64_t x130; fiat_secp256k1_mulx_u64(&x129, &x130, x125, UINT64_C(0xffffffffffffffff)); uint64_t x131; uint64_t x132; fiat_secp256k1_mulx_u64(&x131, &x132, x125, UINT64_C(0xffffffffffffffff)); uint64_t x133; uint64_t x134; fiat_secp256k1_mulx_u64(&x133, &x134, x125, UINT64_C(0xfffffffefffffc2f)); uint64_t x135; fiat_secp256k1_uint1 x136; fiat_secp256k1_addcarryx_u64(&x135, &x136, 0x0, x134, x131); uint64_t x137; fiat_secp256k1_uint1 x138; fiat_secp256k1_addcarryx_u64(&x137, &x138, x136, x132, x129); uint64_t x139; fiat_secp256k1_uint1 x140; fiat_secp256k1_addcarryx_u64(&x139, &x140, x138, x130, x127); uint64_t x141 = (x140 + x128); uint64_t x142; fiat_secp256k1_uint1 x143; fiat_secp256k1_addcarryx_u64(&x142, &x143, 0x0, x115, x133); uint64_t x144; fiat_secp256k1_uint1 x145; fiat_secp256k1_addcarryx_u64(&x144, &x145, x143, x117, x135); uint64_t x146; fiat_secp256k1_uint1 x147; fiat_secp256k1_addcarryx_u64(&x146, &x147, x145, x119, x137); uint64_t x148; fiat_secp256k1_uint1 x149; fiat_secp256k1_addcarryx_u64(&x148, &x149, x147, x121, x139); uint64_t x150; fiat_secp256k1_uint1 x151; fiat_secp256k1_addcarryx_u64(&x150, &x151, x149, x123, x141); uint64_t x152 = ((uint64_t)x151 + x124); uint64_t x153; uint64_t x154; fiat_secp256k1_mulx_u64(&x153, &x154, x3, (arg1[3])); uint64_t x155; uint64_t x156; fiat_secp256k1_mulx_u64(&x155, &x156, x3, (arg1[2])); uint64_t x157; uint64_t x158; fiat_secp256k1_mulx_u64(&x157, &x158, x3, (arg1[1])); uint64_t x159; uint64_t x160; fiat_secp256k1_mulx_u64(&x159, &x160, x3, (arg1[0])); uint64_t x161; fiat_secp256k1_uint1 x162; fiat_secp256k1_addcarryx_u64(&x161, &x162, 0x0, x160, x157); uint64_t x163; fiat_secp256k1_uint1 x164; fiat_secp256k1_addcarryx_u64(&x163, &x164, x162, x158, x155); uint64_t x165; fiat_secp256k1_uint1 x166; fiat_secp256k1_addcarryx_u64(&x165, &x166, x164, x156, x153); uint64_t x167 = (x166 + x154); uint64_t x168; fiat_secp256k1_uint1 x169; fiat_secp256k1_addcarryx_u64(&x168, &x169, 0x0, x144, x159); uint64_t x170; fiat_secp256k1_uint1 x171; fiat_secp256k1_addcarryx_u64(&x170, &x171, x169, x146, x161); uint64_t x172; fiat_secp256k1_uint1 x173; fiat_secp256k1_addcarryx_u64(&x172, &x173, x171, x148, x163); uint64_t x174; fiat_secp256k1_uint1 x175; fiat_secp256k1_addcarryx_u64(&x174, &x175, x173, x150, x165); uint64_t x176; fiat_secp256k1_uint1 x177; fiat_secp256k1_addcarryx_u64(&x176, &x177, x175, x152, x167); uint64_t x178; uint64_t x179; fiat_secp256k1_mulx_u64(&x178, &x179, x168, UINT64_C(0xd838091dd2253531)); uint64_t x180; uint64_t x181; fiat_secp256k1_mulx_u64(&x180, &x181, x178, UINT64_C(0xffffffffffffffff)); uint64_t x182; uint64_t x183; fiat_secp256k1_mulx_u64(&x182, &x183, x178, UINT64_C(0xffffffffffffffff)); uint64_t x184; uint64_t x185; fiat_secp256k1_mulx_u64(&x184, &x185, x178, UINT64_C(0xffffffffffffffff)); uint64_t x186; uint64_t x187; fiat_secp256k1_mulx_u64(&x186, &x187, x178, UINT64_C(0xfffffffefffffc2f)); uint64_t x188; fiat_secp256k1_uint1 x189; fiat_secp256k1_addcarryx_u64(&x188, &x189, 0x0, x187, x184); uint64_t x190; fiat_secp256k1_uint1 x191; fiat_secp256k1_addcarryx_u64(&x190, &x191, x189, x185, x182); uint64_t x192; fiat_secp256k1_uint1 x193; fiat_secp256k1_addcarryx_u64(&x192, &x193, x191, x183, x180); uint64_t x194 = (x193 + x181); uint64_t x195; fiat_secp256k1_uint1 x196; fiat_secp256k1_addcarryx_u64(&x195, &x196, 0x0, x168, x186); uint64_t x197; fiat_secp256k1_uint1 x198; fiat_secp256k1_addcarryx_u64(&x197, &x198, x196, x170, x188); uint64_t x199; fiat_secp256k1_uint1 x200; fiat_secp256k1_addcarryx_u64(&x199, &x200, x198, x172, x190); uint64_t x201; fiat_secp256k1_uint1 x202; fiat_secp256k1_addcarryx_u64(&x201, &x202, x200, x174, x192); uint64_t x203; fiat_secp256k1_uint1 x204; fiat_secp256k1_addcarryx_u64(&x203, &x204, x202, x176, x194); uint64_t x205 = ((uint64_t)x204 + x177); uint64_t x206; fiat_secp256k1_uint1 x207; fiat_secp256k1_subborrowx_u64(&x206, &x207, 0x0, x197, UINT64_C(0xfffffffefffffc2f)); uint64_t x208; fiat_secp256k1_uint1 x209; fiat_secp256k1_subborrowx_u64(&x208, &x209, x207, x199, UINT64_C(0xffffffffffffffff)); uint64_t x210; fiat_secp256k1_uint1 x211; fiat_secp256k1_subborrowx_u64(&x210, &x211, x209, x201, UINT64_C(0xffffffffffffffff)); uint64_t x212; fiat_secp256k1_uint1 x213; fiat_secp256k1_subborrowx_u64(&x212, &x213, x211, x203, UINT64_C(0xffffffffffffffff)); uint64_t x214; fiat_secp256k1_uint1 x215; fiat_secp256k1_subborrowx_u64(&x214, &x215, x213, x205, 0x0); uint64_t x216; fiat_secp256k1_cmovznz_u64(&x216, x215, x206, x197); uint64_t x217; fiat_secp256k1_cmovznz_u64(&x217, x215, x208, x199); uint64_t x218; fiat_secp256k1_cmovznz_u64(&x218, x215, x210, x201); uint64_t x219; fiat_secp256k1_cmovznz_u64(&x219, x215, x212, x203); out1[0] = x216; out1[1] = x217; out1[2] = x218; out1[3] = x219; } /* * The function fiat_secp256k1_add adds two field elements in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * 0 ≤ eval arg2 < m * Postconditions: * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) + eval (from_montgomery arg2)) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_secp256k1_add(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) { uint64_t x1; fiat_secp256k1_uint1 x2; fiat_secp256k1_addcarryx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); uint64_t x3; fiat_secp256k1_uint1 x4; fiat_secp256k1_addcarryx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1])); uint64_t x5; fiat_secp256k1_uint1 x6; fiat_secp256k1_addcarryx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2])); uint64_t x7; fiat_secp256k1_uint1 x8; fiat_secp256k1_addcarryx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3])); uint64_t x9; fiat_secp256k1_uint1 x10; fiat_secp256k1_subborrowx_u64(&x9, &x10, 0x0, x1, UINT64_C(0xfffffffefffffc2f)); uint64_t x11; fiat_secp256k1_uint1 x12; fiat_secp256k1_subborrowx_u64(&x11, &x12, x10, x3, UINT64_C(0xffffffffffffffff)); uint64_t x13; fiat_secp256k1_uint1 x14; fiat_secp256k1_subborrowx_u64(&x13, &x14, x12, x5, UINT64_C(0xffffffffffffffff)); uint64_t x15; fiat_secp256k1_uint1 x16; fiat_secp256k1_subborrowx_u64(&x15, &x16, x14, x7, UINT64_C(0xffffffffffffffff)); uint64_t x17; fiat_secp256k1_uint1 x18; fiat_secp256k1_subborrowx_u64(&x17, &x18, x16, x8, 0x0); uint64_t x19; fiat_secp256k1_cmovznz_u64(&x19, x18, x9, x1); uint64_t x20; fiat_secp256k1_cmovznz_u64(&x20, x18, x11, x3); uint64_t x21; fiat_secp256k1_cmovznz_u64(&x21, x18, x13, x5); uint64_t x22; fiat_secp256k1_cmovznz_u64(&x22, x18, x15, x7); out1[0] = x19; out1[1] = x20; out1[2] = x21; out1[3] = x22; } /* * The function fiat_secp256k1_sub subtracts two field elements in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * 0 ≤ eval arg2 < m * Postconditions: * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) - eval (from_montgomery arg2)) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_secp256k1_sub(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) { uint64_t x1; fiat_secp256k1_uint1 x2; fiat_secp256k1_subborrowx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); uint64_t x3; fiat_secp256k1_uint1 x4; fiat_secp256k1_subborrowx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1])); uint64_t x5; fiat_secp256k1_uint1 x6; fiat_secp256k1_subborrowx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2])); uint64_t x7; fiat_secp256k1_uint1 x8; fiat_secp256k1_subborrowx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3])); uint64_t x9; fiat_secp256k1_cmovznz_u64(&x9, x8, 0x0, UINT64_C(0xffffffffffffffff)); uint64_t x10; fiat_secp256k1_uint1 x11; fiat_secp256k1_addcarryx_u64(&x10, &x11, 0x0, x1, (x9 & UINT64_C(0xfffffffefffffc2f))); uint64_t x12; fiat_secp256k1_uint1 x13; fiat_secp256k1_addcarryx_u64(&x12, &x13, x11, x3, (x9 & UINT64_C(0xffffffffffffffff))); uint64_t x14; fiat_secp256k1_uint1 x15; fiat_secp256k1_addcarryx_u64(&x14, &x15, x13, x5, (x9 & UINT64_C(0xffffffffffffffff))); uint64_t x16; fiat_secp256k1_uint1 x17; fiat_secp256k1_addcarryx_u64(&x16, &x17, x15, x7, (x9 & UINT64_C(0xffffffffffffffff))); out1[0] = x10; out1[1] = x12; out1[2] = x14; out1[3] = x16; } /* * The function fiat_secp256k1_opp negates a field element in the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_secp256k1_opp(uint64_t out1[4], const uint64_t arg1[4]) { uint64_t x1; fiat_secp256k1_uint1 x2; fiat_secp256k1_subborrowx_u64(&x1, &x2, 0x0, 0x0, (arg1[0])); uint64_t x3; fiat_secp256k1_uint1 x4; fiat_secp256k1_subborrowx_u64(&x3, &x4, x2, 0x0, (arg1[1])); uint64_t x5; fiat_secp256k1_uint1 x6; fiat_secp256k1_subborrowx_u64(&x5, &x6, x4, 0x0, (arg1[2])); uint64_t x7; fiat_secp256k1_uint1 x8; fiat_secp256k1_subborrowx_u64(&x7, &x8, x6, 0x0, (arg1[3])); uint64_t x9; fiat_secp256k1_cmovznz_u64(&x9, x8, 0x0, UINT64_C(0xffffffffffffffff)); uint64_t x10; fiat_secp256k1_uint1 x11; fiat_secp256k1_addcarryx_u64(&x10, &x11, 0x0, x1, (x9 & UINT64_C(0xfffffffefffffc2f))); uint64_t x12; fiat_secp256k1_uint1 x13; fiat_secp256k1_addcarryx_u64(&x12, &x13, x11, x3, (x9 & UINT64_C(0xffffffffffffffff))); uint64_t x14; fiat_secp256k1_uint1 x15; fiat_secp256k1_addcarryx_u64(&x14, &x15, x13, x5, (x9 & UINT64_C(0xffffffffffffffff))); uint64_t x16; fiat_secp256k1_uint1 x17; fiat_secp256k1_addcarryx_u64(&x16, &x17, x15, x7, (x9 & UINT64_C(0xffffffffffffffff))); out1[0] = x10; out1[1] = x12; out1[2] = x14; out1[3] = x16; } /* * The function fiat_secp256k1_from_montgomery translates a field element out of the Montgomery domain. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * eval out1 mod m = (eval arg1 * ((2^64)⁻¹ mod m)^4) mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_secp256k1_from_montgomery(uint64_t out1[4], const uint64_t arg1[4]) { uint64_t x1 = (arg1[0]); uint64_t x2; uint64_t x3; fiat_secp256k1_mulx_u64(&x2, &x3, x1, UINT64_C(0xd838091dd2253531)); uint64_t x4; uint64_t x5; fiat_secp256k1_mulx_u64(&x4, &x5, x2, UINT64_C(0xffffffffffffffff)); uint64_t x6; uint64_t x7; fiat_secp256k1_mulx_u64(&x6, &x7, x2, UINT64_C(0xffffffffffffffff)); uint64_t x8; uint64_t x9; fiat_secp256k1_mulx_u64(&x8, &x9, x2, UINT64_C(0xffffffffffffffff)); uint64_t x10; uint64_t x11; fiat_secp256k1_mulx_u64(&x10, &x11, x2, UINT64_C(0xfffffffefffffc2f)); uint64_t x12; fiat_secp256k1_uint1 x13; fiat_secp256k1_addcarryx_u64(&x12, &x13, 0x0, x11, x8); uint64_t x14; fiat_secp256k1_uint1 x15; fiat_secp256k1_addcarryx_u64(&x14, &x15, x13, x9, x6); uint64_t x16; fiat_secp256k1_uint1 x17; fiat_secp256k1_addcarryx_u64(&x16, &x17, x15, x7, x4); uint64_t x18; fiat_secp256k1_uint1 x19; fiat_secp256k1_addcarryx_u64(&x18, &x19, 0x0, x1, x10); uint64_t x20; fiat_secp256k1_uint1 x21; fiat_secp256k1_addcarryx_u64(&x20, &x21, x19, 0x0, x12); uint64_t x22; fiat_secp256k1_uint1 x23; fiat_secp256k1_addcarryx_u64(&x22, &x23, x21, 0x0, x14); uint64_t x24; fiat_secp256k1_uint1 x25; fiat_secp256k1_addcarryx_u64(&x24, &x25, x23, 0x0, x16); uint64_t x26; fiat_secp256k1_uint1 x27; fiat_secp256k1_addcarryx_u64(&x26, &x27, x25, 0x0, (x17 + x5)); uint64_t x28; fiat_secp256k1_uint1 x29; fiat_secp256k1_addcarryx_u64(&x28, &x29, 0x0, x20, (arg1[1])); uint64_t x30; fiat_secp256k1_uint1 x31; fiat_secp256k1_addcarryx_u64(&x30, &x31, x29, x22, 0x0); uint64_t x32; fiat_secp256k1_uint1 x33; fiat_secp256k1_addcarryx_u64(&x32, &x33, x31, x24, 0x0); uint64_t x34; fiat_secp256k1_uint1 x35; fiat_secp256k1_addcarryx_u64(&x34, &x35, x33, x26, 0x0); uint64_t x36; uint64_t x37; fiat_secp256k1_mulx_u64(&x36, &x37, x28, UINT64_C(0xd838091dd2253531)); uint64_t x38; uint64_t x39; fiat_secp256k1_mulx_u64(&x38, &x39, x36, UINT64_C(0xffffffffffffffff)); uint64_t x40; uint64_t x41; fiat_secp256k1_mulx_u64(&x40, &x41, x36, UINT64_C(0xffffffffffffffff)); uint64_t x42; uint64_t x43; fiat_secp256k1_mulx_u64(&x42, &x43, x36, UINT64_C(0xffffffffffffffff)); uint64_t x44; uint64_t x45; fiat_secp256k1_mulx_u64(&x44, &x45, x36, UINT64_C(0xfffffffefffffc2f)); uint64_t x46; fiat_secp256k1_uint1 x47; fiat_secp256k1_addcarryx_u64(&x46, &x47, 0x0, x45, x42); uint64_t x48; fiat_secp256k1_uint1 x49; fiat_secp256k1_addcarryx_u64(&x48, &x49, x47, x43, x40); uint64_t x50; fiat_secp256k1_uint1 x51; fiat_secp256k1_addcarryx_u64(&x50, &x51, x49, x41, x38); uint64_t x52; fiat_secp256k1_uint1 x53; fiat_secp256k1_addcarryx_u64(&x52, &x53, 0x0, x28, x44); uint64_t x54; fiat_secp256k1_uint1 x55; fiat_secp256k1_addcarryx_u64(&x54, &x55, x53, x30, x46); uint64_t x56; fiat_secp256k1_uint1 x57; fiat_secp256k1_addcarryx_u64(&x56, &x57, x55, x32, x48); uint64_t x58; fiat_secp256k1_uint1 x59; fiat_secp256k1_addcarryx_u64(&x58, &x59, x57, x34, x50); uint64_t x60; fiat_secp256k1_uint1 x61; fiat_secp256k1_addcarryx_u64(&x60, &x61, x59, ((uint64_t)x35 + x27), (x51 + x39)); uint64_t x62; fiat_secp256k1_uint1 x63; fiat_secp256k1_addcarryx_u64(&x62, &x63, 0x0, x54, (arg1[2])); uint64_t x64; fiat_secp256k1_uint1 x65; fiat_secp256k1_addcarryx_u64(&x64, &x65, x63, x56, 0x0); uint64_t x66; fiat_secp256k1_uint1 x67; fiat_secp256k1_addcarryx_u64(&x66, &x67, x65, x58, 0x0); uint64_t x68; fiat_secp256k1_uint1 x69; fiat_secp256k1_addcarryx_u64(&x68, &x69, x67, x60, 0x0); uint64_t x70; uint64_t x71; fiat_secp256k1_mulx_u64(&x70, &x71, x62, UINT64_C(0xd838091dd2253531)); uint64_t x72; uint64_t x73; fiat_secp256k1_mulx_u64(&x72, &x73, x70, UINT64_C(0xffffffffffffffff)); uint64_t x74; uint64_t x75; fiat_secp256k1_mulx_u64(&x74, &x75, x70, UINT64_C(0xffffffffffffffff)); uint64_t x76; uint64_t x77; fiat_secp256k1_mulx_u64(&x76, &x77, x70, UINT64_C(0xffffffffffffffff)); uint64_t x78; uint64_t x79; fiat_secp256k1_mulx_u64(&x78, &x79, x70, UINT64_C(0xfffffffefffffc2f)); uint64_t x80; fiat_secp256k1_uint1 x81; fiat_secp256k1_addcarryx_u64(&x80, &x81, 0x0, x79, x76); uint64_t x82; fiat_secp256k1_uint1 x83; fiat_secp256k1_addcarryx_u64(&x82, &x83, x81, x77, x74); uint64_t x84; fiat_secp256k1_uint1 x85; fiat_secp256k1_addcarryx_u64(&x84, &x85, x83, x75, x72); uint64_t x86; fiat_secp256k1_uint1 x87; fiat_secp256k1_addcarryx_u64(&x86, &x87, 0x0, x62, x78); uint64_t x88; fiat_secp256k1_uint1 x89; fiat_secp256k1_addcarryx_u64(&x88, &x89, x87, x64, x80); uint64_t x90; fiat_secp256k1_uint1 x91; fiat_secp256k1_addcarryx_u64(&x90, &x91, x89, x66, x82); uint64_t x92; fiat_secp256k1_uint1 x93; fiat_secp256k1_addcarryx_u64(&x92, &x93, x91, x68, x84); uint64_t x94; fiat_secp256k1_uint1 x95; fiat_secp256k1_addcarryx_u64(&x94, &x95, x93, ((uint64_t)x69 + x61), (x85 + x73)); uint64_t x96; fiat_secp256k1_uint1 x97; fiat_secp256k1_addcarryx_u64(&x96, &x97, 0x0, x88, (arg1[3])); uint64_t x98; fiat_secp256k1_uint1 x99; fiat_secp256k1_addcarryx_u64(&x98, &x99, x97, x90, 0x0); uint64_t x100; fiat_secp256k1_uint1 x101; fiat_secp256k1_addcarryx_u64(&x100, &x101, x99, x92, 0x0); uint64_t x102; fiat_secp256k1_uint1 x103; fiat_secp256k1_addcarryx_u64(&x102, &x103, x101, x94, 0x0); uint64_t x104; uint64_t x105; fiat_secp256k1_mulx_u64(&x104, &x105, x96, UINT64_C(0xd838091dd2253531)); uint64_t x106; uint64_t x107; fiat_secp256k1_mulx_u64(&x106, &x107, x104, UINT64_C(0xffffffffffffffff)); uint64_t x108; uint64_t x109; fiat_secp256k1_mulx_u64(&x108, &x109, x104, UINT64_C(0xffffffffffffffff)); uint64_t x110; uint64_t x111; fiat_secp256k1_mulx_u64(&x110, &x111, x104, UINT64_C(0xffffffffffffffff)); uint64_t x112; uint64_t x113; fiat_secp256k1_mulx_u64(&x112, &x113, x104, UINT64_C(0xfffffffefffffc2f)); uint64_t x114; fiat_secp256k1_uint1 x115; fiat_secp256k1_addcarryx_u64(&x114, &x115, 0x0, x113, x110); uint64_t x116; fiat_secp256k1_uint1 x117; fiat_secp256k1_addcarryx_u64(&x116, &x117, x115, x111, x108); uint64_t x118; fiat_secp256k1_uint1 x119; fiat_secp256k1_addcarryx_u64(&x118, &x119, x117, x109, x106); uint64_t x120; fiat_secp256k1_uint1 x121; fiat_secp256k1_addcarryx_u64(&x120, &x121, 0x0, x96, x112); uint64_t x122; fiat_secp256k1_uint1 x123; fiat_secp256k1_addcarryx_u64(&x122, &x123, x121, x98, x114); uint64_t x124; fiat_secp256k1_uint1 x125; fiat_secp256k1_addcarryx_u64(&x124, &x125, x123, x100, x116); uint64_t x126; fiat_secp256k1_uint1 x127; fiat_secp256k1_addcarryx_u64(&x126, &x127, x125, x102, x118); uint64_t x128; fiat_secp256k1_uint1 x129; fiat_secp256k1_addcarryx_u64(&x128, &x129, x127, ((uint64_t)x103 + x95), (x119 + x107)); uint64_t x130; fiat_secp256k1_uint1 x131; fiat_secp256k1_subborrowx_u64(&x130, &x131, 0x0, x122, UINT64_C(0xfffffffefffffc2f)); uint64_t x132; fiat_secp256k1_uint1 x133; fiat_secp256k1_subborrowx_u64(&x132, &x133, x131, x124, UINT64_C(0xffffffffffffffff)); uint64_t x134; fiat_secp256k1_uint1 x135; fiat_secp256k1_subborrowx_u64(&x134, &x135, x133, x126, UINT64_C(0xffffffffffffffff)); uint64_t x136; fiat_secp256k1_uint1 x137; fiat_secp256k1_subborrowx_u64(&x136, &x137, x135, x128, UINT64_C(0xffffffffffffffff)); uint64_t x138; fiat_secp256k1_uint1 x139; fiat_secp256k1_subborrowx_u64(&x138, &x139, x137, x129, 0x0); uint64_t x140; fiat_secp256k1_cmovznz_u64(&x140, x139, x130, x122); uint64_t x141; fiat_secp256k1_cmovznz_u64(&x141, x139, x132, x124); uint64_t x142; fiat_secp256k1_cmovznz_u64(&x142, x139, x134, x126); uint64_t x143; fiat_secp256k1_cmovznz_u64(&x143, x139, x136, x128); out1[0] = x140; out1[1] = x141; out1[2] = x142; out1[3] = x143; } /* * The function fiat_secp256k1_nonzero outputs a single non-zero word if the input is non-zero and zero otherwise. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * out1 = 0 ↔ eval (from_montgomery arg1) mod m = 0 * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [0x0 ~> 0xffffffffffffffff] */ static void fiat_secp256k1_nonzero(uint64_t* out1, const uint64_t arg1[4]) { uint64_t x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | ((arg1[3]) | (uint64_t)0x0)))); *out1 = x1; } /* * The function fiat_secp256k1_selectznz is a multi-limb conditional select. * Postconditions: * eval out1 = (if arg1 = 0 then eval arg2 else eval arg3) * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_secp256k1_selectznz(uint64_t out1[4], fiat_secp256k1_uint1 arg1, const uint64_t arg2[4], const uint64_t arg3[4]) { uint64_t x1; fiat_secp256k1_cmovznz_u64(&x1, arg1, (arg2[0]), (arg3[0])); uint64_t x2; fiat_secp256k1_cmovznz_u64(&x2, arg1, (arg2[1]), (arg3[1])); uint64_t x3; fiat_secp256k1_cmovznz_u64(&x3, arg1, (arg2[2]), (arg3[2])); uint64_t x4; fiat_secp256k1_cmovznz_u64(&x4, arg1, (arg2[3]), (arg3[3])); out1[0] = x1; out1[1] = x2; out1[2] = x3; out1[3] = x4; } /* * The function fiat_secp256k1_to_bytes serializes a field element in the Montgomery domain to bytes in little-endian order. * Preconditions: * 0 ≤ eval arg1 < m * Postconditions: * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..31] * * Input Bounds: * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] */ static void fiat_secp256k1_to_bytes(uint8_t out1[32], const uint64_t arg1[4]) { uint64_t x1 = (arg1[3]); uint64_t x2 = (arg1[2]); uint64_t x3 = (arg1[1]); uint64_t x4 = (arg1[0]); uint64_t x5 = (x4 >> 8); uint8_t x6 = (uint8_t)(x4 & UINT8_C(0xff)); uint64_t x7 = (x5 >> 8); uint8_t x8 = (uint8_t)(x5 & UINT8_C(0xff)); uint64_t x9 = (x7 >> 8); uint8_t x10 = (uint8_t)(x7 & UINT8_C(0xff)); uint64_t x11 = (x9 >> 8); uint8_t x12 = (uint8_t)(x9 & UINT8_C(0xff)); uint64_t x13 = (x11 >> 8); uint8_t x14 = (uint8_t)(x11 & UINT8_C(0xff)); uint64_t x15 = (x13 >> 8); uint8_t x16 = (uint8_t)(x13 & UINT8_C(0xff)); uint8_t x17 = (uint8_t)(x15 >> 8); uint8_t x18 = (uint8_t)(x15 & UINT8_C(0xff)); uint8_t x19 = (uint8_t)(x17 & UINT8_C(0xff)); uint64_t x20 = (x3 >> 8); uint8_t x21 = (uint8_t)(x3 & UINT8_C(0xff)); uint64_t x22 = (x20 >> 8); uint8_t x23 = (uint8_t)(x20 & UINT8_C(0xff)); uint64_t x24 = (x22 >> 8); uint8_t x25 = (uint8_t)(x22 & UINT8_C(0xff)); uint64_t x26 = (x24 >> 8); uint8_t x27 = (uint8_t)(x24 & UINT8_C(0xff)); uint64_t x28 = (x26 >> 8); uint8_t x29 = (uint8_t)(x26 & UINT8_C(0xff)); uint64_t x30 = (x28 >> 8); uint8_t x31 = (uint8_t)(x28 & UINT8_C(0xff)); uint8_t x32 = (uint8_t)(x30 >> 8); uint8_t x33 = (uint8_t)(x30 & UINT8_C(0xff)); uint8_t x34 = (uint8_t)(x32 & UINT8_C(0xff)); uint64_t x35 = (x2 >> 8); uint8_t x36 = (uint8_t)(x2 & UINT8_C(0xff)); uint64_t x37 = (x35 >> 8); uint8_t x38 = (uint8_t)(x35 & UINT8_C(0xff)); uint64_t x39 = (x37 >> 8); uint8_t x40 = (uint8_t)(x37 & UINT8_C(0xff)); uint64_t x41 = (x39 >> 8); uint8_t x42 = (uint8_t)(x39 & UINT8_C(0xff)); uint64_t x43 = (x41 >> 8); uint8_t x44 = (uint8_t)(x41 & UINT8_C(0xff)); uint64_t x45 = (x43 >> 8); uint8_t x46 = (uint8_t)(x43 & UINT8_C(0xff)); uint8_t x47 = (uint8_t)(x45 >> 8); uint8_t x48 = (uint8_t)(x45 & UINT8_C(0xff)); uint8_t x49 = (uint8_t)(x47 & UINT8_C(0xff)); uint64_t x50 = (x1 >> 8); uint8_t x51 = (uint8_t)(x1 & UINT8_C(0xff)); uint64_t x52 = (x50 >> 8); uint8_t x53 = (uint8_t)(x50 & UINT8_C(0xff)); uint64_t x54 = (x52 >> 8); uint8_t x55 = (uint8_t)(x52 & UINT8_C(0xff)); uint64_t x56 = (x54 >> 8); uint8_t x57 = (uint8_t)(x54 & UINT8_C(0xff)); uint64_t x58 = (x56 >> 8); uint8_t x59 = (uint8_t)(x56 & UINT8_C(0xff)); uint64_t x60 = (x58 >> 8); uint8_t x61 = (uint8_t)(x58 & UINT8_C(0xff)); uint8_t x62 = (uint8_t)(x60 >> 8); uint8_t x63 = (uint8_t)(x60 & UINT8_C(0xff)); out1[0] = x6; out1[1] = x8; out1[2] = x10; out1[3] = x12; out1[4] = x14; out1[5] = x16; out1[6] = x18; out1[7] = x19; out1[8] = x21; out1[9] = x23; out1[10] = x25; out1[11] = x27; out1[12] = x29; out1[13] = x31; out1[14] = x33; out1[15] = x34; out1[16] = x36; out1[17] = x38; out1[18] = x40; out1[19] = x42; out1[20] = x44; out1[21] = x46; out1[22] = x48; out1[23] = x49; out1[24] = x51; out1[25] = x53; out1[26] = x55; out1[27] = x57; out1[28] = x59; out1[29] = x61; out1[30] = x63; out1[31] = x62; } /* * The function fiat_secp256k1_from_bytes deserializes a field element in the Montgomery domain from bytes in little-endian order. * Preconditions: * 0 ≤ bytes_eval arg1 < m * Postconditions: * eval out1 mod m = bytes_eval arg1 mod m * 0 ≤ eval out1 < m * * Input Bounds: * arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] * Output Bounds: * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void fiat_secp256k1_from_bytes(uint64_t out1[4], const uint8_t arg1[32]) { uint64_t x1 = ((uint64_t)(arg1[31]) << 56); uint64_t x2 = ((uint64_t)(arg1[30]) << 48); uint64_t x3 = ((uint64_t)(arg1[29]) << 40); uint64_t x4 = ((uint64_t)(arg1[28]) << 32); uint64_t x5 = ((uint64_t)(arg1[27]) << 24); uint64_t x6 = ((uint64_t)(arg1[26]) << 16); uint64_t x7 = ((uint64_t)(arg1[25]) << 8); uint8_t x8 = (arg1[24]); uint64_t x9 = ((uint64_t)(arg1[23]) << 56); uint64_t x10 = ((uint64_t)(arg1[22]) << 48); uint64_t x11 = ((uint64_t)(arg1[21]) << 40); uint64_t x12 = ((uint64_t)(arg1[20]) << 32); uint64_t x13 = ((uint64_t)(arg1[19]) << 24); uint64_t x14 = ((uint64_t)(arg1[18]) << 16); uint64_t x15 = ((uint64_t)(arg1[17]) << 8); uint8_t x16 = (arg1[16]); uint64_t x17 = ((uint64_t)(arg1[15]) << 56); uint64_t x18 = ((uint64_t)(arg1[14]) << 48); uint64_t x19 = ((uint64_t)(arg1[13]) << 40); uint64_t x20 = ((uint64_t)(arg1[12]) << 32); uint64_t x21 = ((uint64_t)(arg1[11]) << 24); uint64_t x22 = ((uint64_t)(arg1[10]) << 16); uint64_t x23 = ((uint64_t)(arg1[9]) << 8); uint8_t x24 = (arg1[8]); uint64_t x25 = ((uint64_t)(arg1[7]) << 56); uint64_t x26 = ((uint64_t)(arg1[6]) << 48); uint64_t x27 = ((uint64_t)(arg1[5]) << 40); uint64_t x28 = ((uint64_t)(arg1[4]) << 32); uint64_t x29 = ((uint64_t)(arg1[3]) << 24); uint64_t x30 = ((uint64_t)(arg1[2]) << 16); uint64_t x31 = ((uint64_t)(arg1[1]) << 8); uint8_t x32 = (arg1[0]); uint64_t x33 = (x32 + (x31 + (x30 + (x29 + (x28 + (x27 + (x26 + x25))))))); uint64_t x34 = (x33 & UINT64_C(0xffffffffffffffff)); uint64_t x35 = (x8 + (x7 + (x6 + (x5 + (x4 + (x3 + (x2 + x1))))))); uint64_t x36 = (x16 + (x15 + (x14 + (x13 + (x12 + (x11 + (x10 + x9))))))); uint64_t x37 = (x24 + (x23 + (x22 + (x21 + (x20 + (x19 + (x18 + x17))))))); uint64_t x38 = (x37 & UINT64_C(0xffffffffffffffff)); uint64_t x39 = (x36 & UINT64_C(0xffffffffffffffff)); out1[0] = x34; out1[1] = x38; out1[2] = x39; out1[3] = x35; }