Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
scalar_4x64_impl.h File Reference
#include "modinv64_impl.h"
Include dependency graph for scalar_4x64_impl.h:

Go to the source code of this file.

Macros

#define SECP256K1_N_0   ((uint64_t)0xBFD25E8CD0364141ULL)
 
#define SECP256K1_N_1   ((uint64_t)0xBAAEDCE6AF48A03BULL)
 
#define SECP256K1_N_2   ((uint64_t)0xFFFFFFFFFFFFFFFEULL)
 
#define SECP256K1_N_3   ((uint64_t)0xFFFFFFFFFFFFFFFFULL)
 
#define SECP256K1_N_C_0   (~SECP256K1_N_0 + 1)
 
#define SECP256K1_N_C_1   (~SECP256K1_N_1)
 
#define SECP256K1_N_C_2   (1)
 
#define SECP256K1_N_H_0   ((uint64_t)0xDFE92F46681B20A0ULL)
 
#define SECP256K1_N_H_1   ((uint64_t)0x5D576E7357A4501DULL)
 
#define SECP256K1_N_H_2   ((uint64_t)0xFFFFFFFFFFFFFFFFULL)
 
#define SECP256K1_N_H_3   ((uint64_t)0x7FFFFFFFFFFFFFFFULL)
 
#define muladd(a, b)
 
#define muladd_fast(a, b)
 
#define sumadd(a)
 
#define sumadd_fast(a)
 
#define extract(n)
 
#define extract_fast(n)
 

Macro Definition Documentation

◆ extract

#define extract ( n)
Value:
{ \
(n) = c0; \
c0 = c1; \
c1 = c2; \
c2 = 0; \
}

Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits.

Definition at line 235 of file scalar_4x64_impl.h.

235#define extract(n) { \
236 (n) = c0; \
237 c0 = c1; \
238 c1 = c2; \
239 c2 = 0; \
240}

◆ extract_fast

#define extract_fast ( n)
Value:
{ \
(n) = c0; \
c0 = c1; \
c1 = 0; \
VERIFY_CHECK(c2 == 0); \
}

Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits. c2 is required to be zero.

Definition at line 243 of file scalar_4x64_impl.h.

243#define extract_fast(n) { \
244 (n) = c0; \
245 c0 = c1; \
246 c1 = 0; \
247 VERIFY_CHECK(c2 == 0); \
248}

◆ muladd

#define muladd ( a,
b )
Value:
{ \
uint64_t tl, th; \
{ \
uint128_t t = (uint128_t)a * b; \
th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \
tl = t; \
} \
c0 += tl; /* overflow is handled on the next line */ \
th += (c0 < tl); /* at most 0xFFFFFFFFFFFFFFFF */ \
c1 += th; /* overflow is handled on the next line */ \
c2 += (c1 < th); /* never overflows by contract (verified in the next line) */ \
VERIFY_CHECK((c1 >= th) || (c2 != 0)); \
}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
unsigned __int64 uint64_t
Definition stdint.h:136

Add a*b to the number defined by (c0,c1,c2). c2 must never overflow.

Definition at line 189 of file scalar_4x64_impl.h.

189#define muladd(a,b) { \
190 uint64_t tl, th; \
191 { \
192 uint128_t t = (uint128_t)a * b; \
193 th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \
194 tl = t; \
195 } \
196 c0 += tl; /* overflow is handled on the next line */ \
197 th += (c0 < tl); /* at most 0xFFFFFFFFFFFFFFFF */ \
198 c1 += th; /* overflow is handled on the next line */ \
199 c2 += (c1 < th); /* never overflows by contract (verified in the next line) */ \
200 VERIFY_CHECK((c1 >= th) || (c2 != 0)); \
201}

◆ muladd_fast

#define muladd_fast ( a,
b )
Value:
{ \
uint64_t tl, th; \
{ \
uint128_t t = (uint128_t)a * b; \
th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \
tl = t; \
} \
c0 += tl; /* overflow is handled on the next line */ \
th += (c0 < tl); /* at most 0xFFFFFFFFFFFFFFFF */ \
c1 += th; /* never overflows by contract (verified in the next line) */ \
VERIFY_CHECK(c1 >= th); \
}

Add a*b to the number defined by (c0,c1). c1 must never overflow.

