public Receipt(Proof proof) { _proof = proof; Context = "https://w3id.org/chainpoint/v2"; TargetHash = proof.Target; MerkleRoot = proof.MerkleRoot; var hashAlgorithmName = proof.HashAlgorithm.GetType().DeclaringType.Name; Type = $"Chainpoint{hashAlgorithmName}v2"; _anchors = new List <Anchor>(); }
internal Proof GetProof(MerkleLeaf leaf) { var proof = new Proof(leaf.Hash, Root.Hash, _hashAlgorithm); var node = (MerkleNodeBase)leaf; while (node.Parent != null) { if (node.Parent.Left == node) { proof.AddRight(node.Parent.Right.Hash); } else { proof.AddLeft(node.Parent.Left.Hash); } node = node.Parent; } return(proof); }
public bool ValidateProof(Proof proof, byte[] hash) { return(proof.Validate(hash, MerkleRootHash, _hashAlgorithm)); }