# Path: axolotl/state/signedprekeystore.py
# class SignedPreKeyStore(object):
#     __metaclass__ = abc.ABCMeta
# 
#     @abc.abstractmethod
#     def loadSignedPreKey(self, signedPreKeyId):
#         pass
# 
#     @abc.abstractmethod
#     def loadSignedPreKeys(self):
#         pass
# 
#     @abc.abstractmethod
#     def storeSignedPreKey(self, signedPreKeyId, signedPreKeyRecord):
#         pass
# 
#     @abc.abstractmethod
#     def containsSignedPreKey(self, signedPreKeyId):
#         pass
# 
#     @abc.abstractmethod
#     def removeSignedPreKey(self, signedPreKeyId):
#         pass
# 
# Path: axolotl/state/signedprekeyrecord.py
# class SignedPreKeyRecord:
#     def __init__(self, _id=None, timestamp=None, ecKeyPair=None, signature=None, serialized=None):
#         self.structure = SignedPreKeyRecordStructure()
#         if serialized:
#             self.structure.ParseFromString(serialized)
#         else:
#             self.structure.id = _id
#             self.structure.publicKey = ecKeyPair.getPublicKey().serialize()
#             self.structure.privateKey = ecKeyPair.getPrivateKey().serialize()
#             self.structure.signature = signature
#             self.structure.timestamp = timestamp
# 
#     def getId(self):
#         return self.structure.id
# 
#     def getTimestamp(self):
#         return self.structure.timestamp
# 
#     def getKeyPair(self):
#         publicKey = Curve.decodePoint(bytearray(self.structure.publicKey), 0)
#         privateKey = Curve.decodePrivatePoint(bytearray(self.structure.privateKey))
# 
#         return ECKeyPair(publicKey, privateKey)
# 
#     def getSignature(self):
#         return self.structure.signature
# 
#     def serialize(self):
#         return self.structure.SerializeToString()
# 
# Path: axolotl/invalidkeyidexception.py
# class InvalidKeyIdException(Exception):
#     pass


from ..state.signedprekeystore import SignedPreKeyStore
from ..state.signedprekeyrecord import SignedPreKeyRecord
from ..invalidkeyidexception import InvalidKeyIdException
# -*- coding: utf-8 -*-



class InMemorySignedPreKeyStore(SignedPreKeyStore):
    def __init__(self):
        self.store = {}

    def loadSignedPreKey(self, signedPreKeyId):
        if signedPreKeyId not in self.store:
            raise InvalidKeyIdException("No such signedprekeyrecord! %s " % signedPreKeyId)

        return SignedPreKeyRecord(serialized=self.store[signedPreKeyId])

    def loadSignedPreKeys(self):
        results = []
        for serialized in self.store.values():

# Path: axolotl/state/signedprekeystore.py
# class SignedPreKeyStore(object):
#     __metaclass__ = abc.ABCMeta
# 
#     @abc.abstractmethod
#     def loadSignedPreKey(self, signedPreKeyId):
#         pass
# 
#     @abc.abstractmethod
#     def loadSignedPreKeys(self):
#         pass
# 
#     @abc.abstractmethod
#     def storeSignedPreKey(self, signedPreKeyId, signedPreKeyRecord):
#         pass
# 
#     @abc.abstractmethod
#     def containsSignedPreKey(self, signedPreKeyId):
#         pass
# 
#     @abc.abstractmethod
#     def removeSignedPreKey(self, signedPreKeyId):
#         pass
# 
# Path: axolotl/state/signedprekeyrecord.py
# class SignedPreKeyRecord:
#     def __init__(self, _id=None, timestamp=None, ecKeyPair=None, signature=None, serialized=None):
#         self.structure = SignedPreKeyRecordStructure()
#         if serialized:
#             self.structure.ParseFromString(serialized)
#         else:
#             self.structure.id = _id
#             self.structure.publicKey = ecKeyPair.getPublicKey().serialize()
#             self.structure.privateKey = ecKeyPair.getPrivateKey().serialize()
#             self.structure.signature = signature
#             self.structure.timestamp = timestamp
# 
#     def getId(self):
#         return self.structure.id
# 
#     def getTimestamp(self):
#         return self.structure.timestamp
# 
#     def getKeyPair(self):
#         publicKey = Curve.decodePoint(bytearray(self.structure.publicKey), 0)
#         privateKey = Curve.decodePrivatePoint(bytearray(self.structure.privateKey))
# 
#         return ECKeyPair(publicKey, privateKey)
# 
#     def getSignature(self):
#         return self.structure.signature
# 
#     def serialize(self):
#         return self.structure.SerializeToString()
# 
# Path: axolotl/invalidkeyidexception.py
# class InvalidKeyIdException(Exception):
#     pass


# Path: axolotl/tests/inmemorysignedprekeystore.py
from ..state.signedprekeystore import SignedPreKeyStore
from ..state.signedprekeyrecord import SignedPreKeyRecord
from ..invalidkeyidexception import InvalidKeyIdException

# -*- coding: utf-8 -*-



class InMemorySignedPreKeyStore(SignedPreKeyStore):
    def __init__(self):
        self.store = {}

    def loadSignedPreKey(self, signedPreKeyId):
        if signedPreKeyId not in self.store:
            raise InvalidKeyIdException("No such signedprekeyrecord! %s " % signedPreKeyId)

        return SignedPreKeyRecord(serialized=self.store[signedPreKeyId])

    def loadSignedPreKeys(self):
        results = []
        for serialized in self.store.values():

            results.append(SignedPreKeyRecord(serialized=serialized))