cred.rs 3.3 KB

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