/// <summary>
 /// Deserialize.
 /// </summary>
 /// <param name="context"></param>
 public override void FinishDeserializing()
 {
     base.FinishDeserializing();
     if ((_witnesses != null) && (AreWitnessesSerializable))
     {
         if (this.AreWitnessBasesSerializable)
         {
             this.Witnesses = CryptoSerializer.Deserialize <DLRepOfGroupElement>(_witnesses, this.Group);
         }
         else
         {
             this.Witnesses = CryptoSerializer.Deserialize <DLRepOfGroupElement>(_witnesses, this.Group, this.Generators);
         }
     }
     if ((_publicValues != null) && ArePublicValuesSerializable)
     {
         this.PublicValues = CryptoSerializer.DeserializeGroupElementArray(_publicValues, "PublicValues", this.Group);
     }
     if ((this.PublicValues == null) && (this.Witnesses != null))
     {
         this.PublicValues = new GroupElement[this.Witnesses.Length];
         for (int i = 0; i < this.PublicValues.Length; ++i)
         {
             this.PublicValues[i] = this.Witnesses[i].Value;
         }
     }
 }
        /// <summary>
        /// Finishes deserializing once json deserialization is complete.
        /// </summary>
        /// <param name="group">May be null. Used only if group was not serialized.</param>
        /// <param name="bases">May be null.  Used only if group was not serialized.</param>
        public void FinishDeserializing(Group group, GroupElement[] bases)
        {
            // get group
            if (this.Group == null)
            {
                if (group == null)
                {
                    throw new SerializationException("Cannot deserialize because serialized group and group argument are both null.");
                }
                this.Group = group;
            }

            // get value
            this.Value = CryptoSerializer.DeserializeGroupElement(_value, this.Group);

            // get bases
            if (this._bases == null)
            {
                if (bases == null)
                {
                    throw new SerializationException("Cannot deserialize because serialized bases and bases argument are both null.");
                }
                if (bases.Length == this._representationLength)
                {
                    this.Bases = bases;
                }
                else
                {
                    this.Bases = new GroupElement[this._representationLength];
                    for (int i = 0; i < this.Bases.Length; ++i)
                    {
                        this.Bases[i] = bases[i];
                    }
                }
            }
            else
            {
                this.Bases = CryptoSerializer.DeserializeGroupElementArray(this._bases, "bases", this.Group);
            }

            // get exponents
            if (this._exponents == null)
            {
                this.Exponents = null;
            }
            else
            {
                this.Exponents = CryptoSerializer.DeserializeFieldZqElementArray(this._exponents, "Exponents", this.Group);
                if (this.Exponents.Length != this.Bases.Length)
                {
                    throw new SerializationException("Cannot Deserialize. Must have equal number of exponents and bases.");
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Deserialize A and B. Finish deserialing Proof.
        /// </summary>
        public override void FinishDeserializing()
        {
            GroupElement[] AB = CryptoSerializer.DeserializeGroupElementArray(this._AB, 0, 2, "AB", this.Group);
            this.A = AB[0];
            this.B = AB[1];

            if (this.Proof != null)
            {
                this.Proof.FinishDeserializing(this.Group);
            }
            if (this.UPIProof != null)
            {
                this.UPIProof.FinishDeserializing(this.Group);
            }
        }
        /// <summary>
        /// Deserialize a,c,r.
        /// </summary>
        public override void FinishDeserializing()
        {
            a = CryptoSerializer.DeserializeGroupElementArray(_a, "a", this.Group);
            c = CryptoSerializer.DeserializeFieldZqElementArray(_c, "c", this.Group);
            r = CryptoSerializer.DeserializeFieldZqElementArray(_r, "r", this.Group);

            if (a.Length - 1 != c.Length || a.Length != r.Length)
            {
                throw new SerializationException("Arrays a, and r must have the same length, while c must be one element shorter.");
            }

            if (this.UPIProof != null)
            {
                this.UPIProof.FinishDeserializing(this.Group);
            }
        }
Exemple #5
0
        /// <summary>
        /// Deserialize A,B,X,D, as well as all proofs.
        /// </summary>
        public override void FinishDeserializing()
        {
            // deserialize A
            this.A = CryptoSerializer.DeserializeGroupElementArray(_a, "A", this.Group);
            int length = A.Length;

            if (this._b != null)
            {
                this.B = CryptoSerializer.DeserializeGroupElementArray(_b, "B", this.Group);
            }
            this.X = CryptoSerializer.DeserializeGroupElementArray(_x, 1, _x.Length + 1, "X", this.Group);
            this.D = CryptoSerializer.DeserializeGroupElementArray(_d, 1, _d.Length + 1, "D", this.Group);

            if (this.ProofBitDecompositionOfA != null)
            {
                this.ProofBitDecompositionOfA.FinishDeserializing(this.Group);
            }
            if (this.ProofBitDecompositionOfB != null)
            {
                this.ProofBitDecompositionOfB.FinishDeserializing(this.Group);
            }
            if (this.FullRangeProof != null)
            {
                this.FullRangeProof.FinishDeserializing(this.Group);
            }
            if (this.OrEqualToProof != null)
            {
                this.OrEqualToProof.FinishDeserializing(this.Group);
            }
            if (this.StrictlyThanProof != null)
            {
                this.StrictlyThanProof.FinishDeserializing(this.Group);
            }
            if (this.UPIProof != null)
            {
                this.UPIProof.FinishDeserializing(this.Group);
            }
        }
 /// <summary>
 /// Deserialize generators.
 /// </summary>
 public override void FinishDeserializing()
 {
     this.Generators = CryptoSerializer.DeserializeGroupElementArray(_generators, "Generators", this.Group);
 }
 /// <summary>
 /// Deserialize b, responseEqual, responseUnequal
 /// </summary>
 public override void FinishDeserializing()
 {
     this.b               = CryptoSerializer.DeserializeGroupElementArray(this._b, "b", this.Group);
     this.responseEqual   = CryptoSerializer.DeserializeFieldZqElementArray(this._responseEqual, "responseEqual", this.Group);
     this.responseUnequal = CryptoSerializer.DeserializeFieldZqElementArray(this._responseUnequal, "responseUnequal", this.Group);
 }