]> Git Repo - secp256k1.git/blame - src/field_5x52.h
Merge #459: Add pubkey prefix constants to include/secp256k1.h
[secp256k1.git] / src / field_5x52.h
CommitLineData
71712b27
GM
1/**********************************************************************
2 * Copyright (c) 2013, 2014 Pieter Wuille *
3 * Distributed under the MIT software license, see the accompanying *
4 * file COPYING or http://www.opensource.org/licenses/mit-license.php.*
5 **********************************************************************/
0a433ea2 6
7a4b7691
PW
7#ifndef _SECP256K1_FIELD_REPR_
8#define _SECP256K1_FIELD_REPR_
e6d142a8 9
e6d142a8 10#include <stdint.h>
e6d142a8 11
910d0de4 12typedef struct {
71712b27 13 /* X = sum(i=0..4, elem[i]*2^52) mod n */
e6d142a8 14 uint64_t n[5];
910d0de4 15#ifdef VERIFY
e6d142a8 16 int magnitude;
910d0de4 17 int normalized;
e6d142a8 18#endif
dd891e0e 19} secp256k1_fe;
e6d142a8 20
6efd6e77 21/* Unpacks a constant into a overlapping multi-limbed FE element. */
4732d260 22#define SECP256K1_FE_CONST_INNER(d7, d6, d5, d4, d3, d2, d1, d0) { \
cfe0ed91
GM
23 (d0) | (((uint64_t)(d1) & 0xFFFFFUL) << 32), \
24 ((uint64_t)(d1) >> 20) | (((uint64_t)(d2)) << 12) | (((uint64_t)(d3) & 0xFFUL) << 44), \
25 ((uint64_t)(d3) >> 8) | (((uint64_t)(d4) & 0xFFFFFFFUL) << 24), \
26 ((uint64_t)(d4) >> 28) | (((uint64_t)(d5)) << 4) | (((uint64_t)(d6) & 0xFFFFUL) << 36), \
27 ((uint64_t)(d6) >> 16) | (((uint64_t)(d7)) << 16) \
4732d260
PW
28}
29
30#ifdef VERIFY
31#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0)), 1, 1}
32#else
33#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0))}
34#endif
35
ff889f7d
PW
36typedef struct {
37 uint64_t n[4];
dd891e0e 38} secp256k1_fe_storage;
ff889f7d
PW
39
40#define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{ \
cfe0ed91
GM
41 (d0) | (((uint64_t)(d1)) << 32), \
42 (d2) | (((uint64_t)(d3)) << 32), \
43 (d4) | (((uint64_t)(d5)) << 32), \
44 (d6) | (((uint64_t)(d7)) << 32) \
ff889f7d
PW
45}}
46
e6d142a8 47#endif
This page took 0.038136 seconds and 4 git commands to generate.