Definition at line 204 of file scalar_4x64_impl.h.

204#define muladd_fast(a,b) { \
205 uint64_t tl, th; \
206 { \
207 uint128_t t = (uint128_t)a * b; \
208 th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \
209 tl = t; \
210 } \
211 c0 += tl; /* overflow is handled on the next line */ \
212 th += (c0 < tl); /* at most 0xFFFFFFFFFFFFFFFF */ \
213 c1 += th; /* never overflows by contract (verified in the next line) */ \
214 VERIFY_CHECK(c1 >= th); \
215}

◆ SECP256K1_N_0

#define SECP256K1_N_0   ((uint64_t)0xBFD25E8CD0364141ULL)

Definition at line 13 of file scalar_4x64_impl.h.

◆ SECP256K1_N_1

#define SECP256K1_N_1   ((uint64_t)0xBAAEDCE6AF48A03BULL)

Definition at line 14 of file scalar_4x64_impl.h.

◆ SECP256K1_N_2

#define SECP256K1_N_2   ((uint64_t)0xFFFFFFFFFFFFFFFEULL)

Definition at line 15 of file scalar_4x64_impl.h.

◆ SECP256K1_N_3

#define SECP256K1_N_3   ((uint64_t)0xFFFFFFFFFFFFFFFFULL)

Definition at line 16 of file scalar_4x64_impl.h.

◆ SECP256K1_N_C_0

#define SECP256K1_N_C_0   (~SECP256K1_N_0 + 1)

Definition at line 19 of file scalar_4x64_impl.h.

◆ SECP256K1_N_C_1

#define SECP256K1_N_C_1   (~SECP256K1_N_1)

Definition at line 20 of file scalar_4x64_impl.h.

◆ SECP256K1_N_C_2

#define SECP256K1_N_C_2   (1)

Definition at line 21 of file scalar_4x64_impl.h.

◆ SECP256K1_N_H_0

#define SECP256K1_N_H_0   ((uint64_t)0xDFE92F46681B20A0ULL)

Definition at line 24 of file scalar_4x64_impl.h.

◆ SECP256K1_N_H_1

#define SECP256K1_N_H_1   ((uint64_t)0x5D576E7357A4501DULL)

Definition at line 25 of file scalar_4x64_impl.h.

◆ SECP256K1_N_H_2

#define SECP256K1_N_H_2   ((uint64_t)0xFFFFFFFFFFFFFFFFULL)

Definition at line 26 of file scalar_4x64_impl.h.

◆ SECP256K1_N_H_3

#define SECP256K1_N_H_3   ((uint64_t)0x7FFFFFFFFFFFFFFFULL)

Definition at line 27 of file scalar_4x64_impl.h.

◆ sumadd

#define sumadd ( a)
Value:
{ \
unsigned int over; \
c0 += (a); /* overflow is handled on the next line */ \
over = (c0 < (a)); \
c1 += over; /* overflow is handled on the next line */ \
c2 += (c1 < over); /* never overflows by contract */ \
}

Add a to the number defined by (c0,c1,c2). c2 must never overflow.

Definition at line 218 of file scalar_4x64_impl.h.

218#define sumadd(a) { \
219 unsigned int over; \
220 c0 += (a); /* overflow is handled on the next line */ \
221 over = (c0 < (a)); \
222 c1 += over; /* overflow is handled on the next line */ \
223 c2 += (c1 < over); /* never overflows by contract */ \
224}

◆ sumadd_fast

#define sumadd_fast ( a)
Value:
{ \
c0 += (a); /* overflow is handled on the next line */ \
c1 += (c0 < (a)); /* never overflows by contract (verified the next line) */ \
VERIFY_CHECK((c1 != 0) | (c0 >= (a))); \
VERIFY_CHECK(c2 == 0); \
}

Add a to the number defined by (c0,c1). c1 must never overflow, c2 must be zero.

Definition at line 227 of file scalar_4x64_impl.h.

227#define sumadd_fast(a) { \
228 c0 += (a); /* overflow is handled on the next line */ \
229 c1 += (c0 < (a)); /* never overflows by contract (verified the next line) */ \
230 VERIFY_CHECK((c1 != 0) | (c0 >= (a))); \
231 VERIFY_CHECK(c2 == 0); \
232}