Poly1305 is a universal hash family designed by Daniel J. Bernstein in 2002 for use in cryptography. As with any universal hash family, Poly1305 can be used as a one-time message authentication code to authenticate a single message using a secret key shared between sender and recipient, similar to the way that a one-time pad can be used to conceal the content of a single message using a secret key shared between sender and recipient. Originally Poly1305 was proposed as part of Poly1305-AES, a Carter–Wegman authenticator that combines the Poly1305 hash with AES-128 to authenticate many messages using a single short key and distinct message numbers. Poly1305 was later applied with a single-use key generated for each message using XSalsa20 in the NaCl crypto_secretbox_xsalsa20poly1305 authenticated cipher, and then using ChaCha in the ChaCha20-Poly1305 authenticated cipher deployed in TLS on the internet.
Description
Definition of Poly1305 Poly1305 takes a 16-byte secret key r {\displaystyle r} and an L {\displaystyle L} -byte message m {\displaystyle m} and returns a 16-byte hash Poly1305 r ( m ) {\displaystyle \operatorname {Poly1305} _{r}(m)} . To do this, Poly1305:
Interprets r {\displaystyle r} as a little-endian 16-byte integer. Breaks the message m = ( m [ 0 ] , m [ 1 ] , m [ 2 ] , … , m [ L − 1 ] ) {\displaystyle m=(m[0],m[1],m[2],\dotsc ,m[L-1])} into consecutive 16-byte chunks. Interprets the 16-byte chunks as 17-byte little-endian integers by appending a 1 byte to every 16-byte chunk, to be used as coefficients of a polynomial. Evaluates the polynomial at the point r {\displaystyle r} modulo the prime 2 130 − 5 {\displaystyle 2^{130}-5} . Reduces the result modulo 2 128 {\displaystyle 2^{128}} encoded in little-endian return a 16-byte hash. The coefficients c i {\displaystyle c_{i}} of the polynomial c 1 r q + c 2 r q − 1 + ⋯ + c q r {\displaystyle c_{1}r^{q}+c_{2}r^{q-1}+\cdots +c_{q}r} , where q = ⌈ L / 16 ⌉ {\displaystyle q=\lceil L/16\rceil } , are:
c i = m [ 16 i − 16 ] + 2 8 m [ 16 i − 15 ] + 2 16 m [ 16 i − 14 ] + ⋯ + 2 120 m [ 16 i − 1 ] + 2 128 , {\displaystyle c_{i}=m[16i-16]+2^{8}m[16i-15]+2^{16}m[16i-14]+\cdots +2^{120}m[16i-1]+2^{128},}
with the exception that, if L ≢ 0 ( mod 16 ) {\displaystyle L\not \equiv 0{\pmod {16}}} , then:
c q = m [ 16 q − 16 ] + 2 8 m [ 16 q − 15 ] + ⋯ + 2 8 ( L mod 1 6 ) − 8 m [ L − 1 ] + 2 8 ( L mod 1 6 ) . {\displaystyle c_{q}=m[16q-16]+2^{8}m[16q-15]+\cdots +2^{8(L{\bmod {1}}6)-8}m[L-1]+2^{8(L{\bmod {1}}6)}.}
… excerpt ends here. Continue reading the full article.
