new ttl range checking
This commit is contained in:
parent
a7bb1bc27f
commit
eba0aa649d
@ -2,6 +2,11 @@
|
||||
|
||||
This project uses Semantic Versioning
|
||||
|
||||
## 7.0.0
|
||||
|
||||
- Have minimum and maximum TTL allowance to avoid overflow/nonsense
|
||||
|
||||
|
||||
## 6.0.0
|
||||
|
||||
- Use TTL instead of rounds
|
||||
|
@ -16,6 +16,12 @@ class NotEnoughRounds(Exception):
|
||||
class NoTTLSet(Exception):
|
||||
pass
|
||||
|
||||
class RoundsOutOfBounds(Exception):
|
||||
pass
|
||||
|
||||
MAX_ROUNDS = 999_999_999
|
||||
MINIMUM_ROUNDS = 10_000
|
||||
|
||||
|
||||
class AnonVDFGenerator(generator.KastenBaseGenerator):
|
||||
|
||||
@ -50,6 +56,10 @@ class AnonVDFGenerator(generator.KastenBaseGenerator):
|
||||
raise NoTTLSet(e)
|
||||
|
||||
rounds = AnonVDFGenerator.get_rounds_for_ttl_seconds(ttl, len(packed_bytes))
|
||||
|
||||
if rounds > MAX_ROUNDS or rounds < MINIMUM_ROUNDS:
|
||||
raise RoundsOutOfBounds()
|
||||
|
||||
check_block_sanity(packed_bytes)
|
||||
vdf = vdf_create(
|
||||
packed_bytes,
|
||||
@ -74,6 +84,8 @@ class AnonVDFGenerator(generator.KastenBaseGenerator):
|
||||
|
||||
ttl = int(ttl)
|
||||
rounds = AnonVDFGenerator.get_rounds_for_ttl_seconds(ttl, len(packed_bytes))
|
||||
if rounds > MAX_ROUNDS or rounds < MINIMUM_ROUNDS:
|
||||
raise RoundsOutOfBounds()
|
||||
|
||||
|
||||
#hash = hash.lstrip(b"0")
|
||||
|
Loading…
Reference in New Issue
Block a user