Documentation

AMATELUS.TrustChainTypes

初期最大信頼チェーン深さ(N階層対応)

新設計では、プロトコルレベルの上限を設けない。 各委任者がmaxDepthを指定し、単調減少により有限回で停止することを保証する。

この値は検証アルゴリズムの初期remainingDepthとして使用される。 実際の制限は各delegationのmaxDepthで決まる。

Equations
Instances For

    委任内容(Delegation Content)- maxDepth対応

    委任者から受託者へのクレーム発行権限の委譲を表現する構造。

    設計思想:

    • grantorDID: 権限を与える側のDID
    • granteeDID: 権限を受ける側のDID
    • label: クレームの表示ラベル(人間向け、機能を持たない)
    • claimSchema: JSON Schema(正式な定義)
    • maxDepth: 最大委任階層数(1以上の自然数、必須)

    maxDepthの役割:

    • この委任からさらに何階層まで委任を許可するか
    • 受託者は親のremainingDepth-1と自分のmaxDepthの小さい方まで委任可能
    • 計算式:nextDepth = min(parentDepth - 1, delegation.maxDepth)
    • grantorDID : ValidDID

      委任者DID(権限を与える側)

    • granteeDID : ValidDID

      受託者DID(権限を受ける側)

    • label : String

      クレームの表示ラベル(人間向け)

    • claimSchema : Schema

      Legacy parsed view for structural examples; authorization uses schemaSource.

    • schemaSource : JSONValue

      Exact signed raw schema; never silently strip unsupported constraints.

    • allowedClaims : List String

      Explicit issuance authority, separate from schema format validation.

    • maxDepth : ℕ

      最大委任階層数(1以上の自然数)

    Instances For
      Equations
      • One or more equations did not get rendered due to their size.

      maxDepthが有効かどうかを判定(1以上であること)

      Equations
      Instances For

        DelegationContentの等価性判定(DID比較用)

        Equations
        Instances For
          structure W3CProof :

          W3C Proof構造(簡略版)

          実際のW3C.Proof型は別モジュールで定義されていますが、 ここでは型定義のために簡略版を使用します。

          • verificationMethod : String

            検証メソッド(公開鍵へのリファレンス)

          • proofValue : String

            署名値

          Instances For

            委任チェーン(Delegation Chain)- N階層対応

            複数の委任を連鎖させた構造。

            設計思想:

            • delegations: 委任のリスト(順序重要:[0]が初代、[n]が最終)
            • chainProofs: 各委任に対応する署名リスト(同じ長さ)
            • 循環委任の検出が可能(DID重複チェック)
            • 単調減少性により無限階層を防止
            • delegations : List DelegationContent

              委任のリスト([0]が初代、[n]が最終)

            • chainProofs : List W3CProof

              各委任に対応する署名リスト(delegationsと同じ長さ)

            Instances For

              委任チェーン内のすべてのDIDを取得

              Equations
              Instances For

                循環委任チェック(DID重複がないことを確認)

                アルゴリズム:

                • すべてのDID(grantorDIDとgranteeDID)を抽出
                • 重複があればtrue(循環委任)、なければfalse

                計算量: O(n²) where n = DIDs数

                Equations
                Instances For

                  委任チェーンの深さ(委任の数)

                  Equations
                  Instances For
                    def DelegationChain.computeNextDepth (parentDepth delegationMaxDepth : ℕ) :

                    次の階層の残り深さを計算

                    計算式: nextDepth = min(parentDepth - 1, delegationMaxDepth)

                    単調減少性:

                    • parentDepth = 0の場合: nextDepth = 0(これ以上委任不可)
                    • それ以外: parentDepth-1とmaxDepthの小さい方

                    例:

                    • computeNextDepth 5 3 = min(4, 3) = 3
                    • computeNextDepth 2 5 = min(1, 5) = 1
                    • computeNextDepth 0 5 = 0
                    Equations
                    Instances For
                      @[irreducible]
                      def DelegationChain.verifyChain (delegations : List DelegationContent) (remainingDepth : ℕ) (trustedAnchors : List ValidDID) :

                      委任チェーンの検証(再帰的、Nat単調減少で停止性保証)

                      パラメータ:

                      • delegations: 検証する委任のリスト
                      • remainingDepth: 現在の残り深さ
                      • trustedAnchors: 信頼されたDIDのリスト

                      検証ロジック:

                      1. delegationsが空の場合: true(検証成功)
                      2. remainingDepth=0の場合: false(深さ超過)
                      3. 先頭のdelegationを取り出し:
                        • grantorDIDがtrustedAnchorsに含まれるか確認
                        • nextDepthを計算(単調減少)
                        • 残りのdelegationsを再帰的に検証

                      停止性: remainingDepthが0になるか、delegationsが空になるまで必ず減少する。 Natの単調減少により、有限回で必ず停止する。

                      Equations
                      Instances For

                        委任チェーン全体の検証

                        パラメータ:

                        • chain: 検証する委任チェーン
                        • trustedAnchors: 信頼されたDIDのリスト

                        検証内容:

                        1. 循環委任チェック
                        2. 委任チェーンの検証(verifyChain使用)

                        初期深さ: InitialMaxDepthを初期remainingDepthとして使用。 実際の制限は各delegationのmaxDepthで決まる。

                        Equations
                        Instances For

                          Crypto/semantic adapters must verify the complete signed delegation (including scope, schemaSource and maxDepth). Schema backend enforces the supplied branch and regex budgets and returns none for unsupported syntax or exhaustion.

                          Instances For
                            def DelegationChain.verify (chain : DelegationChain) (trustedAnchors : List ValidDID) (issuer : ValidDID) (value : JSONValue) (checks : Checks) (budget : ResourceBudget) :

                            Public authorization boundary; profile budgets are receiver-selected.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              structure Claim :

                              クレーム(Claim)- 属性VCに含まれる個々のクレーム

                              設計思想:

                              • 各クレームは自己完結構造(content + delegation chain + proofs)
                              • 0階層(直接発行): contentのみ
                              • N階層(委譲発行): content + delegationChain + contentProof
                              • contentProofは最終発行者によるcontentへの署名でZKP検証時にHolderの改ざんを検出

                              フィールド:

                              • content: クレームの実データ(ZKPの入力となる)
                              • delegationChain: 委任チェーン(N階層の場合のみ)
                              • contentProof: 最終発行者によるcontentへの署名(N階層の場合のみ、ZKP検証に必要)
                              • content : String

                                クレームの実データ

                              • delegationChain : Option DelegationChain

                                委任チェーン(None=直接発行、Some=委譲発行)

                              • contentProof : Option W3CProof

                                最終発行者によるcontentへの署名(ZKP検証に必要)

                              Instances For

                                0階層(直接発行)のクレームを構築

                                Equations
                                Instances For
                                  def Claim.makeDelegatedClaim (content : String) (chain : DelegationChain) (contentProof : W3CProof) :

                                  N階層(委譲発行)のクレームを構築

                                  Equations
                                  Instances For

                                    クレームが委譲発行かどうか判定

                                    Equations
                                    Instances For
                                      def Claim.depth (claim : Claim) :

                                      クレームの委任階層数を取得

                                      戻り値:

                                      • 0: 直接発行
                                      • N: N階層の委任チェーン
                                      Equations
                                      Instances For
                                        def Claim.verifyStructure (claim : Claim) (trustedAnchors : List ValidDID) :

                                        クレームの検証

                                        パラメータ:

                                        • claim: 検証するクレーム
                                        • trustedAnchors: 信頼されたDIDのリスト

                                        検証内容:

                                        • 直接発行: 常にtrue(issuer検証は別途実施)
                                        • 委譲発行: delegationChainを検証
                                        Equations
                                        Instances For
                                          def Claim.verify (claim : Claim) (issuer : ValidDID) (trustedAnchors : List ValidDID) (checks : DelegationChain.Checks) (budget : ResourceBudget) (parse : ResourceBudget → String → Option JSONValue) (verifyContent : ValidDID → String → Option W3CProof → Bool) :

                                          Original claim signature plus independently parsed content and issuance scope. The parser enforces ResourceBudget while reading; it must parse this exact content. Holder packaging is outside this original-claim verification boundary.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            theorem computeNextDepth_decreasing (parentDepth maxDepth : ℕ) :
                                            parentDepth > 0 → DelegationChain.computeNextDepth parentDepth maxDepth < parentDepth

                                            Theorem: computeNextDepthは単調減少

                                            parentDepth > 0の場合、computeNextDepthの結果は必ずparentDepthより小さい。 これにより、有限回の適用でゼロに到達することが保証される。

                                            theorem verifyChain_terminates (delegations : List DelegationContent) (remainingDepth : ℕ) (trustedAnchors : List ValidDID) :
                                            ∃ (result : Bool), DelegationChain.verifyChain delegations remainingDepth trustedAnchors = result

                                            Theorem: verifyChainは有限回で停止

                                            verifyChainは remainingDepth を単調減少させるため、有限回で必ず停止する。 これはtermination_by remainingDepthで自動的に保証されている。

                                            @[irreducible]
                                            theorem verifyChain_length_bound (delegations : List DelegationContent) (remainingDepth : ℕ) (trustedAnchors : List ValidDID) :
                                            DelegationChain.verifyChain delegations remainingDepth trustedAnchors = true → delegations.length ≤ remainingDepth

                                            補助定理: verifyChainの長さ上限

                                            verifyChainがtrueを返す場合、委任リストの長さはremainingDepth以下である。

                                            証明戦略: verifyChainの構造を利用し、再帰的に証明する。 各ステップで、computeNextDepthによりremainingDepthが減少することを使う。

                                            theorem finite_delegation_chain (delegations : List DelegationContent) (initialDepth : ℕ) (trustedAnchors : List ValidDID) :
                                            DelegationChain.verifyChain delegations initialDepth trustedAnchors = true → delegations.length ≤ initialDepth

                                            Theorem: 委任チェーンの深さは有限

                                            verifyChainがtrueを返す場合、委任チェーンの長さは initialDepth以下であることが保証される。

                                            証明: 補助定理verifyChain_length_boundから直接導かれる。