Post
Topic
Board Development & Technical Discussion
Merits 6 from 2 users
Re: Selecting p-values for secp160k1, secp192k1 and secp224k1
by
vjudeu
on 25/08/2023, 19:44:30 UTC
⭐ Merited by NotATether (5) ,garlonicon (1)
Quote
So, which formula is used to derive those p-values for other curves?
Finally, I found the answer, and it is easier than you probably think. Just picking p-value alone is not sufficient. You should always also calculate n-value. And then, you can see that those values are the first ones, that were possible to reach.

Quote
For all other curves, our t-value is bigger than 1024.
This "1024" value is very misleading. If you start from t=0, and keep incrementing it, without thinking about any "window", then t=977 will be the first value, where both p-value and n-value will be prime.

Code:
p= 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffef9 (t = 263)
n= 0xffffffffffffffffffffffffffffffff9d70b40e72725ad652cd62c55808d873 (non-prime)

p= 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffe99 (t = 359)
n=0x100000000000000000000000000000000b3c017eacf02babf49040910abee2e35 (non-prime)

p= 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffe97 (t = 361)
n= 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffe98 (non-prime)

p= 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffe19 (t = 487)
n= 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffe1a (non-prime)

p= 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffd1d (t = 739)
n= 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffd1e (non-prime)

p= 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc4b (t = 949)
n= 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc4c (non-prime)

p= 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f (t = 977)
n= 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 (prime)

If you want to get n-value, based on p-value, then you can visit Sage Cell Server and use this code:
Code:
p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffef9
P = GF(p)
aP = P(0x0)
bP = P(0x7)
Secp256k1 = EllipticCurve(P, (aP, bP))
print(hex(Secp256k1.order()))
Then, you will see 0xffffffffffffffffffffffffffffffff9d70b40e72725ad652cd62c55808d873 as a result.

Also, don't forget to change b-value for other curves, because they are different:
Code:
secp160k1 a=0 b=7
secp192k1 a=0 b=3
secp224k1 a=0 b=5
secp256k1 a=0 b=7