# How to convert a Node Id (02... or 03...) from the Radix log file into a Validator Address (rv...)?

**URL:** <https://radixtalk.com/t/how-to-convert-a-node-id-02-or-03-from-the-radix-log-file-into-a-validator-address-rv/63>\
**Category:** Developers\
**Tags:** howto, python, replit\
**Created:** [25 December 2021 14:04 UTC](https://radixtalk.com/t/how-to-convert-a-node-id-02-or-03-from-the-radix-log-file-into-a-validator-address-rv/63 "2021-12-25T14:04:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stuart](https://radixtalk.com/letter_avatar_proxy/v4/letter/s/cab0a1/32.png) [@Stuart](https://radixtalk.com/u/Stuart)\
**Post date:** [25 December 2021 14:04 UTC](https://radixtalk.com/t/how-to-convert-a-node-id-02-or-03-from-the-radix-log-file-into-a-validator-address-rv/63/1 "2021-12-25T14:04:41Z")

</div>

The Node Id reported in the Radix Node logs is a compressed public key - it starts with either 02 or 03 and is 33 bytes long. To convert it into a Validator Address then just bech32 encode it with a human readable part of `rv.`

```python
import bech32

hrp = "rv"
node_id = "03d781270fcebe921a9517ead7f79ec4761a4dc80e2b8b705bc1f47938e1421305"

# Convert hex string into bytes
public_key = bytearray.fromhex(node_id)

# Convert from array of 8 bit unsigned integers to array of 5 bit unsigned integers
public_key5 = bech32.convertbits(public_key, 8, 5)

validator_address = bech32.bech32_encode(hrp, public_key5)
print("Validator Adddress:", validator_address)

# Validator Adddress: rv1q0tczfc0e6lfyx54zl4d0au7c3mp5nwgpc4ckuzmc868jw8pggfs2prskrz

```

_The python bech32 library we are using is a reference implementation for creating bitcoin segwit addresses so we have to do a bit of ceremony to convert the public key bytes from 8 bits to 5 bits and use a lower level encode function to work with Radix addresses._

## Run this code on Replit:

https://replit.com/@radixtalk/Public-Key-to-Validator?embed=true
