Просмотр исходного кода

Define G and Scalar type in lib.rs

onyinyang 10 месяцев назад
Родитель
Сommit
5e9f998349
1 измененных файлов с 13 добавлено и 3 удалено
  1. 13 3
      src/lib.rs

+ 13 - 3
src/lib.rs

@@ -15,7 +15,6 @@ The notation follows that of the paper "Hyphae: Social Secret Sharing"
 // to be capital letters
 #![allow(non_snake_case)]
 
-use curve25519_dalek::scalar::Scalar;
 #[cfg(feature = "bridgeauth")]
 use ed25519_dalek::{Signature, SignatureError, SigningKey, Verifier, VerifyingKey};
 use subtle::ConstantTimeEq;
@@ -24,9 +23,11 @@ use subtle::ConstantTimeEq;
 use chrono::{DateTime, Utc};
 #[cfg(feature = "bridgeauth")]
 use cmz::*;
-#[cfg(feature = "bridgeauth")]
 use curve25519_dalek::ristretto::RistrettoPoint as G;
-use rand_core::OsRng;
+use group::Group;
+#[cfg(feature = "bridgeauth")]
+use rand::rngs::OsRng;
+type Scalar = <G as Group>::Scalar;
 #[cfg(feature = "bridgeauth")]
 use sha2::Sha512;
 
@@ -52,6 +53,7 @@ pub mod proto {
 use bridge_table::BridgeTable;
 //    BridgeLine, EncryptedBucket, MAX_BRIDGES_PER_BUCKET, MIN_BUCKET_REACHABILITY,
 //};
+#[cfg(feature = "bridgeauth")]
 use lox_creds::*;
 #[cfg(feature = "bridgeauth")]
 use migration_table::{MigrationTable, MigrationType};
@@ -64,6 +66,7 @@ use std::collections::HashSet;
 pub const OPENINV_K: u32 = 10;
 /// TODO: Decide on maximum daily number of invitations to be distributed
 pub const MAX_DAILY_BRIDGES: u32 = 100;
+
 /// The BridgeDb. This will typically be a singleton object. The
 /// BridgeDb's role is simply to issue signed "open invitations" to
 /// people who are not yet part of the system.
@@ -124,6 +127,13 @@ pub const OPENINV_LENGTH: usize = 32 // the length of the random
     + 4 // the length of the u32 for the bucket number
     + ed25519_dalek::SIGNATURE_LENGTH; // the length of the signature
 
+#[cfg(feature = "bridgeauth")]
+impl Default for BridgeDb {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
 #[cfg(feature = "bridgeauth")]
 impl BridgeDb {
     /// Create the BridgeDb.