mcl_core_lan_challenge (mcl_core v1.0.0)

View Source

The 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

handle_call(Request, From, State)

handle_cast(Msg, State)

handle_info(Info, State)

init(_)

issue(NodeId)

-spec issue(<<_:256>>) -> <<_:256>>.

A fresh challenge for NodeId. The caller has checked the list.

live(Nonce, NodeId)

-spec live(term(), <<_:256>>) -> boolean().

Whether Nonce is a live challenge issued to NodeId. Leaves it.

start_link()

take(Nonce, NodeId)

-spec take(term(), <<_:256>>) -> boolean().

Redeem Nonce for NodeId: true once, when it is live and was issued to NodeId; it is gone afterwards either way.

ttl_ms()

-spec ttl_ms() -> pos_integer().

How long a challenge lives.