Welcome to the USEncrypt® Library!

Reading this document will allow you to:

  • Understand the purpose of the USEncrypt® library.

  • Import the USEncrypt® library and use it to encrypt and decrypt a value.

  • Perform simple computations with encrypted objects.


Using the USEncrypt® library requires knowledge of the Python programming language. For an overview of Python, please refer to their documentation.

Getting Started#

USEncrypt® is a robust Python library for computation with encrypted data. Using USEncryption’s Encrypted Operator Computing (EOC) method, USEncrypt® allows users to:

  • Operate on encrypted data, combining encrypted and non-encrypted data in a secure way.

  • Serve as a building block to be used with other libraries.

Data Owners vs. Data Users#

At USEncryption, we make a clear distinction between two types of users:

  • Data Owners, who own confidential data that can be valuable to other internal or external users, and have access to the encryption and decryption functions. (See USEncrypt® for Data Owners.)

  • Data Users, who would like to use data owners’ data to gather insights and create models, but currently cannot have access to the raw data due to regulatory or commercial reasons. The solution is to provide Data Users with access to the encrypted confidential data and the USEncrypt® library which can be used to operate on the encrypted data. Data Users should not have access to the decrypt function but can request to the Data Owner to decrypt the result of their calculations. (See USEncrypt® for Data Users.)

For more information, see Encrypted Data as a Service (EDaaS) Model.

Importing USEncrypt®#

The contents of the USEncrypt® library are divided into files for organizational purposes, making it a namespace package. Once installed, all users can simply import the library to have access to all the most commonly needed elements by using the following import statement:

>>> import usencrypt

To simplify use of the library, one can also import the library with a common alias as follows:

>>> import usencrypt as ue

Encrypting and Decrypting a Value#

Data Owners have access to two key functions:

These two functions allow Data Owners to encrypt and decrypt values, represented as \(E(\cdot)\) for encryption and \(D(\cdot)\) for decryption, where \(D = E^{-1}\). This is done through USEncryption’s Encrypted Operator Computing (EOC) method, which allows us to encrypt and decrypt values and perform computations on them without losing any data, keeping it secure and confidential throughout the entire process.

For example, a simple value can be encrypted and decrypted as follows:

>>> import usencrypt as ue
>>> x = 2.5
>>> x
>>> ue_x = ue.encrypt(x)
>>> ue_x
(0x7f3989cd4310) Float: 0x0cd495927ccce5d47687add675f78439cd76198cc61d2b279df6880ee2d5381e
>>> ue.decrypt(ue_x)

When encrypting a value, a new encrypted object is created, which contains all the encrypted information. Decrypting an encrypted object then converts it back to the original data type. Here, we start with a float, encrypt it to a usencrypt.cipher.Float object, and decrypt it once again to a float. (See The Ciphertext Representation.)

Simple Computations with Encrypted Data#

Once values are encrypted with USEncrypt®, they can be used for a wide variety of computations. This includes everything from simple addition and multiplication, all the way to complex neural networks.

The following example shows how to multiply two encrypted values with USEncrypt®:

>>> x = 2.5
>>> y = 3.3
>>> result = x * y
>>> result
>>> ue_x = ue.encrypt(x)
>>> ue_x
(0x7f3989cd4f70) Float: 0x67fab9118da26b2e59712e50066e2325107bd81ba06f4bd7931093e908394fec
>>> ue_y = ue.encrypt(y)
>>> ue_y
(0x7f3989cd4310) Float: 0xaa7e3d028ddd2d1aafc8c2f768c8f3522f6691fd104b4afb350438eeadb5ba73
>>> ue_result = ue_x * ue_y
>>> ue_result
(0x7f3989c817c0) Float: 0xb4e09de2f6fa324676b902ff6ced51bf5676b548a2e97a25c2ae875cf7a6b09a
>>> ue.decrypt(ue_result)

Further Reading#