rainbowadn/rainbowadn/core/metaorigin.py
2022-07-10 21:14:02 +03:00

22 lines
672 B
Python

from typing import Generic, TypeVar
from .asserts import *
from .hashpoint import *
from .origin import *
from .rainbow_factory import *
__all__ = ('MetaOrigin',)
Mentioned = TypeVar('Mentioned')
class MetaOrigin(Generic[Mentioned]):
def origin(self, factory: RainbowFactory[Mentioned], point: bytes) -> Origin[Mentioned]:
raise NotImplementedError
def hash_point(self, factory: RainbowFactory[Mentioned], point: bytes) -> HashPoint[Mentioned]:
assert isinstance(factory, RainbowFactory)
assert isinstance(point, bytes)
assert_eq(len(point), HashPoint.HASH_LENGTH)
return HashPoint(point, self.origin(factory, point))