eos icon indicating copy to clipboard operation
eos copied to clipboard

How to transfer a pre-encrypted key through submitting the transcation?

Open Danilo0120 opened this issue 8 years ago • 2 comments

@jgiszczak @taokayan

How to transfer a pre-encrypted key through submitting the transcation?Does it have limitation of memory?

Danilo0120 avatar Oct 22 '18 13:10 Danilo0120

2018-10-22T13:00:19.495 thread-0 http_plugin.cpp:581 handle_exception ] Exception Details: 3050003 eosio_assert_message_exception: eosio_assert_message assertion failure assertion failure with message: memo has more than 256 bytes {"s":"memo has more than 256 bytes"} thread-0 wasm_interface.cpp:930 eosio_assert pending console output: {"console":""} thread-0 apply_context.cpp:61 exec_one

Danilo0120 avatar Oct 22 '18 13:10 Danilo0120

As you have already discovered, the memo field of the transfer transaction is limited to 256 bytes. You must carefully select both your cipher and your encoding algorithm.

The best encoding algorithm that's likely to survive in all circumstances is the ZeroMQ implementation of ASCII85, known as Z85. It is 80% efficient. This means your effective encrypted key size can be no more than 204 binary bytes.

Obviously RSA keys of useful length are not an option. The raw key material only just fits, but an encrypted encoded version does not. If you want keys which are compatible with the chain, you will be transmitting ECC keys of 32 bytes.

RSA encryption is also not suitable, since recommended keys sizes have been 2048 bits or higher for some time, and the off the shelf RSA implementations always output a minimum size of the key size to maintain their security.

If you wish you use a symmetric cipher, you can encrypt with AES-GCM and the result is 32+16 bytes, which fits easily in the 204 byte limit.

If you wish to use the Elliptic Curve Integrated Encryption Scheme (ECIES), the result will be 32+32+20 bytes (assuming HMAC-SHA-1-160), which also fits in the 204 byte limit.


If you wish to avoid the limitations of the memo field, create a contract which accepts an action with data of whatever length you are willing to stake network bandwidth for and use that to place data on the chain.

jgiszczak avatar Oct 22 '18 22:10 jgiszczak