Ejemplo n.º 1
0
def slices():
    ret = []
    for case in seeks():
        size = case["input_len"]
        offsets = case["seek_offsets"]
        b = input_bytes(size)
        encoded = bao.bao_encode(b)
        slices = []
        for offset in offsets:
            slice_bytes = io.BytesIO()
            slice_len = 2 * CHUNK_SIZE
            bao.bao_slice(io.BytesIO(encoded), slice_bytes, offset, slice_len)
            slice_hash = blake2b_hash(slice_bytes.getbuffer())
            fields = [
                ("start", offset),
                ("len", slice_len),
                ("output_len", len(slice_bytes.getbuffer())),
                ("output_blake2b", slice_hash),
                ("corruptions",
                 slice_corruption_points(size, offset, slice_len)),
            ]
            slices.append(OrderedDict(fields))
        fields = [
            ("input_len", size),
            ("bao_hash", bao.bao_hash(io.BytesIO(b)).hex()),
            ("slices", slices),
        ]
        ret.append(OrderedDict(fields))
    return ret
Ejemplo n.º 2
0
def hashes():
    ret = []
    for size in SIZES:
        b = input_bytes(size)
        h = bao.bao_hash(io.BytesIO(b))
        fields = [("input_len", size), ("bao_hash", h.hex())]
        ret.append(OrderedDict(fields))
    return ret
Ejemplo n.º 3
0
def encoded():
    ret = []
    for size in SIZES:
        b = input_bytes(size)
        encoded = bao.bao_encode(b)
        fields = [
            ("input_len", size),
            ("output_len", len(encoded)),
            ("bao_hash", bao.bao_hash(io.BytesIO(b)).hex()),
            ("encoded_blake2b", blake2b_hash(encoded)),
            ("corruptions", encode_corruption_points(size)),
        ]
        ret.append(OrderedDict(fields))
    return ret
Ejemplo n.º 4
0
def outboard():
    ret = []
    for size in SIZES:
        b = input_bytes(size)
        encoded = bao.bao_encode(b, outboard=True)
        input_corruptions = []
        corruption = 0
        while corruption < size:
            input_corruptions.append(corruption)
            corruption += CHUNK_SIZE
        fields = [
            ("input_len", size),
            ("output_len", len(encoded)),
            ("bao_hash", bao.bao_hash(io.BytesIO(b)).hex()),
            ("encoded_blake2b", blake2b_hash(encoded)),
            ("outboard_corruptions",
             encode_corruption_points(size, outboard=True)),
            ("input_corruptions", input_corruptions),
        ]
        ret.append(OrderedDict(fields))
    return ret
Ejemplo n.º 5
0
def bao_hash(content):
    return bao.bao_hash(io.BytesIO(content)).hex()
Ejemplo n.º 6
0
def blake3_hash(b):
    return hexlify(bao.bao_hash(io.BytesIO(b))).decode("utf-8")
Ejemplo n.º 7
0
def bao_hash(content):
    return hexlify(bao.bao_hash(io.BytesIO(content))).decode("utf-8")