35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, JSON, Boolean
|
|
from sqlalchemy.orm import relationship
|
|
from base58 import b58decode
|
|
|
|
from .base import AlchemyBase
|
|
|
|
|
|
class KnownKey(AlchemyBase):
|
|
__tablename__ = 'known_keys'
|
|
|
|
id = Column(Integer, autoincrement=True, primary_key=True)
|
|
type = Column(String(32), nullable=False, default="NOT_SPECIFIED")
|
|
seed = Column(String(6144), nullable=True, default=None, unique=True)
|
|
seed_hash = Column(String(64), nullable=True, default=None, unique=True) # base58
|
|
public_key = Column(String(6144), nullable=False, unique=True)
|
|
public_key_hash = Column(String(64), nullable=False, unique=True) # base58
|
|
|
|
algo = Column(String(32), nullable=True, default=None)
|
|
meta = Column(JSON, nullable=False, default={})
|
|
# {
|
|
# "I_user_id": TRUSTED_USER_ID,
|
|
# }
|
|
|
|
created = Column(DateTime, nullable=False, default=0)
|
|
|
|
# stored_content = relationship('StoredContent', back_populates='key')
|
|
|
|
@property
|
|
def seed_bin(self) -> bytes:
|
|
return b58decode(self.seed)
|
|
|
|
@property
|
|
def public_key_bin(self) -> bytes:
|
|
return b58decode(self.public_key)
|