public void TestIssuerSetupParameters() { System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); byte[][] A = new byte[][] { encoding.GetBytes("attribute value") }; byte[] TI = encoding.GetBytes("TI value"); IssuerSetupParameters isp = new IssuerSetupParameters(); isp.GroupConstruction = GroupType.Subgroup; isp.UidP = encoding.GetBytes("UIDP value"); isp.E = new byte[] { 1 }; IssuerKeyAndParameters ikap = isp.Generate(); ikap.IssuerParameters.Verify(); // invalidate the issuer parameters IssuerParameters ip = ikap.IssuerParameters; SubgroupGroupElement sgG0 = (SubgroupGroupElement)ip.G[0]; byte[] g0Bytes = ip.G[0].GetEncoded(); g0Bytes[g0Bytes.Length - 1]++; ip.G[0] = (SubgroupGroupElement)ip.Gq.CreateGroupElement(g0Bytes); try { ip.Verify(); Assert.Fail(); } catch (InvalidUProveArtifactException) { } }
public static void VerifySmartCard(SmartCardDevice smartCardDevice, byte[] com, byte[] response, string hashFunctionName, byte[] proofSession, byte[] challangeMgs) { BigInteger resp = new BigInteger(1, response); //BigInteger comBig = new BigInteger(1, com); HashFunction hash = new HashFunction(hashFunctionName); //hash.Hash(new byte[1] {0x1}); //hash.Hash(1); byte[] proofSessionFoo = new byte[1 + proofSession.Length]; proofSessionFoo[0] = 1; Buffer.BlockCopy(proofSession, 0, proofSessionFoo, 1, proofSession.Length); hash.Hash(proofSessionFoo); hash.Hash(challangeMgs); byte[] cByte = hash.Digest; BigInteger c = new BigInteger(1, cByte); byte[] devicePubKeyByte = smartCardDevice.Device.GetDevicePublicKey(true); //BigInteger devicePubKey = new BigInteger(1, devicePubKeyByte); SubgroupGroupDescription subGq = (SubgroupGroupDescription)smartCardDevice.getGroupDescription(); SubgroupGroupElement leftSide = (SubgroupGroupElement)smartCardDevice.getGroupElement().Exponentiate(resp); SubgroupGroupElement pk = (SubgroupGroupElement)subGq.CreateGroupElement(devicePubKeyByte); SubgroupGroupElement pkc = (SubgroupGroupElement)pk.Exponentiate(c.Negate()); SubgroupGroupElement rightSide = (SubgroupGroupElement)pkc.Multiply(smartCardDevice.getGroupDescription().CreateGroupElement(com)); Console.Out.WriteLine("Printing left and right side"); Utils.PrintByteArrayToConsole(leftSide.GetEncoded()); Utils.PrintByteArrayToConsole(rightSide.GetEncoded()); }