Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
fp-karatsuba.c File Reference
#include "fp-karatsuba.h"
#include "../fp-counters.h"
#include "../../primes.h"
#include <gmp.h>
Include dependency graph for fp-karatsuba.c:

Go to the source code of this file.

Macros

#define pbits   2047
#define itch_size   128

Functions

void fp_pow (fp b, const fp e, const fp a)
void fp_mul (fp c, const fp a, const fp b)
void fp_add (fp c, const fp a, const fp b)
void fp_sub (fp c, const fp a, const fp b)
void fp_sqr (fp b, const fp a)
void fp_mont_redc (fp a, const uint64_t b[2 *NUMBER_OF_WORDS])

Macro Definition Documentation

◆ itch_size

#define itch_size   128

Definition at line 14 of file fp-karatsuba.c.

Referenced by fp_inv(), fp_mont_redc(), and fp_mul().

◆ pbits

#define pbits   2047

Definition at line 13 of file fp-karatsuba.c.

Referenced by fp_random().

Function Documentation

◆ fp_add()

void fp_add ( fp c,
const fp a,
const fp b )

Definition at line 40 of file fp-karatsuba.c.

41{
42
43 fp_add_s(c, a, b);
45}
#define CNT_FP_ADD_INC()
Definition fp-counters.h:29
#define fp_add_s
f a
Definition to_model.m:12

References a, CNT_FP_ADD_INC, and fp_add_s.

◆ fp_mont_redc()

void fp_mont_redc ( fp a,
const uint64_t b[2 *NUMBER_OF_WORDS] )

Definition at line 100 of file fp-karatsuba.c.

101{
102
103 static __thread uint64_t tp[itch_size];
104 uint64_t A[2 * NUMBER_OF_WORDS + 1] = {0x0};
105 // uint64_t a_i[1] = {0x0};
106 uint64_t tmp_1[NUMBER_OF_WORDS + 1] = {0x0};
107
108 // 1. A = T
109 mpn_copyd(A, b, 2 * NUMBER_OF_WORDS);
110
111 for (int i = 0; i < NUMBER_OF_WORDS; i++)
112 {
113 // 2.1 u_i = a_i * m' mod b
114 // since montgomery friendly m' = 1
115 // a_i[0] = A[i];
116
117 // 2.2 tmp_1 = u_i * m
118 mpn_sec_mul(tmp_1, p, NUMBER_OF_WORDS, &A[i], 1, tp);
119
120 // 2.2 A = A + u_i * m * b^i
121 mpn_add(A + i, A + i, 2 * NUMBER_OF_WORDS + 1 - i, tmp_1, NUMBER_OF_WORDS + 1);
122
123 }
124
125 // 3. A = A/b^n
126 mpn_copyd(a, A + NUMBER_OF_WORDS, NUMBER_OF_WORDS);
127
128 // 4. If A > m then A = A - m
129 mpn_cnd_sub_n(mpn_cmp(a, p, NUMBER_OF_WORDS) > 0, a, a, p, NUMBER_OF_WORDS);
130}
#define p
Definition fp-gmp.h:44
#define itch_size
A
Definition tests.py:29
for i

References a, i, itch_size, and p.

Referenced by fp_sqr().

Here is the caller graph for this function:

◆ fp_mul()

void fp_mul ( fp c,
const fp a,
const fp b )

Definition at line 31 of file fp-karatsuba.c.

32{
33// #if defined(P2047m1l226)
34 uint64_t result[64] = {0};
35 fp_mult_32x32(result, a, b);
36 fp_word_redc(c, result);
38}
#define CNT_FP_MUL_INC()
Definition fp-counters.h:30

References a, and CNT_FP_MUL_INC.

◆ fp_pow()

void fp_pow ( fp b,
const fp e,
const fp a )

Definition at line 20 of file fp-karatsuba.c.

21{
22 (void) a;
23 (void) b;
24 (void) e;
25}

References a.

◆ fp_sqr()

void fp_sqr ( fp b,
const fp a )

Definition at line 55 of file fp-karatsuba.c.

56{
57
58 uint64_t result[64];
59 fp_squaring(result, a, a);
60 fp_word_redc(b, result);
61
63}
#define CNT_FP_SQR_INC()
Definition fp-counters.h:32
#define fp_squaring

References a, CNT_FP_SQR_INC, and fp_squaring.

◆ fp_sub()

void fp_sub ( fp c,
const fp a,
const fp b )

Definition at line 47 of file fp-karatsuba.c.

48{
49
50 fp_sub_s(c, a, b);
52}
#define fp_sub_s

References a, CNT_FP_ADD_INC, and fp_sub_s.