Efficiently encrypt data off-chain and store securely on the blockchain
Project description
Crypto Vault (off-chain)
Version 0.1.0
About
Crypto Vault is a Python library designed to securely encrypt and store secrets on-chain. It facilitates off-chain encryption followed by on-chain storage through smart contracts, offering a robust solution for managing sensitive data in blockchain applications.
Requirements
- Python 3.9^
- Polygon wallet with enough MATIC to pay gas
- HTTP provider URL (Polygon-mumbai RPC)
Installation
pip install crypto-vault
Usage
Basic Workflow:
- Initialize Crypto Vault with a private key and HTTP provider.
- Store, retrieve, and update secrets on-chain.
- Encrypt and decrypt data off-chain.
Code Examples
Generate secure encryption key with Encryption
from crypto_vault import Encryption
# Generate encryption key
encryption_key = Encryption.generate_key()
Initialize Crypto Vault:
from crypto_vault.crypto_vault import CryptoVault
crypto_vault = CryptoVault(
app="myApp",
env="prod",
private_key="private_key",
encryption_key=encryption_key,
http_provider="http-provider-url-with-api-key",
)
Store, retrieve, and update secrets
# Store
crypto_vault.store(data={"password": "secret", "foo": "bar"})
# Retrieve secrets
secrets = crypto_vault.retrieve()
# Retrieve single secret
password = crypto_vault.retrieve(value_name="password")
# Update single secret
crypto_vault.update(data={"foo": "Hello world!"})
# Update secrets -> To update all secrets use crypto_vault.store()
Encrypt and decrypt data
# Encrypt
encrypted_data = crypto_vault.encrypt(data="secret")
# Decrypt
decrypted_data = crypto_vault.decrypt(data=encrypted_data)
Crypto Vault API
- Storage
- Store data. Input parameters: data(k: v)
- Retrieve data. Params: value_name(optional)
- Update parameter. Params: data
- Encryption
- Generate encryption key
- Encrypt data(str, int, list, dict). Params: value, key
- Decrypt data(bytes32). Params: value, key
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
crypto-vault-0.1.0.tar.gz
(10.7 kB
view hashes)
Built Distribution
Close
Hashes for crypto_vault-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 730e2aef796a0dfc51038ccbab09c9c7ac8b43f285d9bc7cc227f6662e211bd4 |
|
MD5 | 954eec89bacbc928ea5275a4b04c78ad |
|
BLAKE2b-256 | a27d5598149ff1783a6b8df57a2152d798a9792f4830a5f7fcec1b862f3ff7be |