Comparing Encoding/Decoding with another erasure coding library #282
-
Hi, I currently use this (very nice !) library to encode and decode blocks for storage. I'd like to be able to use another python-based library to encode content to be consumed by this project, and vice-versa. I selected zfec because it appears to use the same primitive polynomial you use (0x11D). As a start I wrote some pretty stupid code to encode random bytes with both libraries which results in different content. I double-checked that both zfec and this library do zero-padding. To be extra-safe, I did a simple test a data file of 2 random bytes, 2 data shards and 2 parity shards. This should result in zero padding for all shards. For example: with this code:
and this one:
--> The last shard (shard index 3) contains differing content. Do you have suggestions on what I should look into that might explain this difference ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Both the poly and matrix must match. Code comments claim it is Vandermonde, but I don't have any way to check. Neither of the other matrices match the output either. |
Beta Was this translation helpful? Give feedback.
-
hi @klauspost , Thank you for this hint. I looked carefully at the encoding matrix: And, yes, after a while staring at the code, it is pretty obvious that zfec is not generating its encoding matrix from a vandermonde matrix:
The patch below fixes both issues and appears to generate the same matrix you use in reedsolomon.go. Encoding and decoding then works cross-library. I doubt this is of much use to anyone but me and I doubt the zfec maintainers will be interested in this but, in case someone stumbles upon this problem, the below might be helpful.
|
Beta Was this translation helpful? Give feedback.
hi @klauspost ,
Thank you for this hint. I looked carefully at the encoding matrix:
zfec vs klauspost/reedsolomon
And, yes, after a while staring at the code, it is pretty obvious that zfec is not generating its encoding matrix from a vandermonde matrix:
The patch below fixes both issues and appears to generate the same matrix you use in reedsolomon.go. Encoding and decoding then works cross-library. I doubt this i…