|
@@ -51,26 +51,29 @@ use super::super::dup_filter::SeenType;
|
|
|
use super::super::BridgeAuth;
|
|
|
use super::super::{scalar_u32, Scalar, G};
|
|
|
use super::errors::CredentialError;
|
|
|
+use super::level_up::{LEVEL_INVITATIONS, MAX_LEVEL};
|
|
|
use crate::lox_creds::{BucketReachability, Invitation, Lox};
|
|
|
use cmz::*;
|
|
|
use group::Group;
|
|
|
use rand::{CryptoRng, RngCore};
|
|
|
use sha2::Sha512;
|
|
|
|
|
|
+const SESSION_ID: &[u8] = b"issue_invite";
|
|
|
+
|
|
|
/// Invitations must be used within this many days of being issued.
|
|
|
/// Note that if you change this number to be larger than 15, you must
|
|
|
/// also add bits to the zero knowledge proof.
|
|
|
pub const INVITATION_EXPIRY: u32 = 15;
|
|
|
|
|
|
-muCMZProtocol! { issue_invite,
|
|
|
+muCMZProtocol! { issue_invite<max_invitations>,
|
|
|
[L: Lox {id: R, bucket: H, trust_level: H, level_since: H, invites_remaining: H, blockages: H}, B: BucketReachability { date: R, bucket: H } ],
|
|
|
[ I: Invitation { inv_id: J, date: S, bucket: H, blockages: H }, N: Lox {id: J, bucket: H, trust_level: H, level_since: H, invites_remaining: H, blockages: H }],
|
|
|
L.bucket = B.bucket,
|
|
|
- L.invites_remaining != 0,
|
|
|
+ (1..=max_invitations).contains(L.invites_remaining),
|
|
|
N.bucket = L.bucket,
|
|
|
N.trust_level = L.trust_level,
|
|
|
N.level_since = L.level_since,
|
|
|
- N.invites_remaining = L.invites_remaining - 1,
|
|
|
+// N.invites_remaining = L.invites_remaining - 1,
|
|
|
N.blockages = L.blockages,
|
|
|
I. bucket = L.bucket,
|
|
|
I.blockages = L.blockages
|
|
@@ -121,12 +124,18 @@ pub fn request(
|
|
|
));
|
|
|
}
|
|
|
|
|
|
+ let params = issue_invite::Params {
|
|
|
+ max_invitations: LEVEL_INVITATIONS[MAX_LEVEL].into(),
|
|
|
+ };
|
|
|
+
|
|
|
match issue_invite::prepare(
|
|
|
&mut rng,
|
|
|
+ SESSION_ID,
|
|
|
&L,
|
|
|
&B,
|
|
|
Invitation::using_pubkey(&inv_pub),
|
|
|
Lox::using_pubkey(&lox_pubkeys),
|
|
|
+ ¶ms,
|
|
|
) {
|
|
|
Ok(req_state) => Ok(req_state),
|
|
|
Err(e) => Err(CredentialError::CMZError(e)),
|
|
@@ -145,6 +154,7 @@ impl BridgeAuth {
|
|
|
let today = self.today();
|
|
|
match issue_invite::handle(
|
|
|
&mut rng,
|
|
|
+ SESSION_ID,
|
|
|
recvreq,
|
|
|
|L: &mut Lox, B: &mut BucketReachability, I: &mut Invitation, N: &mut Lox| {
|
|
|
L.set_privkey(&self.lox_priv);
|
|
@@ -162,7 +172,9 @@ impl BridgeAuth {
|
|
|
N.blockages = L.blockages;
|
|
|
I.bucket = N.bucket;
|
|
|
I.blockages = L.blockages;
|
|
|
- Ok(())
|
|
|
+ Ok(issue_invite::Params {
|
|
|
+ max_invitations: LEVEL_INVITATIONS[MAX_LEVEL].into(),
|
|
|
+ })
|
|
|
},
|
|
|
|_L: &Lox, _B: &BucketReachability, I: &Invitation, _N: &Lox| {
|
|
|
if self.inv_id_filter.filter(&I.inv_id.unwrap()) == SeenType::Seen {
|