mcl_core_lan_challenge (mcl_core v1.0.0)
View SourceThe LAN entry point's challenges (docs/DESIGN.md §4.2, mcl-core#4).
A challenge is 32 random bytes issued to one listed node id, kept in this node's memory for 60 seconds, and removed when it is redeemed: a signed challenge buys one token, and only at the node that issued it. Redeeming is an atomic ets:take, so of two requests carrying the same signed challenge exactly one gets it.
Node ids are not secret, so anyone may ask for challenges under a listed one: at most ?PER_NODE live challenges are kept per node id, the oldest dropped first, and expired ones are swept, so the table stays bounded by the list.
Summary
Functions
A fresh challenge for NodeId. The caller has checked the list.
Whether Nonce is a live challenge issued to NodeId. Leaves it.
Redeem Nonce for NodeId: true once, when it is live and was issued to NodeId; it is gone afterwards either way.
How long a challenge lives.
Functions
-spec issue(<<_:256>>) -> <<_:256>>.
A fresh challenge for NodeId. The caller has checked the list.
Whether Nonce is a live challenge issued to NodeId. Leaves it.
Redeem Nonce for NodeId: true once, when it is live and was issued to NodeId; it is gone afterwards either way.
-spec ttl_ms() -> pos_integer().
How long a challenge lives.