Arcium Docs
arcium.com@ArciumHQ
  • Documentation
  • Developers
  • Intro to Arcium
  • Installation
    • Arcup Version Manager
  • Hello World with Arcium
  • Arcium Computation Lifecycle
  • Encryption
    • Sealing aka re-encryption
  • Arcis
    • Operations
    • Types
    • Input/Output
    • Best practices
  • Invoking a Computation from your Solana program
    • Computation Definition Accounts
    • Callback Accounts
  • JavaScript Client
    • Encrypting inputs
    • Tracking callbacks
  • Callback Server
  • Current Limitations
Powered by GitBook
On this page
  1. Encryption

Sealing aka re-encryption

Suppose you're Alice, and you have secret data onchain, and you want to share it with Bob. Or it could be that you want to compute a function on your sensitive data, and share the result with Bob without revealing the data, or the result to anyone else.

Arcium enables you to re-encrypt any data to a given public key. This is known as "sealing" in cryptography, effectively having the ability to restrict data access and information flow.

This is useful for a variety of reasons, such as compliance, end-to-end privacy, and more.

#[encrypted]
mod circuits {
    use arcis_imports::*;

    pub struct UserData {
        data: u128,
    }

    #[instruction]
    pub fn share_result(user_data_ctxt: Enc<Shared, UserData>, mxe_data_ctxt: Enc<Mxe, u128>, user: Shared) -> Enc<Shared, u128> {
        let user_data = user_data_ctxt.to_arcis();
        let mxe_data = mxe_data_ctxt.to_arcis();

        let result = /* compute some function on the data */;

        user.from_arcis(result)
    }
}

In this example, we have a confidential function share_result that takes in an encrypted UserData struct which is encrypted using a shared secret between the user Alice and the MXE, another encrypted u128 which is encrypted using the MXE's key, as well a Shared type parameter which defines the user Bob (it holds his public key and a nonce) to whom we want to encrypt the data to. It converts the data to secret shares for the nodes in the given cluster, computes some function on the secret shares, and then encrypts the result using the derived shared secret between the MXE and Bob (using the public key available within the Shared type parameter). The unencrypted data is never exposed to the nodes in the given cluster. Likewise, Bob can perform the key exchange on his side and decrypt the result.

PreviousEncryptionNextArcis

Last updated 22 days ago