コンテンツへスキップ
uencoder

属性ベース暗号を使う方法

受信者の属性(役割、部門、アクセス権レベル)に基づいてデータを暗号化し、属性が一致するユーザーだけが復号できるようにします。きめ細かいアクセス制御が可能になります。

问题

異なるアクセス権を持つ複数の受信者と暗号化データを共有する必要がありますが、従来の公開鍵暗号では受信者ごとに個別に暗号化しなければなりません。属性ベース暗号(ABE)なら、アクセスポリシーを指定して一度だけ暗号化すれば、属性がポリシーを満たすユーザーだけが復号できます。

前提条件

  • 公開鍵暗号とアクセス制御の理解
  • 双線形ペアリングと楕円曲線への習熟
  • アクセス構造(単調ブール式、LSSS)に関する知識

ステップ

  1. 1. Choose ABE variant and setup authority

    Select between Ciphertext-Policy ABE (CP-ABE: policy embedded in ciphertext, attributes in keys) and Key-Policy ABE (KP-ABE: policy embedded in keys, attributes in ciphertext). CP-ABE is more common for data sharing: encrypt with an access policy, users with matching attribute keys decrypt. Run Setup to generate master public key (mpk) and master secret key (msk). The authority holds msk and issues user keys. Use the ECC and modular exponentiation tools to understand the underlying math.

    入力
    variant: CP-ABE | universe: department, clearance, role
    输出
    mpk: public params | msk: master secret (held by authority)
  2. 2. Issue attribute keys to users

    For each user, define their attribute set based on their role and properties. Call KeyGen(msk, user_attributes) to generate a private key specific to those attributes. For example, Alice gets attributes {department:engineering, clearance:secret, role:lead}. The key can only decrypt ciphertexts whose access policy is satisfied by these attributes. Distribute keys securely to users. Use the hash and HMAC tools for key derivation.

    入力
    user: Alice | attributes: {dept:eng, clearance:secret, role:lead}
    输出
    sk_alice: KeyGen(msk, {dept:eng, clearance:secret, role:lead})
  3. 3. Encrypt data with an access policy

    Define the access policy as a boolean formula or tree. For example: (dept:eng AND clearance:secret) OR role:admin. Call Encrypt(mpk, policy, plaintext) to produce a ciphertext that can only be decrypted by users whose attributes satisfy the policy. The ciphertext encodes the policy — no separate access control check is needed at decryption time. The encryption is done once, regardless of how many users might qualify. Use the AES tool for the symmetric data encryption that ABE typically wraps.

    入力
    policy: (dept:eng AND clearance:secret) OR role:admin | data: project roadmap
    输出
    ct: Encrypt(mpk, policy, data) — only matching attributes can decrypt
  4. 4. Decrypt with attribute keys and manage revocation

    Users call Decrypt(sk_user, ct) which succeeds only if their attributes satisfy the embedded policy. If attributes don't match, decryption fails (output is random/garbage). For revocation: add a time attribute to keys and policies (e.g., AND time<2026-12-31), or use revocable ABE schemes with a revocation list. Re-key when attributes change (promotions, department transfers). Audit decryption attempts. Use the AES decrypt tool for the final data decryption layer.

    入力
    sk_alice + ct (policy: dept:eng AND clearance:secret)
    输出
    Alice: dept:eng ✓, clearance:secret ✓ -> decrypt succeeds -> plaintext

期待される結果

データをアクセスポリシーと共に一度だけ暗号化し、ポリシーを満たす属性を持つユーザーだけが復号できる、属性ベース暗号システム。スケーラブルな細粒度アクセス制御を実現します。

よくあるエラー

Using ABE for large data directly
ABE is slow for large data. Use hybrid encryption: ABE-encrypt a symmetric key (AES), then AES-encrypt the data. Only the small key uses ABE.
Not handling attribute revocation
ABE keys are static. For revocation, use time-based attributes (expiring keys), lazy revocation (re-encrypt data with new policy), or revocable ABE schemes with a revocation authority.
Choosing the wrong ABE variant
CP-ABE (policy in ciphertext) is better for data sharing where access policies vary per document. KP-ABE (policy in key) is better when users have fixed access patterns and data has varying attributes.

トラブルシューティング指引

  • If decryption fails for authorized users, verify the attribute naming matches exactly between key generation and policy, and that the access tree is correctly structured.
  • If performance is slow, use hybrid encryption (ABE for key, AES for data) and consider outsourcing decryption to a proxy server.
  • For large-scale deployment, consider using a proxy re-encryption or hybrid ABE-proxy approach to reduce client-side computation.

セキュリティ上の制限

  • ABE relies on bilinear pairing assumptions — if broken, all ciphertexts are compromised. Use established parameter choices.
  • The authority holding the master secret key can decrypt all data — protect it with HSM and split authority if needed.
  • All key generation and encryption happen locally; only the master public key and ciphertexts are shared.

関連ツール

関連用語

参考链接