Electroneum
Loading...
Searching...
No Matches
crypto-ops.h
Go to the documentation of this file.
1// Copyrights(c) 2017-2021, The Electroneum Project
2// Copyrights(c) 2014-2019, The Monero Project
3//
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without modification, are
7// permitted provided that the following conditions are met:
8//
9// 1. Redistributions of source code must retain the above copyright notice, this list of
10// conditions and the following disclaimer.
11//
12// 2. Redistributions in binary form must reproduce the above copyright notice, this list
13// of conditions and the following disclaimer in the documentation and/or other
14// materials provided with the distribution.
15//
16// 3. Neither the name of the copyright holder nor the names of its contributors may be
17// used to endorse or promote products derived from this software without specific
18// prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//
30// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31#include <stdint.h>
32
33#pragma once
34
35
36/* From fe.h */
37
38//this guy may throw errors in windows
39typedef int32_t fe[10];
40
41/* From ge.h */
42
43typedef struct {
44 fe X;
45 fe Y;
46 fe Z;
47} ge_p2;
48
49typedef struct {
50 fe X;
51 fe Y;
52 fe Z;
53 fe T;
54} ge_p3;
55
56typedef struct {
57 fe X;
58 fe Y;
59 fe Z;
60 fe T;
61} ge_p1p1;
62
63typedef struct {
64 fe yplusx;
65 fe yminusx;
66 fe xy2d;
68
69typedef struct {
70 fe YplusX;
71 fe YminusX;
72 fe Z;
73 fe T2d;
74} ge_cached;
75
76/* From ge_add.c */
77
78void ge_add(ge_p1p1 *, const ge_p3 *, const ge_cached *);
79
80/* From ge_double_scalarmult.c, modified */
81
82typedef ge_cached ge_dsmp[8];
83extern const ge_precomp ge_Bi[8];
84void ge_dsm_precomp(ge_dsmp r, const ge_p3 *s);
85void ge_double_scalarmult_base_vartime(ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *);
86
87/* From ge_frombytes.c, modified */
88
89extern const fe fe_sqrtm1;
90extern const fe fe_d;
91int ge_frombytes_vartime(ge_p3 *, const unsigned char *);
92
93/* From ge_p1p1_to_p2.c */
94
95void ge_p1p1_to_p2(ge_p2 *, const ge_p1p1 *);
96
97/* From ge_p1p1_to_p3.c */
98
99void ge_p1p1_to_p3(ge_p3 *, const ge_p1p1 *);
100
101/* From ge_p2_dbl.c */
102
103void ge_p2_dbl(ge_p1p1 *, const ge_p2 *);
104
105/* From ge_p3_to_cached.c */
106
107extern const fe fe_d2;
109
110/* From ge_p3_to_p2.c */
111
112void ge_p3_to_p2(ge_p2 *, const ge_p3 *);
113
114/* From ge_p3_tobytes.c */
115
116void ge_p3_tobytes(unsigned char *, const ge_p3 *);
117
118/* From ge_scalarmult_base.c */
119
120extern const ge_precomp ge_base[32][8];
121void ge_scalarmult_base(ge_p3 *, const unsigned char *);
122
123/* From ge_tobytes.c */
124
125void ge_tobytes(unsigned char *, const ge_p2 *);
126
127/* From sc_reduce.c */
128
129void sc_reduce(unsigned char *);
130
131/* New code */
132
133void ge_scalarmult(ge_p2 *, const unsigned char *, const ge_p3 *);
134void ge_double_scalarmult_precomp_vartime(ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *, const ge_dsmp);
135void ge_mul8(ge_p1p1 *, const ge_p2 *);
136extern const fe fe_ma2;
137extern const fe fe_ma;
138extern const fe fe_fffb1;
139extern const fe fe_fffb2;
140extern const fe fe_fffb3;
141extern const fe fe_fffb4;
142void ge_fromfe_frombytes_vartime(ge_p2 *, const unsigned char *);
143void sc_0(unsigned char *);
144void sc_reduce32(unsigned char *);
145void sc_add(unsigned char *, const unsigned char *, const unsigned char *);
146void sc_sub(unsigned char *, const unsigned char *, const unsigned char *);
147void sc_mulsub(unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *);
148int sc_check(const unsigned char *);
149int sc_isnonzero(const unsigned char *); /* Doesn't normalize */
const fe fe_fffb4
const fe fe_d2
void ge_double_scalarmult_precomp_vartime(ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *, const ge_dsmp)
void sc_0(unsigned char *)
const fe fe_fffb3
ge_cached ge_dsmp[8]
Definition crypto-ops.h:79
const fe fe_ma2
int32_t fe[10]
Definition crypto-ops.h:36
const fe fe_ma
const ge_precomp ge_base[32][8]
void sc_reduce32(unsigned char *)
void ge_dsm_precomp(ge_dsmp r, const ge_p3 *s)
int ge_frombytes_vartime(ge_p3 *, const unsigned char *)
const fe fe_d
void sc_sub(unsigned char *, const unsigned char *, const unsigned char *)
const fe fe_fffb1
void sc_mulsub(unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *)
void ge_mul8(ge_p1p1 *, const ge_p2 *)
const ge_precomp ge_Bi[8]
int sc_check(const unsigned char *)
void ge_double_scalarmult_base_vartime(ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *)
const fe fe_sqrtm1
int sc_isnonzero(const unsigned char *)
void sc_add(unsigned char *, const unsigned char *, const unsigned char *)
void ge_fromfe_frombytes_vartime(ge_p2 *, const unsigned char *)
void ge_scalarmult(ge_p2 *, const unsigned char *, const ge_p3 *)
const fe fe_fffb2
#define ge_scalarmult_base
Definition ge.h:71
#define ge_p1p1_to_p2
Definition ge.h:62
#define ge_p1p1_to_p3
Definition ge.h:63
#define ge_p3_tobytes
Definition ge.h:55
#define ge_p3_to_cached
Definition ge.h:61
#define ge_add
Definition ge.h:69
#define ge_p3_to_p2
Definition ge.h:60
#define ge_p2_dbl
Definition ge.h:64
#define ge_tobytes
Definition ge.h:54
#define sc_reduce
Definition sc.h:9
signed int int32_t
Definition stdint.h:123
#define T(x)