Simple math ECDSA example I'm trying to setup an ECDSA math example using just integer math and multiply (no EC).  The purpose is just to help people understand why this works with out the added complication of understanding EC.  However, it looks like I either don't understand something or I'm making a simple math mistake.  

Can someone help me fix this?

Here is what I'm doing:

Signer workflow:

private da = 7

G          = 2 

pubkey     = da * G = 14 

message z  = 10 

n          = 17 

k          = 13 

k^-1       = 4 

x1         = 26 

r          = 26 mod 17 = 9  

s          = 4(10 - 9 * 7) mod 17 = 8 

Verify workflow:

w  = s^-1 = 15 

u1 = z * w mod n = 14 

u2 = r * w mod n = 16 

x2 = u1*G + u2*pubkey = 252 

r2 = x2 mod n = 14 &lt;=== failed...??
s = 4(10 - 9 * 7) mod 17 = 8 


That should be:

s = 4(10 + 9 * 7) mod 17 = 3

If you modify the rest of the example to account for this, the example works.