Threshold Access Control (TACo)
  • Getting Started
    • Introduction to TACo
    • How TACo Works
    • Quickstart (Testnet)
  • For Developers
    • Integrate TACo Into Apps
      • Testnets
      • Mainnet Access
      • Mainnet Deployment
    • Ecosystem Integrations
      • OrbisDB
      • Waku
      • Irys
      • ComposeDB
      • Turbo
    • API
      • Encryptor Allowlist
      • Encrypt & Decrypt
      • Authentication
        • Condition Context
      • Access Control
        • TimeCondition
        • RpcCondition
        • ContractCondition
          • Use custom contract calls
          • Implement access revocation via smart contract
        • JSON Endpoint Conditions
          • JsonApiCondition
          • JsonRpcCondition
        • JWT Conditions
        • Logical Conditions
          • CompoundCondition
          • IfThenElseCondition
          • SequentialCondition
        • WIP / Feature Requests
          • Any (Major) EVM Chain Condition Support
    • Blueprints & Inspiration
      • Seed phrase recovery & transfer
      • Digital Rights Management for on-chain assets
      • Trustless channels for journalists, archivists & whistleblowers
      • Crowdsourcing real-world data with trustless contribution
  • For Product Leads
    • Value Propositions
    • Capabilities & Extensions
    • Use cases
      • Seed phrase recovery & transfer
      • Digital Rights Management for on-chain assets
      • Trustless channels for journalists, archivists & whistleblowers
      • Crowdsourcing real-world data with trustless contribution
    • Mainnet Fees
    • Trust Assumptions
      • Mainnet Trust Disclosure (Provider Answers)
      • Mainnet Trust Model Foundation
      • Trust levers & parameter packages
  • Reference
    • Contract Addresses
    • Architecture
      • Porter
    • Github
    • TACo Playground
    • TACo Scan
  • For Node Operators
    • Getting Set Up
      • Minimum System Requirements
      • Run a TACo Node with Docker
    • Operations
      • TACo Node Management
      • TACo Node Recovery
      • Stake Authorization
    • Duties, Compensation & Penalties
    • Run a Porter Instance
Powered by GitBook
On this page
  • 1. Installation
  • 2. Configuration
  • 3. Define decryption condition and encrypt data
  • 4. Decrypt the data
  • Next steps
  • Example applications
  1. Getting Started

Quickstart (Testnet)

The TACo SDK allows you to use threshold encryption & decryption in your application.

PreviousHow TACo WorksNextIntegrate TACo Into Apps

Last updated 17 days ago

In just a few minutes you will able to:

  • Define decryption conditions – these are predefined rules or criteria that must be fulfilled before the encrypted data can be decrypted.

  • Encrypt data & assign decryption conditions – when you encrypt data, you not only secure it but also tie the decryption process to the conditions you defined.

  • Threshold-decrypt data – once the decryption conditions are met and validated by a threshold of TACo nodes, decryption can occur.

1. Installation

Install taco , taco-auth, and ethers with your favorite package manager:

$ npm install @nucypher/taco @nucypher/taco-auth ethers@5.7.2

2. Configuration

To run the code examples below, you will need the ritualId encryption parameter. In production, your wallet address (encryptor) will also have to be allow-listed for this specific ritual. Please reach out to us to receive a ritualId and allow-list access. Additionally, we have for use when developing your apps.

3. Define decryption condition and encrypt data

With ritualId and , we can taco.encrypt our data.

In this example, we will use our , where you can freely use ritualId = 6; A read-only connection to Polygon Amoy is required due to DKG Coordination contracts being stored there. The signerProvider is required to the Encryptor.

import { initialize, encrypt, conditions, domains } from '@nucypher/taco';
import { ethers } from "ethers";

// We have to initialize the TACo library first
await initialize();

// Define decryption condition
const ownsNFT = new conditions.predefined.erc721.ERC721Ownership({
  contractAddress: '0x1e988ba4692e52Bc50b375bcC8585b95c48AaD77',
  parameters: [3591],
  chain: 11155111,  // sepolia
});

const signerProvider = new ethers.providers.Web3Provider(window.ethereum);
const polygonProvider = new ethers.providers.JsonRpcProvider("https://polygon-amoy.drpc.org");

const message = "my secret message";
const ritualId = 6

// encrypt data
const messageKit = await encrypt(
  polygonProvider,
  domains.TESTNET,
  message,
  ownsNFT,
  ritualId,
  signerProvider.getSigner() 
);

4. Decrypt the data

Now we just have to pass the messageKit to the intended data consumer:

import { conditions, decrypt, domains, initialize,  } from '@nucypher/taco';
import { EIP4361AuthProvider, USER_ADDRESS_PARAM_DEFAULT } from '@nucypher/taco-auth';
import { ethers } from "ethers";

// We have to initialize the TACo library first
await initialize();

const web3Provider = new ethers.providers.Web3Provider(window.ethereum); 

const conditionContext =
  conditions.context.ConditionContext.fromMessageKit(messageKit);
  
// auth provider when condition contains ":userAddress" context variable
// the decryptor user must provide a signature to prove ownership of their wallet address
const authProvider = new EIP4361AuthProvider(
  web3Provider,
  web3Provider.getSigner(),
);
conditionContext.addAuthProvider(USER_ADDRESS_PARAM_DEFAULT, authProvider);

const decryptedMessage = await decrypt(
  web3Provider,
  domains.TESTNET,
  messageKit,
  conditionContext,
);

Since ownsNFT condition refers to an NFT owned by the data consumer, decrypt call will prompt the recipient to sign a message and prove the ownership of the caller's wallet.

Next steps

Example applications

The following samples showcase integrations with React-based web apps, and serve as an 'end-to-end' reference for creating conditions-based encryption & decryption:

Learn more about using TACo in a sandboxed environment in the section.

Testnets
taco-web/demos
taco-web/examples/taco
here
a web3 provider from ethers
tapir testnet
authenticate
publicly available testnet rituals