diff --git a/enzevalos_iphone.xcodeproj/project.pbxproj b/enzevalos_iphone.xcodeproj/project.pbxproj
index 07d4b24ca65ac5685d65dedf638457a4dbe54394..30d692622579653449208d674d5c23e609f07f15 100644
--- a/enzevalos_iphone.xcodeproj/project.pbxproj
+++ b/enzevalos_iphone.xcodeproj/project.pbxproj
@@ -132,6 +132,8 @@
 		47F867E22052B48E00AA832F /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 47F867E12052B48E00AA832F /* libz.tbd */; };
 		47F867E42052B49800AA832F /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 47F867E32052B49800AA832F /* libbz2.tbd */; };
 		50F2E7D66366C779705987A7 /* Pods_enzevalos_iphoneUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF67EF30BB065CC9C0D17940 /* Pods_enzevalos_iphoneUITests.framework */; };
+		71497EC0240FE37800B6210F /* MailComparison.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71497EBF240FE37800B6210F /* MailComparison.swift */; };
+		71497EC3240FF82700B6210F /* MailComparisonTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71497EC2240FF82700B6210F /* MailComparisonTests.swift */; };
 		71DFE5BA240679E80042019C /* HeaderExtractionValues.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71DFE5B9240679E80042019C /* HeaderExtractionValues.swift */; };
 		7500EE9D4F3130671F5C1AE2 /* Pods_enzevalos_iphoneTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7977EA7012D8E98D186D5C60 /* Pods_enzevalos_iphoneTests.framework */; };
 		8428A8531F4369C0007649A5 /* Gamification.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8428A8521F4369C0007649A5 /* Gamification.storyboard */; };
@@ -401,6 +403,8 @@
 		48C250BB32BF11B683003BA1 /* Pods-enzevalos_iphone-enzevalos_iphoneUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphone-enzevalos_iphoneUITests.debug.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphone-enzevalos_iphoneUITests/Pods-enzevalos_iphone-enzevalos_iphoneUITests.debug.xcconfig"; sourceTree = "<group>"; };
 		66E758F271CD65AB3E5FE7A7 /* Pods-enzevalos_iphoneUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphoneUITests.debug.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphoneUITests/Pods-enzevalos_iphoneUITests.debug.xcconfig"; sourceTree = "<group>"; };
 		6EBCCD02AD3B95D8317810E2 /* Pods-enzevalos_iphoneTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphoneTests.debug.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphoneTests/Pods-enzevalos_iphoneTests.debug.xcconfig"; sourceTree = "<group>"; };
+		71497EBF240FE37800B6210F /* MailComparison.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailComparison.swift; sourceTree = "<group>"; };
+		71497EC2240FF82700B6210F /* MailComparisonTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailComparisonTests.swift; sourceTree = "<group>"; };
 		71DFE5B9240679E80042019C /* HeaderExtractionValues.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderExtractionValues.swift; sourceTree = "<group>"; };
 		796D16D79BED5D60B580E602 /* Pods-enzevalos_iphoneUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphoneUITests.release.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphoneUITests/Pods-enzevalos_iphoneUITests.release.xcconfig"; sourceTree = "<group>"; };
 		7977EA7012D8E98D186D5C60 /* Pods_enzevalos_iphoneTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_enzevalos_iphoneTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -788,6 +792,23 @@
 			path = private;
 			sourceTree = "<group>";
 		};
+		71497EBE240FE2E300B6210F /* phishing */ = {
+			isa = PBXGroup;
+			children = (
+				71497EBF240FE37800B6210F /* MailComparison.swift */,
+			);
+			path = phishing;
+			sourceTree = "<group>";
+		};
+		71497EC1240FF7FC00B6210F /* phishing */ = {
+			isa = PBXGroup;
+			children = (
+				988C9C5C240D507A006213F0 /* PhishingTests.swift */,
+				71497EC2240FF82700B6210F /* MailComparisonTests.swift */,
+			);
+			path = phishing;
+			sourceTree = "<group>";
+		};
 		78280F99990BFF65543B7F0B /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
