Example #1
0
        public Task Initialize()
        {
            CryptoServices.CreateKeyPair(out publicKey, out privateKey);

            identityID = CryptoServices.CreatePrefixedHash(HashType.PublicKeyHash, publicKey);

            return(Task.CompletedTask);
        }
Example #2
0
        private static void ImportSk()
        {
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("Import private key");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Enter encoded private key: ");
            edsk = Console.ReadLine();
            var keys = CryptoServices.ImportEd25519(edsk);

            publicKey  = keys.Item1;
            privateKey = keys.Item2;
            tz1        = CryptoServices.CreatePrefixedHash(HashType.PublicKeyHash, publicKey);
            edsk       = CryptoServices.EncodePrefixed(HashType.Private, privateKey);
        }
Example #3
0
        private static void ImportSeed()
        {
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("Import mnemonic");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Enter words: ");
            mnemonic = Console.ReadLine();
            Console.Write("Enter password or press Enter: ");
            string pass = Console.ReadLine();
            var    bip  = new BIP39(mnemonic, pass);
            var    seed = new ArraySegment <byte>(bip.SeedBytes, 0, Ed25519.PrivateKeySeedSizeInBytes);

            Ed25519.KeyPairFromSeed(out publicKey, out privateKey, seed.ToArray());
            tz1  = CryptoServices.CreatePrefixedHash(HashType.PublicKeyHash, publicKey);
            edsk = CryptoServices.EncodePrefixed(HashType.Private, privateKey);
        }
Example #4
0
        public PublicKey(SerializationInfo info, StreamingContext context)
        {
            this.Data = (byte[])info.GetValue("Data", typeof(byte[]));

            Hash = CryptoServices.CreatePrefixedHash(HashType.PublicKeyHash, Data);
        }
Example #5
0
        public PublicKey(byte[] data)
        {
            this.Data = data ?? throw new ArgumentNullException(nameof(data));

            Hash = CryptoServices.CreatePrefixedHash(HashType.PublicKeyHash, Data);
        }