This repository is now deprecated as it can only be used with the legacy IOTA network.
IOTA Trytes compression/decompression provides a mechanism by which trytes can be more efficiently stored or transmitted.
By considering the data domain and the specific way in which tryte data is used we created an algorithm that works extremely efficiently in the most common use cases. The algorithm is also implemented in such a way as to make it lightweight enough to be used by embedded devices.
The algorithm uses a combination of run-length-encoding and huffman encoding based on a static huffman tree. The static huffman tree was generated by analyzing 10000s of actual transactions.
This code is a port of the JavaScript package https://github.com/iotaledger/tryte-compress-js
The main library is tryte-compress
it exports two functions.
// Accepts trytes converted into their ascii characters, it returns compressed byte data.
fn compress(trytes: &Vec<u8>) -> Vec<u8>
// Accepts byte data returned by compress, it returns the ascii characters for the decompressed trytes.
fn decompress(buffer: &Vec<u8>) -> Vec<u8>
Benchmarks can be performed running cargo bench
You can run tests by modifying and running the tryte-compress-cli
.
MIT License - Copyright (c) 2019 IOTA Stiftung