peerbit icon indicating copy to clipboard operation
peerbit copied to clipboard

`Crypto`: Should `Key` be serializable?

Open marcus-pousette opened this issue 2 years ago • 1 comments
trafficstars

Currently you can not do

@field({type: Key}) 
key: PublicSignKey | PublicKeyEncryptionKey

only

@field({type: PublicSignKey}) 
key: PublicSignKey

marcus-pousette avatar Sep 21 '23 08:09 marcus-pousette

Pros:

  • Above example can be done

Cons:

  • The serialized key will be more complicated, i.e. an additional discriminator and more deserialization paths (performance?)
  • Composition patterns are better than inheritance. You can create your own crypto wrappers for serializing

marcus-pousette avatar Sep 21 '23 08:09 marcus-pousette