fix
This commit is contained in:
95
my-blog/content/posts/2025-09-05-plc.md
Normal file
95
my-blog/content/posts/2025-09-05-plc.md
Normal file
@@ -0,0 +1,95 @@
|
||||
---
|
||||
title: "plcにhandle changeを反映する"
|
||||
slug: "plc"
|
||||
date: "2025-09-05"
|
||||
tags: ["atproto"]
|
||||
draft: false
|
||||
---
|
||||
|
||||
いつまで経ってもbsky.teamのplcにhandle changeが反映されないので色々やってみました。
|
||||
|
||||
結論から言うと、`PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX`を使用し、rotation-keyを作成後に、indigoにある`goat plc`を使用します。
|
||||
|
||||
1. `goat key generate --type secp256k1`で生成されたキーを分析
|
||||
2. そのキーから正しいmulticodecプレフィックスを抽出
|
||||
3. PDSのhex keyに同じプレフィックスを適用
|
||||
|
||||
```sh
|
||||
$ go install github.com/bluesky-social/indigo/cmd/goat@latest
|
||||
```
|
||||
|
||||
```sh
|
||||
$ goat account login -u syui.syui.ai -p $PASS --pds-host https://syu.is
|
||||
|
||||
$ goat plc history did:plc:vzsvtbtbnwn22xjqhcu3vd6y
|
||||
did:key:zQ3shZj81oA4A9CmUQgYUv97nFdd7m5qNaRMyG16XZixytTmQ
|
||||
|
||||
$ goat plc update did:plc:vzsvtbtbnwn22xjqhcu3vd6y \
|
||||
--handle syui.syui.ai \
|
||||
--pds https://syu.is \
|
||||
--atproto-key did:key:zQ3shZj81oA4A9CmUQgYUv97nFdd7m5qNaRMyG16XZixytTmQ > plc_operation_syui.json
|
||||
```
|
||||
|
||||
```sh
|
||||
source base58_env/bin/activate
|
||||
|
||||
python3 -c "
|
||||
import base58
|
||||
|
||||
# 生成されたsecp256k1キーを分析
|
||||
generated_secp256k1 = '${zXXX...}'
|
||||
decoded = base58.b58decode(generated_secp256k1[1:]) # 'z'を除く
|
||||
|
||||
print('Generated secp256k1 key analysis:')
|
||||
print(' Total length:', len(decoded))
|
||||
print(' Full hex:', decoded.hex())
|
||||
|
||||
# 32バイトの鍵データを除いたプレフィックスを抽出
|
||||
if len(decoded) > 32:
|
||||
prefix = decoded[:-32]
|
||||
key_data = decoded[-32:]
|
||||
print(' Prefix hex:', prefix.hex())
|
||||
print(' Prefix length:', len(prefix))
|
||||
print(' Key data length:', len(key_data))
|
||||
|
||||
pds_rotation_hex = '${PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX}'
|
||||
pds_rotation_bytes = bytes.fromhex(pds_rotation_hex)
|
||||
|
||||
prefixed_rotation_key = prefix + pds_rotation_bytes
|
||||
multibase_rotation_key = 'z' + base58.b58encode(prefixed_rotation_key).decode()
|
||||
|
||||
print('\\nConverted PDS rotation key:')
|
||||
print(' Multibase:', multibase_rotation_key)
|
||||
|
||||
else:
|
||||
print(' No prefix found, key is raw')
|
||||
"
|
||||
|
||||
deactivate
|
||||
```
|
||||
|
||||
```sh
|
||||
$ PDS_ROTATION_KEY=zXXX...
|
||||
|
||||
$ goat plc sign --plc-signing-key "$PDS_ROTATION_KEY" plc_operation_syui.json > plc_signed_syui.json
|
||||
$ goat plc submit --did did:plc:vzsvtbtbnwn22xjqhcu3vd6y plc_signed_syui.json
|
||||
success
|
||||
|
||||
$ goat plc history did:plc:vzsvtbtbnwn22xjqhcu3vd6y
|
||||
```
|
||||
|
||||
## plcを確認
|
||||
|
||||
```sh
|
||||
did=did:plc:6qyecktefllvenje24fcxnie
|
||||
handle=ai.syui.ai
|
||||
curl -sL "https://plc.directory/$did"|jq .alsoKnownAs
|
||||
curl -sL "https://plc.syu.is/$did"|jq .alsoKnownAs
|
||||
[
|
||||
"at://ai.syui.ai"
|
||||
]
|
||||
[
|
||||
"at://ai.syui.ai"
|
||||
]
|
||||
```
|
||||
|
Reference in New Issue
Block a user