Closed6

Keyoxideの原理

ピン留めされたアイテム
zundazunda

このスクラップは https://github.com/zunda/mitome.in/issues/66 のためのものです。https://mitome.in/sns/keyoxide.html に公開しました。

Keyoxide

Keyoxide is a modern, secure and privacy-friendly platform to establish your decentralized online identity.

公開鍵へのnotationの追加

公開鍵へnotationを署名追加してキーサーバにアップロードすることで、notation先のURLを指定した自分が私有鍵を読めることの証明が成立する。

$ gpg --edit-key FINGERPRINT
> notation
proof@metacode.biz=プルーフのURL
> save
$ gpg --keyserver hkps://keys.openpgp.org --send-keys FINGERPRINT

サードパーティのサービスへのプルーフの追加

サードパーティのサービスに公開鍵の指紋を公開することで、自分がサードパーティのサービスに書き込めることの証明が成立する。

GitHubTwitter

This is an OpenPGP proof that connects [my OpenPGP key](https://keyoxide.org/FINGERPRINT) to [this Github account](https://github.com/USERNAME). For details check out https://keyoxide.org/guides/openpgp-proofs

[Verifying my OpenPGP key: openpgp4fpr:FINGERPRINT]

Mastodon

Add a new item under Profile metadata with the label OpenPGP and your PGP fingerprint as the content, or with the label Keyoxide and your Keyoxide profile URL as the content.

JSON応答の例は下記。

zundazunda

Mastodonから得られるアカウント関連の情報

keyoxide/cliがrequireしているkeyoxide/doipjsではhttps://domain.org/@alice形式のURLを確認に行き、.attachment.valueから指紋の一致するproofを探すようだ。

/@ユーザーID

例えば下記のコマンドで下記のようなJSONが得られる。

curl -H 'Accept: application/json' https://mastodon.zunda.ninja/@zundan
{
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://w3id.org/security/v1",
    {
      "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
      "toot": "http://joinmastodon.org/ns#",
      "featured": {
        "@id": "toot:featured",
        "@type": "@id"
      },
      "featuredTags": {
        "@id": "toot:featuredTags",
        "@type": "@id"
      },
      "alsoKnownAs": {
        "@id": "as:alsoKnownAs",
        "@type": "@id"
      },
      "movedTo": {
        "@id": "as:movedTo",
        "@type": "@id"
      },
      "schema": "http://schema.org#",
      "PropertyValue": "schema:PropertyValue",
      "value": "schema:value",
      "IdentityProof": "toot:IdentityProof",
      "discoverable": "toot:discoverable",
      "Device": "toot:Device",
      "Ed25519Signature": "toot:Ed25519Signature",
      "Ed25519Key": "toot:Ed25519Key",
      "Curve25519Key": "toot:Curve25519Key",
      "EncryptedMessage": "toot:EncryptedMessage",
      "publicKeyBase64": "toot:publicKeyBase64",
      "deviceId": "toot:deviceId",
      "claim": {
        "@type": "@id",
        "@id": "toot:claim"
      },
      "fingerprintKey": {
        "@type": "@id",
        "@id": "toot:fingerprintKey"
      },
      "identityKey": {
        "@type": "@id",
        "@id": "toot:identityKey"
      },
      "devices": {
        "@type": "@id",
        "@id": "toot:devices"
      },
      "messageFranking": "toot:messageFranking",
      "messageType": "toot:messageType",
      "cipherText": "toot:cipherText",
      "suspended": "toot:suspended",
      "focalPoint": {
        "@container": "@list",
        "@id": "toot:focalPoint"
      }
    }
  ],
  "id": "https://mastodon.zunda.ninja/users/zundan",
  "type": "Person",
  "following": "https://mastodon.zunda.ninja/users/zundan/following",
  "followers": "https://mastodon.zunda.ninja/users/zundan/followers",
  "inbox": "https://mastodon.zunda.ninja/users/zundan/inbox",
  "outbox": "https://mastodon.zunda.ninja/users/zundan/outbox",
  "featured": "https://mastodon.zunda.ninja/users/zundan/collections/featured",
  "featuredTags": "https://mastodon.zunda.ninja/users/zundan/collections/tags",
  "preferredUsername": "zundan",
  "name": "zunda",
  "summary": "<p>Reads and writes in Japanese and English. ぽんこつです。nはオマケなんです。</p>",
  "url": "https://mastodon.zunda.ninja/@zundan",
  "manuallyApprovesFollowers": false,
  "discoverable": false,
  "devices": "https://mastodon.zunda.ninja/users/zundan/collections/devices",
  "publicKey": {
    "id": "https://mastodon.zunda.ninja/users/zundan#main-key",
    "owner": "https://mastodon.zunda.ninja/users/zundan",
    "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/sIyT2CCvwb9nbblcRfS\nE5dPRkfFCT3nR2v1Q2s3FF7QQybEYrIT8pXGvDQF00PQN9ABypUMLwTQecLni4p8\nrG14dJyEQFA9RstAN/CHXhRU4jIr2fgvKeF0WLUAci+YDxYJONZYlUT2S8EawLfy\nWAkc1017ol++Pz4Ur3YSAMld1LmIg21fuDrP54WgvPPE/KgNKb689ui2C6Z0xYpp\nSaqhliAibQan3QzMeZLUV6XwJFwuFoAjtxYFL26FvsDDP8P3aLizrUqbszgeD54x\ntVtt0Ld59a+hds+G/rkfhInpB3b4VQaotv34EFcNKdQpn11jl4hREves9guRGJ8C\nzwIDAQAB\n-----END PUBLIC KEY-----\n"
  },
  "tag": [],
  "attachment": [
    {
      "type": "PropertyValue",
      "name": "Web",
      "value": "<a href=\"http://zunda.freeshell.org\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">http://</span><span class=\"\">zunda.freeshell.org</span><span class=\"invisible\"></span></a>"
    },
    {
      "type": "PropertyValue",
      "name": "商品名",
      "value": "ずんだもち"
    },
    {
      "type": "PropertyValue",
      "name": "原材料",
      "value": "大豆 餅米 砂糖 食塩"
    },
    {
      "type": "IdentityProof",
      "name": "zunda",
      "signatureAlgorithm": "keybase",
      "signatureValue": "d583d35bf8d0467fdb4b6d82b1d56f8ca93e9a55ffc22439bf63a2b2821b74a00f"
    }
  ],
  "endpoints": {
    "sharedInbox": "https://mastodon.zunda.ninja/inbox"
  },
  "icon": {
    "type": "Image",
    "mediaType": "image/gif",
    "url": "https://s3.amazonaws.com/zundan-mastodon/accounts/avatars/000/000/001/original/4b8def44acb30e97.gif"
  },
  "image": {
    "type": "Image",
    "mediaType": "image/jpeg",
    "url": "https://s3.amazonaws.com/zundan-mastodon/accounts/headers/000/000/001/original/0e87b502ca5cd524.jpg"
  }
}

