Generic | Example 1 | Example 2 | |
1. | w = s-1(mod n) | = 1317(mod 19) = 3 |
|
2. | u1 = e w (mod n) | = (8)(3) (mod 19) = 5 |
|
3. | u2 = r w (mod n) |
= (10)(3) (mod 19)
= 30 (mod 19)
= 11
|
|
4. |
(x1, y1) = (u1 ⨯ G) + (u2 ⨯ QA)
ephemeral public key matches, therefore verifies.
|
= 5 ⨯ (5, 1) + 11 ⨯ (9, 16) = (9, 16) + (6, 14) = (10, 6) |
var w = BigInteger.ModPow(s, curve.n - 2, curve.n); // s = Signature part 2 of 2 var u1 = BigInteger.ModPow(e * w, BigInteger.One, curve.n); // e = Message Hash var u2 = BigInteger.ModPow(r * w, BigInteger.One, curve.n); // r = Signature part 1 of 2 ECPoint u1G = curve.Multiply(u1, curve.G); ECPoint u2QA = curve.Multiply(u2, QA); // QA = Public Key = K = (K_x, K_y) ECPoint vP = curve.PointAddition(u1G, u2QA); // x1 = r Console.WriteLine("X is the same: {0}", vP.X.Equals(K.X));