Make credentials serializable for Tor JS bindings

Author:    onyinyang <onyinyang@users.noreply.github.com>
This commit is contained in:
onyinyang 2023-01-16 22:33:01 -05:00
parent f7002632f7
commit 9ce2a81fe7
No known key found for this signature in database
GPG Key ID: 156A6435430C2036
1 changed files with 6 additions and 5 deletions

View File

@ -6,6 +6,7 @@ zero-knowledge proof of its correctness (as it does at issuing time). */
use curve25519_dalek::ristretto::RistrettoPoint; use curve25519_dalek::ristretto::RistrettoPoint;
use curve25519_dalek::scalar::Scalar; use curve25519_dalek::scalar::Scalar;
use serde::{Deserialize, Serialize};
/// A migration credential. /// 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 /// from a 1-bridge untrusted bucket to a 3-bridge trusted bucket) and 1
/// for blockage migrations (moving buckets because the from_bucket has /// for blockage migrations (moving buckets because the from_bucket has
/// been blocked). /// been blocked).
#[derive(Debug)] #[derive(Debug, Serialize, Deserialize)]
pub struct Migration { pub struct Migration {
pub P: RistrettoPoint, pub P: RistrettoPoint,
pub Q: RistrettoPoint, pub Q: RistrettoPoint,
@ -31,7 +32,7 @@ pub struct Migration {
/// authority), but known only to the user. The level_since date is the /// 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 /// Julian date of when this user was changed to the current trust
/// level. /// level.
#[derive(Debug)] #[derive(Debug, Serialize, Deserialize)]
pub struct Lox { pub struct Lox {
pub P: RistrettoPoint, pub P: RistrettoPoint,
pub Q: RistrettoPoint, pub Q: RistrettoPoint,
@ -57,7 +58,7 @@ pub struct Lox {
/// That way, people entitled to migrate buckets can receive a Migration /// That way, people entitled to migrate buckets can receive a Migration
/// credential with their new bucket, without the BA learning either /// credential with their new bucket, without the BA learning either
/// their old or new buckets. /// their old or new buckets.
#[derive(Debug)] #[derive(Debug, Serialize, Deserialize)]
pub struct MigrationKey { pub struct MigrationKey {
pub P: RistrettoPoint, pub P: RistrettoPoint,
pub Q: RistrettoPoint, pub Q: RistrettoPoint,
@ -73,7 +74,7 @@ pub struct MigrationKey {
/// credential (in zero knowledge) with today's date to prove that the /// 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 /// bridges in their bucket have not been blocked, in order to gain a
/// trust level. /// trust level.
#[derive(Debug)] #[derive(Debug, Serialize, Deserialize)]
pub struct BucketReachability { pub struct BucketReachability {
pub P: RistrettoPoint, pub P: RistrettoPoint,
pub Q: RistrettoPoint, pub Q: RistrettoPoint,
@ -89,7 +90,7 @@ pub struct BucketReachability {
/// as the inviter, and inherits the inviter's blockages count (so that /// as the inviter, and inherits the inviter's blockages count (so that
/// you can't clear your blockages count simply by inviting yourself). /// you can't clear your blockages count simply by inviting yourself).
/// Invitations expire after some amount of time. /// Invitations expire after some amount of time.
#[derive(Debug)] #[derive(Debug, Serialize, Deserialize)]
pub struct Invitation { pub struct Invitation {
pub P: RistrettoPoint, pub P: RistrettoPoint,
pub Q: RistrettoPoint, pub Q: RistrettoPoint,