Twisted Edwards-Form Elliptic Curve Cryptography for 8-Bit AVR-Based Sensor Nodes
Total Page:16
File Type:pdf, Size:1020Kb
Twisted Edwards-Form Elliptic Curve Cryptography for 8-bit AVR-based Sensor Nodes Dalin Chu Johann Großschädl Zhe Liu Shandong University, China University of Luxembourg University of Luxembourg [email protected] [email protected] [email protected] Volker Müller Yang Zhang University of Luxembourg University of Luxembourg [email protected] [email protected] ABSTRACT 1. INTRODUCTION Wireless Sensor Networks (WSNs) pose a number of unique In recent years, Wireless Sensor Networks (WSNs) have security challenges that demand innovation in several areas found widespread adoption in such areas as environmental including the design of cryptographic primitives and proto- monitoring, military surveillance, industrial control, home cols. Despite recent progress, the efficient implementation automation, and health care [1]. Many of said applications of Elliptic Curve Cryptography (ECC) for WSNs is still a collect or process sensitive information, which initiated an very active research topic and techniques to further reduce extensive body of research on security and privacy aspects the time and energy cost of ECC are eagerly sought. This of WSNs. The special adversary models and threat scenar- paper presents an optimized ECC implementation that we ios of WSNs pose a multitude of unique research problems developed from scratch to comply with the severe resource (see e.g. [22] for an overview), including some that are still constraints of 8-bit sensor nodes such as the MICAz and not properly solved and, hence, need further consideration IRIS motes. Our ECC software uses Optimal Prime Fields [16]. Wang et al [23] identify the following building blocks (OPFs) as underlying algebraic structure and supports two as essential for the design and implementation of a secure different families of elliptic curves, namely Weierstraß-form WSN: cryptography, key management, secure routing, se- and twisted Edwards-form curves. Due to the combination cure data aggregation, and intrusion detection. One of the of efficient field arithmetic and fast group operations, we open research issues mentioned in [23] is to further improve achieve an execution time of 5.8 · 106 clock cycles for a full the efficiency of Public-Key Cryptography (PKC) on small 158-bit scalar multiplication on an 8-bit ATmega128 micro- sensor nodes with limited computational power. They state controller, which is 2.78 times faster than the widely-used that “public key cryptography can greatly ease the design TinyECC library. Our implementation also shows that the of security in WSNs” [23, p. 19], but perceive overheads in energy cost of scalar multiplication on a MICAz (or IRIS) execution time and energy consumption as limiting factors mote amounts to just 19 mJ when using a twisted Edwards for the widespread deployment of PKC. curve over a 160-bit OPF. This result compares fairly well The benefits and drawbacks of using PKC in WSNs have with the energy figures of two recently-presented hardware been widely researched in the past ten years. Early work on designs of ECC based on twisted Edwards curves. the feasibility of PKC in WSNs includes that of Carman et al [6], who analyzed and compared the computation time Categories and Subject Descriptors and energy requirements of RSA, DSA, Diffie-Hellman and a few other public-key algorithms. The first really practical E.3 [Data]: Data Encryption—Public Key Cryptosystems; RSA implementation for an 8-bit sensor node, namely the K.6.5 [Management of Computing and Information prevalent MICAz mote [9], was presented by Gura et al in Systems]: Security and Protection 2004 [13]. They also introduced highly-optimized software for Elliptic Curve Cryptography (ECC) on 8-bit AVR mi- General Terms cro-controllers and reported an execution time of less than Algorithms, Experimentation, Performance, Security 6.5 · 106 clock cycles for a 160-bit scalar multiplication. This result set a new speed record for ECC on an 8-bit platform Keywords and has since then been generally regarded as the ultimate proof that strong PKC is feasible on resource-constrained MICAz Mote, AVR Processor, Twisted Edwards Curve sensor nodes. One of the most widely used ECC implemen- tations for WSNs is TinyECC [19], whose first version was released in the late 2007. TinyECC is a highly configurable ECC library for wireless sensor nodes running TinyOS and supports Weierstraß curves over arbitrary prime fields. To Permission to make digital or hard copies of all or part of this work for increase efficiency, TinyECC contains special optimizations personal or classroom use is granted without fee provided that copies are for standardized 128, 160, and 192-bit fields. not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to In this paper, we describe a carefully-optimized software republish, to post on servers or to redistribute to lists, requires prior specific implementation of ECC for 8-bit AVR-based sensor nodes permission and/or a fee. like the MICAz and IRIS motes. The aim of our work is to Cryptology ePrint Archive, Report 2012/730, http://eprint.iacr.org, 2013. advance the state-of-the-art in lightweight ECC for WSNs 3. TWISTED EDWARDS CURVES by exploring the potential of new families of elliptic curves In July 2007, Harold Edwards introduced a normal form and prime fields with special arithmetic properties. In con- for elliptic curves along with a simple, symmetric addition trast, most existing ECC libraries for 8-bit AVR processors law [10]. Bernstein and Lange [5] established the relevance (in particular TinyECC) are optimized for curves and fields of Edwards’ work for elliptic curve cryptography and came that have been standardized by such bodies as the Natinal up with more efficient formulas for point addition and dou- Institute of Standards and Technology (NIST) [21]. These bling using standard projective coordinates [14]. They also so-called NIST curves were specified some 15 years ago and extended Edwards’ curve definition to a more general form do not reflect the current state-of-the-art of ECC in terms that covers a much larger class of elliptic curves. In formal of efficiency. Our implementation “departs” from these old terms, a so-called Edwards curve over a prime field Fp can standards and puts forward a novel approach for ECC on be described by the equation1 small sensor nodes that combines twisted Edwards curves 2 2 2 2 (which provide very fast point arithmetic [4]) with so-called E : x + y = 1 + dx y (1) Optimal Prime Fields (which allow for efficient modular re- with d ∈ Fp \{0, 1}. Edwards curves have some attractive duction [24]). Besides achieving high performance, we also properties for practical use, most notably efficiency of the aim for a “lightweight” implementation with low RAM and point arithmetic and completeness of the addition law when ROM footprint. Therefore, we use the conventional double- d is not a square in p. Completeness means the addition and-add method for scalar multiplication, even though one F formula is valid for all P, Q ∈ E(Fp), including the special could reach better execution times at the cost of additional cases P = Q, P = −Q, P = O, and Q = O. Bernstein and memory for storing multiples of the base point. Our results Lange [5] also showed that every Edwards curve contains a show that an 8-bit sensor node, such as the MICAz mote, is point of order 4 and, thus, has a co-factor of h ≥ 4. able to perform a full 160-bit scalar multiplication in some 6 In 2008, Bernstein et al [4] introduced twisted Edwards 5.8 · 10 clock cycles, which is about 2.78 times faster than curves as a generalization of Edwards curves. Formally, a the widely-used TinyECC library. twisted Edwards curve over a prime field Fp is defined via the equation 2. OPTIMAL PRIME FIELDS 2 2 2 2 The specific field we use for our implementation belongs E : ax + y = 1 + dx y (2) to the family of Optimal Prime Fields (OPFs), which were where a and d are distinct, non-zero elements of Fp. Bern- originally introduced in [11]. These fields are represented by stein et al observed empirically that the twisted Edwards k “low-weight” primes of the form p = u · 2 + v, where u and form covers much more curves than the “original” Edwards k v are relatively small compared to 2 ; in our case, u has a form2 based on Equation 1. Furthermore, as demonstrated length of 16 bits so that it fits into two 8-bit registers of an in [4], every twisted Edwards curve over a non-binary field AVR processor, and v is equal to 1. A concrete example is q is birationally equivalent over q to a Montgomery curve 144 F F p = 65356 · 2 + 1, which is a 160-bit prime that looks as (i.e. every twisted Edwards curve can be transformed to a follows when written in hex notation. Montgomery curve, and vice versa). Bernstein et al [4] also 0xFF4C000000000000000000000000000000000001 presented explicit formulas for addition and doubling on a twisted Edwards curve; these formulas are complete if a is Primes of such a form are characterized by a low Hamming a square and d a non-square in the underlying field. weight because only the two most significant bytes and the least significant byte are non-zero; all other “middle” bytes 3.1 Curve Generation are zero. The low weight of p allows for optimization of the The security of elliptic curve cryptosystems relies on the modular arithmetic as only the non-zero bytes of p need to computational intractability of the Elliptic Curve Discrete be processed in the reduction operation.