public IssuerKeyAndParameters CreateIssuerSetupParameters(IssuerSetupParametersSpec spec) { IssuerSetupParameters isp = new IssuerSetupParameters(); isp.GroupConstruction = spec.GroupConstruction ?? GroupType.Subgroup; isp.UidP = ExtensionMethods.ToByteArray(spec.IssuerID); isp.E = spec.AttributeEncoding != null ? spec.AttributeEncoding : IssuerSetupParameters.GetDefaultEValues(spec.NumberOfAttributes); isp.UseRecommendedParameterSet = spec.UseRecommendedParameterSet ?? true; if (issuerStore.HasValue(spec.IssuerID) && spec.StoreOnServer) { ApiArgumentFault fault = new ApiArgumentFault(); fault.Details = "Issuer with unique ID was found"; fault.Argument = "IssuerSetupParametersSpec.ID"; fault.ArgumentValue = spec.ParameterSetName; throw new FaultException <ApiArgumentFault>(fault); } // look up ParameterSet. if (isp.UseRecommendedParameterSet) { isp.ParameterSet = IssuerSetupParameters.GetDefaultParameterSet(isp.GroupConstruction); // XXX add a check here to see if the name of the default parameterset is that same as // specified in spec.ParameterSetName and that match with the sha method specified. } else { ParameterSet pSet; if (ParameterSet.TryGetNamedParameterSet(spec.ParameterSetName, out pSet)) { isp.ParameterSet = pSet; } else { ApiArgumentFault fault = new ApiArgumentFault(); fault.Details = "Member value vas not found"; fault.Argument = "IssuerSetupParametersSpec.ParameterSetName"; fault.ArgumentValue = spec.ParameterSetName; throw new FaultException <ApiArgumentFault>(fault); } } // specification field unused in ABC4Trust isp.S = null; IssuerKeyAndParameters issuerKeyParam = isp.Generate(true); if (spec.StoreOnServer) { issuerStore.AddValue(spec.IssuerID, issuerKeyParam); } return(issuerKeyParam); }
public static void GetUProveParameters( bool hashAttributes, out ProverPresentationProtocolParameters proverParams, out VerifierPresentationProtocolParameters verifierParams, byte [] customTokenInformation = null, byte [][] customAttributes = null, GroupElement [] customGenerators = null, byte [] customUidP = null ) { // Issuer setup IssuerSetupParameters isp = new IssuerSetupParameters(maxNumberOfAttributes); if (customUidP == null) { isp.UidP = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; } else { isp.UidP = customUidP; } if (hashAttributes) { isp.E = _e1; } else { isp.E = _e0; } isp.S = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; if (customGenerators != null) { isp.ParameterSet = IssuerSetupParameters.GetDefaultParameterSet(); PrivateObject customParams = new PrivateObject(isp.ParameterSet); customParams.SetField("G", customGenerators); } else { isp.UseRecommendedParameterSet = true; } IssuerKeyAndParameters ikap = isp.Generate(); IssuerParameters ip = ikap.IssuerParameters; // Issuance byte[][] attributes = new byte[][] { _encoding.GetBytes("Attribute 1"), _encoding.GetBytes("Attribute 2"), _encoding.GetBytes("Attribute 3"), _encoding.GetBytes("Attribute 4") }; if (customAttributes != null) { attributes = customAttributes; } byte[] tokenInformation = new byte[] { }; if (customTokenInformation != null) { tokenInformation = customTokenInformation; } byte[] proverInformation = new byte[] { }; int numberOfTokens = 1; IssuerProtocolParameters ipp = new IssuerProtocolParameters(ikap); ipp.Attributes = attributes; ipp.NumberOfTokens = numberOfTokens; ipp.TokenInformation = tokenInformation; Issuer issuer = ipp.CreateIssuer(); FirstIssuanceMessage msg1 = issuer.GenerateFirstMessage(); ProverProtocolParameters ppp = new ProverProtocolParameters(ip); ppp.Attributes = attributes; ppp.NumberOfTokens = numberOfTokens; ppp.TokenInformation = tokenInformation; ppp.ProverInformation = proverInformation; // ppp.BatchValidationSecurityLevel = -1; Prover prover = ppp.CreateProver(); SecondIssuanceMessage msg2 = prover.GenerateSecondMessage(msg1); ThirdIssuanceMessage msg3 = issuer.GenerateThirdMessage(msg2); UProveKeyAndToken[] upkt = prover.GenerateTokens(msg3, true); // Pseudonym int[] disclosed = new int[0]; int[] committed = new int[] { 1, 3, 4, 2 }; byte[] message = _encoding.GetBytes("this is the presentation message, this can be a very long message"); byte[] scope = _encoding.GetBytes("scope"); //Generate prover proverParams = new ProverPresentationProtocolParameters(ip, disclosed, message, upkt[0], attributes); proverParams.Committed = committed; //Generate verifier verifierParams = new VerifierPresentationProtocolParameters(ip, disclosed, message, upkt[0].Token); verifierParams.Committed = committed; }