コード例 #1
0
 public bool CreatePublicKey()//hashing private keys//easy to parallel
 {
     using (SHA256 mySHA = SHA256.Create())
     {
         byte[] temp;
         for (int i = 0; i < 256; i++)
         {
             temp = Support.SubArray(PrivateKey1, 32 * i, 32); //substract 256bit number(32*8)
             temp = mySHA.ComputeHash(temp);                   //hashing
             for (int j = 0; j < 32; j++)                      //putting into public key variable
             {
                 PublicKey1[32 * i + j] = temp[j];
             }
         }
         for (int i = 0; i < 256; i++)
         {
             temp = Support.SubArray(PrivateKey2, 32 * i, 32);
             temp = mySHA.ComputeHash(temp);
             for (int j = 0; j < 32; j++)
             {
                 PublicKey2[32 * i + j] = temp[j];
             }
         }
     }
     return(true);
 }
コード例 #2
0
ファイル: Verify.cs プロジェクト: TheSchei/BUS_PRO
 private void TransferBytes(int x, int y)
 {
     byte[] temp;
     temp = Support.SubArray(PublicKey2, (8 * x + y) * 32, 32);
     for (int j = 0; j < 32; j++)
     {
         PublicKey1[(8 * x + y) * 32 + j] = temp[j];
     }
 }
コード例 #3
0
 private void TransferBytes(int x, int y)
 {
     byte[] temp;
     //temp = Support.SubArray(PrivateKey2, (32 * x + y) * 32, 32);
     temp = Support.SubArray(PrivateKey2, (8 * x + y) * 32, 32);
     for (int j = 0; j < 32; j++)
     {
         //PrivateKey1[32 * x + j] = temp[j];
         PrivateKey1[(8 * x + y) * 32 + j] = temp[j];
     }
 }
コード例 #4
0
ファイル: Verify.cs プロジェクト: TheSchei/BUS_PRO
 public bool VerifySignature(string filePath)
 {
     using (SHA256 mySHA = SHA256.Create())
     {
         FileStream file = new FileStream(filePath, FileMode.Open);
         Hash = mySHA.ComputeHash(file);
         file.Close();
     }
     using (SHA256 mySHA = SHA256.Create())
     {
         byte[] temp;
         for (int i = 0; i < 256; i++)
         {
             temp = Support.SubArray(Signature, 32 * i, 32); //substract 256bit number(32*8)
             temp = mySHA.ComputeHash(temp);                 //hashing
             for (int j = 0; j < 32; j++)                    //putting into public key variable
             {
                 Signature[32 * i + j] = temp[j];
             }
         }
     }
     //compare ChooseBytes(Hash) and new signature
     return(Signature.SequenceEqual(ChooseBytes(Hash)));
 }