lsd0003

LSD0003: Set Union
Log | Files | Refs | README

commit 7206b03239f8335b407878e8468f2b1f4474927f
parent 5e3e7e1d6e822b25b2ce4b4dfcee6541807990cb
Author: Elias Summermatter <elias.summermatter@seccom.ch>
Date:   Mon, 14 Jun 2021 15:34:59 +0200

Fixed packing algo

Diffstat:
Mdraft-summermatter-set-union.xml | 27++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/draft-summermatter-set-union.xml b/draft-summermatter-set-union.xml @@ -2240,38 +2240,46 @@ FUNCTION ibf_get_max_counter(ibf) # OUTPUTS: # returns: A byte array of packed counters to send over the network +# INPUTS: +# ibf: The IBF +# offset: The offset which defines the starting point from which bucket the +# pack operation starts +# count: The number of buckets in the array that will be packed +# OUTPUTS: +# returns: A byte array of packed counters to send over the network + FUNCTION pack_counter(ibf, offset, count) counter_bytes = ibf_get_max_counter(ibf) - store = 0 store_bits = 0 + store = 0 byte_ctr = 0 buffer=[] FOR bucket IN ibf[offset] to ibf[count] - byte_len = counter_bytes counter = bucket.counter + byte_len = counter_bytes - WHILE byte_len > 0 + WHILE TRUE byte_to_write = 0 - IF counter_bytes + store_bits >= 8 + IF byte_len + store_bits >= 8 bit_to_shift = 0 - IF store_bits > 0 OR counter_bytes > 8 + IF store_bits > 0 OR byte_len > 8 bit_free = 8 - store_bits - bit_to_shift = counter_bytes - bit_free + bit_to_shift = byte_len - bit_free store = store << bit_free END IF byte_to_write = (( counter >> bit_to_shift) | store) & 0xFF - bit_to_shift -= 8 - store_bits - counter = counter & ((1 << counter_bytes) - 1) + byte_len -= 8 - store_bits + counter = counter & ((1 << byte_len) - 1) store = 0 store_bits = 0 ELSE IF 0 == store_bits store = counter ELSE - store = (store << counter_bytes) | counter + store = (store << byte_len) | counter END IF store_bits = store_bits + byte_len byte_len = 0 @@ -2288,6 +2296,7 @@ FUNCTION pack_counter(ibf, offset, count) byte_ctr = byte_ctr + 1 RETURN buffer +FUNCTION END # INPUTS: # ibf: The IBF