https://fosstodon.org/@keyoxide さんの場合 (jq .attachmentしてあります)

[
  {
    "type": "PropertyValue",
    "name": "Website",
    "value": "<a href=\"https://keyoxide.org\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">keyoxide.org</span><span class=\"invisible\"></span></a>"
  },
  {
    "type": "PropertyValue",
    "name": "Repo",
    "value": "<a href=\"https://codeberg.org/keyoxide/web\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">codeberg.org/keyoxide/web</span><span class=\"invisible\"></span></a>"
  },
  {
    "type": "PropertyValue",
    "name": "OpenPGP",
    "value": "9f0048ac0b23301e1f77e994909f6bd6f80f485d"
  },
  {
    "type": "PropertyValue",
    "name": "OpenPGP DOIP",
    "value": "3637202523e7c1309ab79e99ef2dc5827b445f4b"
  }
]

https://fosstodon.org/@yarmo さんの場合


[
  {
    "type": "PropertyValue",
    "name": "Web",
    "value": "<a href=\"https://yarmo.eu\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">yarmo.eu</span><span class=\"invisible\"></span></a>"
  },
  {
    "type": "PropertyValue",
    "name": "Keyoxide",
    "value": "<a href=\"https://keyoxide.org/9f0048ac0b23301e1f77e994909f6bd6f80f485d\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"ellipsis\">keyoxide.org/9f0048ac0b23301e1</span><span class=\"invisible\">f77e994909f6bd6f80f485d</span></a>"
  },
  {
    "type": "PropertyValue",
    "name": "Pronouns",
    "value": "he/him/his"
  }
]

