Internals - HelloZeroNet/Plugin-PeerMessage GitHub Wiki
This is docs about how PeerMessage works inside. It's likely that you don't need this. Again: YOU DON'T NEED THIS. Most developers don't know ZeroNet core architecture, how plugins work. Remember: you were warned.
Peer actions
peerBroadcast
and peerSend
Arguments:
raw
- JSON-encoded message object (see below).nonce
- a random integer chosen by message creator (see below).signature
- message signature, if it is signed, or empty string.cert
- certificate object (see below).
Message object
site
- site address.message
- message itself.immediate
- from caller's arguments.broadcast
- from caller's arguments.peer_count
- from caller's arguments.to
(only forpeerSend
) - from caller's arguments.
hash & nonce
Nonce is a random integer generated by message creator. Hash is calculated as sha256("%s,%s" % (nonce, json_encoded_message_object))
. Notice that msgpack
(the stuff ZeroNet works to send objects over network) and json
module don't guarantee that decode(encode(message))
is equal to message
. Object property order may be different. So message must be JSON-encoded on caller's side to save hash and signature (read below).
Certificate object
Certificate object is an array: [auth_type, auth_user_name, cert_issuer, cert_sign]
.
auth_type
is usuallyweb
(generated by most ID providers). It may bebitmessage
or something else - whatever the ID provider chooses.auth_user_name
is your name - e.g.gitcenter
.cert_issuer
iszeroid.bit
,kaffie.bit
or another site. This is specified on cert issuer's site usually.cert_sign
is from yourusers.json
.