Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Web5の全体像

Takahiro Kanuma
December 21, 2023
330

 Web5の全体像

## Description
DIF Japan Monthly Sync(2023/12)の登壇資料です。

## 関連リソースリンク
- DIF Japan: https://collabogate.notion.site/DIF-Japan-75b404b8f3ca4d619c907a84999e7684
- アーカイブ動画: https://us02web.zoom.us/rec/share/yXOMqAvlcFm2yqpYBdb6Uws73nDpeYCf3rIq-ovz9ftpGTASQ-I8wpApdlNrbdaq.DvY45juRsAnGZMnf

## メモ
- P21のNo.3"自DIDで対称鍵を暗号化"の部分において、自DIDではなく、自DIDと他DIDの鍵交換でKEKを生成し、それで(使い捨ての)CEKを暗号化してメッセージに入れて送れば、Remote Nodeを運用するプラットフォーマーからもデータを保護できると考える。(DIDCommのように)

Takahiro Kanuma

December 21, 2023
Tweet

Transcript

  1. Web5のコンセプト (IMHO) • SSIコンセプト = デジタル空間をフィジカル空間の紙モデルと同等に • いつどこで誰にどんな⽬的でCredentialを提⽰するかをHolder次第に • OpenID4VC,

    Hyperledger Aries • Identityを事業者から本⼈に集約する(個⼈に分散する) • Web5 • Identity + App Dataを事業者から本⼈に集約する(個⼈に分散する) • DIF DWN仕様を実装 ⇨ Personal Data Store(PDS) • Decentralized Web App(DWA) の実現 ⇨ Webをよりパーソナルに、パワフルに 3
  2. ⼤まかな全体像 5 Remote Node (マルチテナント) Local Node Local Node ION

    Remote Node did:ion:yyy did:ion:xxx 3.Sync 2-(a). Send Messages(signed by DID, HTTPS POST) 1. DID Resolution Service Endpoint: Remote Node URL Protocol (Data Schema & Access Control) DWA FE/Mobile App 2-b. Write data to my own node. did:ion:yyy?service=DecentralizedWebNode&message=W3sgT...
  3. ⼤まかな全体像 6 Remote Node (on AWS) Remote Node (on GCP)

    多 対 多の分散環境 Frontend, Mobile, Desktop App
  4. 現在の状況 • Tech Preview状態 • Are We Web5 yet? :

    85% done • 来年Identity Walletがリリースされる • DIFでDWAのハッカソンを開くなど、啓蒙中の模様 • did:ionはまだLong-Formのみ(簡単に動かして確認済み) 7
  5. TBD54566975内のWeb5関連リポジトリ群 11 リポジトリ 概要 web5-js アプリに対しAPIを提供するSDK (= Local Node) TypeScript、⼀番成熟

    web5-kt 同上 Kotlin、2023/8から開発 web5-rs 同上? Rust、2023/11から開発 dwn-server Remote Nodeの実装 dwn-sdk-js web5-js / dwn-serverが依存するDIF DWN仕様の実装 sdk-developement 上記web5-{lang} SDKの実装状況を記す管理ドキュメント web5-wallet Identity Wallet?(後述)
  6. TBD54566975内のWeb5関連リポジトリ群 12 リポジトリ 概要 ssi-service SSIに関する機能を提供するREST API Endpoints仕様 / KMSなどのConfig

    ssi-sdk 上記ssi-serviceが依存するSDK Goで実装 / 豊富な機能 ssi-sdk-wasm 上記ssi-sdkをWASM化する実装 Deprecated 独⽴ 前ページの表
  7. web5-js(SDK)内の各種npm package web5-js(SDK)内の依存関係の概略 14 agent api common cryto dids user-agent

    @decentralized-identity/ion-sdk @decentralized-identity/ion-pow-sdk credential dwn-sdk-js App いずれapiパッケージから参照される模様/ 機能的に発展途上 @sphereon/pex
  8. ⼤まかな全体像 16 Remote Node (マルチテナント) Local Node Local Node ION

    Remote Node did:ion:yyy did:ion:xxx 3.Sync 2. Send Messages(HTTPS POST) 1. DID Resolution Service Endpoint: Remote Node URL Protocol (Data Schema & Access Control) DWA FE/Mobile App 2-b. Write data to my own node. did:ion:yyy?service=DecentralizedWebNode&message=W3sgT...
  9. API提供機能: 基本的な使い⽅ 1. Static MethodであるWeb5.connection(option)でweb5インスタンス⽣成 • 内部でdid:ion作って、DWNを紐づける。 • option •

    Remote NodeのEndpoint情報 • 後述するSyncの設定 • Local Nodeのストレージ暗号化⽅式 2. web5インスタンスを操る。 • web5.dwn.* • Records(Messages): DIF DWN Spec 10.2 Interface - Records • Protocols: DIF DWN Spec 10.3 Interface - Protocols • web5.did.* • did:ion, did:keyの⽣成 • ↑でDWNコントール⽤did:ionは作るので、今のところVC、VP署名⽤のみ︖ • web5.vc.* : VC、VP周り 17
  10. API提供機能: web5.dwn.* 18 メソッド 概要 records.query(request) ⾃Node or 他Node(許可される場合)のRecord[]の取得 records.read(request)

    ⾃Node or 他Node(許可される場合)のRecordの取得 records.create(request) ⾃Node or 他Node(許可済みの場合)上にRecord作成 records.write(request) createのalias records.delete(request) ⾃Node or 他Node(許可される場合)上のRecord削除 protocols.query(request) ⾃Node or 他Nodeの特定のprotocolの設定内容を取得 procols.configure(request) ⾃Node or 他Node(許可される場合)の特定のprotocolの内容を設定 各メソッドのRequestの必須/オプションプロパティ及びResponseの内容は、GitHub開発ドキュメント参照
  11. Recordの暗号化(こんな形︖) 21 Remote Node Local Node App プライベートなデータの暗号化 1. 対称鍵⽣成

    2. 対称鍵でRecordを暗号化 3. ⾃DIDで対称鍵を暗号化 4. Recordと暗号化済み対称鍵をLocal/Remote Nodeに書き込み 書き込み 同期
  12. (現時点での)API提供機能: いずれweb5.vc.* 22 分類 機能 誰⽤ JWT-VC データ⽣成(未署名) Issuer 署名(ES256K

    or Ed25519) Issuer 検証(完全性、真正性) Verifier Presentation Exchange V2 Definitionを満たすVC抽出 Holder VCがDefinitionを満たすか検証 Holder VP⽣成 Holder Submissionの妥当性検証 Verifier VPの検証(Definitionに沿うか) Verifier GitHub: 開発ドキュメント
  13. ポイントと疑問 • ION DID • DID作成に関して、ユーザ/App開発者は詳細に全く関わらなくて良い。 • 疑問: SidetreeのUpdate, Recovery,

    Deactivate操作は︖ -> Identity Walletを使う? • e.g. Remote NodeをAWSからGCPに引っ越ししたい場合は︖ • Local Node • デフォルトでは、Level DBに暗号化せずにデータ/鍵ペアを保管する。 • In-browser NodeではIndexed DBにLocal Nodeが作られる。(FrontendのOriginで区分け) • 疑問: 複数デバイスで同じApp/Data使いたい場合は︖どう複製︖ -> Identity Walletを使う? • 疑問: Local Nodeのストレージ暗号化の実装は︖ • 疑問: 企業はどうWeb5を使えばいい︖ • Verifiable Credential周り • SSI SDKに⽐べると機能不⾜に⾒える。(後述) • 今のところHolderとしての役回り︖(後述) 23
  14. • Web5.connect(option) • option.appDataStore: AppDataStore(インターフェース) • デフォルト実装: agent/app-data-store.ts内のAppDataVault Class Local

    Nodeのストレージ暗号化⽅式 24 App パスフレーズ 設定 AppDataVault#initialize 鍵ペア⽣成 鍵ペア パスフレーズ HKDF(公開鍵,..)⇨salt PBKDF2(salt, パスフレーズ)⇨KEK JWE protectedの⼀部: salt cipher text: 暗号化されたCEK 初期起動 CEK = 秘密鍵 XChaCha20Poly1305(KEK, CEK) JWEをLocal Nodeに保管 処理概略
  15. 業務システム 企業はどう使えばいい︖ (こんなイメージ︖) 25 Node.js App Remote Node Local Node

    (web5-js) 社員 / エンドユーザー 業務システム内の バックエンドアプリの1つ
  16. ⼤まかな全体像 27 Remote Node (マルチテナント) Local Node Local Node ION

    Remote Node did:ion:yyy did:ion:xxx 3.Sync 2-a. Send messages(HTTPS POST) 1. DID Resolution Service Endpoint: Remote Node URL Protocol (Data Schema & Access Control) DWA FE/Mobile App did:ion:yyy?service=DecentralizedWebNode&message=W3sgT... 2-b. Write data to my own node.
  17. Remote Node概要 28 dwn-sdk-js Node.js (on container) dwn-server Level DB

    or SQLite MySQL or Postgres JSON-RPC API または ⾃Local Node 他Local Node 同期 メッセージ送信 (HTTPS) DID秘密鍵 秘密鍵はRemoteに同期しない (YouTube) SSI Meetup - Web5: Open to Build - Block/TBD
  18. その他 • Tech Previewでは、TBD社のRemote Nodeを使える。 • ⾃分でも建てられる。 • “どのDIDに対し⾃ノードとしての利⽤を許可するのか“ •

    基本オープン︖ • ⾃分で対応しないといけない︖ • 実際、誰がRemote Nodeを運⽤するの問題 • ⾊々考えられる︓⾃分、友達、Remote Nodeサービス提供者、財団が建てた公共財 • (YouTube) Web5: An open source decentralized web platform • Remote Nodeを提供するサービサーは登場すると想定できる。 • それによりDecentralizationの度合いは低下する。 • そういったサービスはPublicなデータを集めて検索機能を作ったりするだろう。 29
  19. ⼤まかな全体像 31 Remote Node (マルチテナント) Local Node Local Node ION

    Remote Node did:ion:yyy did:ion:xxx 3.Sync 2-a. Send messages(HTTPS POST) 1. DID Resolution Service Endpoint: Remote Node URL Protocol (Data Schema & Access Control) DWA FE/Mobile App did:ion:yyy?service=DecentralizedWebNode&message=W3sgT... 2-b. Write data to my own node.
  20. メッセージのフォーマット 32 target: アクセスするDWNのDID(必須) encodedData: Writeの場合のみ messageの中がDIF DWN 9.Messagesに則る dataCid:

    encodedDataのCID messageの外がJSON-RPCに則る recordID: (平たくいうと)descriptor -> DAG CBOR -> CID payload: descriptor -> DAG CBOR -> CID all Messages MUST be committed to an IPLD DAG in a tree allocated to the DID of the owner [出展] DIF DWN 9.Messages protected: alg, kid=DID
  21. Web5のSync 34 Remote Node (マルチテナント) Local Node Local Node ION

    Remote Node did:ion:yyy did:ion:xxx 3.Sync 2-a. Send messages(HTTPS POST) 1. DID Resolution Service Endpoint: Remote Node URL Protocol (Data Schema & Access Control) DWA FE/Mobile App did:ion:yyy?service=DecentralizedWebNode&message=W3sgT... 2-b. Write data to my own node.
  22. Hyperledger AriesのMessage Forwarding 35 Mediator (on cloud) App FW DIDComm(Mediation依頼)

    Holder Mobile App DIDComm(Forwarding) 初期起動でMediation依頼 (⽅式: Push) callback WebsocketでPush DIDComm受信 Mediator (on cloud) App FW DIDComm(Mediation依頼) Holder Mobile App DIDComm(HTTP Req) DIDComm受信 初期起動でMediation依頼 (⽅式: Pull) 滞留メッセージの取得 HTTP Resp Queue callback Polling App側で制御する DIDCommとしては例外的にHTTP Response でJWEデータを返却
  23. Web5のSync(2つの⽅向) 36 Local Node Remote Node 同期 Web5側で執り⾏う(App/開発者側が深く関与しない) Local Node

    App データ書き込み Remote Node Local Node 1.メッセージ送信 2. 同期 Remote Node 2. 同期
  24. Web5のSync • Local -> Remote • デフォルトでは2分に⼀度、HTTPS POSTで同期する(簡単に動かして確認済み) • 調整可能

    • ConfigでLocal Node単位で同期間隔の調整 • アプリ側から即時同期させる • Remote -> Local • 無い︖ Local -> Remote⽅向だけ︖(相⼿からの受信がない環境での検証だと) • WebSocketでリアルタイム︖(DWN Server Configから推測) • Local-Remoteが多:多の分散環境でどのような同期プロトコルなのかは不明 • 各Nodeでの状態管理は前述のMerkle DAG? 37
  25. Web5のSync: 即時同期が必要になるケース 38 Remote Node (マルチテナント) Local Node Local Node

    Remote Node 1. Tweet的メッセージ送信 2. すぐに同期 3. すぐにリプライ Chatアプリ 4. (2分後)No.1の同期 5. データ不整合発⽣
  26. ⼤まかな全体像 40 Remote Node (マルチテナント) Local Node Local Node ION

    Remote Node did:ion:yyy did:ion:xxx 3.Sync 2-a. Send messages(HTTPS POST) 1. DID Resolution Service Endpoint: Remote Node URL Protocol (Data Schema & Access Control) DWA FE/Mobile App did:ion:yyy?service=DecentralizedWebNode&message=W3sgT... 2-b. Write data to my own node.
  27. Protocol Definition 41 • ユーザー/アプリレベルでの肝になると思う。 • 相互運⽤性の鍵 • あるエコシステム内で異なるアプリが同じ Protocolを使うことが普及の鍵になると思う。

    • 例) ⾳楽配信アプリ間で共通のプレイリストの Protocolを⽤意 structure: • 各typeの関係を構造化 • binaryImageはphotoの配下 $actions: • 各typeに対し誰が何をできるか • anyone, recipient, author: web5.dwn.*でのrequestに紐づく。 • album,photoはrecipient(=DID)に メッセージを送信する。 (Remote NodeにWriteする) • binariImage: 後から書き込めると⾔う意味︖ よくわからない。 JSON Schema? Remote Nodeへの︖
  28. ⼤まかな全体像 43 Remote Node (マルチテナント) Local Node Local Node ION

    Remote Node did:ion:yyy did:ion:xxx 3.Sync 2-a. Send messages(HTTPS POST) 1. DID Resolution Service Endpoint: Remote Node URL Protocol (Data Schema & Access Control) DWA FE/Mobile App did:ion:yyy?service=DecentralizedWebNode&message=W3sgT... 2-b. Write data to my own node.
  29. デフォルトのDID Method • did:ion • YouTube: Introducing did:dht - Our

    newest DID Method! • 将来的に使わなくなる可能性あり • MS撤退の動きを察知。 • ⾃分達(TBD)で運⽤、難しい -> インフラコスト、Bitcoin⼿数料の問題︖ • did:dht • Distributed Hash Table • 現状、仕様はTBD内で管理 • IONのようにTXを積み重ねるのではなく、DID Docをそのまま保管する⽅式︖ • 2001年からあるBitTorrent(P2Pファイル交換プロトコル/ソフトウェア) の既存ネットワーク?インフラ?であるMainline DHTを利⽤する 44
  30. TBD54566975内のWeb5関連リポジトリ群 46 リポジトリ 概要 ssi-service SSIに関する機能を提供するREST API Endpoints仕様 / KMSなどのConfig

    ssi-sdk 上記ssi-serviceが依存するSDK Goで実装 / 豊富な機能 ssi-sdk-wasm 上記ssi-sdkをWASM化する実装 Deprecated 独⽴ 前ページの表
  31. SSI SDKの機能 • DID Methods: web, key, jwk, pkh, peer

    • VC Formats • JWT-VC / SD-JWT • LDP-VC (JSON Web Signature 2020 / BBS+ Signature) • その他 • DIF Credential Manifest • DIF Presentation Exchange 2.0 • W3C Status List 2021 • W3C VC JSON Schema • W3C Wallet Rendering 47 [出展]https://github.com/TBD54566975/ssi-sdk?tab=readme-ov-file #key-types--signature-algorithms
  32. 当初(2023/7)の推測 48 Frontend/Mobile App web5-js (SDK) dwn-sdk-js (Local Node) DWA

    ssi-sdk ssi-sdk-wasm (現在deprecated) JS環境にSSI機能提供 当初の計画はこうだった︖ 今はこの形は無くなった︖ WASM File It enables SSI functionality in the browser and other JavaScript environments by compiling the SDK to a WASM file. This repository is responsible for building the main.wasm file and making it available as an npm package. [出展]https://github.com/TBD54566975/ssi-sdk?tab=readme-ov-file#wasm
  33. 業務システム 典型的な使い⽅の形(Issuer/Verifier)︖ 49 Node.js App Remote Node Local Node (web5-js)

    SSI Service (REST API) SSI Serviceは企業に使われる︖ Issuer/Verifier向け︖ HolderはWeb5 SDK内の VC関連機能を使う︖ 利⽤ 社員 / エンドユーザー 業務システム内の バックエンドアプリの1つ VC発⾏⽤DID秘密鍵
  34. web5-js(SDK)内の各種npm package 前述: credential packageの機能 50 agent api common cryto

    dids user-agent @decentralized-identity/ion-sdk @decentralized-identity/ion-pow-sdk credential dwn-sdk-js App いずれapiパッケージから参照される模様 / 機能的に発展途上
  35. credential package、dids packageの提供機能 • TBD54566975/sdk-development • 実装済み • Presentation Exchange

    2.0 • did:ion, did:keyのCreation/Resolution • 実装予定 • SD-JWTのCreation • did:jwkのCreation/Resolution • Holderとして機能できそう 51
  36. Web5とTrust Triangle(総合するとこんな形︖) • DWNのMessageでやりとり • (DIF Credential Manifest/Presentation Exchangeは暗黙的にフローまで定義していると考える) 52

    Issuer (Local/Remote Node) Holder (Local/Remote Node) Verifier (Local/Remote Node) 2. VC要求(Credential Application) 3. VC発⾏ (Credential Response(Fulfillment)) 1. オファー(Credential Manifest) 1. VP要求(Presentation Definition) 3. VP提⽰(Presentation Submission) SSI Service SSI Service Web5 JS SDK 2. 抽出(Definitionを満たすVC抽出) (署名) did:web ionのdid docはassertionMethod持って いなかったためとりあえず除外 (フォーマット) JWT-VC (署名) did:key, did:jwk, did:ion
  37. TBD54566975内のWeb5関連リポジトリ群 54 リポジトリ 概要 web5-js アプリに対しAPIを提供するSDK (= Local Node) TypeScript、⼀番成熟

    web5-kt 同上 Kotlin、2023/8から開発 web5-rs 同上? Rust、2023/11から開発 dwn-server Remote Nodeの実装 dwn-sdk-js web5-js / dwn-serverが依存するDIF DWN仕様の実装 sdk-developement 上記web5-{lang} SDKの実装状況を記す管理ドキュメント web5-wallet Identity Wallet?(後述)
  38. Identity Wallet 55 DID管理 DID Doc 作成更新復旧 アプリへの割り当て VP提⽰ Protocol

    定義︖ [出展]https://developer.tbd.website/files/Decentralized-Web-Platform.pdf