cred.rs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. (P_noopmigration, Q_noopmigration) are the MAC on the
  25. /// implicit no-op migration credential formed by the attributes (id,
  26. /// bucket, bucket), which authorizes the user to switch from its
  27. /// current bucket to the same bucket (i.e., a no-op). This can be
  28. /// useful for hiding from the BA whether or not the user is performing
  29. /// a bucket migration.
  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 invites_issued: Scalar,
  40. pub P_noopmigration: RistrettoPoint,
  41. pub Q_noopmigration: RistrettoPoint,
  42. }
  43. /// The migration key credential.
  44. ///
  45. /// This credential is never actually instantiated. It is an implicit
  46. /// credential on attributes lox_id and from_bucket. This credential
  47. /// type does have an associated private and public key, however. The
  48. /// idea is that if a user proves (in zero knowledge) that their Lox
  49. /// credential entitles them to migrate from one bucket to another, the
  50. /// BA will issue a (blinded, so the BA will not know the values of the
  51. /// attributes or of Q) MAC on this implicit credential. The Q value
  52. /// will then be used (actually, a hash of lox_id, from_bucket, and Q)
  53. /// to encrypt the to_bucket, P, and Q fields of a Migration credential.
  54. /// That way, people entitled to migrate buckets can receive a Migration
  55. /// credential with their new bucket, without the BA learning either
  56. /// their old or new buckets.
  57. #[derive(Debug)]
  58. pub struct MigrationKey {
  59. pub P: RistrettoPoint,
  60. pub Q: RistrettoPoint,
  61. pub lox_id: Scalar,
  62. pub from_bucket: Scalar,
  63. }
  64. /// The Bucket Reachability credential.
  65. ///
  66. /// Each day, a credential of this type is put in each bucket that has
  67. /// at least a (configurable) threshold number of bridges that have not
  68. /// been blocked as of the given date. Users can present this
  69. /// credential (in zero knowledge) with today's date to prove that the
  70. /// bridges in their bucket have not been blocked, in order to gain a
  71. /// trust level.
  72. #[derive(Debug)]
  73. pub struct BucketReachability {
  74. pub P: RistrettoPoint,
  75. pub Q: RistrettoPoint,
  76. pub date: Scalar,
  77. pub bucket: Scalar,
  78. }