Skip to content

Commit

Permalink
validate input for audit proof validation
Browse files Browse the repository at this point in the history
  • Loading branch information
F483 committed Feb 7, 2016
1 parent 2a9d9d7 commit bc0ef06
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion storjlib/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import six
import apigen
import storjlib
from . version import __version__ # NOQA
Expand All @@ -20,7 +21,16 @@ def contract_validate(self, contract):

@apigen.command()
def audit_validate(self, proof, root, challengenum, leaves):
# TODO validate input

# validate input
assert(isinstance(proof, list))
assert(storjlib.util.is_hex_hash(root))
assert(isinstance(leaves, list))
for leaf in leaves:
assert(storjlib.util.is_hex_hash(leaf))
assert(isinstance(challengenum, six.integer_types))
assert(0 <= challengenum < len(leaves))

return storjlib.audit.validate(proof, root, challengenum, leaves)


Expand Down

0 comments on commit bc0ef06

Please sign in to comment.