From 4ce49fa106f0dd58736a361685cc8c9298caf899 Mon Sep 17 00:00:00 2001 From: webwarrior Date: Mon, 5 Jun 2023 14:20:15 +0200 Subject: [PATCH] NOnion: minor refactoring Renamed IdentityKey type to Fingerprint as technically this is the digest of identity key. --- NOnion/Directory/TorDirectory.fs | 2 +- NOnion/KeyTypes.fs | 3 ++- NOnion/Network/TorCircuit.fs | 2 +- NOnion/Network/TorGuard.fs | 4 ++-- NOnion/Services/TorServiceClient.fs | 2 +- NOnion/Services/TorServiceHost.fs | 4 ++-- NOnion/TorHandshakes/NTorHandshake.fs | 4 ++-- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/NOnion/Directory/TorDirectory.fs b/NOnion/Directory/TorDirectory.fs index 4286762e..7edd56dd 100644 --- a/NOnion/Directory/TorDirectory.fs +++ b/NOnion/Directory/TorDirectory.fs @@ -277,7 +277,7 @@ type TorDirectory = CircuitNodeDetail.Create( endpoint, NTorOnionKey nTorOnionKeyBytes, - IdentityKey fingerprintBytes + Fingerprint fingerprintBytes ) } diff --git a/NOnion/KeyTypes.fs b/NOnion/KeyTypes.fs index f58f50a3..06aa4a6e 100644 --- a/NOnion/KeyTypes.fs +++ b/NOnion/KeyTypes.fs @@ -57,7 +57,8 @@ type NTorOnionKey(bytes: array) = member self.ToByteArray() = bytes -type IdentityKey(bytes: array) = +/// Digest of identity key. +type Fingerprint(bytes: array) = do if bytes.Length <> Constants.IdentityKeyLength then failwithf diff --git a/NOnion/Network/TorCircuit.fs b/NOnion/Network/TorCircuit.fs index fc50c1ba..6e4672d7 100644 --- a/NOnion/Network/TorCircuit.fs +++ b/NOnion/Network/TorCircuit.fs @@ -26,7 +26,7 @@ type CircuitNodeDetail = | Create of EndPoint: IPEndPoint * NTorOnionKey: NTorOnionKey * - IdentityKey: IdentityKey + Fingerprint: Fingerprint member self.GetIdentityKey() = match self with diff --git a/NOnion/Network/TorGuard.fs b/NOnion/Network/TorGuard.fs index a02b0185..0c215daf 100644 --- a/NOnion/Network/TorGuard.fs +++ b/NOnion/Network/TorGuard.fs @@ -49,7 +49,7 @@ type TorGuard ( client: TcpClient, sslStream: SslStream, - fingerprintOpt: Option + fingerprintOpt: Option ) = let shutdownToken = new CancellationTokenSource() @@ -116,7 +116,7 @@ type TorGuard static member private InnerNewClient (ipEndpoint: IPEndPoint) - (fingerprintOpt: Option) + (fingerprintOpt: Option) = async { let tcpClient = new TcpClient() diff --git a/NOnion/Services/TorServiceClient.fs b/NOnion/Services/TorServiceClient.fs index ee94300c..ef626bcf 100644 --- a/NOnion/Services/TorServiceClient.fs +++ b/NOnion/Services/TorServiceClient.fs @@ -373,7 +373,7 @@ type TorServiceClient = CircuitNodeDetail.Create( endpointSpecifier, introductionPoint.OnionKey.Value, - IdentityKey identityKey + Fingerprint identityKey ) return diff --git a/NOnion/Services/TorServiceHost.fs b/NOnion/Services/TorServiceHost.fs index 52fba205..c66b9085 100644 --- a/NOnion/Services/TorServiceHost.fs +++ b/NOnion/Services/TorServiceHost.fs @@ -31,7 +31,7 @@ type IntroductionPointInfo = AuthKey: AsymmetricCipherKeyPair MasterPublicKey: Ed25519PublicKeyParameters NTorOnionKey: NTorOnionKey - Fingerprint: IdentityKey + Fingerprint: Fingerprint } type TorServiceHost @@ -234,7 +234,7 @@ type TorServiceHost |> Seq.tryExactlyOne match linkSpecifierOpt with - | Some linkSpecifier -> IdentityKey linkSpecifier.Data + | Some linkSpecifier -> Fingerprint linkSpecifier.Data | None -> failwith "No rendezvous fingerprint found!" let connectToRendezvousJob = diff --git a/NOnion/TorHandshakes/NTorHandshake.fs b/NOnion/TorHandshakes/NTorHandshake.fs index 4b78373f..501fd322 100644 --- a/NOnion/TorHandshakes/NTorHandshake.fs +++ b/NOnion/TorHandshakes/NTorHandshake.fs @@ -15,13 +15,13 @@ type NTorHandshake = { RandomClientPrivateKey: X25519PrivateKeyParameters RandomClientPublicKey: X25519PublicKeyParameters - IdentityDigest: IdentityKey + IdentityDigest: Fingerprint NTorOnionKey: X25519PublicKeyParameters } static member Create - (identityDigest: IdentityKey) + (identityDigest: Fingerprint) (nTorOnionKey: NTorOnionKey) =