Encryption/Decryption

This guide will cover the overview of encryption and decryption in the Integra ecosystem. It will also go over how examples of encryption/decryption are used in specific instances and also the ability to expand these usages into the blockchain authentication layer added on to existing applications.

Overview

There are two main types of encryption (also known as cryptography) symmetric (ok symmetric-key encryption) and public/private key encryption. The third topic this guide will cover is how both of these encryption methodologies are used in parallel to do large document and data encryption securely in the Integra ecosystem. The guide will dive deeper into both types of cryptography and how they are used in the Integra Ecosystem. They both have unique uses and are both important to understand the concepts before developing a blockchain authentication layer on top of an existing application.

In the decentralized world of blockchain and in the case of data transfer, data flowing between applications in a public network environment can flow across any number of nodes or networks and is viewable to anyone on the network. Cryptography ensures that even though these nodes can see the data, they cannot understand the data. This is where encryption becomes critical in data transfer and storing secure data, like the private key or other sensitive data.

Symmetric Encryption

Symmetric encryption is highly effective for large amounts of data, requires less processing power to produce the cipher and the overall algorithm is inexpensive in regards to cycles consumed. The preferred algorithm that is used in the Integra ecosystem for symmetric encryption is AES. AES works really well for large amounts of data in terms of processing power and speed. AES encryption uses the same secret key (passphrase) to both encrypt and decrypt the data. There are two values that can be used for AES encryption/cryptography, they are the key and IV. The key is always the passphrase that the user generates and can be used alone to encrypt and decrypt the information. The IV, also known as the initialization vector, provides randomization for the key along with the AES algorithm to produce more secure encryption. The IV is typically required to be random or pseudorandom, but sometimes an IV only needs to be unpredictable or unique. Below is the flow of symmetric encryption.

18961896

Figure 1: Symmetric-Key Encryption flow. The same key is used to encrypt and decrypt the document.

For encryption of the Integra Smart Identity Document private key, for any user on the Integra blockchain, AES with only a key-value (which is referred to as the passphrase) is used for the encryption of the private key. Other types of Integra documents are also encrypted in this manner and the AES key is auto-generated and sent to the user's phone while the document is sent to the email, this way the only way to decrypt the document is to have access to both the email and phone. When looking at the private key in an Integra Smart Identity Document, it looks like the following data in Figure 1, versus a typical RSA private key shown in Figure 2.

"private_key": "U2FsdGVkX1+vdHazY17UdN8L7Otk4wAs5+xhfgZT4qT4VR47adgeM1XsLgf/rinGfOV6ojhWdb1B2zvw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key in Integra Smart Identity Document

"private_key": "-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp
wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5
1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh
3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2
pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX
GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il
AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF
L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k
X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl
U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=
-----END RSA PRIVATE KEY-----"

Figure 2: RSA private key example. Note this RSA private key does not match the example from Figure 1

Later in this guide AES encryption with both Key and IV will be discussed in the section Encrypting Data below.

Public/Private Key Encryption

The recommended public key pair encryption algorithm for the Integra ecosystem, for small amounts of data, is RSA (Rivest-Shamir-Adelman). The important distinction between RSA and Symmetric encryption is that in public key pair encryption there is a public encryption key that is distinct from the decryption key. The downside of public key pair encryption is that it requires more calculations (using two large prime numbers and an auxiliary value) and is therefore a relatively slow algorithm. Due to the slowness of the algorithm, it is not appropriate to encrypt large amounts of data with this type of encryption. Below in figure 2 is how public key pair encryption works.

31843184

Figure 2: Public/Private Key Encryption and how it works for encrypting data between parties. The data is encrypted by the user's IntegraId/public key. The only way to decrypt the ciphertext is by having the private key that was created with the public key.

Public key pair encryption is very useful for encrypting data like messaging or codes that are used for Symmetric encryption. When it comes to encrypting an entire PDF file, this method carries too much overhead, and speed, to make it an acceptable solution. When encrypting messages or data, the first step is looking up the recipient's public key by using their IntegraId in order to look up their public key by using the KeyForOwner API call. The call takes in an IntegraId and returns an RSA public key. The format for the public key is shown below.

-----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEA+xGZ/wcz9ugFpP07Nspo6U17l0YhFiFpxxU4pTk3Lifz9R3zsIsu
ERwta7+fWIfxOo208ett/jhskiVodSEt3QBGh4XBipyWopKwZ93HHaDVZAALi/2A
+xTBtWdEo7XGUujKDvC2/aZKukfjpOiUI8AhLAfjmlcD/UZ1QPh0mHsglRNCmpCw
mwSXA9VNmhz+PiB+Dml4WWnKW/VHo2ujTXxq7+efMU4H2fny3Se3KYOsFPFGZ1TN
QSYlFuShWrHPtiLmUdPoP6CV2mML1tk+l7DIIqXrQhLUKDACeM5roMx0kLhUWB8P
+0uj1CNlNN4JRZlC7xFfqiMbFRU9Z4N6YwIDAQAB
-----END RSA PUBLIC KEY-----

The ciphertext that is created from RSA encryption can only be decrypted by the corresponding private key that was associated with the public key that encrypted the data. The communications using this type of encryption are suited for the public domain such as the Internet. This type of encryption only works if the private key remains in possession of the owner of the key. The possession of the private key is essential for the Integra ecosystem, this includes tokens, digital signatures, encrypted files, and other items, without the private key none of these others are valid. This works very much in the same way as the private key in every cryptocurrency.

Encrypting Data and Documents

The Integra ecosystem deals with large amounts of data in the form of documents so neither of these forms of encryption, on their own, work perfectly and or securely for the distributed network. Using the strengths of both encryption methodologies, Integra encrypts documents using both forms of encryption. Dealing with the large documents that are hashed on the network, AES encryption is used to encrypt the document itself, with a generated IV and key for the encryption of the document. The key and IV are then encrypted using the RSA encryption with the public key of the recipient. The public key encrypts this key and IV so only the holder of the corresponding private key will be able to decrypt the key and IV which will then allow the decryption of the original document using AES encryption. The speed and security of this method is ideal for the Integra ecosystem. Figure 3 below shows the metadata contained within an Integra Smart Encryption Document.

12341234

Figure 3: The image shows how the actual document's contents are encrypted using AES and the key/IV combo to generate the AES is encrypted with RSA encryption with the public key of the intended recipient.


Did this page help you?