In computer security, we often have to represent binary data, in single values or groups of characters, bytes, words, long words, signed integers, floating-point values, double-precision floating-point values, and so on. This might be in the form of a data object, a signature or even encrypted content. For this, the ANS.1 DER format is often used, such as presenting digital certificates and signatures. An improvement on this for small messages with security is Concise Binary Object Representation (CBOR) — and which is defined in RFC8949 [1]. While JSON represents text-based data objects CBOR focuses on binary objects. It has been designed to create a lightweight encoder and decoder. This supports the use of CBOR within an IoT infrastructure. The data, also, does not require a data schema to be able to decode it, along with being extensible. CBOR defines the format of binary data with data objects and messages. We can then integrate security with CBOR Object Signing and Encryption (COSE), and which is defined in RFC8152 [2]. This includes signatures, message authentication codes (MACs), encryption and creating serialised objects.
In this case we create a symmetric key from ECDH. For this we will derive a shared key from the public key of Alice and Bob, and then define a single recipient which can derive the CEK (Content Encryption Key) using their private key. We will use the curves of P-256 (secp256r1), P-384 (secp384r1), P-521 (secp521r1) or SECP256K1 (as used with Bitcoin).