MCCI TweetNaCl
TweetNaCl library adapted for embedded use
mcci_tweetnacl_scalarmult.h
Go to the documentation of this file.
1 /*
2 
3 Module: mcci_tweetnacl_scalarmult.h
4 
5 Function:
6  MCCI TweetNacl equivalent of NaCl "crypto_scalarmult.h"
7 
8 Copyright and License:
9  This file copyright (C) 2021 by
10 
11  MCCI Corporation
12  3520 Krums Corners Road
13  Ithaca, NY 14850
14 
15  See accompanying LICENSE file for copyright and license information.
16 
17 Author:
18  fullname, MCCI Corporation March 2021
19 
20 */
21 
22 #ifndef _mcci_tweetnacl_scalarmult_h_
23 #define _mcci_tweetnacl_scalarmult_h_ /* prevent multiple includes */
24 
25 #pragma once
26 
27 #include "mcci_tweetnacl.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /****************************************************************************\
34 |
35 | Meta
36 |
37 \****************************************************************************/
38 
39 /// \addtogroup public-key-crypto Public-key cryptography
40 /// @{
41 /// \defgroup crypto-scalarmult Scalar multiplication
42 /// @{
43 
44 /****************************************************************************\
45 |
46 | Forward types
47 |
48 \****************************************************************************/
49 
50 /// \brief curve25519 group element
51 /// \see https://nacl.cr.yp.to/scalarmult.html
52 typedef struct
53  {
54  /// bytes of the group element
55  unsigned char bytes[32];
57 
58 /// \brief curve25519 scalar integer
59 /// \see https://nacl.cr.yp.to/scalarmult.html
60 typedef struct
61  {
62  /// bytes of the scalar
63  unsigned char bytes[32];
65 
66 /****************************************************************************\
67 |
68 | APIs
69 |
70 \****************************************************************************/
71 
72 ///
73 /// \brief do a scalar multiplication of a curve255129 group element by an integer
74 ///
75 /// \param[out] q is set to the result
76 /// \param[in] p is the input group element,
77 /// \param[in] n is the input integer scalalar.
78 ///
79 /// \see https://nacl.cr.yp.to/scalarmult.html
80 ///
81 static inline void
86  )
87  {
88  extern int crypto_scalarmult_curve25519_tweet(unsigned char *,const unsigned char *,const unsigned char *);
89  (void) crypto_scalarmult_curve25519_tweet(
90  q->bytes,
91  p->bytes,
92  n->bytes
93  );
94  }
95 
96 ///
97 /// \brief do a scalar multiplication of the well known group element by an integer
98 ///
99 /// \param[out] q is set to the result
100 /// \param[in] n is the input integer scalalar.
101 ///
102 /// \see https://nacl.cr.yp.to/scalarmult.html
103 ///
104 static inline void
108  )
109  {
110  extern int crypto_scalarmult_curve25519_tweet_base(unsigned char *,const unsigned char *);
111  (void) crypto_scalarmult_curve25519_tweet_base(
112  q->bytes,
113  n->bytes
114  );
115  }
116 
117 /****************************************************************************\
118 |
119 | Post-Meta
120 |
121 \****************************************************************************/
122 
123 //--- close groups ---
124 /// @}
125 /// @}
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif /* _mcci_tweetnacl_scalarmult_h_ */
mcci_tweetnacl_scalarmult_curve25519_base
static void mcci_tweetnacl_scalarmult_curve25519_base(mcci_tweetnacl_curve25519_group_element_t *q, const mcci_tweetnacl_curve25519_scalar_t *n)
do a scalar multiplication of the well known group element by an integer
Definition: mcci_tweetnacl_scalarmult.h:105
mcci_tweetnacl_curve25519_group_element_t
curve25519 group element
Definition: mcci_tweetnacl_scalarmult.h:53
mcci_tweetnacl_curve25519_scalar_t
curve25519 scalar integer
Definition: mcci_tweetnacl_scalarmult.h:61
mcci_tweetnacl.h
mcci_tweetnacl_scalarmult_curve25519
static void mcci_tweetnacl_scalarmult_curve25519(mcci_tweetnacl_curve25519_group_element_t *q, const mcci_tweetnacl_curve25519_group_element_t *p, const mcci_tweetnacl_curve25519_scalar_t *n)
do a scalar multiplication of a curve255129 group element by an integer
Definition: mcci_tweetnacl_scalarmult.h:82
mcci_tweetnacl_curve25519_group_element_t::bytes
unsigned char bytes[32]
bytes of the group element
Definition: mcci_tweetnacl_scalarmult.h:55
mcci_tweetnacl_curve25519_scalar_t::bytes
unsigned char bytes[32]
bytes of the scalar
Definition: mcci_tweetnacl_scalarmult.h:63