mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-23 11:44:19 +01:00
base
This commit is contained in:
42
core/base.py
Normal file
42
core/base.py
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user