1) Get the identifiers of the current and next authority set from the Runtime API, e.g. using the RPC interface for a PoC. ```javascript const res = await api.call.authorityDiscoveryApi.authorities() const authorities = res.toHuman().map(a => keyring.decodeAddress(a)) ``` Reference: https://docs.rs/sp-authority-discovery/27.0.0/sp_authority_discovery/trait.AuthorityDiscoveryApi.html 2) Load the protobuf DHT discovery types. ```javascript const disco = await protobuf.load(dirname(import.meta.url) + '/dht_disco-v2.proto') const SignedAuthorityRecord = disco.lookupType('authority_discovery_v2.SignedAuthorityRecord') ``` 3) Resolve peer identities for the authorities. ```javascript for (const authKey of authorities) { const keyHash = crypto.createHash('sha256').update(authKey).digest() try { // find the key hash in the DHT for await (const res of this.dht.get(keyHash)) { if (res.type === 5) { // decode with the protobuf SignedAuthorityRecord type const rec = SignedAuthorityRecord.decode(res.value) // where 0x00 = no hash, 0x36 = id length const id = new Uint8Array([0, 36, ...rec.peerSignature.publicKey]) const authorityPeerId = peerIdFromBytes(id) console.log('Found', authorityPeerId, authKey) // ... } } } // ... } ``` 4) Have fun! (ಠ◡ಠ)