public static void TestProtocol() { var rsa = new RSACryptography(); var validator = new Validator(rsa); validator.CreateKeys(); var agency = new Agency(rsa, validator.PublicKey.GetChangeableCopy(), 10); var elector = new Elector(rsa, validator.PublicKey.GetChangeableCopy()); elector.CreateNewKeys(); var blinded = elector.CreateBlindedMessage(0); var blindedSigned = elector.CreateBlindedSignedMessage(0); if (validator.VerifyBulletin(blindedSigned, blinded, elector.PublicSignKey.GetChangeableCopy())) { var signedByValidator = validator.SignBulletin(blinded); var signedValidatorUnBlind = elector.RemoveBlindEncryption(signedByValidator); var encryptedBulletin = elector.GetEncryptedBulletin(0); var signedEncryptedBulletin = elector.GetSignedEncryptedBulletin(0); agency.AddBulletin(signedValidatorUnBlind, encryptedBulletin, signedEncryptedBulletin, elector.PublicSignKey.GetChangeableCopy(), 1); } }
private void CreateValidator() { var checkCrypto = false; var i = 0; while (!checkCrypto) { Validator = new Validator(CryptographyProvider); Validator.CreateKeys(); var validatorKey = Validator.PublicKey.GetChangeableCopy(); var elector = new Elector(CryptographyProvider, validatorKey); elector.CreateNewKeys(); var blindedSigned = elector.CreateBlindedSignedMessage(0); var blinded = elector.CreateBlindedMessage(0); checkCrypto = CryptographyProvider.VerifyData(elector.PublicSignKey.GetChangeableCopy(), blinded, blindedSigned); i++; } }
public void InitializeElector(Dictionary <string, object> validatorKey) { var checkCrypto = false; var i = 0; while (!checkCrypto) { Elector = new Elector(CryptographyProvider, validatorKey); Elector.CreateNewKeys(); var blindedSigned = Elector.CreateBlindedSignedMessage(0); var blinded = Elector.CreateBlindedMessage(0); checkCrypto = CryptographyProvider.VerifyData(Elector.PublicSignKey.GetCopy(), blinded, blindedSigned); i++; } LogIn(); Debug.Log("Elector created"); }