Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

msgpack_rlp_python-0.5.7-cp36-cp36m-manylinux1_i686.whl (14.1 kB view details)

Uploaded CPython 3.6m

msgpack_rlp_python-0.5.7-cp35-cp35m-manylinux1_i686.whl (14.1 kB view details)

Uploaded CPython 3.5m

msgpack_rlp_python-0.5.7-cp27-cp27mu-manylinux1_i686.whl (14.1 kB view details)

Uploaded CPython 2.7mu

msgpack_rlp_python-0.5.7-cp27-cp27m-manylinux1_i686.whl (14.1 kB view details)

Uploaded CPython 2.7m

File details

Details for the file msgpack_rlp_python-0.5.7-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: msgpack_rlp_python-0.5.7-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 14.1 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

Hashes for msgpack_rlp_python-0.5.7-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 48491d3f6e05225d739d9bcf8a7e738e4b1e9b6aeae237ffbe04e5773793828e
MD5 9ee707771b71a83ef9c564227cacf836
BLAKE2b-256 dfa15fd96f7a18dbfba8c2bd5ef3b827ae704414ce5e5d254eefa31971eaf702

See more details on using hashes here.

File details

Details for the file msgpack_rlp_python-0.5.7-cp36-cp36m-manylinux1_i686.whl.

File metadata

  • Download URL: msgpack_rlp_python-0.5.7-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 14.1 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

Hashes for msgpack_rlp_python-0.5.7-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ea0c9a0e39233e8301961848de2d140d17af3f8a45a4fe02948cef62509da413
MD5 28978795a6739800898539ec45fc5c39
BLAKE2b-256 439aabcd511561ea7367d0a86131d844415846e554ea4bb86392760cc3240d32

See more details on using hashes here.

File details

Details for the file msgpack_rlp_python-0.5.7-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: msgpack_rlp_python-0.5.7-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 14.1 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

Hashes for msgpack_rlp_python-0.5.7-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1350e587c97345b870f71d512ed03e3c1c6f306d54873dd875abe26215954de5
MD5 bf4919325f11f67822aa82118574f52b
BLAKE2b-256 0c987c6b3a4d9ec2e622c4aec6c3d1118841f1d8a7a9945232d24dc822e46649

See more details on using hashes here.

File details

Details for the file msgpack_rlp_python-0.5.7-cp35-cp35m-manylinux1_i686.whl.

File metadata

  • Download URL: msgpack_rlp_python-0.5.7-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 14.1 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

Hashes for msgpack_rlp_python-0.5.7-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 de41c5ff98991f6c7190227bb40facf2d8918a87d746597e2491115512a8f8d4
MD5 fe9407fd413d0040633c0d5948461da5
BLAKE2b-256 6d2473e66a05a34007743d6ef3698221e0004f0314670b21633d96e01ee09c1b

See more details on using hashes here.

File details

Details for the file msgpack_rlp_python-0.5.7-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for msgpack_rlp_python-0.5.7-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ee43bcaff8f8dbb7bc07c4bdaeb4375954e77f6284a8b77876935d6769f16c4e
MD5 c4563dcf3442935e338a5cd29c85bf8c
BLAKE2b-256 c044d19479314db9fe5534064010bed9218907d2b0b779ae3639b52cc8bfdd21

See more details on using hashes here.

File details

Details for the file msgpack_rlp_python-0.5.7-cp27-cp27mu-manylinux1_i686.whl.

File metadata

  • Download URL: msgpack_rlp_python-0.5.7-cp27-cp27mu-manylinux1_i686.whl
  • Upload date:
  • Size: 14.1 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

Hashes for msgpack_rlp_python-0.5.7-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 1e8d9bd5932c43ab74eb41ffc381e58974bec1592e071cb64d0eb9e1aca14198
MD5 164e4123177bad2e70c4a466b730f126
BLAKE2b-256 6b1fc50ff5187459ca0aab9cd40c459016548461d43e7806187106513f202e55

See more details on using hashes here.

File details

Details for the file msgpack_rlp_python-0.5.7-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

  • Download URL: msgpack_rlp_python-0.5.7-cp27-cp27m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 14.1 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

Hashes for msgpack_rlp_python-0.5.7-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 42ee4742e02a4c3cd84073596b38ce7ba85255ca279ef20074377fec818b85bf
MD5 a921647cdac59acb58ab8087d7a52a8d
BLAKE2b-256 b81d519b8a423e140cf36a717e2901d54be4c74c52dbff9cc469403dd3330a66

See more details on using hashes here.

File details

Details for the file msgpack_rlp_python-0.5.7-cp27-cp27m-manylinux1_i686.whl.

File metadata

  • Download URL: msgpack_rlp_python-0.5.7-cp27-cp27m-manylinux1_i686.whl
  • Upload date:
  • Size: 14.1 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

Hashes for msgpack_rlp_python-0.5.7-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 8a2876dfa320f45ed3ac3bce37a547ebf5edbe2ea8b76dd9798ad08b75aa6d17
MD5 9dbb601b7dda884c3454ac9b837e037d
BLAKE2b-256 ad793e53c709de60de2354e7fa09f5664bbdc99053991558196ef8e3f6476117

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page