new ttl range checking

This commit is contained in:
Kevin F 2022-01-30 01:26:16 -06:00
parent a7bb1bc27f
commit eba0aa649d
3 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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")

View File

@ -1,7 +1,7 @@
from setuptools import setup, find_packages
setup(name='onionrblocks',
version='6.0.0',
version='7.0.0',
description='Onionr message format',
author='Kevin Froman',
author_email='beardog@mailbox.org',