static void Main(string[] args) { using (var sim = new QuantumSimulator()) { System.Console.WriteLine("Message to send:"); int msg = System.Convert.ToInt32(System.Console.ReadLine()); System.Console.WriteLine("Size of the message in bits: "); int msgSz = System.Convert.ToInt32(System.Console.ReadLine()); System.Console.WriteLine("Enconding basis - Standard (s) or Hadamard (h)"); char basis = System.Console.ReadLine().ToString()[0]; basis = char.ToUpper(basis); System.Console.WriteLine("Bob read in x or y direction? (x/y)"); char bob = System.Console.ReadLine().ToString()[0]; bob = char.ToUpper(bob); System.Console.WriteLine("Number of iterations: "); int iterations = System.Convert.ToInt32(System.Console.ReadLine()); var result = SecretSharing.Run(sim, msg, msgSz, basis.ToString(), bob.ToString(), iterations).Result; if (!result) { System.Console.WriteLine("Didn't work..."); } } System.Console.WriteLine("Press any key to continue."); System.Console.Read(); }
public BlockConsensusRequest CreateRequest(MinerWallet wallet) { lock (SyncRoot) { if (!Valid) { throw new InvalidOperationException(); } if (_request == null) { _request = new BlockConsensusRequest { PrevHash = PrevHash, Miner = my_pubkey, IV = new byte[16], NonceHash = NonceHashes[my_pubkey], TransactionHashes = TransactionHashes.ToArray() }; Random rand = new Random(); rand.NextBytes(_request.IV); SplitSecret secret = SecretSharing.Split(Nonces[my_pubkey].ToArray(), (Miners.Length - 1) / 2 + 1); for (int i = 0; i < Miners.Length; i++) { if (Miners[i].Equals(my_pubkey)) { continue; } byte[] aeskey = wallet.GetAesKey(Miners[i]); byte[] piece = secret.GetShare(i + 1).ToArray(); using (AesManaged aes = new AesManaged()) using (ICryptoTransform encryptor = aes.CreateEncryptor(aeskey, _request.IV)) { piece = encryptor.TransformFinalBlock(piece, 0, piece.Length); } Array.Clear(aeskey, 0, aeskey.Length); _request.NoncePieces.Add(Miners[i], piece); } } return(_request); } }