migration.rs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /*! A module for the protocol for the user to migrate from one bucket to
  2. another (and possibly also change trust level).
  3. For the case of migrating from trust level 0 (a one-bridge bucket) to
  4. trust level 1 (a three-bridge bucket), the user presents their current
  5. Lox credential:
  6. - id: revealed
  7. - bucket: blinded
  8. - trust_level: revealed to be 0
  9. - level_since: blinded
  10. - invites_remaining: revealed to be 0
  11. - invites_issued: revealed to be 0
  12. and a Migration credential:
  13. - id: revealed as the same as the Lox credential id above
  14. - from_bucket: blinded, but proved in ZK that it's the same as the
  15. bucket in the Lox credential above
  16. - to_bucket: blinded
  17. and a new Lox credential to be issued:
  18. - id: jointly chosen by the user and BA
  19. - bucket: blinded, but proved in ZK that it's the same as the to_bucket
  20. in the Migration credential above
  21. - trust_level: 1
  22. - level_since: today
  23. - invites_remaining: 0
  24. - invites_issued: 0
  25. */
  26. use curve25519_dalek::ristretto::RistrettoBasepointTable;
  27. use curve25519_dalek::ristretto::RistrettoPoint;
  28. use curve25519_dalek::scalar::Scalar;
  29. use curve25519_dalek::traits::IsIdentity;
  30. use zkp::CompactProof;
  31. use zkp::ProofError;
  32. use zkp::Transcript;
  33. use super::cred;
  34. use super::{BridgeAuth, IssuerPubKey};
  35. use super::{CMZ_A, CMZ_A_TABLE, CMZ_B, CMZ_B_TABLE};
  36. pub struct Request {
  37. // Fields for blind showing the Lox credential
  38. // We don't need to include invites_remaining or invites_issued,
  39. // since they must be 0
  40. P_lox: RistrettoPoint,
  41. id: Scalar,
  42. CBucket: RistrettoPoint,
  43. trust_level: Scalar,
  44. CSince: RistrettoPoint,
  45. CQ_lox: RistrettoPoint,
  46. // Fields for blind showing the Migration credential
  47. P_mig: RistrettoPoint,
  48. CFromBucket: RistrettoPoint,
  49. CToBucket: RistrettoPoint,
  50. CQ_mig: RistrettoPoint,
  51. // Fields for user blinding of the Lox credential to be issued
  52. D: RistrettoPoint,
  53. EncIdClient: (RistrettoPoint, RistrettoPoint),
  54. EncBucket: (RistrettoPoint, RistrettoPoint),
  55. // The combined ZKP
  56. piUser: CompactProof,
  57. }
  58. #[derive(Debug)]
  59. pub struct State {
  60. d: Scalar,
  61. D: RistrettoPoint,
  62. EncIdClient: (RistrettoPoint, RistrettoPoint),
  63. EncBucket: (RistrettoPoint, RistrettoPoint),
  64. id_client: Scalar,
  65. to_bucket: Scalar,
  66. }
  67. pub struct Response {
  68. // The new attributes; trust_level = 1 is implicit
  69. level_since: Scalar,
  70. // The fields for the new Lox credential
  71. P: RistrettoPoint,
  72. EncQ: (RistrettoPoint, RistrettoPoint),
  73. id_server: Scalar,
  74. TId: RistrettoPoint,
  75. TBucket: RistrettoPoint,
  76. // The fields for the implicit noop migration ("nm") credential
  77. P_nm: RistrettoPoint,
  78. EncQ_nm: (RistrettoPoint, RistrettoPoint),
  79. TId_nm: RistrettoPoint,
  80. TBucket_nm: RistrettoPoint,
  81. // The ZKP
  82. piBlindIssue: CompactProof,
  83. }
  84. define_proof! {
  85. requestproof,
  86. "Migration Request",
  87. (bucket, since, zbucket, zsince, negzQ_lox,
  88. tobucket, zfrombucket, ztobucket, negzQ_mig,
  89. d, eid_client, ebucket, id_client),
  90. (P_lox, CBucket, CSince, V_lox, Xbucket, Xsince,
  91. P_mig, CFromBucket, CToBucket, V_mig, Xfrombucket, Xtobucket,
  92. D, EncIdClient0, EncIdClient1, EncBucket0, EncBucket1),
  93. (A, B):
  94. // Blind showing of the Lox credential
  95. CBucket = (bucket*P_lox + zbucket*A),
  96. CSince = (since*P_lox + zsince*A),
  97. V_lox = (zbucket*Xbucket + zsince*Xsince + negzQ_lox*A),
  98. // Blind showing of the Migration credential; note the use of the
  99. // same "bucket" secret variable
  100. CFromBucket = (bucket*P_mig + zfrombucket*A),
  101. CToBucket = (tobucket*P_mig + ztobucket*A),
  102. V_mig = (zfrombucket*Xfrombucket + ztobucket*Xtobucket + negzQ_mig*A),
  103. // User blinding of the Lox credential to be issued; note the use of
  104. // the same "tobucket" secret variable
  105. EncIdClient0 = (eid_client*B),
  106. EncIdClient1 = (id_client*B + eid_client*D),
  107. EncBucket0 = (ebucket*B),
  108. EncBucket1 = (tobucket*B + ebucket*D),
  109. D = (d*B)
  110. }
  111. define_proof! {
  112. blindissue,
  113. "Migration Blind Issuing",
  114. (x0, x0tilde, xid, xbucket, xlevel, xsince, s, b, tid, tbucket,
  115. x0_nm, x0tilde_nm, xid_nm, xfrom_nm, xto_nm, s_nm, b_nm, tid_nm, tbucket_nm),
  116. (P, EncQ0, EncQ1, X0, Xid, Xbucket, Xlevel, Xsince, Plevel, Psince, TId, TBucket,
  117. P_nm, EncQ0_nm, EncQ1_nm, X0_nm, Xid_nm, Xfrom_nm, Xto_nm,
  118. TId_nm, TBucket_nm,
  119. D, EncId0, EncId1, EncBucket0, EncBucket1),
  120. (A, B):
  121. Xid = (xid*A),
  122. Xlevel = (xlevel*A),
  123. Xbucket = (xbucket*A),
  124. Xsince = (xsince*A),
  125. X0 = (x0*B + x0tilde*A),
  126. P = (b*B),
  127. TId = (b*Xid),
  128. TId = (tid*A),
  129. TBucket = (b*Xbucket),
  130. TBucket = (tbucket*A),
  131. EncQ0 = (s*B + tid*EncId0 + tbucket*EncBucket0),
  132. EncQ1 = (s*D + tid*EncId1 + tbucket*EncBucket1 + x0*P + xlevel*Plevel + xsince*Psince),
  133. Xid_nm = (xid_nm*A),
  134. Xfrom_nm = (xfrom_nm*A),
  135. Xto_nm = (xto_nm*A),
  136. X0_nm = (x0_nm*B + x0tilde_nm*A),
  137. P_nm = (b_nm*B),
  138. TId_nm = (b_nm*Xid_nm),
  139. TId_nm = (tid_nm*A),
  140. TBucket_nm = (b_nm*Xfrom_nm + b_nm*Xto_nm),
  141. TBucket_nm = (tbucket_nm*A),
  142. EncQ0_nm = (s_nm*B + tid_nm*EncId0 + tbucket_nm*EncBucket0),
  143. EncQ1_nm = (s_nm*D + tid_nm*EncId1 + tbucket_nm*EncBucket1 + x0_nm*P_nm)
  144. }
  145. pub fn request(
  146. lox_cred: &cred::Lox,
  147. migration_cred: &cred::Migration,
  148. lox_pub: &IssuerPubKey,
  149. migration_pub: &IssuerPubKey,
  150. ) -> Result<(Request, State), ProofError> {
  151. let A: &RistrettoPoint = &CMZ_A;
  152. let B: &RistrettoPoint = &CMZ_B;
  153. let Atable: &RistrettoBasepointTable = &CMZ_A_TABLE;
  154. let Btable: &RistrettoBasepointTable = &CMZ_B_TABLE;
  155. // Ensure that the credenials can be correctly shown; that is, the
  156. // ids match and the Lox credential bucket matches the Migration
  157. // credential from_bucket
  158. if lox_cred.id != migration_cred.lox_id || lox_cred.bucket != migration_cred.from_bucket {
  159. return Err(ProofError::VerificationFailure);
  160. }
  161. // We only support migrating from trust level 0 to trust level 1
  162. // right now
  163. if lox_cred.trust_level != Scalar::zero() {
  164. return Err(ProofError::VerificationFailure);
  165. }
  166. // Blind showing the Lox credential
  167. // Reblind P and Q
  168. let mut rng = rand::thread_rng();
  169. let t_lox = Scalar::random(&mut rng);
  170. let P_lox = t_lox * lox_cred.P;
  171. let Q_lox = t_lox * lox_cred.Q;
  172. // Form Pedersen commitments to the blinded attributes
  173. let zbucket = Scalar::random(&mut rng);
  174. let zsince = Scalar::random(&mut rng);
  175. let CBucket = lox_cred.bucket * P_lox + &zbucket * Atable;
  176. let CSince = lox_cred.level_since * P_lox + &zsince * Atable;
  177. // Form a Pedersen commitment to the MAC Q
  178. // We flip the sign of zQ from that of the Hyphae paper so that
  179. // the ZKP has a "+" instead of a "-", as that's what the zkp
  180. // macro supports.
  181. let negzQ_lox = Scalar::random(&mut rng);
  182. let CQ_lox = Q_lox - &negzQ_lox * Atable;
  183. // Compute the "error factor"
  184. let V_lox = zbucket * lox_pub.X[2] + zsince * lox_pub.X[4] + &negzQ_lox * Atable;
  185. // Blind showing the Migration credential
  186. // Reblind P and Q
  187. let t_mig = Scalar::random(&mut rng);
  188. let P_mig = t_mig * migration_cred.P;
  189. let Q_mig = t_mig * migration_cred.Q;
  190. // Form Pedersen commitments to the blinded attributes
  191. let zfrombucket = Scalar::random(&mut rng);
  192. let ztobucket = Scalar::random(&mut rng);
  193. let CFromBucket = migration_cred.from_bucket * P_mig + &zfrombucket * Atable;
  194. let CToBucket = migration_cred.to_bucket * P_mig + &ztobucket * Atable;
  195. // Form a Pedersen commitment to the MAC Q
  196. // We flip the sign of zQ from that of the Hyphae paper so that
  197. // the ZKP has a "+" instead of a "-", as that's what the zkp
  198. // macro supports.
  199. let negzQ_mig = Scalar::random(&mut rng);
  200. let CQ_mig = Q_mig - &negzQ_mig * Atable;
  201. // Compute the "error factor"
  202. let V_mig =
  203. zfrombucket * migration_pub.X[2] + ztobucket * migration_pub.X[3] + &negzQ_mig * Atable;
  204. // User blinding for the Lox certificate to be issued
  205. // Pick an ElGamal keypair
  206. let d = Scalar::random(&mut rng);
  207. let D = &d * Btable;
  208. // Pick a random client component of the id
  209. let id_client = Scalar::random(&mut rng);
  210. // Encrypt it (times the basepoint B) to the ElGamal public key D we
  211. // just created
  212. let eid_client = Scalar::random(&mut rng);
  213. let EncIdClient = (&eid_client * Btable, &id_client * Btable + eid_client * D);
  214. // Encrypt the bucket field (times B) to D as well
  215. let ebucket = Scalar::random(&mut rng);
  216. let EncBucket = (
  217. &ebucket * Btable,
  218. &migration_cred.to_bucket * Btable + ebucket * D,
  219. );
  220. // Construct the proof
  221. let mut transcript = Transcript::new(b"migration request");
  222. let piUser = requestproof::prove_compact(
  223. &mut transcript,
  224. requestproof::ProveAssignments {
  225. A: &A,
  226. B: &B,
  227. P_lox: &P_lox,
  228. CBucket: &CBucket,
  229. CSince: &CSince,
  230. V_lox: &V_lox,
  231. Xbucket: &lox_pub.X[2],
  232. Xsince: &lox_pub.X[4],
  233. P_mig: &P_mig,
  234. CFromBucket: &CFromBucket,
  235. CToBucket: &CToBucket,
  236. V_mig: &V_mig,
  237. Xfrombucket: &migration_pub.X[2],
  238. Xtobucket: &migration_pub.X[3],
  239. D: &D,
  240. EncIdClient0: &EncIdClient.0,
  241. EncIdClient1: &EncIdClient.1,
  242. EncBucket0: &EncBucket.0,
  243. EncBucket1: &EncBucket.1,
  244. bucket: &lox_cred.bucket,
  245. since: &lox_cred.level_since,
  246. zbucket: &zbucket,
  247. zsince: &zsince,
  248. negzQ_lox: &negzQ_lox,
  249. tobucket: &migration_cred.to_bucket,
  250. zfrombucket: &zfrombucket,
  251. ztobucket: &ztobucket,
  252. negzQ_mig: &negzQ_mig,
  253. d: &d,
  254. eid_client: &eid_client,
  255. ebucket: &ebucket,
  256. id_client: &id_client,
  257. },
  258. )
  259. .0;
  260. Ok((
  261. Request {
  262. P_lox,
  263. id: lox_cred.id,
  264. CBucket,
  265. trust_level: lox_cred.trust_level,
  266. CSince,
  267. CQ_lox,
  268. P_mig,
  269. CFromBucket,
  270. CToBucket,
  271. CQ_mig,
  272. D,
  273. EncIdClient,
  274. EncBucket,
  275. piUser,
  276. },
  277. State {
  278. d,
  279. D,
  280. EncIdClient,
  281. EncBucket,
  282. id_client,
  283. to_bucket: migration_cred.to_bucket,
  284. },
  285. ))
  286. }
  287. impl BridgeAuth {
  288. /// Receive a migration request
  289. pub fn handle_migration(&mut self, req: Request) -> Result<Response, ProofError> {
  290. let A: &RistrettoPoint = &CMZ_A;
  291. let B: &RistrettoPoint = &CMZ_B;
  292. let Atable: &RistrettoBasepointTable = &CMZ_A_TABLE;
  293. let Btable: &RistrettoBasepointTable = &CMZ_B_TABLE;
  294. if req.P_lox.is_identity() || req.P_mig.is_identity() {
  295. return Err(ProofError::VerificationFailure);
  296. }
  297. // We only currently support migrating from trust level 0
  298. if req.trust_level != Scalar::zero() {
  299. return Err(ProofError::VerificationFailure);
  300. }
  301. // Recompute the "error factors" using knowledge of our own
  302. // (the issuer's) private key instead of knowledge of the
  303. // hidden attributes
  304. let Vprime_lox = (self.lox_priv.x[0]
  305. + self.lox_priv.x[1] * req.id
  306. + self.lox_priv.x[3] * req.trust_level)
  307. * req.P_lox
  308. + self.lox_priv.x[2] * req.CBucket
  309. + self.lox_priv.x[4] * req.CSince
  310. - req.CQ_lox;
  311. let Vprime_mig = (self.migration_priv.x[0] + self.migration_priv.x[1] * req.id) * req.P_mig
  312. + self.migration_priv.x[2] * req.CFromBucket
  313. + self.migration_priv.x[3] * req.CToBucket
  314. - req.CQ_mig;
  315. // Verify the ZKP
  316. let mut transcript = Transcript::new(b"migration request");
  317. requestproof::verify_compact(
  318. &req.piUser,
  319. &mut transcript,
  320. requestproof::VerifyAssignments {
  321. A: &A.compress(),
  322. B: &B.compress(),
  323. P_lox: &req.P_lox.compress(),
  324. CBucket: &req.CBucket.compress(),
  325. CSince: &req.CSince.compress(),
  326. V_lox: &Vprime_lox.compress(),
  327. Xbucket: &self.lox_pub.X[2].compress(),
  328. Xsince: &self.lox_pub.X[4].compress(),
  329. P_mig: &req.P_mig.compress(),
  330. CFromBucket: &req.CFromBucket.compress(),
  331. CToBucket: &req.CToBucket.compress(),
  332. V_mig: &Vprime_mig.compress(),
  333. Xfrombucket: &self.migration_pub.X[2].compress(),
  334. Xtobucket: &self.migration_pub.X[3].compress(),
  335. D: &req.D.compress(),
  336. EncIdClient0: &req.EncIdClient.0.compress(),
  337. EncIdClient1: &req.EncIdClient.1.compress(),
  338. EncBucket0: &req.EncBucket.0.compress(),
  339. EncBucket1: &req.EncBucket.1.compress(),
  340. },
  341. )?;
  342. // Blind issuing of the new Lox credential
  343. // Choose a random server id component to add to the client's
  344. // (blinded) id component
  345. let mut rng = rand::thread_rng();
  346. let id_server = Scalar::random(&mut rng);
  347. let EncId = (req.EncIdClient.0, req.EncIdClient.1 + &id_server * Btable);
  348. // Create the trust_level attrubute (Scalar), which will be
  349. // level 1
  350. let trust_level: Scalar = Scalar::one();
  351. // Create the level_since attribute (Scalar), which is today's
  352. // Julian date
  353. let level_since: Scalar = self.today().into();
  354. // The invitations_remaining and invitations_issued attributes
  355. // are 0 for level 0 and level 1 Lox credentials, so we don't
  356. // need to explicitly create them.
  357. // Compute the MAC on the visible attributes
  358. let b = Scalar::random(&mut rng);
  359. let P = &b * Btable;
  360. // invites_remaining = invites_issued = 0
  361. let QHc = (self.lox_priv.x[0]
  362. + self.lox_priv.x[3] * trust_level
  363. + self.lox_priv.x[4] * level_since)
  364. * P;
  365. // El Gamal encrypt it to the public key req.D
  366. let s = Scalar::random(&mut rng);
  367. let EncQHc = (&s * Btable, QHc + s * req.D);
  368. // Homomorphically compute the part of the MAC corresponding to
  369. // the blinded id attribute
  370. let tid = self.lox_priv.x[1] * b;
  371. let TId = &tid * Atable;
  372. let EncQId = (tid * EncId.0, tid * EncId.1);
  373. let tbucket = self.lox_priv.x[2] * b;
  374. let TBucket = &tbucket * Atable;
  375. let EncQBucket = (tbucket * req.EncBucket.0, tbucket * req.EncBucket.1);
  376. let EncQ = (
  377. EncQHc.0 + EncQId.0 + EncQBucket.0,
  378. EncQHc.1 + EncQId.1 + EncQBucket.1,
  379. );
  380. // Now the no-op migration credential
  381. // Compute the MAC on the visible attributes (none here)
  382. let b_nm = Scalar::random(&mut rng);
  383. let P_nm = &b_nm * Btable;
  384. let QHc_nm = (self.migration_priv.x[0]) * P_nm;
  385. // El Gamal encrypt it to the public key req.D
  386. let s_nm = Scalar::random(&mut rng);
  387. let EncQHc_nm = (&s_nm * Btable, QHc_nm + s_nm * req.D);
  388. // Homomorphically compute the part of the MAC corresponding to
  389. // the blinded attributes
  390. let tid_nm = self.migration_priv.x[1] * b_nm;
  391. let TId_nm = &tid_nm * Atable;
  392. let EncQId_nm = (tid_nm * EncId.0, tid_nm * EncId.1);
  393. let tbucket_nm = (self.migration_priv.x[2] + self.migration_priv.x[3]) * b_nm;
  394. let TBucket_nm = &tbucket_nm * Atable;
  395. let EncQBucket_nm = (tbucket_nm * req.EncBucket.0, tbucket_nm * req.EncBucket.1);
  396. let EncQ_nm = (
  397. EncQHc_nm.0 + EncQId_nm.0 + EncQBucket_nm.0,
  398. EncQHc_nm.1 + EncQId_nm.1 + EncQBucket_nm.1,
  399. );
  400. let mut transcript = Transcript::new(b"migration issuing");
  401. let piBlindIssue = blindissue::prove_compact(
  402. &mut transcript,
  403. blindissue::ProveAssignments {
  404. A: &A,
  405. B: &B,
  406. P: &P,
  407. EncQ0: &EncQ.0,
  408. EncQ1: &EncQ.1,
  409. X0: &self.lox_pub.X[0],
  410. Xid: &self.lox_pub.X[1],
  411. Xbucket: &self.lox_pub.X[2],
  412. Xlevel: &self.lox_pub.X[3],
  413. Xsince: &self.lox_pub.X[4],
  414. Plevel: &(trust_level * P),
  415. Psince: &(level_since * P),
  416. TId: &TId,
  417. TBucket: &TBucket,
  418. P_nm: &P_nm,
  419. EncQ0_nm: &EncQ_nm.0,
  420. EncQ1_nm: &EncQ_nm.1,
  421. X0_nm: &self.migration_pub.X[0],
  422. Xid_nm: &self.migration_pub.X[1],
  423. Xfrom_nm: &self.migration_pub.X[2],
  424. Xto_nm: &self.migration_pub.X[3],
  425. TId_nm: &TId_nm,
  426. TBucket_nm: &TBucket_nm,
  427. D: &req.D,
  428. EncId0: &EncId.0,
  429. EncId1: &EncId.1,
  430. EncBucket0: &req.EncBucket.0,
  431. EncBucket1: &req.EncBucket.1,
  432. x0: &self.lox_priv.x[0],
  433. x0tilde: &self.lox_priv.x0tilde,
  434. xid: &self.lox_priv.x[1],
  435. xbucket: &self.lox_priv.x[2],
  436. xlevel: &self.lox_priv.x[3],
  437. xsince: &self.lox_priv.x[4],
  438. s: &s,
  439. b: &b,
  440. tid: &tid,
  441. tbucket: &tbucket,
  442. x0_nm: &self.migration_priv.x[0],
  443. x0tilde_nm: &self.migration_priv.x0tilde,
  444. xid_nm: &self.migration_priv.x[1],
  445. xfrom_nm: &self.migration_priv.x[2],
  446. xto_nm: &self.migration_priv.x[3],
  447. s_nm: &s_nm,
  448. b_nm: &b_nm,
  449. tid_nm: &tid_nm,
  450. tbucket_nm: &tbucket_nm,
  451. },
  452. )
  453. .0;
  454. Ok(Response {
  455. level_since,
  456. P,
  457. EncQ,
  458. id_server,
  459. TId,
  460. TBucket,
  461. P_nm,
  462. EncQ_nm,
  463. TId_nm,
  464. TBucket_nm,
  465. piBlindIssue,
  466. })
  467. }
  468. }
  469. /// Handle the response to the request, producing the new Lox credential
  470. /// if successful.
  471. pub fn handle_response(
  472. state: State,
  473. resp: Response,
  474. lox_pub: &IssuerPubKey,
  475. migration_pub: &IssuerPubKey,
  476. ) -> Result<cred::Lox, ProofError> {
  477. let A: &RistrettoPoint = &CMZ_A;
  478. let B: &RistrettoPoint = &CMZ_B;
  479. let Btable: &RistrettoBasepointTable = &CMZ_B_TABLE;
  480. if resp.P.is_identity() || resp.P_nm.is_identity() {
  481. return Err(ProofError::VerificationFailure);
  482. }
  483. // Add the server's contribution to the id to our own, both in plain
  484. // and encrypted form
  485. let id = state.id_client + resp.id_server;
  486. let EncId = (
  487. state.EncIdClient.0,
  488. state.EncIdClient.1 + &resp.id_server * Btable,
  489. );
  490. // Verify the proof
  491. let mut transcript = Transcript::new(b"migration issuing");
  492. blindissue::verify_compact(
  493. &resp.piBlindIssue,
  494. &mut transcript,
  495. blindissue::VerifyAssignments {
  496. A: &A.compress(),
  497. B: &B.compress(),
  498. P: &resp.P.compress(),
  499. EncQ0: &resp.EncQ.0.compress(),
  500. EncQ1: &resp.EncQ.1.compress(),
  501. X0: &lox_pub.X[0].compress(),
  502. Xid: &lox_pub.X[1].compress(),
  503. Xbucket: &lox_pub.X[2].compress(),
  504. Xlevel: &lox_pub.X[3].compress(),
  505. Xsince: &lox_pub.X[4].compress(),
  506. // The new trust level is 1
  507. Plevel: &(Scalar::one() * resp.P).compress(),
  508. Psince: &(resp.level_since * resp.P).compress(),
  509. TId: &resp.TId.compress(),
  510. TBucket: &resp.TBucket.compress(),
  511. P_nm: &resp.P_nm.compress(),
  512. EncQ0_nm: &resp.EncQ_nm.0.compress(),
  513. EncQ1_nm: &resp.EncQ_nm.1.compress(),
  514. X0_nm: &migration_pub.X[0].compress(),
  515. Xid_nm: &migration_pub.X[1].compress(),
  516. Xfrom_nm: &migration_pub.X[2].compress(),
  517. Xto_nm: &migration_pub.X[3].compress(),
  518. TId_nm: &resp.TId_nm.compress(),
  519. TBucket_nm: &resp.TBucket_nm.compress(),
  520. D: &state.D.compress(),
  521. EncId0: &EncId.0.compress(),
  522. EncId1: &EncId.1.compress(),
  523. EncBucket0: &state.EncBucket.0.compress(),
  524. EncBucket1: &state.EncBucket.1.compress(),
  525. },
  526. )?;
  527. // Decrypt EncQ
  528. let Q = resp.EncQ.1 - (state.d * resp.EncQ.0);
  529. // Decrypt EncQ_nm
  530. let Q_nm = resp.EncQ_nm.1 - (state.d * resp.EncQ_nm.0);
  531. Ok(cred::Lox {
  532. P: resp.P,
  533. Q,
  534. id,
  535. bucket: state.to_bucket,
  536. trust_level: Scalar::one(),
  537. level_since: resp.level_since,
  538. invites_remaining: Scalar::zero(),
  539. invites_issued: Scalar::zero(),
  540. P_noopmigration: resp.P_nm,
  541. Q_noopmigration: Q_nm,
  542. })
  543. }