Skip to content

NKN Client Protocol

Lucien Grondin edited this page Apr 15, 2022 · 4 revisions

NKN client can be written in any language as long as the following protocol is implemented.

Client NKN address

Each client has a unique and permanent NKN address, which consists of an arbitrary string and a public key, see more at https://github.com/nknorg/nkn/wiki/Tech-Design-Doc%3A-NKN-Address-Scheme#clients

Note that all communications with nodes use the pre-hash raw string "anything.public" for client NKN address.

Currently the key pair is generated with p256r1 curve, but we plan to move to ed25519 soon. The cryptographic scheme used is based on the ed25519 twisted Edwards' curve.

Connect to node

Each NKN client has a designated NKN node it should establish websocket connection depending on the client NKN address. Trying to connect to other nodes will get an error. During initialization, client should make a JSON-RPC call getwsaddr to get the node it should establish websocket connection with.

After getting the node websocket address, it should establish a websocket connection and send setClient message to register with the node before sending anything.

Send packet

Send sendPacket message to node through websocket.

Receive packet

A receivePacket message will be pushed from node through websocket.