Assuming you're talking about ECDSA signing. For BIP340/Schnorr signatures, see this answer.
For valid signatures
Let:
d
: the private key
P=d*G
: the public key
k1
: the (first) nonce
R1=k1*G
: the public first nonce
r1=R1.x mod n
: the public first nonce as it will be encoded in the signature.
k2=2*k1
, R2=k2*G=2*R1
, r2=R2.x mod n
: the same for the second nonce
z1
and z2
: the respective message hash
The two signatures will then be the pairs (r,s)
and (r',s')
for which:
s1 = (z1 + r1*d) / k1 mod n
s2 = (z2 + r2*d) / k2 mod n = (m2 + r2*d) / (2*k1) mod n
Multiplying both sides of the equations by their denominator on the right hand side:
s1*k1 = z1 + r1*d mod n
2*s2*k1 = z2 + r2*d mod n
Assuming 2*r1*s2 ≠ r2*s1
, this is a set of two linear equations in two unknowns (k1
and d
), with solution:
d = (z2*s1 - 2*z1*s2) / (2*r1*s2 - r2*s1) mod n
k1 = (z2*r1 - z1*r2) / (2*r1*s2 - r2*s1) mod n
Don't ever use related nonces for ECDSA (or Schnorr) signatures. Create a fresh, independent, nonce every time. The industry standard is to generate nonces using RFC6979.
For fake "signatures"
The values you've provided however do not correspond to real signatures, despite satisfying the equation. That's because for a signature to be valid, you have to give the messages which hash to the z
values, not just the result. And you can't do that here, because z2 = (r2/r1)*z1
. Such matching ratios will not (and cannot) occur for z
values that are the result of hashing.
It turns out that given any ECDSA triplet (r,s,z)
, and integer a
, another triplet can be found. Let R
be an elliptic curve point whose X coordinate equals r
(mod n), and R' = aR
, and r'
the X coordinate of R'
. Then (r',r'*s/(a*r'),r'*z/r)
is another ECDSA triplet, corresponding to multiplying k
with a
. However, again, this is not a valid signature because its z value will not be the hash of a computable message. And the formula above will also fail to retrieve the private key in this case, because the second "signature" wasn't created by using the private key.