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 , 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 is the result of combining the elements and . A set with this operation is a group when four conditions hold.
Closure: for all and in , the result is in .
Associativity: for all , and , so a chain such as needs no brackets.
Identity: one element, written 1, satisfies for every .
Inverse: every has an element with .
The groups used for key agreement are also commutative, meaning that .
Powers. For a positive whole number , means copies of multiplied together, and is the identity. Associativity gives the two laws that key agreement relies on: and . 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 copies of an element added together are written , the number is called a scalar, and computing is called scalar multiplication. Only the notation differs.
Cyclic subgroup, generator, order. Take any element of a finite group and list and so on. The group is finite, so two entries of the list must be equal, say with . Multiplying both by the inverse of gives , so the list reaches the identity. Let be the smallest positive whole number with . Then are different elements, and from onward the list repeats. These elements form a group of their own under the same operation: the product of two powers of is again a power of , the identity is , and the inverse of is . 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 , written . The number is the order of and also the order of . A whole group is called cyclic when one of its elements generates all of it.
Two facts follow.
Exponents wrap round at the order: exactly when is a multiple of . An exponent may therefore be replaced by its remainder after division by .
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 and keep multiplying by 2. The results are
2, 4, 8, 16, 9, 18, 13, 3, 6, 12, 1.
Four steps needed a reduction: , , and . The identity 1 appears at the eleventh step, so 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 . 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 , the element is the same as . Reducing the exponent modulo 23 instead would give , which is wrong.
Stated precisely
Let be a finite group with identity 1, and write for its order, the number of its elements. For an element of , the order of , written , is the smallest positive whole number with . The cyclic subgroup generated by is For all whole numbers and , where means that is a multiple of . Lagrange’s theorem states that divides for every subgroup of . Hence divides , and for every . If is a prime number, every element other than 1 has order and generates .
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 , the numbers 1 to under multiplication modulo form a cyclic group of order . And by Hasse’s theorem, the order of the group of points of an elliptic curve over the whole numbers modulo a prime satisfies
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 , and 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 for a prime , where every result is replaced by its remainder after division by . This is called arithmetic modulo , and the size of the field is . 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 of , so it is close to the field size , but it is a separate quantity: NIST requires every curve that it recommends to have a number of points different from . 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 . For the curve of the key agreement function X25519, the field size is , 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.
Wrong arithmetic. Coordinates and remainders are reduced modulo the field size. Exponents and private keys, which count how often the group operation is repeated, are reduced modulo the order of the generating element. Modulo 23 the element 2 has order 11, so is the same element as , because . Reducing the exponent modulo 23 would give , which is wrong.
Wrong security estimate. The attacks that work in every group need about as many steps as the square root of the largest prime factor of the order of the generating element, whatever the field size. For key agreement in the whole numbers modulo a prime, one parameter set in NIST Special Publication 800-56A pairs a 2048-bit field size with a subgroup order of only 224 bits, so those attacks need about steps. The field has to be that large because faster attacks exist that use the structure of the whole numbers modulo a prime.
Missing check. A received value can be a valid field element, in the range 0 to , and still lie outside the intended subgroup. A range check is not a group check.
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].