A subgroup is a group contained inside another group: its elements form a subset, operations stay within that subset, and every element has an inverse there. A cyclic subgroup can be generated from one element, called a generator or base. section 5.2.1
Generating a subgroup modulo 5
Using modular multiplication, 4 generates the subgroup {1, 4}: 4 mod 5 = 4, 4 × 4 mod 5 = 1, and the cycle repeats. The number of elements in a subgroup is its order. section 5.2.1
Subgroups matter in Diffie-Hellman because their sizes shape security. For a safe-prime modulus p = 2q + 1, the multiplicative group has order 2q, so its subgroups can have only orders 2 or q. This scarcity prevents small subgroup attacks, in which crafted public keys gradually reveal bits of a private key. section 5.4
Figure 5.6 The different subgroups of the multiplicative group modulo 5. These all include the number 1 (called the identity element) and have different orders (number of elements).
Compare the subgroups of the multiplicative group modulo 5, including their shared identity element and different orders. section 5.2.1
