Beispiel #1
0
        static public void SaveBlindParticipant(APIServer server, GroupRepository groupRepository)
        {
            Console.WriteLine("Enter the group for which you want to register participants:");
            var groupName = Console.ReadLine();

            Console.WriteLine("Enter participant email address that you want to be saved as blind participant:");
            var participantEmail = Console.ReadLine();
            var group            = server.GetGroupByName(groupName);

            var        factor      = File.ReadAllText("BlindFactor.txt");
            BigInteger blindFactor = new BigInteger(factor);

            var fileToRead = (participantEmail.Substring(0, participantEmail.IndexOf("@")) + "PublicKey.txt").ToString();
            RsaKeyParameters  participantPublicKey = (RsaKeyParameters)RsaKeyUtils.GetDeserializedKPublicKey(File.ReadAllText(fileToRead));
            GroupRegistration groupRegistration    = new GroupRegistration(group, new ContentBlinder(group.RsaPublicKey, blindFactor), participantPublicKey);

            ClientParticipant   clientParticipant   = new ClientParticipant(server, groupRepository);
            VerifiedParticipant verifiedParticipant = clientParticipant.CheckVerifiedEntity(group, participantEmail, groupRegistration);

            clientParticipant.AddClientCertificate(verifiedParticipant, group, participantEmail);
            Console.WriteLine("Enter nickname:");
            var nickname = Console.ReadLine();

            clientParticipant.AddBlindParticipant(group.Id, verifiedParticipant, nickname);

            Console.WriteLine();
            Console.WriteLine("Participant was saved as a blind participant to the group");
        }
Beispiel #2
0
        static public AsymmetricCipherKeyPair ImportCertificate(string pubKeyFile, string privKeyFile)
        {
            var pubKey  = (AsymmetricKeyParameter)RsaKeyUtils.GetDeserializedKPublicKey(File.ReadAllText(pubKeyFile));
            var privKey = (AsymmetricKeyParameter)RsaKeyUtils.GetDeserializedPrivateKey(File.ReadAllText(privKeyFile));
            AsymmetricCipherKeyPair keys = new AsymmetricCipherKeyPair(pubKey, privKey);

            return(keys);
        }
Beispiel #3
0
        public void AddMessage(Guid groupId, ParticipantMessage message, VerifiedParticipant participant)
        {
            var groupDetails = groupRepository.GetGroup(groupId);

            var groupPubKey = File.ReadAllText(groupDetails.Name + "PublicKey.txt");
            var rsaPubKey   = RsaKeyUtils.GetDeserializedKPublicKey(groupPubKey);

            SignedEntity signedEntity = new SignedEntity(FromBase64String(participant.PublicKey), FromBase64String(participant.Signature));

            bool isVerified = signatureVerifier.Verify(signedEntity, rsaPubKey);

            if (isVerified)
            {
                groupRepository.SaveMessage(participant, message);
            }
        }