Section 19.1.1

Group, cyclic subgroup, generator, and order

Definition

A group is a set with one operation that turns any two elements into an element of the set, such that regrouping a chain of operations never changes the result, one identity element changes nothing, and every element has an inverse that undoes it. In a finite group, a cyclic subgroup is the group of all results of combining one element, its generator, with itself repeatedly. Order means size: a group’s order is its number of elements, and an element’s order is the order of the cyclic subgroup it generates.

The idea

Two devices that agree on a secret key over an open network each repeat one public operation a secret number of times. That works only if repetition behaves like ordinary powers: raising an element to the power 3 and then to the power 7 must give the same element as raising it to the power 7 and then to the power 3. The group operation keeps every result in the same set. Cryptographic protocols choose a finite group and specify how to encode its elements. For example, the twelve hours on the clock below fit in one byte. The integers under addition also form a group, but no fixed number of bytes can represent every integer.

A clock face is a fair picture. Take the hours 0 to 11, and let the operation be adding hours and wrapping round past 11. Start at 0 and keep adding 5. The hand visits 5, 10, 3, 8, 1, 6, 11, 4, 9, 2, 7 and is back at 0 after 12 steps, having touched every hour. So 5 generates the whole group of 12 hours, and the order of 5 is 12. Keep adding 4 instead. The hand visits 4, 8 and 0, and then repeats. So 4 generates a cyclic subgroup of order 3 inside the group of order 12. Every element of a finite group traces a closed loop like this, which is what the word cyclic refers to, and the order of the element is the length of its loop.

The picture stops being accurate in one respect. On the clock, anyone who sees where the hand stopped can work out how many steps it took by one multiplication. With steps of 5, multiply the hour shown by 5 and keep the remainder after division by 12: a hand at 3 gives 3×5=15=12+33 \times 5 = 15 = 12 + 3, so it took 3 steps, or 3 steps plus any number of whole laps of 12 steps. The groups used in cryptography are chosen so that this reverse question is believed to be infeasible.

How it works

Write the operation as multiplication, so that abab is the result of combining the elements aa and bb. A set GG with this operation is a group when four conditions hold.

The groups used for key agreement are also commutative, meaning that ab=baab = ba.

Powers. For a positive whole number kk, gkg^k means kk copies of gg multiplied together, and g0g^0 is the identity. Associativity gives the two laws that key agreement relies on: gj+k=gjgkg^{j+k} = g^j g^k and (gj)k=gjk(g^j)^k = g^{jk}. Some groups, such as the points of an elliptic curve §19.1.5 (a set of pairs of numbers that satisfy one fixed equation, used for key agreement), are written with a plus sign. There kk copies of an element GG added together are written kGkG, the number kk is called a scalar, and computing kGkG is called scalar multiplication. Only the notation differs.

Cyclic subgroup, generator, order. Take any element gg of a finite group and list g1,g2,g3g^1, g^2, g^3 and so on. The group is finite, so two entries of the list must be equal, say gi=gjg^i = g^j with i<ji < j. Multiplying both by the inverse of gig^i gives gj−i=1g^{j-i} = 1, so the list reaches the identity. Let nn be the smallest positive whole number with gn=1g^n = 1. Then g1,g2,…,gng^1, g^2, \dots, g^n are nn different elements, and from gn+1=gg^{n+1} = g onward the list repeats. These nn elements form a group of their own under the same operation: the product of two powers of gg is again a power of gg, the identity is gng^n, and the inverse of gig^i is gn−ig^{n-i}. A subset of a group that is itself a group under the same operation is called a subgroup. This one is the cyclic subgroup generated by gg, written ⟨g⟩\langle g \rangle. The number nn is the order of gg and also the order of ⟨g⟩\langle g \rangle. A whole group is called cyclic when one of its elements generates all of it.

Two facts follow.

  1. Exponents wrap round at the order: gj=gkg^j = g^k exactly when j−kj - k is a multiple of nn. An exponent may therefore be replaced by its remainder after division by nn.

  2. Lagrange’s theorem: the order of a subgroup divides the order of the group. In particular, the order of every element divides the order of the group.

Worked example

Take the numbers 1 to 22 and multiply modulo 23: multiply as usual, then keep the remainder after division by 23. Because 23 is prime, these 22 numbers form a group of order 22.

Start from g=2g = 2 and keep multiplying by 2. The results are

2, 4, 8, 16, 9, 18, 13, 3, 6, 12, 1.

Four steps needed a reduction: 16×2=32=23+916 \times 2 = 32 = 23 + 9, 18×2=36=23+1318 \times 2 = 36 = 23 + 13, 13×2=26=23+313 \times 2 = 26 = 23 + 3 and 12×2=24=23+112 \times 2 = 24 = 23 + 1. The identity 1 appears at the eleventh step, so 211=12^{11} = 1 in this group, and the order of 2 is 11. The eleven numbers in the list are the cyclic subgroup generated by 2. One more multiplication gives 2 again.

