예제 #1
0
파일: lab4.py 프로젝트: N1cOs/cryptography
import common
import el_gamal as eg
import elliptic

if __name__ == "__main__":
    calc = elliptic.Calculator(common.CURVE, private_key=common.PRIVATE_KEY)

    codec = eg.AlphabetCodec(common.ALPHABET_PATH)
    el_gamal = eg.ElGamal(calc, common.GEN_POINT, codec)

    cipher = [
        (elliptic.Point(283, 493), elliptic.Point(314, 127)),
        (elliptic.Point(425, 663), elliptic.Point(561, 140)),
        (elliptic.Point(568, 355), elliptic.Point(75, 433)),
        (elliptic.Point(440, 539), elliptic.Point(602, 627)),
        (elliptic.Point(188, 93), elliptic.Point(395, 414)),
        (elliptic.Point(179, 275), elliptic.Point(25, 604)),
        (elliptic.Point(72, 254), elliptic.Point(47, 349)),
        (elliptic.Point(72, 254), elliptic.Point(417, 137)),
        (elliptic.Point(188, 93), elliptic.Point(298, 225)),
        (elliptic.Point(56, 419), elliptic.Point(79, 111)),
    ]
    print(el_gamal.decrypt(cipher))
예제 #2
0
import inspect
from os import path

import elliptic


def get_module_dir():
    return path.dirname(inspect.getfile(inspect.currentframe()))


ALPHABET_PATH = path.join(get_module_dir(), "alphabet.json")
CURVE = elliptic.Curve(-1, 1, 751)
GEN_POINT = elliptic.Point(0, 1)
PUBLIC_KEY = elliptic.Point(425, 663)
PRIVATE_KEY = 41
예제 #3
0
파일: lab6.py 프로젝트: N1cOs/cryptography
import common
import elliptic

if __name__ == "__main__":
    calc = elliptic.Calculator(common.CURVE)

    p = elliptic.Point(36, 87)
    print(calc.times(p, 111))
예제 #4
0
 def _load(self, path: str) -> Dict[str, elliptic.Point]:
     with open(path, "r") as f:
         raw = json.load(f)
         return {k: elliptic.Point(v[0], v[1]) for k, v in raw.items()}
예제 #5
0
파일: lab5.py 프로젝트: N1cOs/cryptography
import common
import elliptic

if __name__ == "__main__":
    calc = elliptic.Calculator(common.CURVE)

    p = elliptic.Point(59, 386)
    p2 = calc.times(p, 2)

    q = elliptic.Point(70, 195)
    q3 = calc.times(q, 3)

    r = elliptic.Point(72, 254)
    print(calc.sub(calc.sum(p2, q3), r))