public static RunItem ComputeRunStats(this RunItem runItem) { try { Trace.WriteLine("Start ComputeRunStats : RunItem " + runItem.KeyId); // Load the base64 keys String galKeyString = "", galSingleStepKeyString = "", relinKeyString = ""; KeyUtilities.GetKeys(runItem.KeyId, ref galKeyString, ref galSingleStepKeyString, ref relinKeyString); // Calculate the cipher results SEALWrapper sw = new SEALWrapper(4096); sw.LoadKeys(galKeyString, galSingleStepKeyString, relinKeyString); sw.ComputeStatsCiphers(runItem.Cipher1, runItem.Cipher2, runItem.Summary, runItem.CipherGyro); runItem.Stats = sw.getStats(); runItem.Summary = sw.getSummary(); runItem.CipherGyro = sw.getMlResults(); Trace.WriteLine("End ComputeRunStats : RunItem " + runItem.KeyId); } catch (Exception e) { Trace.TraceError("{%s} occurred while computing stats {RunItem : %d}", runItem.KeyId, e); } return(runItem); }
public void TestGetKeys() { string galKeys = ""; string galSingleStepKeys = ""; string relinKeys = ""; // Right now this is hard coded for testing. If the table is recreated then the values // especially the ID needs to be updated for what is created in the database. KeyUtilities.GetKeys("fea872dde1814bdb951a033d42077e8a", ref galKeys, ref galSingleStepKeys, ref relinKeys); // Try to load the Keys into a Wrapper SEALWrapper sw = new SEALWrapper(4096); sw.LoadKeys(galKeys, galSingleStepKeys, relinKeys); // Get the keys back from the Wrapper string testGalKeys = sw.getGaloisKeys(); string testGalSingleStepKeys = sw.getGaloisSingleStepKeys(); string testRelinKeys = sw.getRelinKeys(); // Test that they equal // Have to test each character at a time because the assert // grabs too much memory if you test 2 strings of this size. Assert.AreEqual(galKeys.Length, testGalKeys.Length); Assert.AreEqual(galSingleStepKeys.Length, testGalSingleStepKeys.Length); Assert.AreEqual(relinKeys.Length, testRelinKeys.Length); for (int i = 0; i < galKeys.Length; i++) { Assert.AreEqual(galKeys[i], testGalKeys[i], "Gal Key Mismatch: " + i); } for (int i = 0; i < galSingleStepKeys.Length; i++) { Assert.AreEqual(galSingleStepKeys[i], testGalSingleStepKeys[i], "Gal Single-Step Key Mismatch: " + i); } for (int i = 0; i < relinKeys.Length; i++) { Assert.AreEqual(relinKeys[i], testRelinKeys[i], "Relin Key Mismatch: " + i); } }