Consider the following case, given x(private key) and y(public key), how to determine whether this key pair is generated by a pre-defined Safe Prime Group(Say FFDHE, RFC 7919)?
In context of SP800 56Ar3 Section 5.6.1.1.4, my understanding is we need to check 2 conditions,
i. y = g^x mod p
ii. 1 < x < min(2^N, q-1)
where N is the max bit size of private key can generate
(i) makes sense because if I change p and g, x and y will fail the key verification.
However, in (ii), if I completely ignore q(makes 1 < x < 2^N), or change value q(makes q != (p-1)/2), I still can pass this key verification method. q seems is only used to bound the range of x to [1, min(2^N, q-1)]. Is there any more meaning for this q in key generation phase?
My understanding of Safe Prime key pair generation are following, please correct me if I am wrong, thanks.
Phase 1: Generate DH parameters p, q, g. Here requires q to hold properties of
1. g^q = 1 mod p,
2. q = (p-1)/2
3. q is a prime
Since RFC defines the exact p, q, g to use, so we don't consider this phase.
Phase 2: Use p, q, g to generate Key Pair x and y. In this phase, SP800 56A bounds the range of x to [1, min(2^N, q-1)], what if I generate a larger x that, q < x < 2^N ? Is this just FIPS document wants it or there are some underlie mathematical meaning behind it?