Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
secp256k1
src
ecmult_compute_table_impl.h
Go to the documentation of this file.
1
/*****************************************************************************************************
2
* Copyright (c) 2013, 2014, 2017, 2021 Pieter Wuille, Andrew Poelstra, Jonas Nick, Russell O'Connor *
3
* Distributed under the MIT software license, see the accompanying *
4
* file COPYING or https://www.opensource.org/licenses/mit-license.php. *
5
*****************************************************************************************************/
6
7
#ifndef SECP256K1_ECMULT_COMPUTE_TABLE_IMPL_H
8
#define SECP256K1_ECMULT_COMPUTE_TABLE_IMPL_H
9
10
#include "
ecmult_compute_table.h
"
11
#include "
group_impl.h
"
12
#include "
field_impl.h
"
13
#include "
ecmult.h
"
14
#include "
util.h
"
15
16
static
void
secp256k1_ecmult_compute_table
(
secp256k1_ge_storage
* table,
int
window_g,
const
secp256k1_gej
* gen) {
17
secp256k1_gej
gj;
18
secp256k1_ge
ge, dgen;
19
size_t
j;
20
21
gj = *gen;
22
secp256k1_ge_set_gej_var
(&ge, &gj);
23
secp256k1_ge_to_storage
(&table[0], &ge);
24
25
secp256k1_gej_double_var
(&gj, gen, NULL);
26
secp256k1_ge_set_gej_var
(&dgen, &gj);
27
28
for
(j = 1; j <
ECMULT_TABLE_SIZE
(window_g); ++j) {
29
secp256k1_gej_set_ge
(&gj, &ge);
30
secp256k1_gej_add_ge_var
(&gj, &gj, &dgen, NULL);
31
secp256k1_ge_set_gej_var
(&ge, &gj);
32
secp256k1_ge_to_storage
(&table[j], &ge);
33
}
34
}
35
36
/* Like secp256k1_ecmult_compute_table, but one for both gen and gen*2^128. */
37
static
void
secp256k1_ecmult_compute_two_tables
(
secp256k1_ge_storage
* table,
secp256k1_ge_storage
* table_128,
int
window_g,
const
secp256k1_ge
* gen) {
38
secp256k1_gej
gj;
39
int
i;
40
41
secp256k1_gej_set_ge
(&gj, gen);
42
secp256k1_ecmult_compute_table
(table, window_g, &gj);
43
for
(i = 0; i < 128; ++i) {
44
secp256k1_gej_double_var
(&gj, &gj, NULL);
45
}
46
secp256k1_ecmult_compute_table
(table_128, window_g, &gj);
47
}
48
49
#endif
/* SECP256K1_ECMULT_COMPUTE_TABLE_IMPL_H */
ecmult.h
ECMULT_TABLE_SIZE
#define ECMULT_TABLE_SIZE(w)
The number of entries a table with precomputed multiples needs to have.
Definition
ecmult.h:41
ecmult_compute_table.h
secp256k1_ecmult_compute_table
static void secp256k1_ecmult_compute_table(secp256k1_ge_storage *table, int window_g, const secp256k1_gej *gen)
Definition
ecmult_compute_table_impl.h:16
secp256k1_ecmult_compute_two_tables
static void secp256k1_ecmult_compute_two_tables(secp256k1_ge_storage *table, secp256k1_ge_storage *table_128, int window_g, const secp256k1_ge *gen)
Definition
ecmult_compute_table_impl.h:37
field_impl.h
secp256k1_gej_double_var
static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr)
Set r equal to the double of a.
secp256k1_gej_add_ge_var
static void secp256k1_gej_add_ge_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, secp256k1_fe *rzr)
Set r equal to the sum of a and b (with b given in affine coordinates).
secp256k1_gej_set_ge
static void secp256k1_gej_set_ge(secp256k1_gej *r, const secp256k1_ge *a)
Set a group element (jacobian) equal to another which is given in affine coordinates.
secp256k1_ge_to_storage
static void secp256k1_ge_to_storage(secp256k1_ge_storage *r, const secp256k1_ge *a)
Convert a group element to the storage type.
secp256k1_ge_set_gej_var
static void secp256k1_ge_set_gej_var(secp256k1_ge *r, secp256k1_gej *a)
Set a group element equal to another which is given in jacobian coordinates.
group_impl.h
util.h
secp256k1_ge_storage
Definition
group.h:38
secp256k1_ge
A group element in affine coordinates on the secp256k1 curve, or occasionally on an isomorphic curve ...
Definition
group.h:16
secp256k1_gej
A group element of the secp256k1 curve, in jacobian coordinates.
Definition
group.h:28
Generated on
for Bitcoin Core by
1.17.0