Esempio n. 1
0
        /// <summary>
        /// Verifies that the digital signature of the block is valid for the indicated signer.
        /// </summary>
        /// <param name="block">The block to verify.</param>
        /// <returns>If the digital signature is valid for the block.</returns>
        public async Task <bool> VerifyBlockSignature(Block <T> block)
        {
            DigitalSignature signature        = block.Signature;
            string           signersPublicKey = await _signerRepository.GetPublicKey(signature.SignerId);

            return(signersPublicKey == signature.PublicKey &&
                   Signer.VerifySignature(signersPublicKey, block.BlockHash, signature.Signature));
        }
Esempio n. 2
0
 internal Block(T data, long blockNumber, string previouskHash, string signerId, string signersPublicKey, string signature, DateTime createdDate, string blockHash)
 {
     this.BlockNumber       = blockNumber;
     this.Data              = data;
     this.CreatedDate       = createdDate;
     this.PreviousBlockHash = previouskHash;
     this.BlockHash         = blockHash;
     this.Signature         = new DigitalSignature
     {
         SignerId  = signerId,
         PublicKey = signersPublicKey
     };
     ApplySignature(signature);
 }
Esempio n. 3
0
 public void ApplySignature(string signature)
 {
     this.Signature.Signature = signature;
 }