iroha icon indicating copy to clipboard operation
iroha copied to clipboard

Immutable payload in `iroha_crypto`

Open mversic opened this issue 2 years ago • 1 comments

Check this comment. Payload (currently a Vec<u8>) in structures like PublicKey, PrivateKey and Signature is immutable for the lifetime of the wrapping type. This means that capacity field of the Vec is redundant and could be removed to reduce the size. A similar thing was done in #1985

mversic avatar Aug 01 '22 11:08 mversic

Probably we can somehow generalize this to no to repeate the code for Name struct

Arjentix avatar Aug 01 '22 11:08 Arjentix

This is a different situation.

In case of ConstStr we want to be able to heap-allocate objects beyond a certain length.

Keys are all stored in enums, immutable and their length is known at compile time. It's likely that the final implementation is going to be a newtype wrapping [u8; X] where X is determined for each key as a constant. (const generics are stable).

appetrosyan avatar Aug 14 '22 07:08 appetrosyan