/// <summary>
        /// Construct a GroupSerializable object from a Group object.
        /// </summary>
        /// <param name="group">The Group object being serialized.</param>
        public GroupSerializable(Group group)
        {
            if (this.InRecommendedGroup(group.GroupName))
            {
                this.type = "named";
                this.name = group.GroupName;
                this.sgDesc = null;
            }
            else if (group.Type == GroupType.ECC)
            {
                this.type = "ec";
                this.name = null;
                this.sgDesc = null;
            }
            else if (group.Type == GroupType.Subgroup)
            {
                this.type = "sg";
                this.sgDesc = new SubgroupGroupSerializable((SubgroupGroup)group);
                this.name = null;
            }
            else
            {
                throw new UProveSerializationException("Invalid GroupConstruction");
            }

            return;
        }
Ejemplo n.º 2
0
 public static GroupElement CreateGroupElement(Group Gq, string value)
 {
     if (Gq is SubgroupGroup)
     {
         return Gq.CreateGroupElement(HexToBytes(value));
     }
     else
     {
         ECGroup ecGq = Gq as ECGroup;
         string[] point = value.Split(',');
         return ecGq.CreateGroupElement(HexToBytes(point[0]), HexToBytes(point[1]));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Private constructor - takes and sets all fields.
 /// </summary>
 /// <param name="Gq">The group</param>
 /// <param name="gd">The device generator</param>
 /// <param name="Zq">The Field associated to the group <c>Gq</c></param>
 /// <param name="xd">The xd.</param>
 /// <param name="preGenWdPrime">The pre gen wd prime.</param>
 VirtualDevice(Group Gq, GroupElement gd, FieldZq Zq, FieldZqElement xd, FieldZqElement preGenWdPrime)
 {
     if (xd != null && !Zq.IsElement(xd))
     {
         throw new ArgumentException("xd is not a valid Zq element");
     }
     this.Gd = gd;
     this.Gq = Gq;
     this.Zq = Zq;
     this.xd = xd ?? this.Zq.GetRandomElement(true);     // assign xd a random value if null
     this.wdPrime = preGenWdPrime;
     this.hd = this.Gd.Exponentiate(this.xd);
 }
 /// <summary>
 /// Convert a base64 string to a GroupElement[] using a specific Group object.
 /// </summary>
 /// <param name="encodedElements">The encoded string to convert.</param>
 /// <param name="group">The group object to use.</param>
 /// <returns>The converted object.</returns>
 public static GroupElement[] ToGroupElementArray(this String[] encodedElements, Group group)
 {
     if (encodedElements == null) return null;
     if (group == null) throw new ArgumentNullException("group");
     GroupElement[] groupElements = new GroupElement[encodedElements.Length];
     for (int i = 0; i < encodedElements.Length; i++)
     {
         groupElements[i] = encodedElements[i].ToGroupElement(group);
     }
     return groupElements;
 }
 /// <summary>
 /// Convert a base64 string to a GroupElement using a specific Group object.
 /// </summary>
 /// <param name="encodedString">The encoded string to convert.</param>
 /// <param name="group">The group object to use.</param>
 /// <returns>The converted object.</returns>
 public static GroupElement ToGroupElement(this String encodedString, Group group)
 {
     if (encodedString == null) return null;
     if (group == null) throw new ArgumentNullException("group");
     return group.CreateGroupElement(encodedString.ToByteArray());
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Hash a Group.
 /// </summary>
 /// <param name="value">A group to be hashed.</param>
 public void Hash(Group value)
 {
     value.UpdateHash(this);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Create the group element associated with a scope.
 /// </summary>
 public static GroupElement GenerateScopeElement(Group Gq, byte[] scope)
 {
     int counter;
     return Gq.DeriveElement(scope, ScopeElementIndex, out counter);
 }