예제 #1
0
 public byte[] SignMessageByServiceKey(byte[] data, int chain, uint index)
 {
     return(BitcoinBasedCurrency
            .CreateExtKeyFromSeed(Seed)
            .Derive(new KeyPath(path: $"m/{ServicePurpose}'/0'/0'/{chain}/{index}"))
            .SignMessage(data));
 }
예제 #2
0
        public byte[] GetServicePublicKey(uint index)
        {
            var extKey = BitcoinBasedCurrency
                         .CreateExtKeyFromSeed(Seed)
                         .Derive(new KeyPath(path: $"m/{ServicePurpose}'/0'/0'/0/{index}"));

            extKey.GetPublicKey(out var publicKey);

            return(publicKey);
        }
예제 #3
0
        public byte[] SignMessageByServiceKey(byte[] data, int chain, uint index)
        {
            using var masterKey = BitcoinBasedCurrency
                                  .CreateExtKeyFromSeed(Seed);

            using var derivedKey = masterKey
                                   .Derive(new KeyPath(path: $"m/{ServicePurpose}'/0'/0'/{chain}/{index}"));

            return(derivedKey.SignMessage(data));
        }
예제 #4
0
        public SecureBytes GetServicePublicKey(uint index)
        {
            using var masterKey = BitcoinBasedCurrency
                                  .CreateExtKeyFromSeed(Seed);

            using var extKey = masterKey
                               .Derive(new KeyPath(path: $"m/{ServicePurpose}'/0'/0'/0/{index}"));

            return(extKey.GetPublicKey());
        }
예제 #5
0
        public byte[] GetDeterministicSecret(Currency currency, DateTime timeStamp)
        {
            var utcTimeStamp = timeStamp.ToUniversalTime();

            var daysIndex    = (int)(utcTimeStamp.Date - DateTime.MinValue).TotalDays;
            var secondsIndex = utcTimeStamp.Hour * 60 * 60 + utcTimeStamp.Minute * 60 + utcTimeStamp.Second;
            var msIndex      = utcTimeStamp.Millisecond;

            using var masterKey = BitcoinBasedCurrency
                                  .CreateExtKeyFromSeed(Seed);

            using var extKey = masterKey
                               .Derive(new KeyPath(path: $"m/{ServicePurpose}'/{currency.Bip44Code}'/0'/{daysIndex}/{secondsIndex}/{msIndex}"));

            using var securePublicKey = extKey.GetPublicKey();
            using var publicKey       = securePublicKey.ToUnsecuredBytes();

            return(Sha512.Compute(publicKey));
        }