From 9ce2a81fe722be6438a6df567a01b6458922cc4e Mon Sep 17 00:00:00 2001 From: onyinyang Date: Mon, 16 Jan 2023 22:33:01 -0500 Subject: [PATCH] Make credentials serializable for Tor JS bindings Author: onyinyang --- crates/lox-library/src/cred.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/lox-library/src/cred.rs b/crates/lox-library/src/cred.rs index a0a320d..9f0fc57 100644 --- a/crates/lox-library/src/cred.rs +++ b/crates/lox-library/src/cred.rs @@ -6,6 +6,7 @@ zero-knowledge proof of its correctness (as it does at issuing time). */ use curve25519_dalek::ristretto::RistrettoPoint; use curve25519_dalek::scalar::Scalar; +use serde::{Deserialize, Serialize}; /// A migration credential. /// @@ -15,7 +16,7 @@ use curve25519_dalek::scalar::Scalar; /// from a 1-bridge untrusted bucket to a 3-bridge trusted bucket) and 1 /// for blockage migrations (moving buckets because the from_bucket has /// been blocked). -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct Migration { pub P: RistrettoPoint, pub Q: RistrettoPoint, @@ -31,7 +32,7 @@ pub struct Migration { /// authority), but known only to the user. The level_since date is the /// Julian date of when this user was changed to the current trust /// level. -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct Lox { pub P: RistrettoPoint, pub Q: RistrettoPoint, @@ -57,7 +58,7 @@ pub struct Lox { /// That way, people entitled to migrate buckets can receive a Migration /// credential with their new bucket, without the BA learning either /// their old or new buckets. -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct MigrationKey { pub P: RistrettoPoint, pub Q: RistrettoPoint, @@ -73,7 +74,7 @@ pub struct MigrationKey { /// credential (in zero knowledge) with today's date to prove that the /// bridges in their bucket have not been blocked, in order to gain a /// trust level. -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct BucketReachability { pub P: RistrettoPoint, pub Q: RistrettoPoint, @@ -89,7 +90,7 @@ pub struct BucketReachability { /// as the inviter, and inherits the inviter's blockages count (so that /// you can't clear your blockages count simply by inviting yourself). /// Invitations expire after some amount of time. -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct Invitation { pub P: RistrettoPoint, pub Q: RistrettoPoint,