fixed sneakernet, removed unused vdf

This commit is contained in:
Kevin Froman 2020-10-10 00:16:24 +00:00
parent d0baa7fd12
commit 2dc706a894
11 changed files with 15 additions and 99 deletions

View File

@ -12,6 +12,5 @@ toomanyobjs==1.1.0
niceware==0.2.1
psutil==5.7.2
filenuke==0.0.0
mimcvdf==1.1.0
watchdog==0.10.3
ujson==4.0.0

View File

@ -137,10 +137,6 @@ markupsafe==1.1.1 \
--hash=sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7 \
--hash=sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be \
# via jinja2
mimcvdf==1.1.0 \
--hash=sha256:97a4ccdebb58352c64c268d2e57ef8817c9fe4ac3dcc922410bfcc72033f344a \
--hash=sha256:ae47c79bfd6b7b76077c8ce3301a48a7c10a609d8a882e7bd785e2ef851ecd28 \
# via -r requirements.in
niceware==0.2.1 \
--hash=sha256:0f8b192f2a1e800e068474f6e208be9c7e2857664b33a96f4045340de4e5c69c \
--hash=sha256:cf2dc0e1567d36d067c61b32fed0f1b9c4534ed511f9eeead4ba548d03b5c9eb \

View File

@ -26,7 +26,7 @@ ONIONR_TAGLINE = 'Private P2P Communication - GPLv3 - https://Onionr.net'
ONIONR_VERSION = '6.0.0'
ONIONR_VERSION_CODENAME = 'Genesis'
ONIONR_VERSION_TUPLE = tuple(ONIONR_VERSION.split('.')) # (MAJOR, MINOR, VERSION)
API_VERSION = '4' # increments of 1; only change when something fundamental about how the API works changes. This way other nodes know how to communicate without learning too much information about you.
API_VERSION = '2' # increments of 1; only change when something fundamental about how the API works changes. This way other nodes know how to communicate without learning too much information about you.
MIN_PY_VERSION = 7 # min version of 7 so we can take advantage of non-cyclic type hints
DEVELOPMENT_MODE = False
IS_QUBES = False

View File

@ -1,45 +0,0 @@
"""Onionr - Private P2P Communication.
verifiable delay function proof
"""
from multiprocessing import Process
from multiprocessing import Pipe
from mimcvdf import vdf_create
from mimcvdf import vdf_verify
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.c
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
ROUND_MULTIPLIER_PER_BYTE = 100
def create(data: bytes) -> str:
rounds = len(data) * ROUND_MULTIPLIER_PER_BYTE
return vdf_create(data, rounds)
def multiproces_create(data: bytes) -> str:
parent_conn, child_conn = Pipe()
def __do_create(conn, data):
conn.send(create(data))
conn.close()
p = Process(target=__do_create, args=(child_conn, data))
p.start()
return parent_conn.recv()
def verify(data: bytes, block_id: str) -> bool:
rounds = len(data) * ROUND_MULTIPLIER_PER_BYTE
return vdf_verify(data, block_id, rounds)

View File

@ -38,15 +38,17 @@ class _Importer(FileSystemEventHandler):
if not event.src_path.endswith(BLOCK_EXPORT_FILE_EXT):
return
with open(event.src_path, 'rb') as block_file:
block_data = block_file.read()
os.remove(event.src_path)
try:
import_block_from_data(block_data)
except onionrexceptions.DataExists:
return
if block_data_location in event.src_path:
try:
import_block_from_data(block_file.read())
except onionrexceptions.DataExists:
return
if block_data_location in event.src_path:
try:
os.remove(event.src_path)
except FileNotFoundError:
pass
os.remove(event.src_path)
except FileNotFoundError:
pass
def sneakernet_import_thread():

View File

@ -14,8 +14,8 @@
"hide_created_blocks": true,
"insert_deniable_blocks": true,
"max_block_age": 2678400,
"minimum_block_pow": 4,
"minimum_send_pow": 4,
"minimum_block_pow": 5,
"minimum_send_pow": 5,
"public_key": "",
"random_bind_ip": true,
"security_level": 0,

View File

@ -1 +1 @@
1599457658
1602268895

View File

@ -1,36 +0,0 @@
#!/usr/bin/env python3
import sys, os
sys.path.append(".")
sys.path.append("src/")
import uuid
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
print("Test directory:", TEST_DIR)
os.environ["ONIONR_HOME"] = TEST_DIR
import unittest, json
from utils import identifyhome, createdirs
from onionrsetup import setup_config
from onionrproofs import vdf
from time import time
createdirs.create_dirs()
setup_config()
class TestVdf(unittest.TestCase):
def test_vdf(self):
res = vdf.create(b'test')
int(res, 16)
if len(res) == 0: raise ValueError
self.assertEqual(vdf.multiproces_create(b'test'), res)
def test_speed(self):
t = time()
vdf.create(b'test')
self.assertTrue(time() - t <= 10)
# test 2 kb
t = time()
vdf.create(b't'*10000)
self.assertTrue(time() - t >= 10)
#timeit(lambda: vdf.create(b'test'))
unittest.main()

View File

@ -13,7 +13,7 @@ from etc import onionrvalues
class TestOnionrValues(unittest.TestCase):
def test_api_version(self):
self.assertEqual(onionrvalues.API_VERSION, '1')
self.assertEqual(onionrvalues.API_VERSION, '2')
def test_default_expire(self):
self.assertEqual(onionrvalues.DEFAULT_EXPIRE, 2678400)