gnunet-android

GNUnet for Android
Log | Files | Refs | README

ge_448.h (2374B)


      1 /* ge_448.h
      2  *
      3  * Copyright (C) 2006-2025 wolfSSL Inc.
      4  *
      5  * This file is part of wolfSSL.
      6  *
      7  * wolfSSL is free software; you can redistribute it and/or modify
      8  * it under the terms of the GNU General Public License as published by
      9  * the Free Software Foundation; either version 3 of the License, or
     10  * (at your option) any later version.
     11  *
     12  * wolfSSL is distributed in the hope that it will be useful,
     13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15  * GNU General Public License for more details.
     16  *
     17  * You should have received a copy of the GNU General Public License
     18  * along with this program; if not, write to the Free Software
     19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
     20  */
     21 
     22 
     23 #ifndef WOLF_CRYPT_GE_448_H
     24 #define WOLF_CRYPT_GE_448_H
     25 
     26 #include <wolfssl/wolfcrypt/settings.h>
     27 
     28 #ifdef HAVE_ED448
     29 
     30 #include <wolfssl/wolfcrypt/fe_448.h>
     31 
     32 /*
     33 ge448 means group element.
     34 
     35 Here the group is the set of pairs (x,y) of field elements (see fe.h)
     36 satisfying -x^2 + y^2 = 1 + d x^2y^2
     37 where d = -39081.
     38 
     39 Representations:
     40   ge448_p2 (projective) : (X:Y:Z) satisfying x=X/Z, y=Y/Z
     41   ge448_precomp (affine): (x,y)
     42 */
     43 
     44 #ifdef ED448_SMALL
     45     typedef byte     ge448;
     46     #define GE448_WORDS    56
     47 #elif defined(CURVED448_128BIT)
     48     typedef sword64  ge448;
     49     #define GE448_WORDS    8
     50 #else
     51     typedef sword32  ge448;
     52     #define GE448_WORDS    16
     53 #endif
     54 
     55 typedef struct {
     56   ge448 X[GE448_WORDS];
     57   ge448 Y[GE448_WORDS];
     58   ge448 Z[GE448_WORDS];
     59 } ge448_p2;
     60 
     61 
     62 WOLFSSL_LOCAL int  ge448_compress_key(byte* out, const byte* xIn, const byte* yIn);
     63 WOLFSSL_LOCAL int  ge448_from_bytes_negate_vartime(ge448_p2 *r, const byte *b);
     64 
     65 WOLFSSL_LOCAL int  ge448_double_scalarmult_vartime(ge448_p2 *r, const byte *a,
     66                                     const ge448_p2 *A, const byte *b);
     67 WOLFSSL_LOCAL int  ge448_scalarmult_base(ge448_p2* h, const byte* a);
     68 /* Only performs a weak reduce. */
     69 WOLFSSL_LOCAL void sc448_reduce(byte* b);
     70 WOLFSSL_LOCAL void sc448_muladd(byte* r, const byte* a, const byte* b, const byte* d);
     71 WOLFSSL_LOCAL void ge448_to_bytes(byte *s, const ge448_p2 *h);
     72 
     73 
     74 #ifndef ED448_SMALL
     75 typedef struct {
     76   ge448 x[GE448_WORDS];
     77   ge448 y[GE448_WORDS];
     78 } ge448_precomp;
     79 
     80 #endif /* !ED448_SMALL */
     81 
     82 #endif /* HAVE_ED448 */
     83 
     84 #endif /* WOLF_CRYPT_GE_448_H */