@@ -921,6 +942,7 @@
 		A13526771D955BDF00D3BFE1 /* enzevalos_iphone */ = {
 			isa = PBXGroup;
 			children = (
+				71497EBE240FE2E300B6210F /* phishing */,
 				A1B9999D21DE7CD2002563F6 /* Travel */,
 				477548DC21F5DA46000B22A8 /* mail */,
 				F1866C84201F703200B72453 /* OAuth */,
@@ -961,7 +983,7 @@
 		A135268F1D955BE000D3BFE1 /* enzevalos_iphoneTests */ = {
 			isa = PBXGroup;
 			children = (
-				988C9C5C240D507A006213F0 /* PhishingTests.swift */,
+				71497EC1240FF7FC00B6210F /* phishing */,
 				47F0376C22A7278A0005C9DE /* private */,
 				470709202189C24800DF71A3 /* testKeys */,
 				470709112189BB4A00DF71A3 /* testMails */,
@@ -1604,6 +1626,7 @@
 				4707096D1F8F9F4900657F41 /* ExportViewController.swift in Sources */,
 				F12060801DA540FE00F6EF37 /* RefreshControlExtension.swift in Sources */,
 				4751C6FC2344C8D1006B2A4D /* KeyTableViewController.swift in Sources */,
+				71497EC0240FE37800B6210F /* MailComparison.swift in Sources */,
 				A13526811D955BDF00D3BFE1 /* enzevalos_iphone.xcdatamodeld in Sources */,
 				472F39821E1E5347009260FB /* Mail_Address+CoreDataProperties.swift in Sources */,
 				477548E221F77466000B22A8 /* SecurityIndicator.swift in Sources */,
@@ -1680,6 +1703,7 @@
 				8428A8831F436AC9007649A5 /* GamificationDataUnitTest.swift in Sources */,
 				3EC35F302003838E008BDF95 /* InvitationTests.swift in Sources */,
 				474054982244D7A9007CF83B /* MailServerConfigurationTest.swift in Sources */,
+				71497EC3240FF82700B6210F /* MailComparisonTests.swift in Sources */,
 				479B5977206914BE00B3944D /* CryptoTests.swift in Sources */,
 				A15D215F223BE6E4003E0CE0 /* MailTest.swift in Sources */,
 				988C9C5D240D507A006213F0 /* PhishingTests.swift in Sources */,
diff --git a/enzevalos_iphone/StringExtension.swift b/enzevalos_iphone/StringExtension.swift
index 4b6f0dbe49224fccfc31548bf59880a42b70ce7f..d77547011263128de41d16d9eb716f2311381588 100644
--- a/enzevalos_iphone/StringExtension.swift
+++ b/enzevalos_iphone/StringExtension.swift
@@ -152,7 +152,6 @@ extension String {
             foundLinks.append(String(self[range]))
         }
         return (foundLinks)
-        
     }
 
     func htmlTagLinkName() -> [String]{
diff --git a/enzevalos_iphone/phishing/MailComparison.swift b/enzevalos_iphone/phishing/MailComparison.swift
new file mode 100644
index 0000000000000000000000000000000000000000..299b1bac15a8ea16f517f17958bb1194ab27dc8e
--- /dev/null
+++ b/enzevalos_iphone/phishing/MailComparison.swift
@@ -0,0 +1,24 @@
+//
+//  MailComparison.swift
+//  enzevalos_iphone
+//
+//  Created by Katharina Müller and Viktoria Sorgalla on 04.03.20.
+//  Copyright © 2020 fu-berlin. All rights reserved.
+//
+
+import Foundation
+
+class MailComparison {
+    func compareMailToContacts (){
+        let dataHandler = DataHandler.handler
+        var contacts = dataHandler.getContacts()
+        var addresses = dataHandler.getAddresses()
+        //var first = String(contacts[0].from)
+        //var first_address = String(addresses[0])
+       // let isEqual = (first == first_address)
+        
+        //let records = DataHandler.handler.getContactByAddress(email).records
+
+    }
+}
+
diff --git a/enzevalos_iphoneTests/phishing/MailComparisonTests.swift b/enzevalos_iphoneTests/phishing/MailComparisonTests.swift
new file mode 100644
index 0000000000000000000000000000000000000000..f9db518574b154a89e7e138909da244584e590b2
--- /dev/null
+++ b/enzevalos_iphoneTests/phishing/MailComparisonTests.swift
@@ -0,0 +1,136 @@
+
+//
+import XCTest
+@testable import enzevalos_iphone
+class MailComparisonTests: XCTestCase {
+    let datahandler = DataHandler.handler
+    let pgp = SwiftPGP()
+
+    let userAdr = "alice@example.com"
+    let userName = "alice"
+    var user: MCOAddress = MCOAddress.init(mailbox: "alice@example.com")
+    var userKeyID: String = ""
+
+    override func setUp() {
+        super.setUp()
+        pgp.resetKeychains()
+        datahandler.reset()
+       // XCTAssertLessThanOrEqual(datahandler.allFolders.count, 1, "Folder: \(datahandler.allFolders.map{$0.frontendName})")
+        XCTAssertEqual(datahandler.findSecretKeys().count, 0)
+        XCTAssertEqual(datahandler.getContacts().count, 0)
+        XCTAssertEqual(datahandler.getAddresses().count, 0)
+        (user, userKeyID) = owner()
+    }
+
+    override func tearDown() {
+        datahandler.reset()
+        pgp.resetKeychains()
+        super.tearDown()
+    }
+    
+    func createUser(adr: String = String.random().lowercased(), name: String = String.random()) -> MCOAddress {
+           return MCOAddress.init(displayName: name, mailbox: adr.lowercased())
+       }
+
+       func createPGPUser(adr: String = String.random().lowercased(), name: String = String.random()) -> (MCOAddress, String) {
+           let user = createUser(adr: adr, name: name)
+           let id = pgp.generateKey(adr: user.mailbox)
+           return (user, id)
+       }
+
+       func owner() -> (MCOAddress, String) {
+           Logger.logging = false
+           let (user, userid) = createPGPUser(adr: userAdr, name: userName)
+           UserManager.storeUserValue(userAdr as AnyObject, attribute: Attribute.userAddr)
+           UserManager.storeUserValue(userid as AnyObject, attribute: Attribute.prefSecretKeyID)
+           UserManager.storeUserValue(userName as AnyObject, attribute: Attribute.accountname)
+           return (user, userid)
+       }
+    
+    func testMail(from: MCOAddress, to: [MCOAddress], cc: [MCOAddress], bcc: [MCOAddress], flags: MCOMessageFlag = MCOMessageFlag.init(rawValue: 0), folder: String = "INBOX", date: Date = Date(timeIntervalSince1970: TimeInterval(arc4random())), cryptoObject: CryptoObject? = nil, body: String = String.random(length: 20)) -> PersistentMail? {
+
+        let subject = String.random(length: 20)
+        let id = UInt64(arc4random())
+        var body = body
+
+        if let decryptedBody = cryptoObject?.decryptedText {
+            body = decryptedBody
+        }
+        var mail: PersistentMail?
+        mail = datahandler.createMail(id, sender: from, receivers: to, cc: cc, time: date, received: true, subject: subject, body: body, flags: flags, record: nil, autocrypt: nil, decryptedData: cryptoObject, folderPath: folder, secretKey: nil, encryptedBody: cryptoObject?.chiperString)
+        XCTAssertNotNil(mail)
+        XCTAssertEqual(mail?.body, body)
+        XCTAssertEqual(mail?.subject, subject)
+        XCTAssertEqual(mail?.folder.name.lowercased(), folder.lowercased())
+
+        return mail
+    }
+    
+    func testOwnRecord() {
+        let (sender, keyID) = createPGPUser()
+        let body = "enc with old key"
+        let folderName = "INBOX"
+        let oldID = userKeyID
+
+        var myrecord = datahandler.getKeyRecord(addr: userAdr, keyID: datahandler.prefSecretKey()?.keyID)
+        XCTAssertEqual(myrecord.keyID, userKeyID)
+        XCTAssertEqual(myrecord.ezContact.records.count, 1)
+
+
+        let cryptoObject1 = pgp.encrypt(plaintext: body, ids: [oldID], myId: keyID)
+        _ = testMail(from: sender, to: [user], cc: [], bcc: [], folder: folderName, cryptoObject: cryptoObject1)
+        let myContact = datahandler.getContactByAddress(userAdr)
+
+        if let newKeyIDs = try? pgp.importKeys(key: CryptoTests.importKey, pw: CryptoTests.importPW, isSecretKey: true, autocrypt: false), let newKeyId = newKeyIDs.first{
+            _ = datahandler.newSecretKey(keyID: newKeyId, addPk: true, saveKey: true)
+            if let prefSK = datahandler.prefSecretKey() {
+                XCTAssertTrue(newKeyId == prefSK.keyID, "newKeyID: \(newKeyId) != \(String(describing: prefSK.keyID)): prefKeyID")
+                XCTAssertTrue(userKeyID != newKeyId)
+                
+                let key = datahandler.findSecretKey(keyID: prefSK.keyID)
+                XCTAssertNotNil(key)
+                XCTAssertTrue(key?.keyID == newKeyId, "newKeyID: \(newKeyId) != \(String(describing: key?.keyID)): prefKeyID")
+                
+                myrecord = datahandler.getKeyRecord(addr: userAdr, keyID: prefSK.keyID)
+            }
+            XCTAssertEqual(myrecord.keyID, newKeyId)
+            XCTAssertEqual(myrecord.ezContact.records.count, 2)
+            XCTAssertTrue(myrecord.isSecure)
+            XCTAssertEqual(myContact.publicKeys.count, 2)
+            let cryptoObject2 = pgp.encrypt(plaintext: body, ids: [newKeyId], myId: keyID)
+            let decryptObject2 = pgp.decrypt(data: cryptoObject2.chiphertext!, decKeyIDs: [newKeyId], signatureIDs: [keyID], fromAddr: userAdr)
+            _ = testMail(from: sender, to: [user], cc: [], bcc: [], folder: folderName, cryptoObject: decryptObject2)
+
+            let cryptoObject3 = pgp.encrypt(plaintext: body, ids: [oldID], myId: keyID)
+            let decryptObject3 = pgp.decrypt(data: cryptoObject3.chiphertext!, decKeyIDs: [oldID], signatureIDs: [keyID], fromAddr: userAdr)
+            let oldMail = testMail(from: sender, to: [user], cc: [], bcc: [], folder: folderName, cryptoObject: decryptObject3)
+            
+            XCTAssertTrue((oldMail?.decryptedWithOldPrivateKey)!)
+
+
+        } else {
+            XCTFail("No new key")
+            return
+        }
+    }
+    
+    func testKeysPerAddress() {
+        let adrKey = "key@example.com"
+        let adrNoKey = "noKey@example.com"
+        let adrNoKey2 = "noKey2@example.com"
+        var mailAdrKey = datahandler.getMailAddress(adrKey, temporary: false)
+        let mailAdrNoKey = datahandler.getMailAddress(adrNoKey, temporary: false)
+        _ = datahandler.getMailAddress(adrNoKey2, temporary: false)
+        XCTAssertFalse(mailAdrKey.hasKey)
+        XCTAssertFalse(mailAdrNoKey.hasKey)
+        XCTAssertEqual(datahandler.getAddresses().count, 3)
+        _ = datahandler.newPublicKey(keyID: "000", cryptoType: .PGP, adr: adrKey, autocrypt: false, transferType: nil)
+        _ = datahandler.newPublicKey(keyID: "001", cryptoType: .PGP, adr: adrKey, autocrypt: false, transferType: nil)
+        mailAdrKey = datahandler.getMailAddress(adrKey, temporary: false)
+        XCTAssertTrue(mailAdrKey.hasKey)
+        let withKeys = datahandler.findMailAddress(withKey: true).count
+        let noKeys = datahandler.findMailAddress(withKey: false).count
+        XCTAssertEqual(withKeys, 1, "Adresses with key: \(withKeys)")
+        XCTAssertEqual(noKeys, 2, "Adresses without key: \(noKeys)")
+    }
+}
diff --git a/enzevalos_iphoneTests/PhishingTests.swift b/enzevalos_iphoneTests/phishing/PhishingTests.swift
similarity index 100%
rename from enzevalos_iphoneTests/PhishingTests.swift
rename to enzevalos_iphoneTests/phishing/PhishingTests.swift