/users/ユーザーID

下記のコマンドで得られるjsonも上記と同様のようだ。

curl -H 'Accept: application/json' https://mastodon.zunda.ninja/users/zundan

/api/proofs

https://docs.joinmastodon.org/methods/proofs/

例えば https://mastodon.zunda.ninja/api/proofs?username=zundan&provider=keybase から下記が返る。

{
  "avatar": "https://s3.amazonaws.com/zundan-mastodon/accounts/avatars/000/000/001/original/4b8def44acb30e97.gif",
  "signatures": [
    {
      "sig_hash": "d583d35bf8d0467fdb4b6d82b1d56f8ca93e9a55ffc22439bf63a2b2821b74a00f",
      "kb_username": "zunda"
    }
  ]
}
zundazunda

OpenPGP公開鍵から得られる情報

https://keyoxide.org/guides/mastodon#update-the-mastodon-account に従ってnotationを追加してみる。

$ gpg --edit-key F60960D80B224382CA8D831CB56C20316D6E8279
gpg> notation
Enter the notation: proof@metacode.biz=https://mastodon.zunda.ninja/@zundan
gpg> save

私有鍵のパスフレーズを聞かれたので署名もしている。下記のようにnotationの付随した署名を確かめられる。

$ gpg --list-keys --with-sig-list --list-options show-notations F60960D80B224382CA8D831CB56C20316D6E8279
pub   rsa3072 2020-06-24 [SC] [expires: 2022-06-24]
      F60960D80B224382CA8D831CB56C20316D6E8279
uid           [ultimate] zunda <zundan@gmail.com>
sig 3    N   B56C20316D6E8279 2021-02-17  zunda <zundan@gmail.com>
   Signature notation: proof@metacode.biz=https://mastodon.zunda.ninja/@zundan
sub   rsa3072 2020-06-24 [E] [expires: 2022-06-24]
sig          B56C20316D6E8279 2020-06-24  zunda <zundan@gmail.com>

https://fosstodon.org/@yarmo さんのnotationも確認してみる。Keyoxide URL https://keyoxide.org/9f0048ac0b23301e1f77e994909f6bd6f80f485d からJavaScriptで表示されるページのFingerprintをクリックすると公開鍵をダウンロードできます。

gpg --show-keys --with-sig-listgpg --list-keys --list-keys --with-sig-list --list-options show-notationsのほか、-edit-keyしてshowprefしてもnotationを確認できる。

$ gpg --show-keys --with-sig-list ~/Downloads/9F0048AC0B23301E1F77E994909F6BD6F80F485D.asc | head
pub   rsa4096 2019-07-10 [SC] [expires: 2022-12-23]
      9F0048AC0B23301E1F77E994909F6BD6F80F485D
uid                      Yarmo Mackenbach <yarmo@yarmo.eu>
sig 3    N   909F6BD6F80F485D 2021-01-13  Yarmo Mackenbach <yarmo@yarmo.eu>
   Signature notation: proof@metacode.biz=https://codeberg.org/yarmo/gitea_proof
   Signature notation: proof@metacode.biz=xmpp:yarmo@404.city?omemo-sid-172925472=3fc7cbdcff2644e1daa772555f47973b062b9d9fc238017dd536f422b5cc187c;omemo-sid-867444219=a46bb6abdd8c73b8a4d6c2ebfcfd66eff6a6be1a27480f2334babf932eed2d16
   Signature notation: proof@metacode.biz=https://dev.to/yarmo/openpgp-identity-proof-2hbl
   Signature notation: proof@metacode.biz=https://community.home-assistant.io/u/yarmom
   Signature notation: proof@metacode.biz=https://news.ycombinator.com/user?id=Yolta
   Signature notation: proof@metacode.biz=dns:yarmo.eu?type=TXT
