public void getcommit(ucommit ucom, user u) { vtb.AppendText("Commitment request received from " + u.name + "! \n"); if (ucom.getD() < ucom.getcert().getexp()) if (verifyuser(ucom)) if (verifycert(ucom.getcert())) { vtb.AppendText("\tCommitment approved, message sent ! \n"); trust = true; ucomm = ucom; lastpay = new payment(ucom.getc0(),0); u.comconfirm(true, this); if (!(cycleth.IsAlive == true)) cycleth.Start(); } else { vtb.AppendText("\tCertificate Signature Invalid, message sent ! \n"); u.comconfirm(false, this); } else { vtb.AppendText("\tUser Signature Invalid, message sent ! \n"); u.comconfirm(false, this); } else { vtb.AppendText("\tCertificate expired, message sent ! \n"); u.comconfirm(false, this); } }
public void comconfirm(bool c,vendor v) { if (c == true) utb.AppendText("\tComitment to vendor: " + v.name + " confirmed !\n"); else { ucomm = null; utb.AppendText("\tComitment to vendor: " + v.name + " failed !\n"); } commited = c; }
private bool verifyuser(ucommit ucom) { rsakey upbkey = ucom.getcert().getukey(); string mess = ucom.getvendor() + "," + ucom.getcert().ToString() + "," + ucom.getc0().ToString() + "," + ucom.getD().ToString() + "," + ucom.getinfo(); BigInteger messh = hashf.hash(mess); return rsa.verifySig(messh, ucom.getsigU(), upbkey); }
public void sendcommit(vendor v) { genpaywords(pwnr + 1); currentpw = 0; utb.AppendText("Commitment : Generated 1$ paywords(" + pwnr + ") !\n"); string info = "adinfo"; string sigstr = v.name + "," + cert.ToString() + "," + pwords[0].ToString() + "," + DateTime.Now.ToString() + "," + info; BigInteger sigh = hashf.hash(sigstr); BigInteger sigU = rsa.createSig(sigh, upvk); ucommit cmes = new ucommit(v.name, cert, pwords[0], DateTime.Now, info, sigU); ucomm = cmes; utb.AppendText("\tSent comitment to " + v.name + " !\n"); v.getcommit(cmes, this); }
public redmess(payment pw, ucommit ucom) { lpay = pw; ucomm = ucom; }
private bool verifyuser(ucommit ucom) { foreach(var it in clist) if (it.getuser() == ucom.getcert().getuser()) { rsakey upbkey = ucom.getcert().getukey(); string mess = ucom.getvendor() + "," + ucom.getcert().ToString() + "," + ucom.getc0().ToString() + "," + ucom.getD().ToString() + "," + ucom.getinfo(); BigInteger messh = hashf.hash(mess); return rsa.verifySig(messh, ucom.getsigU(), upbkey); } return false; }