Skip to content
Snippets Groups Projects
Commit 7a0c59bf authored by Johannes Hitzinger's avatar Johannes Hitzinger
Browse files

started with offer and request, added pint for measurements

parent 84777eab
No related branches found
No related tags found
No related merge requests found
import sys
import random
import dilithium.dilithium
from dilithium import Dilithium
from pint import UnitRegistry
ureg = UnitRegistry()
Q_ = ureg.Quantity
dis1 = 10 * ureg.watt
print(repr(dis1))
print(dis1)
d1 = Dilithium(dilithium.dilithium.DEFAULT_PARAMETERS["dilithium3"])
a, b = d1.keygen([1,2,3,4])
print(a)
print(b)
\ No newline at end of file
pk, sk = d1.keygen([random.randint(0,sys.maxsize),random.randint(0,sys.maxsize),random.randint(0,sys.maxsize),random.randint(0,sys.maxsize)])
msg = b"this is a message"
sig = d1.sign_with_input(sk,msg)
result = d1.verify(pk, msg, sig)
print(result)
from main import ureg,Q_
class Offer:
def __init__(self):
self.__power = 0
\ No newline at end of file
from typing import Optional
from random import randint
import sys
from dilithium import Dilithium
import dilithium.dilithium
from offer import Offer
from request import Request
from trade import Trade
class Participant:
def __init__(self):
d1 = Dilithium(dilithium.dilithium.DEFAULT_PARAMETERS["dilithium3"])
self.__secretKey, self.__publicKey = d1.keygen([randint(0,sys.maxsize),randint(0,sys.maxsize),randint(0,sys.maxsize),randint(0,sys.maxsize)])
self.next_offer: Optional[Offer] = None
self.next_request: Optional[Request] = None
self.active_trades: list[Trade] = []
class Request:
def __init__(self):
self.power = 0
\ No newline at end of file
......@@ -4,6 +4,7 @@
let
mypython = pkgs.python3.withPackages (python-pkgs: [
python-pkgs.numpy
python-pkgs.pint
(python-pkgs.callPackage ./dilithium.nix { })
]);
in
......
from offer import Offer
from request import Request
class Trade:
def __init__(self, o: Offer, r: Request):
self.__offer: Offer = o
self.__request: Request = r
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment