1 FALCON IMPLEMENTATION
4 Falcon is a post-quantum signature algorithm, submitted to NIST's
5 Post-Quantum Cryptography project:
9 Falcon is based on NTRU lattices, used with a hash-and-sign structure
10 and a Fourier-based sampling method that allows efficient signature
11 generation and verification, while producing and using relatively
12 compact signatures and public keys. The official Falcon Web site is:
17 This implementation is written in C and is configurable at compile-time
18 through macros which are documented in config.h; each macro is a boolean
19 option and can be enabled or disabled in config.h and/or as a
20 command-line parameter to the compiler. Several implementation strategies
21 are available; however, in all cases, the same API is implemented.
23 Main options are the following:
25 - FALCON_FPNATIVE and FALCON_FPEMU
27 If using FALCON_FPNATIVE, then the C 'double' type is used for all
28 floating-point operations. This is the default. This requires the
29 'double' type to implement IEEE-754 semantics, in particular
30 rounding to the exact precision of the 'binary64' type (i.e. "53
31 bits"). The Falcon implementation takes special steps to ensure
32 these properties on most common architectures. When using this
33 engine, the code _may_ need to call the standard library function
34 sqrt() (depending on the local architecture), which may in turn
35 require linking with a specific library (e.g. adding '-lm' to the
36 link command on Unix-like systems).
38 FALCON_FPEMU does not use the C 'double' type, but instead works
39 over only 64-bit integers and embeds its own emulation of IEEE-754
40 operations. This is slower but portable, since it will work on any
41 machine with a C99-compliant compiler.
43 - FALCON_AVX2 and FALCON_FMA
45 FALCON_AVX2, when enabled, activates the use of AVX2 compiler
46 intrinsics. This works only on x86 CPU that offer AVX2 opcodes.
47 Use of AVX2 improves performance. FALCON_AVX2 has no effect if
48 FALCON_FPEMU is used.
50 FALCON_FMA further enables the use for FMA ("fused multiply-add")
51 compiler intrinsics for an extra boost to performance. This
52 setting is ignored unless FALCON_FPNATIVE and FALCON_AVX2 are
53 both used. Occasionally (but rarely), use of FALCON_FMA will
54 change the keys and/or signatures generated from a given random
55 seed, impacting reproducibility of test vectors; however, this
56 has no bearing on the security of normal usage.
58 - FALCON_ASM_CORTEXM4
60 When enabled, inline assembly routines for FP emulation and SHAKE256
61 will be used. This will work only on the ARM Cortex M3, M4 and
62 compatible CPU. This assembly code is constant-time on the M4, and
63 about twice faster than the generic C code used by FALCON_FPEMU.
69 See the Makefile for compilation flags, and config.h for configurable
70 options. Type 'make' to compile: this will generate two binaries called
71 'test_falcon' and 'speed'. 'test_falcon' runs unit tests to verify that
72 everything computes the expected values. 'speed' runs performance
73 benchmarks on Falcon-256, Falcon-512 and Falcon-1024 (Falcon-256 is a
74 reduced version that is faster and smaller than Falcon-512, but provides
75 only reduced security, and not part of the "official" Falcon).
77 Applications that want to use Falcon normally work on the external API,
78 which is documented in the "falcon.h" file. This is the only file that
79 an external application needs to use.
81 For research purposes, the inner API is documented in "inner.h". This
82 API gives access to many internal functions that perform some elementary
83 operations used in Falcon. That API also has some non-obvious
84 requirements, such as alignment on temporary buffers, or the need to
85 adjust FPU precision on 32-bit x86 systems.
91 This code is provided under the MIT license:
93 ==========================(LICENSE BEGIN)============================
94 Copyright (c) 2017-2019 Falcon Project
96 Permission is hereby granted, free of charge, to any person obtaining
97 a copy of this software and associated documentation files (the
98 "Software"), to deal in the Software without restriction, including
99 without limitation the rights to use, copy, modify, merge, publish,
100 distribute, sublicense, and/or sell copies of the Software, and to
101 permit persons to whom the Software is furnished to do so, subject to
102 the following conditions:
104 The above copyright notice and this permission notice shall be
105 included in all copies or substantial portions of the Software.
107 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
108 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
109 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
110 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
111 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
112 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
113 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
114 ===========================(LICENSE END)=============================
116 The code was written by Thomas Pornin <email@example.com>, to
117 whom questions may be addressed. I'll endeavour to respond more or less