Changeset - 4fa21dbcdb9d
[Not reviewed]
default
9 0 13
Laman - 4 years ago 2020-04-13 14:46:29

created installation script, reorganized directory structure
13 files changed with 45 insertions and 32 deletions:
0 comments (0 inline, 0 general)
.hgignore
Show inline comments
 
new file 100644
 
^\..*
 
\.pyc$
 
^build/
 
^dist/
 
.egg-info/
setup.py
Show inline comments
 
new file 100644
 
from setuptools import setup
 

	
 

	
 
setup(
 
	name="Shamira",
 
	version="0.1",
 
	packages=["shamira"],
 
	package_dir={"": "src"}
 
)
src/shamira/__init__.py
Show inline comments
 
new file 100644
 
from .core import generate, generate_raw, reconstruct, reconstruct_raw
 
from .core import SException, InvalidParams, DetectionException, DecodingException, MalformedShare
src/shamira/__main__.py
Show inline comments
 
new file 100644
 
from . import cli
 

	
 
cli.run()
src/shamira/benchmark.py
Show inline comments
 
file renamed from src/benchmark.py to src/shamira/benchmark.py
 
from argparse import ArgumentParser
 
import cProfile
 
import timeit
 

	
 
from shamira import generate, reconstruct
 
from tests.test_shamira import TestShamira
 
from . import generate, reconstruct
 
from .tests.test_shamira import TestShamira
 

	
 

	
 
def measure(args):
 
@@ -13,10 +12,10 @@ def measure(args):
 
	symbols.update(locals())
 

	
 
	time = timeit.timeit("""generate(secret, args.k, args.n)""", number=1, globals=symbols)
 
	print("The generation took {0:.3}s, {1:.3} per byte.".format(time, time/16))
 
	print("The generation took {0:.3}s, {1:.3}s per byte.".format(time, time/16))
 

	
 
	time = timeit.timeit("""reconstruct(*shares)""", number=1, globals=symbols)
 
	print("The reconstruction took {0:.3}s, {1:.3} per byte.".format(time, time/16))
 
	print("The reconstruction took {0:.3}s, {1:.3}s per byte.".format(time, time/16))
 

	
 

	
 
def profile(args):
 
@@ -25,17 +24,14 @@ def profile(args):
 
	cProfile.runctx(r"""t.test_generate_reconstruct()""", globals=globals(), locals=locals())
 

	
 

	
 
parser = ArgumentParser()
 
parser.set_defaults(func=lambda _: parser.error("missing command"))
 
subparsers = parser.add_subparsers()
 

	
 
profile_parser = subparsers.add_parser("profile")
 
profile_parser.set_defaults(func=profile)
 
def build_subparsers(parent):
 
	parent.set_defaults(func=lambda _: parent.error("missing command"))
 
	subparsers = parent.add_subparsers()
 

	
 
measure_parser = subparsers.add_parser("measure")
 
measure_parser.add_argument("-k", type=int, required=True)
 
measure_parser.add_argument("-n", type=int, required=True)
 
measure_parser.set_defaults(func=measure)
 
	profile_parser = subparsers.add_parser("profile")
 
	profile_parser.set_defaults(func=profile)
 

	
 
args = parser.parse_args()
 
args.func(args)
 
	measure_parser = subparsers.add_parser("measure")
 
	measure_parser.add_argument("-k", type=int, required=True)
 
	measure_parser.add_argument("-n", type=int, required=True)
 
	measure_parser.set_defaults(func=measure)
src/shamira/cli.py
Show inline comments
 
file renamed from src/cli.py to src/shamira/cli.py
 
@@ -3,7 +3,8 @@
 
import sys
 
from argparse import ArgumentParser
 

	
 
from shamira import generate, reconstruct, SException
 
from .core import generate, reconstruct, SException
 
from .benchmark import build_subparsers as build_benchmark
 

	
 

	
 
def run():
 
@@ -12,6 +13,7 @@ def run():
 

	
 
	build_split_parser(subparsers.add_parser("split"))
 
	build_join_parser(subparsers.add_parser("join"))
 
	build_benchmark(subparsers.add_parser("benchmark"))
 

	
 
	parser.set_defaults(func=lambda _: parser.error("missing command"))
 

	
src/shamira/condensed.py
Show inline comments
 
file renamed from src/condensed.py to src/shamira/condensed.py
src/shamira/core.py
Show inline comments
 
file renamed from src/shamira.py to src/shamira/core.py
 
@@ -5,7 +5,7 @@ import re
 
import base64
 
import binascii
 

	
 
import gf256
 
from . import gf256
 

	
 

	
 
class SException(Exception): pass
 
@@ -124,8 +124,3 @@ def detect_encoding(shares):
 
		if all(regexp.fullmatch(share) for share in shares):
 
			return res
 
	raise DetectionException("No expected encoding detected")
 

	
 

	
 
if __name__=="__main__":
 
	import cli
 
	cli.run()
src/shamira/gf256.py
Show inline comments
 
file renamed from src/gf256.py to src/shamira/gf256.py
src/shamira/tests/__init__.py
Show inline comments
 
file renamed from src/tests/__init__.py to src/shamira/tests/__init__.py
src/shamira/tests/test_condensed.py
Show inline comments
 
file renamed from src/tests/test_condensed.py to src/shamira/tests/test_condensed.py
 
@@ -4,9 +4,9 @@ import os
 
import random
 
from unittest import TestCase
 

	
 
from gf256 import _gfmul, evaluate
 
from shamira import generate_raw, generate
 
from condensed import *
 
from ..gf256 import _gfmul, evaluate
 
from .. import generate_raw, generate
 
from ..condensed import *
 

	
 

	
 
class TestCondensed(TestCase):
src/shamira/tests/test_gf256.py
Show inline comments
 
file renamed from src/tests/test_gf256.py to src/shamira/tests/test_gf256.py
 
@@ -4,8 +4,8 @@ import random
 
import unittest
 
from unittest import TestCase
 

	
 
from gf256 import _gfmul
 
from gf256 import *
 
from ..gf256 import _gfmul
 
from ..gf256 import *
 

	
 

	
 
class TestGF256(TestCase):
src/shamira/tests/test_shamira.py
Show inline comments
 
file renamed from src/tests/test_shamira.py to src/shamira/tests/test_shamira.py
 
# GNU GPLv3, see LICENSE
 

	
 
import os
 
import random
 
from unittest import TestCase
 

	
 
from shamira import _share_byte
 
from shamira import *
 
from .. import *
 
from .. import gf256
 
from ..core import encode, decode,detect_encoding, _share_byte
 

	
 

	
 
class TestShamira(TestCase):
0 comments (0 inline, 0 general)