示例#1
0
        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>();
        }
示例#2
0
        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);
        }
示例#3
0
 public bool ValidateProof(Proof proof, byte[] hash)
 {
     return(proof.Validate(hash, MerkleRootHash, _hashAlgorithm));
 }