# Threshold Network - NuCypher と Keep が併合して出来た ## 特徴 - Decentralized Key Management System (KMS) - 暗号化とアクセスコントロール - Conditions-Based Decryption (CBD) - Proxy Re-Encryption (PRE) - tBTC v2 - Threshold Networkでランダムに選ばれたノードがBTCをDepositする(Decentralized な BTC Bridge)。 - Threshold USD - tBTC backed の USD stable coin ## Conditional-Based Decryption (CBD) - 閾値署名を使った技術で、**on-chain上の特定条件を満たした場合にデータを復号できる鍵を提供する技術**を、Threshold Network が CBD と呼んでいる。 - 条件の種類 - **EVM-based**: e.g. 特定のNFTを所有, ETH残高, Tx status, コントラクト呼び出し - **RPC-driven**: e.g. X token以上所有, EthereumRPC call - **Time-based**: e.g. 指定時間経過, block height - 2023/02 現在 PoC のネットワークのみ存在 ## CBD Mainnet - Trust Assumptions https://docs.threshold.network/app-development/threshold-access-control-tac/trust-assumptions/cbd-mainnet-version CBD を利用する際に、基盤となるトラストモデルを理解することが大事(難しく理解できていない) (DeepL訳) > CBDは、採用する開発者がエンドユーザーの信頼、リスク、コスト、冗長性、レイテンシーの好みを満たすために、さまざまな「信頼レバー」を引くことができるようにします。しかし、信頼とリスクの各次元にまたがる個々のパラメータを正しく選択するには、基盤となるメカニズムや暗号を深く理解する必要があります。さらに、これらのパラメータは、全体としてエンドユーザーのリスク回避と信頼最小化の要求に沿うように、首尾一貫したバンドルにまとめられなければならない。そこで、開発者に負担をかけないように、Thresholdチームは設定済みの「信頼パッケージ」セットを構築しました。 CBDを安全に分散に行うためには、様々なパラメータ設定が必要。 エンドユーザには難しすぎるので、Thresholdチームが **Trust Package** に整理している。 **Trust Package** には 4 つの観点がある。 * Cohort-based trust assumptions * Sampling-based trust assumptions * Population-based trust assumptions * Infrastructure-based trust assumptions **Cohort** * 暗号化・復号をする閾値ノードのグループ * m-of-n のノードが正直者で動く (n は Cohort 内のメンバー数) 例えば `Sampling-based trust assumptions` について 1. Cohort-refresh * Cohortのメンバーを定期的に再サンプリングし、攻撃者が費やせる時間を短縮する。 2. Cohort composition beyond m & n * Cohortの X % を、Stakingや可用性(tBTCv2のアクティビティから測定)等々を判断材料に埋める。 ### デモ [CBDので選択的開示が可能なSBTを実現するデモ](https://github.com/QuestryInc/selective-disclosure-sandbox/tree/main/tn-cbd) ### チュートリアル [Get Started (CBD PoC)](https://docs.threshold.network/app-development/threshold-access-control-tac/get-started-with-tac) - Javascript で、CBD の条件設定 → 暗号化 → 復号 が可能 #### Cohort の立ち上げ - Cohort: データを管理する *m-of-n* のノードのグループ - m: 3, n: 5 の例 ```jsx import { Cohort } from '@nucypher/nucypher-ts'; const config = { threshold: 3, shares: 5, porterUri: 'https://porter-tapir.nucypher.community', }; const newCohort = await Cohort.create(config); ``` #### c.f. Cohort.create() の内容 - Ursula ノードのアドレス (Cohortの中身) は `Cohort.create()` で Porter から降ってくる - Sampling avaliable Ursulas API `GET /get_ursulas` - [https://github.com/nucypher/nucypher/blob/main/docs/source/application_development/web_development.rst#get-get_ursulas](https://github.com/nucypher/nucypher/blob/main/docs/source/application_development/web_development.rst#get-get_ursulas) [nucypher-ts/cohort.ts at 3c4d2f6186bee3e036e9f8c4d6f713e0d94a9857 · nucypher/nucypher-ts](https://github.com/nucypher/nucypher-ts/blob/3c4d2f6186bee3e036e9f8c4d6f713e0d94a9857/src/sdk/cohort.ts#L20) ```tsx public static async create( configuration: CohortConfiguration, include: string[] = [], exclude: string[] = [] ) { const porter = new Porter(configuration.porterUri); const ursulas = await porter.getUrsulas( configuration.shares, exclude, include.splice(0, configuration.shares) ); const ursulaAddresses = ursulas.map((ursula) => ursula.checksumAddress); return new Cohort(ursulaAddresses, configuration); } ``` #### CBD の条件設定 → 暗号化 ```jsx const NFTBalanceConfig = { contractAddress: '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D', standardContractType: 'ERC721', chain: 5, method: 'balanceOf', parameters: [':userAddress'], returnValueTest: { comparator: '>=', value: 3, }, }; const NFTBalance = new Conditions.Condition(NFTBalanceConfig); const encrypter = newDeployed.encrypter; const plaintext = 'this is a secret'; const encryptedMessageKit = encrypter.encryptMessage( plaintext, new ConditionSet([NFTBalance]) ); ``` #### 復号 ```jsx const decrypter = newDeployed.decrypter; const conditionContext = conditions.buildContext(web3Provider); const decryptedMessage = await decrypter.retrieveAndDecrypt( [encryptedMessageKit], conditionContext ); ``` ## Proxy Re-Encryption (PRE) [whitepaper/whitepaper.pdf at master · nucypher/whitepaper · GitHub](https://github.com/nucypher/whitepaper/blob/master/whitepaper.pdf) - 公開鍵暗号では秘密鍵の保持者しか復号できないが、*PRE* で復号の delegate ができる(Alice が暗号化し Bob が復号できる)。 - Alice が自分の鍵を Bob の公開鍵で暗号化した $rK$ を Proxy に渡す。Proxy には内容が見えず、Bob だけが復号できる。 ![](https://i.imgur.com/KEhvdL6.png) ## ネットワーク - CBD Proof-of-Concept - CBD Mainnet, PRE Mainnet (Roadmap: 2023 Q2) ## ノードの運用 ### PRE Node - 分かっていない ### tBTC v2 Node - 分かっていない ### Porter [https://github.com/nucypher/nucypher-porter](https://github.com/nucypher/nucypher-porter) - Porter: Threshold Network の Infura 的なもの(ある種のtrust point) - public endpoint もあるが、自分でも Docker で立ち上げが可能 ![](https://i.imgur.com/v7qUhqj.png) #### Docker起動 - 起動失敗? 要調査 (2023/02/12) ```jsx docker run -d --rm \ --name porter-http \ -v ~/.local/share/nucypher/:/root/.local/share/nucypher \ -p 80:9155 \ nucypher/porter:latest \ nucypher porter run \ --eth-provider https://polygon-rpc.com \ --network nucypher-porter WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested Usage: nucypher [OPTIONS] COMMAND [ARGS]... Try 'nucypher --help' for help. Error: No such command 'porter'. ``` #### Docker Compose - TODO [Web Development - NuCypher 6.2.0 documentation](https://docs.nucypher.com/en/latest/application_development/web_development.html#via-docker-compose) ## 秘匿化技術にまつわるポイント整理 * NFTの持ち主は任意の第三者にデータを開示できるか? * CBD, PREで可能 * ユーザーのsecrets(鍵とかシードとかパスワードとかの機密化のキー)は差し替えできるか? * Trust Package で頑張っている * 運営/サーバ管理者は盗める/見れるか? * Trust Package で頑張っている * オンチェーン(L1)はどう使っているか? * CBD の復号条件を on-chain 情報にできる ## 関連サービス ### NuLink [Privacy-preserving technology for decentralized applications](https://www.nulink.org/) - Nulink API を通じて、Threshold Network (NuCypher) と App, Blockchain, 分散ストレージ など諸々繋ぎこむ #### Whitepaper [Whitepaper | NuLink](https://www.nulink.org/whitepaper) ![https://i.imgur.com/qFwrdyd.png](https://i.imgur.com/qFwrdyd.png) **NuLink 内の秘匿化技術** * Roadmap: 2024 Q2 * IBE, ABEのサポート * IBE (Identity-based encryption) * 受信者のIDを指定できる * public key でなく identity で暗号化出来る * 暗号化・署名したメールのイメージ * ABE (Attribute-based encryption) * 受信者の属性を指定できる * Roadmap: 2024 Q4 * FHEによるPrivacy Data Computing * ZKPによる (off-chain の?) Data Availability の保証 ### Data computing の workflow 例 - A が Database D を持つ - B は D の機械学習した結果が欲しい - B は D の内容を知ることなく結果を得る(計算を FHE で行う) ![https://i.imgur.com/cWkmKE4.png](https://i.imgur.com/cWkmKE4.png) ### ユースケース - 電子カルテ共有 - Privacy-Preserving SNS - Decentralized DRM - Encrypted NFT Encrypted NFT - YouTube: [https://www.nulink.org/encrypted-nft-market](https://www.nulink.org/encrypted-nft-market) - NuLink APIで暗号化したデータをMetadataに置いて、復号もAPIでやる ![https://i.imgur.com/HhCyBFB.png](https://i.imgur.com/HhCyBFB.png)