Пример #1
0
        public Authority(DeserializeContext context, BaseParameters parameters)
        {
            Index = context.ReadInt32();
              this.polynomial = context.ReadObject<Polynomial>();

              if (!context.ReadBoolean())
              {
            this.secretKeyPart = context.ReadBigInt();
              }

              this.parameters = parameters;
        }
Пример #2
0
 protected override void Deserialize(DeserializeContext context)
 {
     base.Deserialize(context);
       P = context.ReadBigInt();
       Q = context.ReadBigInt();
       G = context.ReadBigInt();
       F = context.ReadBigInt();
       Thereshold = context.ReadInt32();
       AuthorityCount = context.ReadInt32();
       MaxVota = context.ReadInt32();
       OptionCount = context.ReadInt32();
       ProofCount = context.ReadInt32();
 }
Пример #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);
       P = context.ReadBigInt();
       Q = context.ReadBigInt();
       G = context.ReadBigInt();
       F = context.ReadBigInt();
       Thereshold = context.ReadInt32();
       AuthorityCount = context.ReadInt32();
       ProofCount = context.ReadInt32();
       this.questions = context.ReadObjectList<Question>();
 }
Пример #4
0
 protected override void Deserialize(DeserializeContext context, byte version)
 {
     base.Deserialize(context, version);
       SourceAuthorityIndex = context.ReadInt32();
       DestinationAuthorityIndex = context.ReadInt32();
       Value = context.ReadBigInt();
 }
Пример #5
0
 protected override void Deserialize(DeserializeContext context, byte version)
 {
     base.Deserialize(context, version);
       T0 = context.ReadBigInt();
       C0 = context.ReadInt32();
       S0 = context.ReadBigInt();
 }
Пример #6
0
        /// <summary>
        /// Tries to load a pregenerated safe prime.
        /// </summary>
        /// <param name="dataPath">Path where application data is stored.</param>
        /// <param name="bitLength">Length of the prime.</param>
        /// <param name="prime">Prime loaded.</param>
        /// <param name="safePrime">Safe prime loaded.</param>
        /// <returns>Was a prime and safe prime found?</returns>
        public static bool TryLoadPregeneratedSafePrime(string dataPath, int bitLength, out BigInt prime, out BigInt safePrime)
        {
            var dataDirectory = new DirectoryInfo(dataPath);
              var files = dataDirectory.GetFiles(Files.SafePrimePattern);

              foreach (var file in files)
              {
            try
            {
              FileStream fileStream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read);
              DeserializeContext context = new DeserializeContext(fileStream);

              prime = context.ReadBigInt();
              safePrime = context.ReadBigInt();

              context.Close();
              fileStream.Close();

              file.Delete();

              if (Prime.HasSufficientLength(prime, bitLength) &&
              Prime.HasSufficientLength(safePrime, bitLength) &&
              Prime.IsPrime(prime) &&
              Prime.IsSafePrime(safePrime))
              {
            return true;
              }
            }
            catch
            {
              file.Delete();
            }
              }

              prime = null;
              safePrime = null;
              return false;
        }
Пример #7
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);
       VotingId = context.ReadGuid();
       AuthorityIndex = context.ReadInt32();
       AcceptShares = context.ReadBoolean();
       PublicKeyPart = context.ReadBigInt();
       VotingParametersHash = context.ReadBytes();
 }
Пример #8
0
 protected override void Deserialize(DeserializeContext context, byte version)
 {
     base.Deserialize(context, version);
       QuestionIndex = context.ReadInt32();
       OptionIndex = context.ReadInt32();
       AuthorityIndex = context.ReadInt32();
       GroupIndex = context.ReadInt32();
       Value = context.ReadBigInt();
 }
Пример #9
0
 protected override void Deserialize(DeserializeContext context, byte version)
 {
     base.Deserialize(context, version);
       HalfKey = context.ReadBigInt();
       Ciphertext = context.ReadBigInt();
       P = context.ReadBigInt();
       RangeProves = context.ReadObjectList<RangeProof>();
 }