public BlockNode(IDataBlock blockData) { blockData.Verify(nameof(blockData)).IsNotNull(); BlockData = blockData; Digest = GetDigest(); }
public BlockNode(IDataBlock blockData, int index, string?previousHash) { blockData.Verify(nameof(blockData)).IsNotNull(); BlockData = blockData; Index = index; PreviousHash = previousHash; Digest = GetDigest(); }
public static void Validate(this IDataBlock subject, IWorkContext context, PrincipleSignature principleSignature) { subject.Verify(nameof(subject)).IsNotNull(); principleSignature.Verify(nameof(principleSignature)).IsNotNull(); subject.Validate(); JwtTokenDetails?tokenDetails = principleSignature.ValidateSignature(context, subject.JwtSignature !); tokenDetails.Verify().IsNotNull("Signature validation failed"); string digest = tokenDetails !.Claims.Where(x => x.Type == "blockDigest").Select(x => x.Value).FirstOrDefault(); (digest == subject.Digest).Verify().Assert <bool, SecurityException>(x => x == true, "Block's digest does not match signature"); }