LCOV - code coverage report
Current view: top level - externals/compact25519/src/c25519 - c25519.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 5 5 100.0 %
Date: 2024-09-16 20:15:30 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* Curve25519 (Montgomery form)
       2                 :            :  * Daniel Beer <dlbeer@gmail.com>, 18 Apr 2014
       3                 :            :  *
       4                 :            :  * This file is in the public domain.
       5                 :            :  */
       6                 :            : 
       7                 :            : #ifndef C25519_H_
       8                 :            : #define C25519_H_
       9                 :            : 
      10                 :            : #ifndef COMPACT_DISABLE_X25519
      11                 :            : #include <stdint.h>
      12                 :            : #include "f25519.h"
      13                 :            : 
      14                 :            : /* Curve25519 has the equation over F(p = 2^255-19):
      15                 :            :  *
      16                 :            :  *    y^2 = x^3 + 486662x^2 + x
      17                 :            :  *
      18                 :            :  * 486662 = 4A+2, where A = 121665. This is a Montgomery curve.
      19                 :            :  *
      20                 :            :  * For more information, see:
      21                 :            :  *
      22                 :            :  *    Bernstein, D.J. (2006) "Curve25519: New Diffie-Hellman speed
      23                 :            :  *    records". Document ID: 4230efdfa673480fc079449d90f322c0.
      24                 :            :  */
      25                 :            : 
      26                 :            : /* This is the site of a Curve25519 exponent (private key) */
      27                 :            : #define C25519_EXPONENT_SIZE  32
      28                 :            : 
      29                 :            : /* Having generated 32 random bytes, you should call this function to
      30                 :            :  * finalize the generated key.
      31                 :            :  */
      32                 :          2 : static inline void c25519_prepare(uint8_t *key)
      33                 :            : {
      34                 :          2 :         key[0] &= 0xf8;
      35                 :          2 :         key[31] &= 0x7f;
      36                 :          2 :         key[31] |= 0x40;
      37                 :          2 : }
      38                 :            : 
      39                 :            : /* X-coordinate of the base point */
      40                 :            : extern const uint8_t c25519_base_x[F25519_SIZE];
      41                 :            : 
      42                 :            : /* X-coordinate scalar multiply: given the X-coordinate of q, return the
      43                 :            :  * X-coordinate of e*q.
      44                 :            :  *
      45                 :            :  * result and q are field elements. e is an exponent.
      46                 :            :  */
      47                 :            : void c25519_smult(uint8_t *result, const uint8_t *q, const uint8_t *e);
      48                 :            : #endif
      49                 :            : #endif

Generated by: LCOV version 1.14