Lagrange’s theorem holds: 11 divides 22. The divisors of 22 are 1, 2, 11 and 22, so no element can have any other order. The element 22 has order 2, because 22×22=484=21×23+122 \times 22 = 484 = 21 \times 23 + 1. The element 5 has order 22: its powers are 5, 2, 10, 4, 20, 8, 17, 16, 11, 9, 22, 18, 21, 13, 19, 3, 15, 6, 7, 12, 14, 1, which is every one of the 22 numbers. So 5 generates the whole group, and the group is cyclic.

Exponents of 2 wrap at 11, the order of 2, and not at 23. Since 25=2×11+325 = 2 \times 11 + 3, the element 2252^{25} is the same as 23=82^3 = 8. Reducing the exponent modulo 23 instead would give 22=42^2 = 4, which is wrong.

Stated precisely

Let GG be a finite group with identity 1, and write |G||G| for its order, the number of its elements. For an element gg of GG, the order of gg, written ord(g)\mathrm{ord}(g), is the smallest positive whole number nn with gn=1g^n = 1. The cyclic subgroup generated by gg is ⟨g⟩={g1,g2,…,gn},|⟨g⟩|=ord(g)=n.\langle g \rangle = \{g^1, g^2, \dots, g^n\}, \qquad |\langle g \rangle| = \mathrm{ord}(g) = n. For all whole numbers j≥0j \ge 0 and k≥0k \ge 0, gj=gk⇔j≡k(modn),g^j = g^k \iff j \equiv k \pmod{n}, where j≡k(modn)j \equiv k \pmod{n} means that j−kj - k is a multiple of nn. Lagrange’s theorem states that |H||H| divides |G||G| for every subgroup HH of GG. Hence ord(g)\mathrm{ord}(g) divides |G||G|, and g|G|=1g^{|G|} = 1 for every gg. If |G||G| is a prime number, every element other than 1 has order |G||G| and generates GG.

These statements are theorems about every finite group and rest on no unproven assumption. Two further theorems describe the groups that key agreement uses. For a prime pp, the numbers 1 to p−1p - 1 under multiplication modulo pp form a cyclic group of order p−1p - 1. And by Hasse’s theorem, the order NN of the group of points of an elliptic curve over the whole numbers modulo a prime pp satisfies p+1−2p≤N≤p+1+2p.p + 1 - 2\sqrt{p} \le N \le p + 1 + 2\sqrt{p}.

Limits and common mistakes

The rules of a group give no secrecy: the clock group described above obeys all of them. That recovering an exponent is infeasible in a chosen group is a separate assumption, treated in the entry on the discrete logarithm §19.1.3.

Not every element generates the whole group, and some elements have a very small order. In the example, 22 has order 2. Raising an element of small order to a secret power leaves only a few possible results. In the prime-order subgroup example, the receiver can check subgroup membership and exclude the identity. The required check depends on the protocol. For example, Transport Layer Security version 1.3 using X25519 checks the computed shared secret and aborts if every byte is zero [325]. This is one reason why protocols work in a subgroup whose order is a large prime: every element of such a subgroup, other than the identity, has that full order.

Not every group is cyclic. Under multiplication modulo 8 the numbers 1, 3, 5 and 7 form a group of order 4. In it 3×3=93 \times 3 = 9, 5×5=255 \times 5 = 25 and 7×7=497 \times 7 = 49 all leave remainder 1, so every element other than 1 has order 2 and none has order 4.

Questions answered

Why distinguish field size from group order?

Field size and group order must be distinguished because they are different numbers with different jobs, and using one where the other belongs gives wrong results or a wrong estimate of security. A finite field §19.1.2 is a finite set of numbers with addition, subtraction, multiplication and division. An example is the whole numbers 0 to p−1p - 1 for a prime pp, where every result is replaced by its remainder after division by pp. This is called arithmetic modulo pp, and the size of the field is pp. A group is a set with a single operation, such as multiplication, in which every element has an inverse that undoes it; the order of a group is the number of its elements. The field size says how many values one stored number can take, and so how wide the numbers are and what they are reduced by. The group order says how many elements the group built from those numbers has, and so where exponents wrap round.

Take multiplication modulo 23. The field size is 23, the number of remainders 0 to 22. The nonzero remainders form a group of order 22. The powers of 2 form a subgroup of order 11. An elliptic curve, the other structure used for key agreement, is a set of points whose two coordinates are field elements, and the points are the group elements. Hasse’s theorem puts the number of points within 2p2\sqrt{p} of p+1p + 1, so it is close to the field size pp, but it is a separate quantity: NIST requires every curve that it recommends to have a number of points different from pp. For the standard curve P-256, the field size and the group order are both 256-bit primes, and they differ by a 127-bit number, about 8.9×10378.9 \times 10^{37}. For the curve of the key agreement function X25519, the field size is 2255−192^{255} - 19, while the order of the base point, the published point whose multiples are used, has only 253 bits, because the curve has 8 times as many points as the subgroup in use.

Three things go wrong when the two are confused.

Related entries: Finite field and modular inverse (§19.1.2), Discrete logarithm and the Diffie–Hellman problem (§19.1.3), Diffie–Hellman key agreement (§19.1.4), Elliptic-curve Diffie–Hellman (ECDH) (§19.1.5). Further reading: [152, 325].