[Cryptography Team] Re: interleaving indexing has me scrambled

Robert Withers robert.w.withers at gmail.com
Thu Dec 17 05:04:59 UTC 2015


God works in mysterious ways, doesn't he? Not that I had any intention 
of breaking it. Not what I am about. Well, perhaps it isn;t meant to be 
interleaved just now. Perhaps,,, we go into the future, togehter.

peace,
robert

On 12/16/2015 11:59 PM, Robert Withers wrote:
> I had to bail on this. I really don't understand what it is doing. sorry
> it didn't deliver, hopefully I'll be able to get your back
>
> regards,
>
> robert
>
> On 12/16/2015 10:23 PM, Robert Withers wrote:
>> In particular the tempIndex of the second scan goes out of range and I
>> scratching my head. If anyone actually wants to look at how this method
>> works and can help, awesome! :)
>>
>> best,
>> robert
>>
>>
>>
>> ---
>>
>> interleave: symbols blockCount: blockCount
>>
>>      | symbolsPerChunk table interleaved interleavedBlock fourChunk
>> symbolsPerBlock |
>>      ((symbols size \\ 4) > 0) ifTrue: [self error: 'interleaving bytes
>> size not a multiple of 4'].
>>      symbolsPerChunk := symbols size // blockCount.
>>      symbolsPerBlock := symbols size // (blockCount // 4).
>>      table := OrderedCollection new: 4 withAll: 0.
>>      table at: 1 put: (ByteArray new: symbolsPerChunk withAll: 0).
>>      table at: 2 put: (ByteArray new: symbolsPerChunk withAll: 0).
>>      table at: 3 put: (ByteArray new: symbolsPerChunk withAll: 0).
>>      table at: 4 put: (ByteArray new: symbolsPerChunk withAll: 0).
>>      interleavedBlock := ByteArray new: (symbols size / blockCount)
>> withAll: 0.
>>      interleaved := ByteArray new: (symbols size + 1) withAll: 0.
>>      interleaved at: 1 put: blockCount.
>>
>>      0 to: blockCount - 1 do: [ :blockIndex |
>>          | end start |
>>          start := blockIndex * symbolsPerBlock + 1.
>>          end := (blockIndex + 1) * symbolsPerBlock.
>>          fourChunk := symbols copyFrom: start to: end.
>>          "first scan: bytes to populate the table"
>>          0 to: 3 do: [ :chunkIndex |
>>              | chunk slice symbol |
>>              chunk := fourChunk copyFrom: (chunkIndex * symbolsPerChunk
>> + 1) to: ((chunkIndex + 1) * symbolsPerChunk).
>>               1 to: symbolsPerChunk do: [ :index |
>>                  slice := table at: (chunkIndex + 1).
>>                  symbol := chunk at: index.
>>                  slice at: index put: symbol]].
>>          "second scan: table to populate the interleaved bytes"
>>          1 to: symbolsPerChunk do: [ :index |
>>              0 to: 3 do: [ :chunkIndex |
>>                  | localIndex offset tempIndex symbol |
>>                  offset := symbolsPerBlock * blockIndex.
>>                  tempIndex := index * 4 + chunkIndex - 3.
>>                  localIndex := offset + tempIndex.
>>                  symbol := (table at: (chunkIndex + 1)) at: index.
>>                  interleavedBlock at: localIndex put: symbol]].
>>          start := symbols size / blockCount * blockIndex + 1.
>>          end := symbols size / blockCount * blockIndex +
>> interleavedBlock size.
>>          interleaved replaceFrom: (start + 1) to: (end + 1) with:
>> interleavedBlock startingAt: 1].
>>      ^ interleaved
>

-- 
. .. .. ^,^ best, robert


More information about the Cryptography mailing list