Пример #1
0
        public byte[] GetExpandedPrivateKey(byte[] privateKey)
        {
            Ed25519.KeyPairFromSeed(out _, out var expandedPrivateKey, privateKey);

            var zero = new byte[] { 0 };

            var buffer = new BigEndianBuffer();

            buffer.Write(expandedPrivateKey);
            return(buffer.ToArray());
        }
Пример #2
0
        public byte[] GetPublicKey(byte[] privateKey, bool withZeroByte = true)
        {
            Ed25519.KeyPairFromSeed(out var publicKey, out _, privateKey);

            var zero = new byte[] { 0 };

            var buffer = new BigEndianBuffer();

            if (withZeroByte)
            {
                buffer.Write(zero);
            }

            buffer.Write(publicKey);

            return(buffer.ToArray());
        }
Пример #3
0
        private (byte[] Key, byte[] ChainCode) GetChildKeyDerivation(byte[] key, byte[] chainCode, uint index)
        {
            BigEndianBuffer buffer = new BigEndianBuffer();

            buffer.Write(new byte[] { 0 });
            buffer.Write(key);
            buffer.WriteUInt(index);

            using (HMACSHA512 hmacSha512 = new HMACSHA512(chainCode))
            {
                var i = hmacSha512.ComputeHash(buffer.ToArray());

                var il = i.Slice(0, 32);
                var ir = i.Slice(32);

                return(Key : il, ChainCode : ir);
            }
        }