Safe Haskell | None |
---|---|
Language | Haskell2010 |
Crypto.Hash.MerkleTree
Synopsis
- data MerkleTree a
- = MerkleEmpty
- | MerkleTree Word32 (MerkleNode a)
- newtype MerkleRoot a = MerkleRoot {}
- data MerkleNode a
- = MerkleBranch {
- mRoot :: MerkleRoot a
- mLeft :: MerkleNode a
- mRight :: MerkleNode a
- | MerkleLeaf {
- mRoot :: MerkleRoot a
- mVal :: a
- = MerkleBranch {
- mkMerkleTree :: [ByteString] -> MerkleTree ByteString
- mkRootHash :: MerkleRoot a -> MerkleRoot a -> MerkleRoot a
- mkLeafRootHash :: ByteArrayAccess a => a -> MerkleRoot a
- emptyHash :: MerkleRoot a
- newtype MerkleProof a = MerkleProof {
- getMerkleProof :: [ProofElem a]
- merkleProof :: MerkleTree a -> MerkleRoot a -> MerkleProof a
- validateMerkleProof :: MerkleProof a -> MerkleRoot a -> MerkleRoot a -> Bool
- mtRoot :: MerkleTree a -> MerkleRoot a
- mtSize :: MerkleTree a -> Word32
- mtHash :: MerkleTree a -> ByteString
- mtHeight :: Int -> Int
- testMerkleProofN :: Int -> IO Bool
Documentation
data MerkleTree a Source #
A merkle tree.
Constructors
MerkleEmpty | |
MerkleTree Word32 (MerkleNode a) |
Instances
newtype MerkleRoot a Source #
A merkle tree root.
Constructors
MerkleRoot | |
Fields |
Instances
Serialize (MerkleRoot a) Source # | |||||
Defined in Crypto.Hash.MerkleTree | |||||
Generic (MerkleRoot a) Source # | |||||
Defined in Crypto.Hash.MerkleTree Associated Types
| |||||
Show (MerkleRoot a) Source # | |||||
Defined in Crypto.Hash.MerkleTree Methods showsPrec :: Int -> MerkleRoot a -> ShowS # show :: MerkleRoot a -> String # showList :: [MerkleRoot a] -> ShowS # | |||||
Eq (MerkleRoot a) Source # | |||||
Defined in Crypto.Hash.MerkleTree | |||||
Ord (MerkleRoot a) Source # | |||||
Defined in Crypto.Hash.MerkleTree Methods compare :: MerkleRoot a -> MerkleRoot a -> Ordering # (<) :: MerkleRoot a -> MerkleRoot a -> Bool # (<=) :: MerkleRoot a -> MerkleRoot a -> Bool # (>) :: MerkleRoot a -> MerkleRoot a -> Bool # (>=) :: MerkleRoot a -> MerkleRoot a -> Bool # max :: MerkleRoot a -> MerkleRoot a -> MerkleRoot a # min :: MerkleRoot a -> MerkleRoot a -> MerkleRoot a # | |||||
ByteArrayAccess (MerkleRoot a) Source # | |||||
Defined in Crypto.Hash.MerkleTree Methods length :: MerkleRoot a -> Int # withByteArray :: MerkleRoot a -> (Ptr p -> IO a0) -> IO a0 # copyByteArrayToPtr :: MerkleRoot a -> Ptr p -> IO () # | |||||
type Rep (MerkleRoot a) Source # | |||||
Defined in Crypto.Hash.MerkleTree type Rep (MerkleRoot a) = D1 ('MetaData "MerkleRoot" "Crypto.Hash.MerkleTree" "merkle-tree-0.1.1-ESkHu8AHkae3AtN8pOIpzp" 'True) (C1 ('MetaCons "MerkleRoot" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMerkleRoot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
data MerkleNode a Source #
Constructors
MerkleBranch | |
Fields
| |
MerkleLeaf | |
Fields
|
Instances
Foldable MerkleNode Source # | |||||
Defined in Crypto.Hash.MerkleTree Methods fold :: Monoid m => MerkleNode m -> m # foldMap :: Monoid m => (a -> m) -> MerkleNode a -> m # foldMap' :: Monoid m => (a -> m) -> MerkleNode a -> m # foldr :: (a -> b -> b) -> b -> MerkleNode a -> b # foldr' :: (a -> b -> b) -> b -> MerkleNode a -> b # foldl :: (b -> a -> b) -> b -> MerkleNode a -> b # foldl' :: (b -> a -> b) -> b -> MerkleNode a -> b # foldr1 :: (a -> a -> a) -> MerkleNode a -> a # foldl1 :: (a -> a -> a) -> MerkleNode a -> a # toList :: MerkleNode a -> [a] # null :: MerkleNode a -> Bool # length :: MerkleNode a -> Int # elem :: Eq a => a -> MerkleNode a -> Bool # maximum :: Ord a => MerkleNode a -> a # minimum :: Ord a => MerkleNode a -> a # sum :: Num a => MerkleNode a -> a # product :: Num a => MerkleNode a -> a # | |||||
Serialize a => Serialize (MerkleNode a) Source # | |||||
Defined in Crypto.Hash.MerkleTree | |||||
Generic (MerkleNode a) Source # | |||||
Defined in Crypto.Hash.MerkleTree Associated Types
| |||||
Show a => Show (MerkleNode a) Source # | |||||
Defined in Crypto.Hash.MerkleTree Methods showsPrec :: Int -> MerkleNode a -> ShowS # show :: MerkleNode a -> String # showList :: [MerkleNode a] -> ShowS # | |||||
Eq a => Eq (MerkleNode a) Source # | |||||
Defined in Crypto.Hash.MerkleTree | |||||
type Rep (MerkleNode a) Source # | |||||
Defined in Crypto.Hash.MerkleTree type Rep (MerkleNode a) = D1 ('MetaData "MerkleNode" "Crypto.Hash.MerkleTree" "merkle-tree-0.1.1-ESkHu8AHkae3AtN8pOIpzp" 'False) (C1 ('MetaCons "MerkleBranch" 'PrefixI 'True) (S1 ('MetaSel ('Just "mRoot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (MerkleRoot a)) :*: (S1 ('MetaSel ('Just "mLeft") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (MerkleNode a)) :*: S1 ('MetaSel ('Just "mRight") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (MerkleNode a)))) :+: C1 ('MetaCons "MerkleLeaf" 'PrefixI 'True) (S1 ('MetaSel ('Just "mRoot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (MerkleRoot a)) :*: S1 ('MetaSel ('Just "mVal") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a))) |
Constructors
mkMerkleTree :: [ByteString] -> MerkleTree ByteString Source #
Smart constructor for MerkleTree
.
mkRootHash :: MerkleRoot a -> MerkleRoot a -> MerkleRoot a Source #
mkLeafRootHash :: ByteArrayAccess a => a -> MerkleRoot a Source #
emptyHash :: MerkleRoot a Source #
Merkle Proof
newtype MerkleProof a Source #
Constructors
MerkleProof | |
Fields
|
Instances
Serialize (MerkleProof a) Source # | |||||
Defined in Crypto.Hash.MerkleTree | |||||
Generic (MerkleProof a) Source # | |||||
Defined in Crypto.Hash.MerkleTree Associated Types
Methods from :: MerkleProof a -> Rep (MerkleProof a) x # to :: Rep (MerkleProof a) x -> MerkleProof a # | |||||
Show (MerkleProof a) Source # | |||||
Defined in Crypto.Hash.MerkleTree Methods showsPrec :: Int -> MerkleProof a -> ShowS # show :: MerkleProof a -> String # showList :: [MerkleProof a] -> ShowS # | |||||
Eq (MerkleProof a) Source # | |||||
Defined in Crypto.Hash.MerkleTree Methods (==) :: MerkleProof a -> MerkleProof a -> Bool # (/=) :: MerkleProof a -> MerkleProof a -> Bool # | |||||
Ord (MerkleProof a) Source # | |||||
Defined in Crypto.Hash.MerkleTree Methods compare :: MerkleProof a -> MerkleProof a -> Ordering # (<) :: MerkleProof a -> MerkleProof a -> Bool # (<=) :: MerkleProof a -> MerkleProof a -> Bool # (>) :: MerkleProof a -> MerkleProof a -> Bool # (>=) :: MerkleProof a -> MerkleProof a -> Bool # max :: MerkleProof a -> MerkleProof a -> MerkleProof a # min :: MerkleProof a -> MerkleProof a -> MerkleProof a # | |||||
type Rep (MerkleProof a) Source # | |||||
Defined in Crypto.Hash.MerkleTree |
merkleProof :: MerkleTree a -> MerkleRoot a -> MerkleProof a Source #
Construct a merkle tree proof of inclusion Walks the entire tree recursively, building a list of "proof elements" that are comprised of the current node's root and it's sibling's root, and whether it is the left or right sibling (this is necessary to determine the order in which to hash each proof element root and it's sibling root). The list is ordered such that the for each element, the next element in the list is the proof element corresponding to the node's parent node.
validateMerkleProof :: MerkleProof a -> MerkleRoot a -> MerkleRoot a -> Bool Source #
Validate a merkle tree proof of inclusion
Size
mtRoot :: MerkleTree a -> MerkleRoot a Source #
Returns root of merkle tree.
mtSize :: MerkleTree a -> Word32 Source #
mtHash :: MerkleTree a -> ByteString Source #
Returns root of merkle tree root hashed.