Example #1
0
        /// <summary>
        /// Decodes user input as either the hexadecimal or PGP word list encoding
        /// of a seed and validates the seed length.
        /// </summary>
        public static byte[] DecodeAndValidateUserInput(string userInput, PgpWordList pgpWordList)
        {
            if (userInput == null)
                throw new ArgumentNullException(nameof(userInput));
            if (pgpWordList == null)
                throw new ArgumentNullException(nameof(pgpWordList));

            var decodedInput = DecodeUserInput(userInput, pgpWordList);
            if (decodedInput.Length != SeedLength)
            {
                throw new Exception($"Decoded seed must have byte length {SeedLength}");
            }
            return decodedInput;
        }
Example #2
0
        private static byte[] DecodeUserInput(string userInput, PgpWordList pgpWordList)
        {
            byte[] seed;
            if (Hexadecimal.TryDecode(userInput, out seed))
                return seed;

            var splitInput = userInput.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
            if (splitInput.Length == 1)
            {
                // Hex decoding failed, but it's not a multi-word mneumonic either.
                // Assume the user intended hex.
                throw new HexadecimalEncodingException();
            }
            return pgpWordList.Decode(splitInput);
        }
Example #3
0
        private static byte[] DecodeUserInput(string userInput, PgpWordList pgpWordList)
        {
            byte[] seed;
            if (Hexadecimal.TryDecode(userInput, out seed))
            {
                return(seed);
            }

            var splitInput = userInput.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);

            if (splitInput.Length == 1)
            {
                // Hex decoding failed, but it's not a multi-word mneumonic either.
                // Assume the user intended hex.
                throw new HexadecimalEncodingException();
            }
            return(pgpWordList.Decode(splitInput));
        }
Example #4
0
        /// <summary>
        /// Decodes user input as either the hexadecimal or PGP word list encoding
        /// of a seed and validates the seed length.
        /// </summary>
        public static byte[] DecodeAndValidateUserInput(string userInput, PgpWordList pgpWordList)
        {
            if (userInput == null)
            {
                throw new ArgumentNullException(nameof(userInput));
            }
            if (pgpWordList == null)
            {
                throw new ArgumentNullException(nameof(pgpWordList));
            }

            var decodedInput = DecodeUserInput(userInput, pgpWordList);

            if (decodedInput.Length != SeedLength)
            {
                throw new Exception($"Decoded seed must have byte length {SeedLength}");
            }
            return(decodedInput);
        }
Example #5
0
 public static string[] EncodeWordList(PgpWordList pgpWordList, byte[] seed) => pgpWordList.Encode(seed);
Example #6
0
 public static string[] EncodeWordList(PgpWordList pgpWordList, byte[] seed) => pgpWordList.Encode(seed);
Example #7
0
        public ConfirmSeedBackupDialog(StartupWizard wizard, CreateOrImportSeedDialog previousDialog,
            byte[] seed, PgpWordList pgpWordlist)
            : base(wizard)
        {
            _previousDialog = previousDialog;
            _seed = seed;
            _pgpWordList = pgpWordlist;

            ConfirmSeedCommand = new DelegateCommand(ConfirmSeed);
            BackCommand = new DelegateCommand(Back);
        }