initial commit

This commit is contained in:
callebtc
2022-09-11 04:31:37 +03:00
parent 213968eca7
commit 13a1e47a3d
18 changed files with 1128 additions and 0 deletions

51
mint/crud.py Normal file
View File

@@ -0,0 +1,51 @@
import secrets
from typing import Optional
from core.db import Connection, Database
async def store_promise(
amount: int,
B_x: str,
B_y: str,
C_x: str,
C_y: str,
db: Database,
conn: Optional[Connection] = None,
):
await (conn or db).execute(
"""
INSERT INTO promises
(amount, B_x, B_y, C_x, C_y)
VALUES (?, ?, ?, ?, ?)
""",
(
amount,
str(B_x),
str(B_y),
str(C_x),
str(C_y),
),
)
async def invalidate_proof(
proof: dict,
db: Database,
conn: Optional[Connection] = None,
):
# we add the proof and secret to the used list
await (conn or db).execute(
"""
INSERT INTO proofs_used
(amount, C_x, C_y, secret)
VALUES (?, ?, ?, ?)
""",
(
proof["amount"],
str(proof["C"]["x"]),
str(proof["C"]["y"]),
str(proof["secret"]),
),
)