routing work
This commit is contained in:
		| @@ -33,7 +33,7 @@ pub trait CryptoSystem { | ||||
|     fn validate_hash_reader( | ||||
|         &self, | ||||
|         reader: &mut dyn std::io::Read, | ||||
|         dht_key: &PublicKey, | ||||
|         key: &PublicKey, | ||||
|     ) -> Result<bool, VeilidAPIError>; | ||||
|  | ||||
|     // Distance Metric | ||||
| @@ -42,13 +42,13 @@ pub trait CryptoSystem { | ||||
|     // Authentication | ||||
|     fn sign( | ||||
|         &self, | ||||
|         dht_key: &PublicKey, | ||||
|         dht_key_secret: &SecretKey, | ||||
|         key: &PublicKey, | ||||
|         secret: &SecretKey, | ||||
|         data: &[u8], | ||||
|     ) -> Result<Signature, VeilidAPIError>; | ||||
|     fn verify( | ||||
|         &self, | ||||
|         dht_key: &PublicKey, | ||||
|         key: &PublicKey, | ||||
|         data: &[u8], | ||||
|         signature: &Signature, | ||||
|     ) -> Result<(), VeilidAPIError>; | ||||
|   | ||||
| @@ -40,6 +40,6 @@ pub fn bytes_to_cache(bytes: &[u8], cache: &mut DHCache) { | ||||
|         let v = DHCacheValue { | ||||
|             shared_secret: SharedSecret::new(d[64..96].try_into().expect("asdf")), | ||||
|         }; | ||||
|         cache.insert(k, v); | ||||
|         cache.insert(k, v, |_k, _v| {}); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -269,10 +269,13 @@ impl Crypto { | ||||
|         secret: &SecretKey, | ||||
|     ) -> Result<SharedSecret, VeilidAPIError> { | ||||
|         Ok( | ||||
|             match self.inner.lock().dh_cache.entry(DHCacheKey { | ||||
|                 key: *key, | ||||
|                 secret: *secret, | ||||
|             }) { | ||||
|             match self.inner.lock().dh_cache.entry( | ||||
|                 DHCacheKey { | ||||
|                     key: *key, | ||||
|                     secret: *secret, | ||||
|                 }, | ||||
|                 |_k, _v| {}, | ||||
|             ) { | ||||
|                 Entry::Occupied(e) => e.get().shared_secret, | ||||
|                 Entry::Vacant(e) => { | ||||
|                     let shared_secret = vcrypto.compute_dh(key, secret)?; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user