Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        private byte[] BlockHash(SignedBlockHashMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (string.IsNullOrEmpty(message.Stamp))
            {
                throw new ArgumentNullException(nameof(message.Stamp));
            }

            if (message.Node <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(message.Node));
            }

            if (message.Round <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(message.Round));
            }

            if (message.PublicKey == null)
            {
                throw new ArgumentNullException(nameof(message.PublicKey));
            }

            if (message.PublicKey.Length < 32)
            {
                throw new ArgumentOutOfRangeException(nameof(message.PublicKey));
            }

            byte[] hash = null;

            try
            {
                hash = Cryptography.GenericHashWithKey($"{message.Stamp}{message.Node}{message.Round}", message.PublicKey);
            }
            catch (Exception ex)
            {
                logger.Warning($"<<< SigningProvider.BlockHash >>>: {ex.ToString()}");
            }

            return(hash);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 public async Task <byte[]> BlockHash(SignedBlockHashMessage message)
 {
     return(await actor.Ask <byte[]>(message));
 }