/* Autogenerated: 'src/ExtractionOCaml/bedrock2_solinas_reduction' --lang bedrock2 --static --no-wide-int --widen-carry --widen-bytes --split-multiret --no-select --no-field-element-typedefs curve25519_solinas 64 '2^255 - 19' mul square */ /* curve description: curve25519_solinas */ /* machine_wordsize = 64 (from "64") */ /* requested operations: mul, square */ /* s-c = 2^255 - [(1, 19)] (from "2^255 - 19") */ /* */ /* Computed values: */ /* */ // Generated from Bedrock code. Avoid editing directly. #include #include #include #define BR_WORD_MAX UINTPTR_MAX typedef uintptr_t br_word_t; typedef intptr_t br_signed_t; static_assert(sizeof(br_word_t) == sizeof(br_signed_t), "signed size"); static_assert(UINTPTR_MAX <= BR_WORD_MAX, "pointer fits in int"); static_assert(~(br_signed_t)0 == -(br_signed_t)1, "two's complement"); #if __STDC_VERSION__ >= 202311L && __has_include() #include static_assert(__STDC_ENDIAN_NATIVE__ == __STDC_ENDIAN_LITTLE__, "little-endian"); #elif defined(__GNUC__) && defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) static_assert(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__, "little-endian"); #elif defined(_MSC_VER) && !defined(__clang__) && \ (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64)) // these MSVC targets are little-endian #else #error "failed to confirm that target is little-endian" #endif // "An object shall have its stored value accessed only ... a character type." static inline br_word_t _br_load1(br_word_t a) { return *((uint8_t *)a); } static inline br_word_t _br_load2(br_word_t a) { uint16_t r = 0; memcpy(&r, (void *)a, sizeof(r)); return r; } static inline br_word_t _br_load4(br_word_t a) { uint32_t r = 0; memcpy(&r, (void *)a, sizeof(r)); return r; } static inline br_word_t _br_load(br_word_t a) { br_word_t r = 0; memcpy(&r, (void *)a, sizeof(r)); return r; } static inline void _br_store1(br_word_t a, uint8_t v) { *((uint8_t *)a) = v; } static inline void _br_store2(br_word_t a, uint16_t v) { memcpy((void *)a, &v, sizeof(v)); } static inline void _br_store4(br_word_t a, uint32_t v) { memcpy((void *)a, &v, sizeof(v)); } static inline void _br_store(br_word_t a, br_word_t v) { memcpy((void *)a, &v, sizeof(v)); } static inline br_word_t _br_mulhuu(br_word_t a, br_word_t b) { #if BR_WORD_MAX == UINT32_MAX return ((uint64_t)a * b) >> 32; #elif BR_WORD_MAX == UINT64_MAX && (defined(__GNUC__) || defined(__clang__)) return ((unsigned __int128)a * b) >> 64; #elif defined(_M_X64) uint64_t hi; _umul128(a, b, &hi); return hi; #elif defined(_M_ARM64) return __umulh(a, b); #else // See full_mul.v br_word_t hh, lh, hl, low, second_halfword_w_oflow, n, ll, M; n = ((((0u-(br_word_t)0x1)>>27)&0x3f)+0x1)>>1; M = ((br_word_t)0x1<>n); hl = (a>>n)*(b&M); hh = (a>>n)*(b>>n); second_halfword_w_oflow = ((ll>>n)+(lh&M))+(hl&M); return ((hh+(lh>>n))+(hl>>n))+(second_halfword_w_oflow>>n); #endif } static inline br_word_t _br_divu(br_word_t a, br_word_t b) { if (!b) return -1; return a/b; } static inline br_word_t _br_remu(br_word_t a, br_word_t b) { if (!b) return a; return a%b; } /* * Input Bounds: * in0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * in1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_curve25519_solinas_mul(br_word_t out0, br_word_t in0, br_word_t in1) { br_word_t x3, x2, x1, x7, x6, x5, x0, x4, x14, x35, x41, x33, x42, x12, x43, x45, x46, x25, x20, x40, x49, x44, x50, x15, x51, x53, x54, x47, x56, x17, x22, x37, x59, x48, x60, x23, x61, x63, x64, x52, x65, x18, x66, x68, x69, x55, x70, x10, x71, x73, x74, x57, x76, x9, x28, x58, x79, x62, x80, x26, x81, x83, x84, x67, x85, x21, x86, x88, x89, x72, x90, x13, x91, x93, x94, x75, x96, x77, x30, x39, x99, x78, x100, x31, x101, x103, x104, x82, x105, x29, x106, x108, x109, x87, x110, x24, x111, x113, x114, x92, x115, x16, x116, x118, x119, x95, x120, x8, x121, x123, x124, x97, x36, x98, x127, x102, x128, x34, x129, x131, x132, x107, x133, x32, x134, x136, x137, x112, x138, x27, x139, x141, x142, x117, x143, x19, x144, x146, x147, x122, x148, x11, x149, x151, x152, x125, x153, x150, x145, x140, x158, x126, x163, x130, x164, x156, x165, x167, x168, x135, x169, x154, x170, x172, x173, x155, x160, x38, x176, x162, x177, x161, x178, x180, x181, x166, x182, x159, x183, x185, x186, x171, x187, x157, x188, x190, x191, x174, x192, x193, x175, x195, x179, x197, x184, x199, x189, x201, x202, x203, x204, x194, x205, x196, x198, x200, x206, x207, x208, x209; x0 = _br_load(in0+0); x1 = _br_load(in0+8); x2 = _br_load(in0+16); x3 = _br_load(in0+24); /*skip*/ x4 = _br_load(in1+0); x5 = _br_load(in1+8); x6 = _br_load(in1+16); x7 = _br_load(in1+24); /*skip*/ /*skip*/ x8 = x3*x7; x9 = _br_mulhuu(x3, x7); x10 = x3*x6; x11 = _br_mulhuu(x3, x6); x12 = x3*x5; x13 = _br_mulhuu(x3, x5); x14 = x3*x4; x15 = _br_mulhuu(x3, x4); x16 = x2*x7; x17 = _br_mulhuu(x2, x7); x18 = x2*x6; x19 = _br_mulhuu(x2, x6); x20 = x2*x5; x21 = _br_mulhuu(x2, x5); x22 = x2*x4; x23 = _br_mulhuu(x2, x4); x24 = x1*x7; x25 = _br_mulhuu(x1, x7); x26 = x1*x6; x27 = _br_mulhuu(x1, x6); x28 = x1*x5; x29 = _br_mulhuu(x1, x5); x30 = x1*x4; x31 = _br_mulhuu(x1, x4); x32 = x0*x7; x33 = _br_mulhuu(x0, x7); x34 = x0*x6; x35 = _br_mulhuu(x0, x6); x36 = x0*x5; x37 = _br_mulhuu(x0, x5); x38 = x0*x4; x39 = _br_mulhuu(x0, x4); x40 = x35+x14; x41 = (br_word_t)(x40 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] * Output Bounds: * out0: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ static void internal_fiat_curve25519_solinas_square(br_word_t out0, br_word_t in0) { br_word_t x6, x9, x15, x7, x16, x4, x17, x19, x20, x5, x21, x12, x22, x24, x25, x13, x26, x10, x27, x29, x30, x11, x32, x18, x35, x23, x36, x33, x37, x39, x40, x28, x42, x31, x8, x46, x47, x14, x48, x50, x51, x52, x34, x53, x55, x56, x57, x38, x58, x60, x61, x62, x41, x63, x65, x66, x67, x43, x68, x70, x71, x44, x3, x2, x1, x0, x80, x45, x82, x49, x83, x77, x84, x86, x87, x54, x88, x78, x89, x91, x92, x59, x93, x75, x94, x96, x97, x64, x98, x76, x99, x101, x102, x69, x103, x73, x104, x106, x107, x72, x108, x74, x109, x105, x100, x95, x114, x81, x119, x85, x120, x112, x121, x123, x124, x90, x125, x110, x126, x128, x129, x111, x116, x79, x132, x118, x133, x117, x134, x136, x137, x122, x138, x115, x139, x141, x142, x127, x143, x113, x144, x146, x147, x130, x148, x149, x131, x151, x135, x153, x140, x155, x145, x157, x158, x159, x160, x150, x161, x152, x154, x156, x162, x163, x164, x165; x0 = _br_load(in0+0); x1 = _br_load(in0+8); x2 = _br_load(in0+16); x3 = _br_load(in0+24); /*skip*/ /*skip*/ x4 = x0*x3; x5 = _br_mulhuu(x0, x3); x6 = x0*x2; x7 = _br_mulhuu(x0, x2); x8 = x0*x1; x9 = _br_mulhuu(x0, x1); x10 = x3*x2; x11 = _br_mulhuu(x3, x2); x12 = x3*x1; x13 = _br_mulhuu(x3, x1); x14 = x9+x6; x15 = (br_word_t)(x14