All repositories specified below contain smart contracts that implement confidentiality features using the COTI V2 protocol. The contracts provide examples for various use cases, such as Non-Fungible Tokens (NFTs), ERC20 tokens, Auction, and Identity management.
These contracts demonstrate how to leverage the confidentiality features of the COTI V2 protocol to enhance privacy and security in decentralized applications. The contracts are written in Solidity and can be compiled and deployed using popular development tools like Hardhat and Foundry.
Docs | Devnet Explorer | Discord | Faucet
Interact with the network using any of the following:
The following contracts are available in each of the packages:
Contract | python sdk | hardhat sdk | typescript sdk | Contract Description | |
---|---|---|---|---|---|
AccountOnboard |
deployment | ✅ * | ✅ | ❌ | Onboard a EOA account - During onboard network creates AES unique for that EOA which is used for decrypting values sent back from the network |
AccountOnboard |
execution | âś… | âś… | âś… | " |
ERC20Example |
deployment | ✅ | ✅ | ❌ | Confidential ERC20 - deploy and transfer encrypted amount of funds |
ERC20Example |
execution | âś… | âś… | âś… | " |
NFTExample |
deployment | ❌ | ✅ | ❌ | Confidential NFT example - saving encrypted data |
NFTExample |
execution | ❌ | ✅ | ❌ | " |
ConfidentialAuction |
deployment | ❌ | ✅ | ❌ | Confidential auction - encrypted bid amount |
ConfidentialAuction |
execution | ❌ | ✅ | ❌ | " |
ConfidentialIdentityRegistry |
deployment | ❌ | ✅ | ❌ | Confidential Identity Registry - Encrypted identity data |
ConfidentialIdentityRegistry |
execution | ❌ | ✅ | ❌ | " |
DataOnChain |
deployment | ✅ | ❌ | ❌ | Basic encryption and decryption - Good place to start explorining network capabilties |
DataOnChain |
execution | ✅ | ❌ | ✅ | " |
Precompile |
deployment | ✅ | ✅ | ❌ | Thorough examples of the precompile functionality |
Precompile |
execution | ✅ | ✅ | ❌ | " |
(*) no deployment needed (system contract)
Note
Due to the nature of ongoing development, future versions might break existing functionality
🤖 To request devnet/testnet funds use our faucet ([join discord] (https://discord.gg/cuCykh8P4m)))
Note
Please refer to the latest tags to find the most stable version to use. All tagged versions are available to install via pypi
The COTI Python SDK can be installed as pypi package named coti_sdk
, its modules are:
crypto_utils
: used for cryptographic operationsutils
: used for web3 related operations
The Python script examples project contain scripts covering various use cases, such as Non-Fungible Tokens (NFTs), ERC20 tokens, Auctions, and Identity management. It contains smart contracts that implement confidentiality features using the COTI V2 protocol. These contracts demonstrate how to leverage the confidentiality features of the COTI V2 protocol to implement privacy and enhance security in decentralized applications.
The COTI faucet provides devnet/testnet funds for developers. To request devnet/testnet tokens:
- Head to https://faucet.coti.io/
- Send a message to the bot in the following format:
devnet <your_eoa_address>
For Example:
devnet 0x71C7656EC7ab88b098defB751B7401B5f6d8976F
There are two libraries located in the coti folder that will allow you to interact with the COTI network.
Encrypts a 128-bit plaintext
using the provided 128-bit AES key
and ECB mode.
-
Parameters:
key (bytes)
: 128-bit AES key (16 bytes).plaintext (bytes)
: 128-bit or smaller plaintext to encrypt.
-
Returns:
ciphertext (bytes)
: The encrypted text.r (bytes)
: A random value used during encryption.
Decrypts the ciphertext
using the provided 128-bit AES key
and the random value r
.
-
Parameters:
key (bytes)
: 128-bit AES key.r (bytes)
: Random value used during encryption.ciphertext (bytes)
: Encrypted text to decrypt.
-
Returns:
plaintext (bytes)
: The decrypted original message.
Generates a random 128-bit AES key.
- Returns:
key (bytes)
: Randomly generated 128-bit key (16 bytes).
Signs an input message composed of multiple parts, including sender address, contract address, function selector, and ciphertext.
-
Parameters:
sender (bytes)
: Sender address.addr (bytes)
: Contract address.function_selector (str)
: Ethereum function selector (in hex).ct (bytes)
: Ciphertext (concatenated).key (bytes)
: Private key for signing.
-
Returns:
signature (bytes)
: Digital signature of the message.
Signs a message
using the provided key
(Ethereum-style private key).
-
Parameters:
message (bytes)
: Message to sign.key (bytes)
: Private key to use for signing.
-
Returns:
signature (bytes)
: The generated signature.
Encrypts a plaintext integer and signs the resulting ciphertext along with other parameters.
-
Parameters:
plaintext (int)
: Integer to encrypt.user_aes_key (bytes)
: AES key for encryption.sender (object)
: Ethereum-like sender object (withaddress
attribute).contract (object)
: Ethereum-like contract object (withaddress
attribute).function_selector (str)
: Function selector (in hex).signing_key (bytes)
: Signing key for signature.
-
Returns:
dict
: Contains theciphertext
andsignature
.
Encrypts and signs string-based input data, breaking it into 8-byte chunks.
-
Parameters:
plaintext (str)
: String to encrypt.user_aes_key (bytes)
: AES key for encryption.sender (object)
: Ethereum-like sender object.contract (object)
: Ethereum-like contract object.function_selector (str)
: Function selector (in hex).signing_key (bytes)
: Signing key for signature.
-
Returns:
dict
: Contains theciphertext
andsignature
.
Decrypts a ciphertext into an unsigned integer using AES.
-
Parameters:
ciphertext (int)
: Ciphertext to decrypt (in integer format).user_key (bytes)
: AES key to use for decryption.
-
Returns:
int
: The decrypted integer.
Decrypts a ciphertext back into a string, handling multiple formats of ciphertext.
-
Parameters:
ciphertext (dict/tuple)
: Ciphertext to decrypt, can be in event or state variable format.user_key (bytes)
: AES key to use for decryption.
-
Returns:
str
: The decrypted string.
Generates an RSA key pair for encryption and decryption.
- Returns:
private_key_bytes (bytes)
: Serialized private key.public_key_bytes (bytes)
: Serialized public key.
Decrypts a ciphertext using RSA and a provided private key.
-
Parameters:
private_key_bytes (bytes)
: Private key used for decryption.ciphertext (bytes)
: Ciphertext to decrypt.
-
Returns:
plaintext (bytes)
: Decrypted plaintext.
Checks if the Web3 instance is connected to the blockchain node.
-
Parameters:
web3 (Web3)
: Web3 instance.
-
Returns:
bool
:True
if connected, otherwiseFalse
.
Prints details about the connected network, such as the provider, chain ID, and the latest block hash.
- Parameters:
web3 (Web3)
: Web3 instance.
Prints details about the default account, including its address, balance in Wei and Ether, and the account nonce.
- Parameters:
web3 (Web3)
: Web3 instance.
Initializes the Web3 instance and sets up the default account. It also injects the Geth POA middleware for POA chains.
-
Parameters:
node_https_address (str)
: The Ethereum node's HTTPS address.eoa (eth_account.Account)
: The account to set as the default.error_not_connected (bool)
: IfTrue
, raises an error if the connection fails.
-
Returns:
web3 (Web3)
: Initialized Web3 instance.
Creates an externally owned account (EOA) from a private key.
-
Parameters:
account_private_key (str)
: The private key for the account.
-
Returns:
eoa (eth_account.Account)
: The Ethereum account object.
Validates if the given address is a valid Ethereum address and returns the checksum version of the address.
-
Parameters:
address (str)
: The Ethereum address.
-
Returns:
dict
: Containsvalid
(boolean) andsafe
(checksum address).
Retrieves the latest block on the blockchain.
-
Parameters:
web3 (Web3)
: Web3 instance.
-
Returns:
block (dict)
: The latest block.
Retrieves the nonce (transaction count) for the default account.
-
Parameters:
web3 (Web3)
: Web3 instance.
-
Returns:
int
: The transaction count (nonce).
Gets the native token balance (e.g., Ether) for a given address or the default account.
-
Parameters:
web3 (Web3)
: Web3 instance.address (str, optional)
: The Ethereum address. Defaults to the default account.
-
Returns:
int
: The balance in Wei.
Loads a Solidity contract source code from a file.
-
Parameters:
file_path (str)
: Path to the Solidity contract file.
-
Returns:
str
: The contract source code.
Transfers the native token (e.g., Ether) from the default account to a recipient address.
-
Parameters:
web3 (Web3)
: Web3 instance.recipient_address (str)
: Address to send the Ether.private_key (str)
: Private key of the sender.amount_to_transfer_ether (float)
: Amount of Ether to transfer.native_gas_units (int)
: Gas units to use for the transaction.
-
Returns:
dict
: Transaction receipt.
Deploys a smart contract with the given constructor arguments and transaction parameters.
-
Parameters:
contract (Contract)
: Web3 contract instance.kwargs (dict)
: Constructor arguments for the contract.tx_params (dict)
: Transaction parameters including gas limit, gas price, and private key.
-
Returns:
dict
: Transaction receipt.
Executes a contract function via a transaction.
-
Parameters:
func (ContractFunction)
: Contract function to execute.tx_params (dict)
: Transaction parameters including gas limit, gas price, and private key.
-
Returns:
dict
: Transaction receipt.
Signs a transaction with the provided private key and sends it to the blockchain.
-
Parameters:
web3 (Web3)
: Web3 instance.private_key (str)
: Private key to sign the transaction.transaction (dict)
: Transaction details.
-
Returns:
dict
: Transaction receipt.