$ gpg --import 9F0048AC0B23301E1F77E994909F6BD6F80F485D.asc
gpg: key 909F6BD6F80F485D: public key "Yarmo Mackenbach <yarmo@yarmo.eu>" imported
gpg: Total number processed: 1
gpg:               imported: 1
$ gpg --list-keys --list-keys --with-sig-list --list-options show-notations 9F0048AC0B23301E1F77E994909F6BD6F80F485D | head
pub   rsa4096 2019-07-10 [SC] [expires: 2022-12-23]
      9F0048AC0B23301E1F77E994909F6BD6F80F485D
uid           [ unknown] Yarmo Mackenbach <yarmo@yarmo.eu>
sig 3    N   909F6BD6F80F485D 2021-01-13  Yarmo Mackenbach <yarmo@yarmo.eu>
   Signature notation: proof@metacode.biz=https://codeberg.org/yarmo/gitea_proof
   Signature notation: proof@metacode.biz=xmpp:yarmo@404.city?omemo-sid-172925472=3fc7cbdcff2644e1daa772555f47973b062b9d9fc238017dd536f422b5cc187c;omemo-sid-867444219=a46bb6abdd8c73b8a4d6c2ebfcfd66eff6a6be1a27480f2334babf932eed2d16
   Signature notation: proof@metacode.biz=https://dev.to/yarmo/openpgp-identity-proof-2hbl
   Signature notation: proof@metacode.biz=https://community.home-assistant.io/u/yarmom
   Signature notation: proof@metacode.biz=https://news.ycombinator.com/user?id=Yolta
   Signature notation: proof@metacode.biz=dns:yarmo.eu?type=TXT
$ gpg --edit-key 9F0048AC0B23301E1F77E994909F6BD6F80F485D
gpg (GnuPG/MacGPG2) 2.2.24; Copyright (C) 2020 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


pub  rsa4096/909F6BD6F80F485D
     created: 2019-07-10  expires: 2022-12-23  usage: SC
     trust: unknown       validity: unknown
sub  rsa2048/D713546F9E11C652
     created: 2020-12-09  expires: never       usage: A
sub  rsa3072/71160D32CB12016D
     created: 2019-07-10  expires: never       usage: E
sub  rsa4096/37367F4AF4087AD1
     created: 2019-08-16  expires: never       usage: S
[ unknown] (1). Yarmo Mackenbach <yarmo@yarmo.eu>
[ unknown] (2)  Yarmo Mackenbach <yarmo@keyoxide.org>
[ unknown] (3)  Yarmo Mackenbach <yarmo@mackenba.ch>

gpg> showpref
[ unknown] (1). Yarmo Mackenbach <yarmo@yarmo.eu>
     Cipher: AES256, AES192, AES, 3DES
     AEAD:
     Digest: SHA512, SHA384, SHA256, SHA224, SHA1
     Compression: ZLIB, BZIP2, ZIP, Uncompressed
     Features: MDC, AEAD, Keyserver no-modify
     Preferred keyserver: https://keys.openpgp.org/
     Notations: proof@metacode.biz=https://codeberg.org/yarmo/gitea_proof
                proof@metacode.biz=xmpp:yarmo@404.city?omemo-sid-172925472=3fc7cbdcff2644e1daa772555f47973b062b9d9fc238017dd536f422b5cc187c;omemo-sid-867444219=a46bb6abdd8c73b8a4d6c2ebfcfd66eff6a6be1a27480f2334babf932eed2d16
                proof@metacode.biz=https://dev.to/yarmo/openpgp-identity-proof-2hbl
                proof@metacode.biz=https://community.home-assistant.io/u/yarmom
                proof@metacode.biz=https://news.ycombinator.com/user?id=Yolta
                proof@metacode.biz=dns:yarmo.eu?type=TXT
                proof@metacode.biz=https://fosstodon.org/@yarmo
                proof@metacode.biz=https://www.reddit.com/user/YarmoM/comments/hhd318/openpgp_proof/
                proof@metacode.biz=https://twitter.com/YarmoM/status/1277886959143157760
                proof@metacode.biz=https://lobste.rs/u/yarmo
                proof@metacode.biz=https://pixelfed.social/users/yarmo
                proof@metacode.biz=https://gitlab.com/yarmo/gitlab_proof
                proof@metacode.biz=https://gist.github.com/YarmoM/ca1b28b636565e8f862f248409a1a6d2
                proof@metacode.biz=https://yarmo.live
