cred.rs 3.6 KB

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