예제 #1
0
 public BadShareProof(int complainingAuthorityIndex, CertificateStorage certificateStorage, Signed<VotingParameters> signedParameters, AllShareParts allShareParts, IDictionary<int, TrapDoor> trapDoors, IDictionary<int, Certificate> authorities)
 {
     ComplainingAuthorityIndex = complainingAuthorityIndex;
       CertificateStorage = certificateStorage;
       SignedParameters = signedParameters;
       AllShareParts = allShareParts;
       TrapDoors = new Dictionary<int, TrapDoor>(trapDoors);
       Authorities = new Dictionary<int, Certificate>(authorities);
 }
예제 #2
0
        /// <summary>
        /// Verifies shares from all authorities.
        /// </summary>
        /// <param name="allShareParts">All share parts from all authorities.</param>
        /// <returns>Signed response.</returns>
        public Signed<ShareResponse> VerifyShares(AllShareParts allShareParts)
        {
            if (allShareParts == null)
            throw new ArgumentNullException("allShareParts");

              List<Share> shares = new List<Share>();
              List<List<VerificationValue>> verificationValuesByAuthority = new List<List<VerificationValue>>();
              bool acceptShares = true;

              foreach (Signed<SharePart> signedShareParrt in allShareParts.ShareParts)
              {
            SharePart sharePart = signedShareParrt.Value;

            acceptShares &= signedShareParrt.Verify(this.certificateStorage);
            acceptShares &= signedShareParrt.Certificate.IsIdentic(this.authorities[sharePart.AuthorityIndex]);

            Encrypted<Share> encryptedShare = sharePart.EncryptedShares[this.authority.Index - 1];
            shares.Add(encryptedShare.Decrypt(this.certificate));

            verificationValuesByAuthority.Add(new List<VerificationValue>());

            for (int l = 0; l <= this.parameters.Thereshold; l++)
            {
              verificationValuesByAuthority[verificationValuesByAuthority.Count - 1].Add(sharePart.VerificationValues[l]);
            }
              }

              acceptShares &= this.authority.VerifySharing(shares, verificationValuesByAuthority);

              BigInt publicKeyPart = acceptShares ? this.authority.PublicKeyPart : new BigInt(0);

              ShareResponse response = new ShareResponse(allShareParts.VotingId, this.authority.Index, acceptShares, publicKeyPart, this.signedParameters);

              return new Signed<ShareResponse>(response, this.certificate);
        }
예제 #3
0
 /// <summary>
 /// Deserializes binary data to object.
 /// </summary>
 /// <param name="context">Context for deserialization</param>
 protected override void Deserialize(DeserializeContext context, byte version)
 {
     base.Deserialize(context, version);
       AllShareParts = context.ReadObject<AllShareParts>();
 }
예제 #4
0
        /// <summary>
        /// Creates a proof for bad shares.
        /// </summary>
        /// <param name="allShareParts">All share parts from all authorities.</param>
        /// <returns>Signed proof data.</returns>
        public Signed<BadShareProof> CreateBadShareProof(AllShareParts allShareParts)
        {
            Dictionary<int, TrapDoor> trapDoors = new Dictionary<int, TrapDoor>();
              foreach (Signed<SharePart> signedSharePart in allShareParts.ShareParts)
              {
            SharePart sharePart = signedSharePart.Value;

            Encrypted<Share> encryptedShare = sharePart.EncryptedShares[this.authority.Index - 1];
            trapDoors.Add(sharePart.AuthorityIndex, encryptedShare.CreateTrapDoor(this.certificate));
              }

              BadShareProof badShareProof = new BadShareProof(
            this.authority.Index,
            this.certificateStorage,
            this.signedParameters,
            allShareParts,
            trapDoors,
            this.authorities);

              return new Signed<BadShareProof>(badShareProof, this.certificate);
        }
예제 #5
0
 public FetchAllSharesResponse(Guid requestId, AllShareParts allShareParts)
     : base(requestId)
 {
     AllShareParts = allShareParts;
 }