Skip to content

Commit

Permalink
add: raw root function
Browse files Browse the repository at this point in the history
  • Loading branch information
olivmath committed Dec 23, 2023
1 parent c257697 commit 70ae04f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion merkly/mtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(
self.raw_leafs: List[str] = leafs
self.leafs: List[str] = self.__hash_leafs(leafs)
self.short_leafs: List[str] = self.short(self.leafs)
self.merkletreejs = merkletreejs

def __hash_leafs(self, leafs: List[str]) -> List[str]:
return list(map(lambda x: self.hash_function(x, ""), leafs))
Expand All @@ -51,7 +52,10 @@ def short(self, data: List[str]) -> List[str]:

@property
def root(self) -> str:
return self.make_root(self.leafs)[0]
if self.merkletreejs:
return self.merkletreejs_root(self.leafs)
else:
return self.make_root(self.leafs)[0]

def proof(self, raw_leaf: str) -> List[Node]:
return self.make_proof(self.leafs, [], self.hash_function(raw_leaf, ""))
Expand Down Expand Up @@ -158,3 +162,7 @@ def up_layer(self, leaves: List[str]) -> List[str]:
data = self.hash_function(pair[0], pair[1])
new_layer.append(data)
return new_layer


def merkletreejs_root(self, leafs: List[str]) -> str:
return ""

0 comments on commit 70ae04f

Please sign in to comment.