Пример #1
0
    def deserialize(cls, ctx):
        ctx.assert_magic(cls.HEADER_MAGIC)

        major = ctx.read_varuint() # FIXME: max-int limit
        if major != cls.MAJOR_VERSION:
            raise opentimestamps.core.serialize.UnsupportedMajorVersion("Version %d detached timestamp files are not supported" % major)

        file_hash_op = CryptOp.deserialize(ctx)
        file_hash = ctx.read_bytes(file_hash_op.DIGEST_LENGTH)
        timestamp = Timestamp.deserialize(ctx, file_hash)

        ctx.assert_eof()

        return DetachedTimestampFile(file_hash_op, timestamp)
Пример #2
0
    def deserialize(cls, ctx):
        ctx.assert_magic(cls.HEADER_MAGIC)

        major = ctx.read_varuint() # FIXME: max-int limit
        if major != cls.MAJOR_VERSION:
            raise opentimestamps.core.serialize.UnsupportedMajorVersion("Version %d detached timestamp files are not supported" % major)

        file_hash_op = CryptOp.deserialize(ctx)
        file_hash = ctx.read_bytes(file_hash_op.DIGEST_LENGTH)
        timestamp = Timestamp.deserialize(ctx, file_hash)

        ctx.assert_eof()

        return DetachedTimestampFile(file_hash_op, timestamp)
Пример #3
0
    def open(cls, fd):
        """Open an existing timestamp log

        fd must be positioned at the start of the log; the header will be
        immediately read and DeserializationError raised if incorrect.
        """
        ctx = StreamDeserializationContext(fd)

        actual_magic = ctx.read_bytes(len(cls.HEADER_MAGIC))

        if cls.HEADER_MAGIC != actual_magic:
            raise BadMagicError(cls.HEADER_MAGIC, actual_magic)

        file_hash_op = CryptOp.deserialize(ctx)

        return cls(fd, file_hash_op)
Пример #4
0
    def open(cls, fd):
        """Open an existing timestamp log

        fd must be positioned at the start of the log; the header will be
        immediately read and DeserializationError raised if incorrect.
        """
        ctx = StreamDeserializationContext(fd)

        actual_magic = ctx.read_bytes(len(cls.HEADER_MAGIC))

        if cls.HEADER_MAGIC != actual_magic:
            raise opentimestamps.core.serialize.BadMagicError(cls.HEADER_MAGIC, actual_magic)

        file_hash_op = CryptOp.deserialize(ctx)

        return cls(fd, file_hash_op)