PreIssuanceData PreIssuance(ProverPreIssuanceParameters ppip, IssuerPreIssuanceParameters ipip) { byte[] message = encoding.GetBytes("Optional Message"); UProveCrypto.Math.FieldZqElement beta0; ppip.Validate(); PreIssuanceProof proof = PreIssuanceProof.CreateProof(ppip, out beta0, message); if (TEST_SERIALIZATION) { string _proof = ip.Serialize<PreIssuanceProof>(proof); proof = ip.Deserialize<PreIssuanceProof>(_proof); } GroupElement gamma = null; try { gamma = PreIssuanceProof.VerifyProof(ipip, proof, message); } catch (InvalidUProveArtifactException e) { Assert.Fail("Invalid proof: " + e.Message); } PreIssuanceData pid = new PreIssuanceData(); pid.Gamma = gamma; pid.Beta0 = beta0; return pid; }
public void CollaborativeIssuanceAllUnknown() { ProverPreIssuanceParameters ppip = new ProverPreIssuanceParameters(ip); ppip.Attributes = new byte[][] { encoding.GetBytes("Secret attribute 1"), encoding.GetBytes("Secret attribute 2"), encoding.GetBytes("Secret attribute 3")}; ppip.U = new int[] { 1, 2, 3 }; IssuerPreIssuanceParameters ipip = new IssuerPreIssuanceParameters(ip); ipip.Attributes = new byte[][] { null, null, null }; ipip.U = ppip.U; PreIssuance(ppip, ipip); }
public void CollaborativeIssuanceNoCarryOver() { byte[] tokenInformation = new byte[] { }; ProverPreIssuanceParameters ppip = new ProverPreIssuanceParameters(ip); ppip.Attributes = new byte[][] { encoding.GetBytes("New attribute 1"), encoding.GetBytes("Secret attribute 2"), encoding.GetBytes("New attribute 3"), encoding.GetBytes("New attribute 4") }; ppip.U = new int[] { 2, 4 }; ppip.K = new int[] { 1, 3 }; ppip.TI = tokenInformation; IssuerPreIssuanceParameters ipip = new IssuerPreIssuanceParameters(ip); ipip.Attributes = new byte[][] { encoding.GetBytes("New attribute 1"), null, encoding.GetBytes("New attribute 3") }; ipip.U = ppip.U; ipip.K = ppip.K; ipip.TI = tokenInformation; PreIssuance(ppip, ipip); }
public void CollaborativeIssuanceTestCarryAllOver() { // Regular Issuance: we need a token to use in the collaborative issuance protocol byte[][] attributes = new byte[][] { encoding.GetBytes("carried-over attribute 1"), encoding.GetBytes("carried-over attribute 2") }; UProveKeyAndToken[] upkt = IssueSourceToken(attributes); // Collaborative Issuance, carrying-over two attributes ProverPreIssuanceParameters ppip = new ProverPreIssuanceParameters(ip); ppip.Attributes = new byte[][] { encoding.GetBytes("New attribute 1"), encoding.GetBytes("carried-over attribute 2"), encoding.GetBytes("carried-over attribute 1") }; ppip.CarryOverAttribute(new int[] { 1, 2 }, new int[] { 3, 2 }, sourceIp, upkt[0], attributes); ppip.U = new int[] { 1 }; IssuerPreIssuanceParameters ipip = new IssuerPreIssuanceParameters(ip); ipip.Attributes = new byte[][] { null, null, null }; ipip.CarryOverAttribute(new int[] { 1, 2 }, new int[] { 3, 2 }, sourceIp, upkt[0].Token); ipip.U = ppip.U; PreIssuance(ppip, ipip); }
public void CollaborativeIssuanceNoUnknown() { // Regular Issuance: we need a token to use in the collaborative issuance protocol byte[][] attributes = new byte[][] { encoding.GetBytes("Attribute 1"), encoding.GetBytes("Attribute 2") }; UProveKeyAndToken[] upkt = IssueSourceToken(attributes); // Collaborative Issuance ProverPreIssuanceParameters ppip = new ProverPreIssuanceParameters(ip); ppip.Attributes = new byte[][] { encoding.GetBytes("Attribute 1"), encoding.GetBytes("New attribute 2"), encoding.GetBytes("New attribute 3") }; ppip.CarryOverAttribute(new int[] { 1 }, new int[] { 1 }, sourceIp, upkt[0], attributes); ppip.K = new int[] { 2, 3 }; IssuerPreIssuanceParameters ipip = new IssuerPreIssuanceParameters(ip); ipip.Attributes = new byte[][] { null, encoding.GetBytes("New attribute 2"), encoding.GetBytes("New attribute 3") }; ipip.CarryOverAttribute(new int[] { 1 }, new int[] { 1 }, sourceIp, upkt[0].Token); ipip.K = ppip.K; PreIssuance(ppip, ipip); }
public void CollaborativeIssuanceTestFull() { byte[][] attributes = new byte[][] { encoding.GetBytes("A1"), encoding.GetBytes("A2") }; UProveKeyAndToken[] upkt = IssueSourceToken(attributes); // carry over one attribute to various positions for (int sourceIndex = 0; sourceIndex < attributes.Length; sourceIndex++) { for (int destinationIndex = 0; destinationIndex < 3; destinationIndex++) { // Collaborative Issuance // First the Prover creates a PreIssuanceProof int[] sourceIndices = new int[] { sourceIndex + 1 }; int[] destinationIndices = new int[] { destinationIndex + 1 }; ProverPreIssuanceParameters ppip = new ProverPreIssuanceParameters(ip); ppip.Attributes = new byte[3][]; ppip.CarryOverAttribute(sourceIndices, destinationIndices, sourceIp, upkt[0], attributes); ppip.U = new int[] { ((destinationIndex + 1) % 3) + 1 }; ppip.K = new int[] { ((destinationIndex + 2) % 3) + 1 }; ppip.Attributes[destinationIndex] = attributes[sourceIndex]; ppip.Attributes[ppip.U[0] - 1] = encoding.GetBytes("unknown"); ppip.Attributes[ppip.K[0] - 1] = encoding.GetBytes("known"); byte[] message = encoding.GetBytes("Optional Message"); // The verifier will only have the token, not the keyAndToken IssuerPreIssuanceParameters ipip = new IssuerPreIssuanceParameters(ip); ipip.Attributes = new byte[3][]; ipip.CarryOverAttribute(sourceIndices, destinationIndices, sourceIp, upkt[0].Token); ipip.U = ppip.U; ipip.K = ppip.K; ipip.Attributes[destinationIndex] = null; // carried-over ipip.Attributes[ppip.U[0] - 1] = null; ipip.Attributes[ppip.K[0] - 1] = encoding.GetBytes("known"); PreIssuanceData pid = PreIssuance(ppip, ipip); // Issuance (collaborative, using blindedGamma) IssuerProtocolParameters ipp2 = new IssuerProtocolParameters(ikap); ipp2.Gamma = pid.Gamma; Issuer issuer2 = ipp2.CreateIssuer(); FirstIssuanceMessage msg1_2 = issuer2.GenerateFirstMessage(); ProverProtocolParameters ppp2 = new ProverProtocolParameters(ip); ppp2.SetBlindedGamma(pid.Gamma, pid.Beta0); Prover prover2 = ppp2.CreateProver(); SecondIssuanceMessage msg2_2 = prover2.GenerateSecondMessage(msg1_2); ThirdIssuanceMessage msg3_2 = issuer2.GenerateThirdMessage(msg2_2); UProveKeyAndToken[] upkt_2 = prover2.GenerateTokens(msg3_2); // Create a presentation proof for each token, disclosing everything, to make sure the new token works for (int i = 0; i < upkt_2.Length; i++) { int[] disclosed = { 1, 2, 3 }; int[] committed = { }; PresentationProof P = PresentationProof.Generate(ip, disclosed, message, null, null, upkt_2[i], ppip.Attributes); P.Verify(ip, disclosed, message, null, upkt_2[i].Token); // verify that carried-over attribute was properly set Assert.IsTrue(P.DisclosedAttributes[destinationIndex].SequenceEqual<byte>(attributes[sourceIndex])); Assert.IsTrue(P.DisclosedAttributes[ppip.U[0] - 1].SequenceEqual<byte>(encoding.GetBytes("unknown"))); Assert.IsTrue(P.DisclosedAttributes[ppip.K[0] - 1].SequenceEqual<byte>(encoding.GetBytes("known"))); } } } }