From c90c5d40e7c529ab364721ce60b63d5841c6e101 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 13 Sep 2022 16:34:45 +0300 Subject: [PATCH] base --- core/base.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 core/base.py diff --git a/core/base.py b/core/base.py new file mode 100644 index 0000000..d0bab2e --- /dev/null +++ b/core/base.py @@ -0,0 +1,42 @@ +from pydantic import BaseModel +from typing import List +from sqlite3 import Row + + +class BasePoint(BaseModel): + """Named BasePoint because it conflicts with ecc.curve.Point""" + + x: int + y: int + + +class Proof(BaseModel): + amount: int + C: BasePoint + secret: str + + @classmethod + def from_row(cls, row: Row): + return dict( + amount=row[0], + C=dict( + x=int(row[1]), + y=int(row[2]), + ), + secret=row[3], + ) + + +class MintPayload(BaseModel): + amount: int + B_: BasePoint + + +class MintPayloads(BaseModel): + payloads: List[MintPayload] = [] + + +class SplitPayload(BaseModel): + proofs: List[Proof] + amount: int + output_data: MintPayloads