1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Proving an account without handing over its secret.
//!
//! The account holds an X25519 keypair derived from the seed. Only the public
//! half is uploaded, once, at account creation. Unlocking is a
//! challenge-response and the private half never leaves this machine:
//!
//! 1. The client asks for a challenge, naming the account id.
//! 2. The server mints a single-use nonce AND an ephemeral X25519 keypair,
//! keeps the private half, and returns the nonce with the public half.
//! 3. The client computes `X25519(account_private, ephemeral_public)` and
//! answers with an HMAC over the nonce under that shared secret.
//! 4. The server computes `X25519(ephemeral_private, account_public)`, which
//! is the same value, and compares in constant time.
//!
//! Nothing secret is transmitted in either direction, and the answer is
//! worthless afterwards because the nonce is consumed and the ephemeral key
//! discarded.
//!
//! What is given up is third-party verifiability: an HMAC under a shared
//! secret proves possession to THIS server and to nobody else, because the
//! server can compute the same value. That is the correct shape for a login
//! and the wrong shape for a signature, so nothing here should ever be
//! repurposed as one.
use crate;
use crate;
use ;
pub const DOMAIN: &str = "mailcycle/v1/auth-proof";
/// Confirming the account's erasure, so an unlock proof cannot stand in for it.
pub const DELETE_DOMAIN: &str = "mailcycle/v1/delete-proof";
/// The answer to a challenge.
///
/// The account id is inside the MAC as well as the nonce, so a proof captured
/// for one account cannot be presented for another even if a server reused a
/// nonce across them.