Helpful utility functions


Create a nonce with expiration timestamp included

Parameters:expiry – a datetime that indicates when the nonce self-expires, defaults to now + 30 minutes
oneid.nonces.set_nonce_handlers(nonce_verifier, nonce_burner, include_context=False)[source]

Sets the functions to verify nonces and record their use.

By default, the nonces are saved in a local file named ~/.oneid/used_nonces.txt (or equivalent)

  • nonce_burner – function to be called to verify.
  • nonce_verifier – function to be called to burn.
  • include_context – if True, both the nonce and context will be passed to the functions, otherwise, only the nonce will.
oneid.nonces.verify_nonce(nonce, expiry=None, context=None)[source]

Ensure that the nonce is correct, and not from the future

Callers should also store used nonces and reject messages with previously-used ones.

  • nonce – Nonce as created with make_nonce()
  • expiry – If not None, a datetime before which the nonce is not valid
  • context – optional data that will be passed to the caller’s verifier function

True only if nonce meets validation criteria

Return type: