public FirstIssuanceMessageInfo FirstMessage(FirstIssuanceMessageSpec spec) { if (!issuerStore.HasValue(spec.IssuerID)) { ApiArgumentFault fault = new ApiArgumentFault(); fault.Details = "Issuer with unique ID was found"; fault.Argument = "FirstIssuanceMessageSpec.IssuerID"; fault.ArgumentValue = spec.IssuerID; throw new FaultException <ApiArgumentFault>(fault); } IssuerKeyAndParameters ikp = issuerStore.GetValue(spec.IssuerID); IssuerProtocolParameters ipp = new IssuerProtocolParameters(ikp); ipp.NumberOfTokens = spec.NumberOfTokens; ipp.Attributes = ConvertToByteArray(spec.Attributes); if (!String.IsNullOrWhiteSpace(spec.TokenInfomation)) { ipp.TokenInformation = ExtensionMethods.ToByteArray(spec.TokenInfomation); } if (!String.IsNullOrWhiteSpace(spec.Gamma)) { ipp.Gamma = ExtensionMethods.ToGroupElement(spec.Gamma, ikp.IssuerParameters); } if (!String.IsNullOrWhiteSpace(spec.DevicePublicKey)) { ipp.DevicePublicKey = ExtensionMethods.ToGroupElement(spec.DevicePublicKey, ikp.IssuerParameters); } ipp.Validate(); Issuer issuer = ipp.CreateIssuer(); FirstIssuanceMessage firstMessage = issuer.GenerateFirstMessage(); FirstIssuanceMessageInfo ret = new FirstIssuanceMessageInfo(); ret.FirstMessage = firstMessage; Guid issuerInstance = Guid.NewGuid(); ret.IssuerInstanceID = issuerInstance; ret.FirstMessageState = issuer.ExportPostFirstMessageState(); issuerInstanceDB.TryAdd(issuerInstance, new IssuerInstanceData(issuer)); return(ret); }
public FirstIssuanceMessageInfo FirstMessage(FirstIssuanceMessageSpec spec) { if (!issuerStore.HasValue(spec.IssuerID)) { ApiArgumentFault fault = new ApiArgumentFault(); fault.Details = "Issuer with unique ID was found"; fault.Argument = "FirstIssuanceMessageSpec.IssuerID"; fault.ArgumentValue = spec.IssuerID; throw new FaultException<ApiArgumentFault>(fault); } IssuerKeyAndParameters ikp = issuerStore.GetValue(spec.IssuerID); IssuerProtocolParameters ipp = new IssuerProtocolParameters(ikp); ipp.NumberOfTokens = spec.NumberOfTokens; ipp.Attributes = ConvertToByteArray(spec.Attributes); if (!String.IsNullOrWhiteSpace(spec.TokenInfomation)) { ipp.TokenInformation = ExtensionMethods.ToByteArray(spec.TokenInfomation); } if (!String.IsNullOrWhiteSpace(spec.Gamma)) { ipp.Gamma = ExtensionMethods.ToGroupElement(spec.Gamma, ikp.IssuerParameters); } if (!String.IsNullOrWhiteSpace(spec.DevicePublicKey)) { ipp.DevicePublicKey = ExtensionMethods.ToGroupElement(spec.DevicePublicKey, ikp.IssuerParameters); } ipp.Validate(); Issuer issuer = ipp.CreateIssuer(); FirstIssuanceMessage firstMessage = issuer.GenerateFirstMessage(); FirstIssuanceMessageInfo ret = new FirstIssuanceMessageInfo(); ret.FirstMessage = firstMessage; Guid issuerInstance = Guid.NewGuid(); ret.IssuerInstanceID = issuerInstance; ret.FirstMessageState = issuer.ExportPostFirstMessageState(); issuerInstanceDB.TryAdd(issuerInstance, new IssuerInstanceData(issuer)); return ret; }