new ttl range checking
This commit is contained in:
parent
a7bb1bc27f
commit
eba0aa649d
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
This project uses Semantic Versioning
|
This project uses Semantic Versioning
|
||||||
|
|
||||||
|
## 7.0.0
|
||||||
|
|
||||||
|
- Have minimum and maximum TTL allowance to avoid overflow/nonsense
|
||||||
|
|
||||||
|
|
||||||
## 6.0.0
|
## 6.0.0
|
||||||
|
|
||||||
- Use TTL instead of rounds
|
- Use TTL instead of rounds
|
||||||
|
@ -16,6 +16,12 @@ class NotEnoughRounds(Exception):
|
|||||||
class NoTTLSet(Exception):
|
class NoTTLSet(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class RoundsOutOfBounds(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
MAX_ROUNDS = 999_999_999
|
||||||
|
MINIMUM_ROUNDS = 10_000
|
||||||
|
|
||||||
|
|
||||||
class AnonVDFGenerator(generator.KastenBaseGenerator):
|
class AnonVDFGenerator(generator.KastenBaseGenerator):
|
||||||
|
|
||||||
@ -50,6 +56,10 @@ class AnonVDFGenerator(generator.KastenBaseGenerator):
|
|||||||
raise NoTTLSet(e)
|
raise NoTTLSet(e)
|
||||||
|
|
||||||
rounds = AnonVDFGenerator.get_rounds_for_ttl_seconds(ttl, len(packed_bytes))
|
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)
|
check_block_sanity(packed_bytes)
|
||||||
vdf = vdf_create(
|
vdf = vdf_create(
|
||||||
packed_bytes,
|
packed_bytes,
|
||||||
@ -74,6 +84,8 @@ class AnonVDFGenerator(generator.KastenBaseGenerator):
|
|||||||
|
|
||||||
ttl = int(ttl)
|
ttl = int(ttl)
|
||||||
rounds = AnonVDFGenerator.get_rounds_for_ttl_seconds(ttl, len(packed_bytes))
|
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")
|
#hash = hash.lstrip(b"0")
|
||||||
|
2
setup.py
2
setup.py
@ -1,7 +1,7 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
setup(name='onionrblocks',
|
setup(name='onionrblocks',
|
||||||
version='6.0.0',
|
version='7.0.0',
|
||||||
description='Onionr message format',
|
description='Onionr message format',
|
||||||
author='Kevin Froman',
|
author='Kevin Froman',
|
||||||
author_email='beardog@mailbox.org',
|
author_email='beardog@mailbox.org',
|
||||||
|
Loading…
Reference in New Issue
Block a user