Encrypting On-Chain Data with Irys and Lit
Learn how you can use Lit and Irys to build powerful privacy-preserving applications.
In today's digitally-mediated world, data integrity and security are of critical importance. The use of distributed ledgers and blockchains for data storage has helped introduce greater integrity guarantees, but these systems still suffer from an inherent lack of privacy.
That's where Irys, a provenance layer that stores data permanently on Arweave, and Lit, a decentralized key management network, come into play. With Lit, you can encrypt your data behind specific access control conditions before using Irys to store it permanently on the open web. The following post explores specific applications at the intersection of Irys and Lit and provides tools you can use as a developer to start building today.
What is Irys?
Irys is a provenance layer that empowers users to achieve permanent data storage while maintaining precise attribution of data origins. By tracing and verifying the source of data, Irys introduces accountability into the world of information. Data uploaded to Irys is stored permanently on Arweave, making it publicly accessible. However, for projects prioritizing privacy, encrypting data with Lit Protocol offers a viable solution.
What’s Possible with Irys x Lit Protocol
Using Lit Protocol with Irys opens up new opportunities for builders, including:
- Gating access to content (videos, images, etc)
- Encrypting posts for Lens protocol
- Decentralized identity verification
- Creating private data marketplaces
- Creating NFTs only viewable by their owner
- Storing private personal data on-chain
How to work with Irys and Lit Protocol
Using the Irys SDK you can permanently upload any data to Arweave using only a few lines of code. Check out the following guides and resources to learn how you can build with Irys and Lit:
- How to use Irys and Lit Together
- Guide: using Irys and Lit for server-side encryption
- Guide: using Irys and Lit for browser-side encryption
- A UI component that handles encryption, uploading, and decryption for image uploads
Encrypting with Lit and Irys
There are three steps to encrypting data:
- Obtain a wallet signature (AuthSig), which proves you own a wallet.
- Define access control conditions for who can decrypt your data.
- Connect to a Lit node and request that it encrypt your data.
Once data has been encrypted, you:
- Connect to an Irys node.
- Create a JSON object containing your encrypted data, hash of the original data and access control conditions.
- Upload the JSON object to Irys where it is stamped with strong provenance before being stored permanently on Arweave. You will receive back a transaction ID that will be used to download the data.
Decrypting with Lit and Irys
There are three steps to decrypting data:
- Obtain a wallet signature (AuthSig), which proves you own a wallet.
- Connect to the Irys gateway and download the data using the transaction ID obtained at upload.
- Connect to a Lit node and request that it decrypt your data.
The Irys Provenance Toolkit
The open-source Irys Provenance Toolkit, which includes components for file uploads, transaction searches, and other operations within the Irys ecosystem, now includes the Encrypted Uploader. This new component is a complete solution for file encryption, storage on Arweave via Irys, and subsequent decryption. It can be added to any React-based project with a single line of code, or modified to fit a user’s unique use-case.
For users new to Lit and Irys, it’s a great entry point to the ecosystem as it enables builders to get up and running in just a few minutes.
Getting Support
If you encounter any questions or issues while building, you can reach out to the Lit development team on Discord. For Irys-related questions, visit the Irys Discord to get in touch.