// issuerPrivateKey must be set using setIssuerPrivateKey() before calling this method public FirstIssuanceMessageComposite getFirstMessage(string[] attributesParam, IssuerParametersComposite ipc, int numberOfTokensParam, string sessionID, byte[] hd) { /* * token issuance - generate first message */ cOut.write("Issuing U-Prove tokens - generate first message, issuer side"); VerifySessionId(sessionID); try { // specify the attribute values agreed to by the Issuer and Prover int numberOfAttributes = attributesParam.Length; byte[][] attributes = new byte[numberOfAttributes][]; for (int i = 0; i < numberOfAttributes; i++) { attributes[i] = encoding.GetBytes(attributesParam[i]); } IssuerParameters ip = ConvertUtils.convertIssuerParametersComposite(ipc, sessionDB[sessionID]); byte[] issuerPrivateKey = sessionDB[sessionID].privateKey; if (issuerPrivateKey == null) { cOut.write("Issuer side, issuerPrivateKey is null. Did you forget to add the issuer private key for the given sessionKey?"); return(null); } BigInteger bi = new BigInteger(1, issuerPrivateKey); IssuerKeyAndParameters ikap = new IssuerKeyAndParameters(bi, ip); // setup the issuer and generate the first issuance message GroupElement hdG = ip.Gq.CreateGroupElement(hd); Issuer issuer = new Issuer(ikap, numberOfTokensParam, attributes, null, hdG); // Store the issuer in issuersDictionary using the sessionKey as key sessionDB[sessionID].issuer = issuer; FirstIssuanceMessage fi = issuer.GenerateFirstMessage(); // Convert FirstIssuanceMessage members to serializable FirstIssuanceMessageComposite FirstIssuanceMessageComposite fic = ConvertUtils.convertFirstIssuanceMessage(fi); // Add the sessionKey to FirstIssuanceMessageComposite fic.SessionKey = sessionID; return(fic); } catch (Exception e) { cOut.write(e.ToString()); DebugUtils.DebugPrint(e.StackTrace.ToString()); } return(null); }
public static FirstIssuanceMessage convertFirstIssuanceMessageComposite(FirstIssuanceMessageComposite fic, IssuerParameters ip) { GroupElement[] geArray1 = new GroupElement[fic.SigmaA.Length]; for (int i = 0; i < fic.SigmaA.Length; i++) { geArray1[i] = ip.Gq.CreateGroupElement(fic.SigmaA[i]); } GroupElement[] geArray2 = new GroupElement[fic.SigmaB.Length]; for (int i = 0; i < fic.SigmaB.Length; i++) { geArray2[i] = ip.Gq.CreateGroupElement(fic.SigmaB[i]); } FirstIssuanceMessage fi = new FirstIssuanceMessage(ip.Gq.CreateGroupElement(fic.SigmaZ), geArray1, geArray2); return fi; }
public static FirstIssuanceMessage convertFirstIssuanceMessageComposite(FirstIssuanceMessageComposite fic, IssuerParameters ip) { GroupElement[] geArray1 = new GroupElement[fic.SigmaA.Length]; for (int i = 0; i < fic.SigmaA.Length; i++) { geArray1[i] = ip.Gq.CreateGroupElement(fic.SigmaA[i]); } GroupElement[] geArray2 = new GroupElement[fic.SigmaB.Length]; for (int i = 0; i < fic.SigmaB.Length; i++) { geArray2[i] = ip.Gq.CreateGroupElement(fic.SigmaB[i]); } FirstIssuanceMessage fi = new FirstIssuanceMessage(ip.Gq.CreateGroupElement(fic.SigmaZ), geArray1, geArray2); return(fi); }
public static FirstIssuanceMessageComposite convertFirstIssuanceMessage(FirstIssuanceMessage fi) { FirstIssuanceMessageComposite fic = new FirstIssuanceMessageComposite(); byte[][] byteArray1 = new byte[fi.sigmaA.Length][]; for (int i = 0; i < byteArray1.Length; i++) { byteArray1[i] = fi.sigmaA[i].GetEncoded(); } byte[][] byteArray2 = new byte[fi.sigmaB.Length][]; for (int i = 0; i < byteArray2.Length; i++) { byteArray2[i] = fi.sigmaB[i].GetEncoded(); } fic.SigmaA = byteArray1; fic.SigmaB = byteArray2; fic.SigmaZ = fi.sigmaZ.GetEncoded(); return(fic); }
public static FirstIssuanceMessageComposite convertFirstIssuanceMessage(FirstIssuanceMessage fi) { FirstIssuanceMessageComposite fic = new FirstIssuanceMessageComposite(); byte[][] byteArray1 = new byte[fi.sigmaA.Length][]; for (int i = 0; i < byteArray1.Length; i++) { byteArray1[i] = fi.sigmaA[i].GetEncoded(); } byte[][] byteArray2 = new byte[fi.sigmaB.Length][]; for (int i = 0; i < byteArray2.Length; i++) { byteArray2[i] = fi.sigmaB[i].GetEncoded(); } fic.SigmaA = byteArray1; fic.SigmaB = byteArray2; fic.SigmaZ = fi.sigmaZ.GetEncoded(); return fic; }
public SecondIssuanceMessageComposite getSecondMessage(string[] attributesParam, IssuerParametersComposite ipc, int numberOfTokensParam, FirstIssuanceMessageComposite firstMessage, string sessionID) { /* * token issuance - generate second message */ cOut.write("Issuing U-Prove tokens - generate second message, prover side"); VerifySessionId(sessionID); try { string tokenInformationParam = null; string proverInformationParam = null; // specify the attribute values agreed to by the Issuer and Prover int numberOfAttributes = attributesParam.Length; byte[][] attributes = new byte[numberOfAttributes][]; for (int i = 0; i < numberOfAttributes; i++) { attributes[i] = encoding.GetBytes(attributesParam[i]); } // specify the special field values byte[] tokenInformation = (tokenInformationParam == null) ? new byte[] { } : encoding.GetBytes(tokenInformationParam); byte[] proverInformation = (proverInformationParam == null) ? new byte[] { } : encoding.GetBytes(proverInformationParam); // specify the number of tokens to issue int numberOfTokens = numberOfTokensParam; IssuerParameters ip = ConvertUtils.convertIssuerParametersComposite(ipc, sessionDB[sessionID]); // Convert serializable FirstIssuanceMessageComposite members to FirstIssuanceMessage FirstIssuanceMessage fi = ConvertUtils.convertFirstIssuanceMessageComposite(firstMessage, ip); // setup the prover and generate the second issuance message Prover prover = new Prover(ip, numberOfTokens, attributes, tokenInformation, proverInformation, sessionDB[sessionID].deviceManager.GetDevice()); // Store the prover in proversDictionary using the sessionKey as key sessionDB[sessionID].prover = prover; SecondIssuanceMessage sm = prover.GenerateSecondMessage(fi); // Convert SecondIssuanceMessage members to serializable SecondIssuanceMessageComposite SecondIssuanceMessageComposite smc = ConvertUtils.convertSecondIssuanceMessage(sm); // Add the sessionKey to SecondIssuanceMessageComposite smc.SessionKey = sessionID; return(smc); } catch (Exception e) { cOut.write(e.ToString()); DebugUtils.DebugPrint(e.StackTrace.ToString()); } return(null); }
public SecondIssuanceMessageComposite getSecondMessage(string[] attributesParam, IssuerParametersComposite ipc, int numberOfTokensParam, FirstIssuanceMessageComposite firstMessage, string sessionID) { /* * token issuance - generate second message */ cOut.write("Issuing U-Prove tokens - generate second message, prover side"); VerifySessionId(sessionID); try { string tokenInformationParam = null; string proverInformationParam = null; // specify the attribute values agreed to by the Issuer and Prover int numberOfAttributes = attributesParam.Length; byte[][] attributes = new byte[numberOfAttributes][]; for (int i = 0; i < numberOfAttributes; i++) { attributes[i] = encoding.GetBytes(attributesParam[i]); } // specify the special field values byte[] tokenInformation = (tokenInformationParam == null) ? new byte[] { } : encoding.GetBytes(tokenInformationParam); byte[] proverInformation = (proverInformationParam == null) ? new byte[] { } : encoding.GetBytes(proverInformationParam); // specify the number of tokens to issue int numberOfTokens = numberOfTokensParam; IssuerParameters ip = ConvertUtils.convertIssuerParametersComposite(ipc, sessionDB[sessionID]); // Convert serializable FirstIssuanceMessageComposite members to FirstIssuanceMessage FirstIssuanceMessage fi = ConvertUtils.convertFirstIssuanceMessageComposite(firstMessage, ip); // setup the prover and generate the second issuance message Prover prover = new Prover(ip, numberOfTokens, attributes, tokenInformation, proverInformation, sessionDB[sessionID].deviceManager.GetDevice()); // Store the prover in proversDictionary using the sessionKey as key sessionDB[sessionID].prover = prover; SecondIssuanceMessage sm = prover.GenerateSecondMessage(fi); // Convert SecondIssuanceMessage members to serializable SecondIssuanceMessageComposite SecondIssuanceMessageComposite smc = ConvertUtils.convertSecondIssuanceMessage(sm); // Add the sessionKey to SecondIssuanceMessageComposite smc.SessionKey = sessionID; return smc; } catch (Exception e) { cOut.write(e.ToString()); DebugUtils.DebugPrint(e.StackTrace.ToString()); } return null; }