Unify SHA256 hash and hex usages (#687)

This commit is contained in:
Islam
2025-09-30 12:47:16 +02:00
committed by GitHub
parent f5af00be88
commit 78fb3f1bf6
14 changed files with 50 additions and 82 deletions
@@ -272,8 +272,7 @@ final class NoiseEncryptionService {
/// Get our identity fingerprint
func getIdentityFingerprint() -> String {
let hash = SHA256.hash(data: staticIdentityPublicKey.rawRepresentation)
return hash.map { String(format: "%02x", $0) }.joined()
staticIdentityPublicKey.rawRepresentation.sha256Fingerprint()
}
/// Get peer's public key data
@@ -554,7 +553,7 @@ final class NoiseEncryptionService {
private func handleSessionEstablished(peerID: String, remoteStaticKey: Curve25519.KeyAgreement.PublicKey) {
// Calculate fingerprint
let fingerprint = calculateFingerprint(for: remoteStaticKey)
let fingerprint = remoteStaticKey.rawRepresentation.sha256Fingerprint()
// Store fingerprint mapping
serviceQueue.sync(flags: .barrier) {
@@ -572,11 +571,6 @@ final class NoiseEncryptionService {
}
}
}
private func calculateFingerprint(for publicKey: Curve25519.KeyAgreement.PublicKey) -> String {
let hash = SHA256.hash(data: publicKey.rawRepresentation)
return hash.map { String(format: "%02x", $0) }.joined()
}
// MARK: - Session Maintenance