/// <summary> /// Deserialize this object into a Group object. /// </summary> /// <returns>The Group object represented by this GroupSerializable object.</returns> public Group ToGroup() { ParameterSet parameterSet; if ((sgDesc != null ? 1 : 0) + (name != null ? 1 : 0) > 1) { throw new UProveSerializationException("Only one of 'name' or 'sgDesc' can be set"); } switch (type) { case "sg": return(sgDesc.ToSubgroupGroup()); case "named": if (ParameterSet.TryGetNamedParameterSet(name, out parameterSet) == false) { throw new UProveSerializationException("Unsupported named group :" + this.name); } break; default: throw new UProveSerializationException("Invalid GroupConstruction: " + this.type); } return(parameterSet.Group); }
internal void OnDeserialized(StreamingContext context) { if (_uidp == null) { throw new UProveSerializationException("uidp"); } if (_group == null) { throw new UProveSerializationException("descGq"); } if (_uidh == null) { throw new UProveSerializationException("uidh"); } if (_g == null) { throw new UProveSerializationException("g"); } this.UidP = _uidp.ToByteArray(); this.Gq = _group.ToGroup(); this.UidH = _uidh; this.Gd = _gd.ToGroupElement(this.Gq); this.E = (_e == null) ? new byte[] {} : _e.ToByteArray(); this.S = _s.ToByteArray(); ParameterSet defaultParamSet; if (ParameterSet.TryGetNamedParameterSet(this.Gq.GroupName, out defaultParamSet)) // named { if ((_g.Length == 1)) // only have g0 { ProtocolHelper.GenerateIssuerParametersCryptoData(this, defaultParamSet.G, false); this.G[0] = _g.ToGroupElementArray(this.Gq)[0]; this.UsesRecommendedParameters = true; } else if (_g.Length == E.Length + 2) // we got all the G elements { this.G = _g.ToGroupElementArray(this.Gq); } else { throw new UProveSerializationException("Invalid number of elements in G"); } if (this.gd == null) { // named group always support devices this.Gd = defaultParamSet.Gd; } } else // custom - use all provided elements of G { if (_g.Length != E.Length + 2) { throw new UProveSerializationException("Invalid number of elements in G"); } this.G = _g.ToGroupElementArray(this.Gq); } }
/// <summary> /// Verifies the Issuer parameters. /// </summary> /// <param name="ip">The Issuer parameters to verify.</param> /// <param name="usesRecommededParameters">If true then use recommended parameters.</param> public static void VerifyIssuerParameters(IssuerParameters ip, bool usesRecommededParameters) { Group Gq = ip.Gq; ParameterSet set; if (!usesRecommededParameters && !ParameterSet.TryGetNamedParameterSet(ip.Gq.GroupName, out set)) { // not a known group, verify it ip.Gq.Verify(); } // verify public key elements ip.Gq.ValidateGroupElement(ip.G[0]); if (!usesRecommededParameters) { for (int i = 1; i < ip.G.Length; i++) { ip.Gq.ValidateGroupElement(ip.G[i]); } } }