[ unknown] (2)  Yarmo Mackenbach <yarmo@keyoxide.org>
     Cipher: AES256, AES192, AES, 3DES
     AEAD:
     Digest: SHA512, SHA384, SHA256, SHA224, SHA1
     Compression: ZLIB, BZIP2, ZIP, Uncompressed
     Features: MDC, AEAD, Keyserver no-modify
     Notations: proof@metacode.biz=dns:keyoxide.org?type=TXT
                proof@metacode.biz=https://fosstodon.org/@keyoxide
[ unknown] (3)  Yarmo Mackenbach <yarmo@mackenba.ch>
     Cipher: AES256, AES192, AES, 3DES
     AEAD:
     Digest: SHA512, SHA384, SHA256, SHA224, SHA1
     Compression: ZLIB, BZIP2, ZIP, Uncompressed
     Features: MDC, AEAD, Keyserver no-modify

gpg> quit

Notations

https://security.stackexchange.com/a/120662

Notations provide meanings to add information to a signature or certification ... The notation has a name and a value, each of which are strings of octets. There may be more than one notation in a signature. Notations can be used for any extension the issuer of the signature cares to make.

zundazunda

claimとproofとnotificationの関係

https://keyoxide.org/9f0048ac0b23301e1f77e994909f6bd6f80f485d をロードすると、「Veifying proofs...」と表示してしばらくしてから結果を表示する。現状では、https://keyoxide.org/F60960D80B224382CA8D831CB56C20316D6E8279 は「No claims associated」と表示する。

notationにclaimが書かれていて、claimに書かれたproofを参照して検証するのだろうか。

https://codeberg.org/keyoxide/doipjs/src/branch/main/src/serviceproviders/mastodon.js を見るとMastodonのプロファイルに書かれている指紋もclaimと呼んでいるように見える。proofにはuriプロパティがある。

zundazunda

keyoxideによる検証

https://keyoxide.org/f60960d80b224382ca8d831cb56c20316d6e8279

公開鍵にnotationが無い場合

公開鍵にnotationはあるけれどプロファイルに指紋が無い場合

下記でキーサーバーにnotationを添付した公開鍵を送っておく。

$ gpg --send-key F60960D80B224382CA8D831CB56C20316D6E8279
gpg: sending key B56C20316D6E8279 to hkps://keys.openpgp.org

公開鍵にnotationとプロファイルに指紋がある場合

Mastodonのプロファイルに鍵対の指紋を追加しておく。

検証に成功した!!

zundazunda

notationの削除

notationの確認

$ gpg --list-keys --with-sig-list --list-options show-notations F60960D80B224382CA8D831CB56C20316D6E8279 | grep proof@metacode.biz=
   Signature notation: proof@metacode.biz=https://mastodon.zunda.ninja/@zundan

notationを削除したい場合には最初に-を書く。

$ gpg --edit-key F60960D80B224382CA8D831CB56C20316D6E8279
gpg> notation
Enter the notation: -proof@metacode.biz=https://mastodon.zunda.ninja/@zundan
Current notations for user ID "zunda <zundan@gmail.com>":
         proof@metacode.biz=https://mastodon.zunda.ninja/@zundan
Removing notation: proof@metacode.biz=https://mastodon.zunda.ninja/@zundan
Proceed? (y/N) y
gpg> save

下記のようにnotationが表示されなくなる。

$ gpg --list-keys --with-sig-list --list-options show-notations F60960D80B224382CA8D831CB56C20316D6E8279 | grep proof@metacode.biz=
<何も表示されない>
このスクラップは2021/03/01にクローズされました