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 static SecondIssuanceMessage convertSecondIssuanceMessageComposite(SecondIssuanceMessageComposite sic) { BigInteger[] biArray = new BigInteger[sic.SigmaC.Length]; for (int i = 0; i < biArray.Length; i++) { biArray[i] = new BigInteger(1, sic.SigmaC[i]); } SecondIssuanceMessage si = new SecondIssuanceMessage(biArray); return(si); }
public static SecondIssuanceMessageComposite convertSecondIssuanceMessage(SecondIssuanceMessage sm) { SecondIssuanceMessageComposite smc = new SecondIssuanceMessageComposite(); byte[][] byteArray1 = new byte[sm.sigmaC.Length][]; for (int i = 0; i < byteArray1.Length; i++) { byteArray1[i] = sm.sigmaC[i].ToByteArray(); } smc.SigmaC = byteArray1; return(smc); }
public ThirdIssuanceMessageComposite getThirdMessage(SecondIssuanceMessageComposite secondMessage, string sessionID) { /* * token issuance - generate third message */ cOut.write("Issuing U-Prove tokens - generate third message, issuer side"); VerifySessionId(sessionID); try { // Convert serializable SecondIssuanceMessageComposite members to SecondIssuanceMessage SecondIssuanceMessage si = ConvertUtils.convertSecondIssuanceMessageComposite(secondMessage); // Get unique session key from SecondIssuanceMessageComposite for retrieving the correct Issuer instance from issuersDictionary string sessionKey = secondMessage.SessionKey; //VerifySessionId(sessionKey); // Retrieve correct Issuer instance from issuersDictionary for the given sessionKey if (sessionDB.ContainsKey(sessionID)) { Issuer issuer = sessionDB[sessionID].issuer; ThirdIssuanceMessage tim = issuer.GenerateThirdMessage(si); // Convert ThirdIssuanceMessage members to serializable ThirdIssuanceMessageComposite ThirdIssuanceMessageComposite timc = ConvertUtils.convertThirdIssuanceMessage(tim); // Add the sessionKey to ThirdIssuanceMessageComposite timc.SessionKey = sessionID; return(timc); } } catch (Exception e) { cOut.write(e.ToString()); DebugUtils.DebugPrint(e.StackTrace.ToString()); } return(null); }
public ThirdIssuanceMessageComposite getThirdMessage(SecondIssuanceMessageComposite secondMessage, string sessionID) { /* * token issuance - generate third message */ cOut.write("Issuing U-Prove tokens - generate third message, issuer side"); VerifySessionId(sessionID); try { // Convert serializable SecondIssuanceMessageComposite members to SecondIssuanceMessage SecondIssuanceMessage si = ConvertUtils.convertSecondIssuanceMessageComposite(secondMessage); // Get unique session key from SecondIssuanceMessageComposite for retrieving the correct Issuer instance from issuersDictionary string sessionKey = secondMessage.SessionKey; //VerifySessionId(sessionKey); // Retrieve correct Issuer instance from issuersDictionary for the given sessionKey if (sessionDB.ContainsKey(sessionID)) { Issuer issuer = sessionDB[sessionID].issuer; ThirdIssuanceMessage tim = issuer.GenerateThirdMessage(si); // Convert ThirdIssuanceMessage members to serializable ThirdIssuanceMessageComposite ThirdIssuanceMessageComposite timc = ConvertUtils.convertThirdIssuanceMessage(tim); // Add the sessionKey to ThirdIssuanceMessageComposite timc.SessionKey = sessionID; return timc; } } catch (Exception e) { cOut.write(e.ToString()); DebugUtils.DebugPrint(e.StackTrace.ToString()); } return null; }
public static SecondIssuanceMessage convertSecondIssuanceMessageComposite(SecondIssuanceMessageComposite sic) { BigInteger[] biArray = new BigInteger[sic.SigmaC.Length]; for (int i = 0; i < biArray.Length; i++) { biArray[i] = new BigInteger(1, sic.SigmaC[i]); } SecondIssuanceMessage si = new SecondIssuanceMessage(biArray); return si; }
public static SecondIssuanceMessageComposite convertSecondIssuanceMessage(SecondIssuanceMessage sm) { SecondIssuanceMessageComposite smc = new SecondIssuanceMessageComposite(); byte[][] byteArray1 = new byte[sm.sigmaC.Length][]; for (int i = 0; i < byteArray1.Length; i++) { byteArray1[i] = sm.sigmaC[i].ToByteArray(); } smc.SigmaC = byteArray1; return smc; }