MessagePack (de)serializer with Ethereum RLP encoding
Project description
This library uses a modified version of msgpack to encode and decode binary data according to the Ethereum RLP specification here https://github.com/ethereum/wiki/wiki/RLP
This is the first release of this library, and there are likely still bugs. Use at your own risk.
Install
$ pip install msgpack-rlp-python
USAGE
RLP doesn’t specify the variable type, so all encoded data is decoded to a bytestring representation. In order to specify the variable types, we use sedes. Sedes are ways of telling the program what variable types you expect from the encoded data. In this version there are only 2 supported sedes: bytes (represented by the integer 0) and integers (represented by the integer 1). These sedes can also contained within lists or nested lists. In order to show that the sedes live within lists or nested lists, we use the standard python list notation. See below.
All lists will be decoded to tuples by default. To decode to a list set use_list = True
Sedes are only used when decoding. This library is smart enough to know what variable types are being encoded, and will convert them to the RLP spec correctly.
This is meant to be a stand-in replacement of msgpack. So the package to import is still called msgpack.
Example sedes:
var = b'\x01'
sede = 0 # A bytestring
var = 12381239
sede = 1 # An integer
var = [b'\x01', b'\x02', b'\x03', b'\x04']
sede = [0] # A list of bytestrings
var = [12312,1234,213412,213421]
sede = [1] # A list of integers
var = [b'\x01', [12312,1234]]
sede = [0,[1]] # Different types, and nested lists
Example usage without sedes. This will always decode to bytestrings.
>>> import msgpack
>>> msgpack.packb([1, 2, 3])
'b'\xc3\x01\x02\x03''
>>> msgpack.unpackb(_)
(b'\x01', b'\x02', b'\x03')
>>> msgpack.packb([1, 2, 3])
'b'\xc3\x01\x02\x03''
>>> msgpack.unpackb(_, use_list = True)
[b'\x01', b'\x02', b'\x03']
Example usage with sedes. This will decode to the variable types that you encoded from.
>>> import msgpack
>>> msgpack.packb([1, 2, 3])
'b'\xc3\x01\x02\x03''
>>> msgpack.unpackb(_)
(b'\x01', b'\x02', b'\x03')
>>> msgpack.packb([1, 2, 3])
'b'\xc3\x01\x02\x03''
>>> msgpack.unpackb(_, sedes=[1], use_list=True)
[1, 2, 3]
>>> msgpack.packb([b'\x01', [12312,1234]])
b'\xc8\x01\xc6\x820\x18\x82\x04\xd2'
>>> msgpack.unpackb(_, sedes=[0,[1]], use_list=True)
[b'\x01', [12312, 1234]]
>>> msgpack.packb([b'\x01', [12312,1234]])
b'\xc8\x01\xc6\x820\x18\x82\x04\xd2'
>>> msgpack.unpackb(_, sedes=[0,[1]], use_list=True)
[b'\x01', [12312, 1234]]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file msgpack_rlp_python-0.5.8-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: msgpack_rlp_python-0.5.8-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 287.5 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 147b17f3cdb526f96e24aeb855c6e6d7da23b7964620b88b84c35294ad3e9df7 |
|
MD5 | b90f1f4cc4e8f84157e011dc4bf3de52 |
|
BLAKE2b-256 | 039385e53cf571882fd855f4a6d8f2fb12d8c6d791a7894243e9d5621c49e623 |
Provenance
File details
Details for the file msgpack_rlp_python-0.5.8-cp36-cp36m-manylinux1_i686.whl
.
File metadata
- Download URL: msgpack_rlp_python-0.5.8-cp36-cp36m-manylinux1_i686.whl
- Upload date:
- Size: 267.6 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 758a93168a799470666a0c0187c2f30b7f5632f4db16366d7826ebce4385c14b |
|
MD5 | c609bf3cc28818a7f1d2444c1a8e1db6 |
|
BLAKE2b-256 | 5b7e63117c57c297920a8ff276f1fa129bd8925612376894f74f12dfcfb9e780 |
Provenance
File details
Details for the file msgpack_rlp_python-0.5.8-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: msgpack_rlp_python-0.5.8-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 281.0 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60e080a73d0b0ecf34474770f0eb61418dd66b240f0f9187c1659579138e9160 |
|
MD5 | b99a18fedcfa2011be05d21bb15da6a6 |
|
BLAKE2b-256 | a3cb57c3ea4e79ddfde3a85d8b280e0ee897ca0876a8b1523f92ccf70659429c |
Provenance
File details
Details for the file msgpack_rlp_python-0.5.8-cp35-cp35m-manylinux1_i686.whl
.
File metadata
- Download URL: msgpack_rlp_python-0.5.8-cp35-cp35m-manylinux1_i686.whl
- Upload date:
- Size: 259.5 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ea96f6ec42401ca339957586b60893f1175265f73ba80f821f3b04991d3b1e3 |
|
MD5 | 2e56dbdc43c62350551a5bfe430437a2 |
|
BLAKE2b-256 | dc83ae013131cf3559fa34d741b1b6e24591da97bf5350bdd6290dc228997993 |
Provenance
File details
Details for the file msgpack_rlp_python-0.5.8-cp27-cp27mu-manylinux1_x86_64.whl
.
File metadata
- Download URL: msgpack_rlp_python-0.5.8-cp27-cp27mu-manylinux1_x86_64.whl
- Upload date:
- Size: 264.2 kB
- Tags: CPython 2.7mu
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b74e7b253140f65efeaa33f49b73f3899fe5f94a6ee78553362f3e0ac3a31da5 |
|
MD5 | 6bd0849c6ddaf3ffe9b174979b058304 |
|
BLAKE2b-256 | 2be2d76db300c236a425b76ed40e403d3e71e3c0d165293c76dade9c21fef4e7 |
Provenance
File details
Details for the file msgpack_rlp_python-0.5.8-cp27-cp27mu-manylinux1_i686.whl
.
File metadata
- Download URL: msgpack_rlp_python-0.5.8-cp27-cp27mu-manylinux1_i686.whl
- Upload date:
- Size: 245.9 kB
- Tags: CPython 2.7mu
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87f6b855e06527ac1bd2ce9a017dda7148eb2a10c03e9c94f14a84d83b4b12c8 |
|
MD5 | 455c307a0c2a49a75481cd6eb5db0516 |
|
BLAKE2b-256 | 880136e36cc5f14ff5e91515dc08a9fac6b9f4f46f71d1cc57e70a0fe5d5967f |
Provenance
File details
Details for the file msgpack_rlp_python-0.5.8-cp27-cp27m-manylinux1_x86_64.whl
.
File metadata
- Download URL: msgpack_rlp_python-0.5.8-cp27-cp27m-manylinux1_x86_64.whl
- Upload date:
- Size: 265.2 kB
- Tags: CPython 2.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e81de71501cfbd9bcd28b6bbd2d7d03110a3cd8a91a7a976ac6367fb0527400 |
|
MD5 | a1aad80da76a2a413330b4b3fc20c3b5 |
|
BLAKE2b-256 | 15b108aaaf08048a54ced6f51f8cc6ae5f7841107698aff9212bb88f324c2e0d |
Provenance
File details
Details for the file msgpack_rlp_python-0.5.8-cp27-cp27m-manylinux1_i686.whl
.
File metadata
- Download URL: msgpack_rlp_python-0.5.8-cp27-cp27m-manylinux1_i686.whl
- Upload date:
- Size: 246.0 kB
- Tags: CPython 2.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84bcec969d4ed792512bacf7187f445d427d3c6f1c137d2338afa702d808a0f6 |
|
MD5 | 9a8ff5e62351ba625351f1b1820e90d6 |
|
BLAKE2b-256 | d18877d170709042066bc493888e5128a594af16f2f88ab71859c09055bf4707 |