Skip to main content

lox_library/
cred.rs

1/*! The various credentials used by the system.
2
3In each case, (P,Q) forms the MAC on the credential. This MAC is
4verifiable only by the issuing party, or if the issuing party issues a
5zero-knowledge proof of its correctness (as it does at issuing time).*/
6
7use curve25519_dalek::ristretto::RistrettoPoint;
8use curve25519_dalek::scalar::Scalar;
9use serde::{Deserialize, Serialize};
10
11/// A migration credential.
12///
13/// This credential authorizes the holder of the Lox credential with the
14/// given id to switch from bucket from_bucket to bucket to_bucket. The
15/// migration_type attribute is 0 for trust upgrade migrations (moving
16/// from a 1-bridge untrusted bucket to a 3-bridge trusted bucket) and 1
17/// for blockage migrations (moving buckets because the from_bucket has
18/// been blocked).
19#[derive(Debug, Serialize, Deserialize)]
20pub struct Migration {
21    pub P: RistrettoPoint,
22    pub Q: RistrettoPoint,
23    pub lox_id: Scalar,
24    pub from_bucket: Scalar,
25    pub to_bucket: Scalar,
26    pub migration_type: Scalar,
27}
28
29/// The main user credential in the Lox system.
30///
31/// Its id is jointly generated by the user and the BA (bridge
32/// authority), but known only to the user. The level_since date is the
33/// Julian date of when this user was changed to the current trust
34/// level.
35#[derive(Debug, Serialize, Deserialize)]
36pub struct Lox {
37    pub P: RistrettoPoint,
38    pub Q: RistrettoPoint,
39    pub id: Scalar,
40    pub bucket: Scalar,
41    pub trust_level: Scalar,
42    pub level_since: Scalar,
43    pub invites_remaining: Scalar,
44    pub blockages: Scalar,
45}
46
47/// The migration key credential.
48///
49/// This credential is never actually instantiated. It is an implicit
50/// credential on attributes lox_id and from_bucket. This credential
51/// type does have an associated private and public key, however. The
52/// idea is that if a user proves (in zero knowledge) that their Lox
53/// credential entitles them to migrate from one bucket to another, the
54/// BA will issue a (blinded, so the BA will not know the values of the
55/// attributes or of Q) MAC on this implicit credential. The Q value
56/// will then be used (actually, a hash of lox_id, from_bucket, and Q)
57/// to encrypt the to_bucket, P, and Q fields of a Migration credential.
58/// That way, people entitled to migrate buckets can receive a Migration
59/// credential with their new bucket, without the BA learning either
60/// their old or new buckets.
61#[derive(Debug, Serialize, Deserialize)]
62pub struct MigrationKey {
63    pub P: RistrettoPoint,
64    pub Q: RistrettoPoint,
65    pub lox_id: Scalar,
66    pub from_bucket: Scalar,
67}
68
69/// The Bucket Reachability credential.
70///
71/// Each day, a credential of this type is put in each bucket that has
72/// at least a (configurable) threshold number of bridges that have not
73/// been blocked as of the given date. Users can present this
74/// credential (in zero knowledge) with today's date to prove that the
75/// bridges in their bucket have not been blocked, in order to gain a
76/// trust level.
77#[derive(Debug, Serialize, Deserialize)]
78pub struct BucketReachability {
79    pub P: RistrettoPoint,
80    pub Q: RistrettoPoint,
81    pub date: Scalar,
82    pub bucket: Scalar,
83}
84
85/// The Invitation credential.
86///
87/// These credentials allow a Lox user (the inviter) of sufficient trust
88/// (level 2 or higher) to invite someone else (the invitee) to join the
89/// system. The invitee ends up at trust level 1, in the _same bucket_
90/// as the inviter, and inherits the inviter's blockages count (so that
91/// you can't clear your blockages count simply by inviting yourself).
92/// Invitations expire after some amount of time.
93#[derive(Debug, Serialize, Deserialize)]
94pub struct Invitation {
95    pub P: RistrettoPoint,
96    pub Q: RistrettoPoint,
97    pub inv_id: Scalar,
98    pub date: Scalar,
99    pub bucket: Scalar,
100    pub blockages: Scalar,
101}