source: trunk/src-ed25519/supercop-ref/sc25519.h

Last change on this file was 9598517, checked in by Brian Warner <warner@…>, at 2012-02-12T15:05:37Z

Add Ed25519 signatures, in pycryptopp.publickey.ed25519 . Closes #75.

This copies in version 1.0 of python-ed25519, from
https://github.com/warner/python-ed25519 (or pypi), with minor source-code
rearrangement to match pycryptopp's build process. It includes unit tests,
power-on self-tests, and full known-answer tests. The standard 'setup.py
test' target only exercises 10% of the test vectors, to let the suite run in
about 1.0s on my laptop. The API documentation is in README.ed25519 .

Tests have been run successfully on Linux, OS-X and windows.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1#ifndef SC25519_H
2#define SC25519_H
3
4#include "crypto_int32.h"
5#include "crypto_uint32.h"
6
7#define sc25519                  crypto_sign_ed25519_ref_sc25519
8#define shortsc25519             crypto_sign_ed25519_ref_shortsc25519
9#define sc25519_from32bytes      crypto_sign_ed25519_ref_sc25519_from32bytes
10#define shortsc25519_from16bytes crypto_sign_ed25519_ref_shortsc25519_from16bytes
11#define sc25519_from64bytes      crypto_sign_ed25519_ref_sc25519_from64bytes
12#define sc25519_from_shortsc     crypto_sign_ed25519_ref_sc25519_from_shortsc
13#define sc25519_to32bytes        crypto_sign_ed25519_ref_sc25519_to32bytes
14#define sc25519_iszero_vartime   crypto_sign_ed25519_ref_sc25519_iszero_vartime
15#define sc25519_isshort_vartime  crypto_sign_ed25519_ref_sc25519_isshort_vartime
16#define sc25519_lt_vartime       crypto_sign_ed25519_ref_sc25519_lt_vartime
17#define sc25519_add              crypto_sign_ed25519_ref_sc25519_add
18#define sc25519_sub_nored        crypto_sign_ed25519_ref_sc25519_sub_nored
19#define sc25519_mul              crypto_sign_ed25519_ref_sc25519_mul
20#define sc25519_mul_shortsc      crypto_sign_ed25519_ref_sc25519_mul_shortsc
21#define sc25519_window3          crypto_sign_ed25519_ref_sc25519_window3
22#define sc25519_window5          crypto_sign_ed25519_ref_sc25519_window5
23#define sc25519_2interleave2     crypto_sign_ed25519_ref_sc25519_2interleave2
24
25typedef struct 
26{
27  crypto_uint32 v[32]; 
28}
29sc25519;
30
31typedef struct 
32{
33  crypto_uint32 v[16]; 
34}
35shortsc25519;
36
37void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]);
38
39void shortsc25519_from16bytes(shortsc25519 *r, const unsigned char x[16]);
40
41void sc25519_from64bytes(sc25519 *r, const unsigned char x[64]);
42
43void sc25519_from_shortsc(sc25519 *r, const shortsc25519 *x);
44
45void sc25519_to32bytes(unsigned char r[32], const sc25519 *x);
46
47int sc25519_iszero_vartime(const sc25519 *x);
48
49int sc25519_isshort_vartime(const sc25519 *x);
50
51int sc25519_lt_vartime(const sc25519 *x, const sc25519 *y);
52
53void sc25519_add(sc25519 *r, const sc25519 *x, const sc25519 *y);
54
55void sc25519_sub_nored(sc25519 *r, const sc25519 *x, const sc25519 *y);
56
57void sc25519_mul(sc25519 *r, const sc25519 *x, const sc25519 *y);
58
59void sc25519_mul_shortsc(sc25519 *r, const sc25519 *x, const shortsc25519 *y);
60
61/* Convert s into a representation of the form \sum_{i=0}^{84}r[i]2^3
62 * with r[i] in {-4,...,3}
63 */
64void sc25519_window3(signed char r[85], const sc25519 *s);
65
66/* Convert s into a representation of the form \sum_{i=0}^{50}r[i]2^5
67 * with r[i] in {-16,...,15}
68 */
69void sc25519_window5(signed char r[51], const sc25519 *s);
70
71void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2);
72
73#endif
Note: See TracBrowser for help on using the repository browser.