| 1 |
#include <string.h> |
| 2 |
#include "crypto_additions.h" |
| 3 |
#include "sc.h" |
| 4 |
|
| 5 |
/* l = order of base point = 2^252 + 27742317777372353535851937790883648493 */ |
| 6 |
|
| 7 |
/* |
| 8 |
static unsigned char l[32] = {0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, |
| 9 |
0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, |
| 10 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 11 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0, 0x10}; |
| 12 |
*/ |
| 13 |
|
| 14 |
static unsigned char lminus1[32] = {0xec, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, |
| 15 |
0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, |
| 16 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 17 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}; |
| 18 |
|
| 19 |
/* b = -a (mod l) */ |
| 20 |
void sc_neg(unsigned char *b, const unsigned char *a) |
| 21 |
{ |
| 22 |
unsigned char zero[32]; |
| 23 |
memset(zero, 0, 32); |
| 24 |
sc_muladd(b, lminus1, a, zero); /* b = (-1)a + 0 (mod l) */ |
| 25 |
} |