3 enum OctagonSelfPeerKeysError: Error {
7 class OctagonSelfPeerKeys: NSObject, CKKSSelfPeer {
8 var encryptionKey: _SFECKeyPair
9 var signingKey: _SFECKeyPair
12 // Here for conformance with CKKSPeer
13 var publicEncryptionKey: _SFECPublicKey?
14 var publicSigningKey: _SFECPublicKey?
16 var encryptionVerificationKey: _SFECPublicKey
17 var signingVerificationKey: _SFECPublicKey
19 func matchesPeer(_ peer: CKKSPeer) -> Bool {
23 init(peerID: String, signingKey: _SFECKeyPair, encryptionKey: _SFECKeyPair) throws {
25 self.signingKey = signingKey
26 self.encryptionKey = encryptionKey
28 self.publicEncryptionKey = encryptionKey.publicKey as? _SFECPublicKey
29 self.publicSigningKey = signingKey.publicKey as? _SFECPublicKey
31 guard let encryptionVerificationKey = self.publicEncryptionKey,
32 let signingVerificationKey = self.publicSigningKey else {
33 throw OctagonSelfPeerKeysError.noPublicKeys
36 self.encryptionVerificationKey = encryptionVerificationKey
37 self.signingVerificationKey = signingVerificationKey
40 override var description: String {
41 return "<OctagonSelfPeerKeys: \(self.peerID)>"
45 extension TPPeerPermanentInfo: CKKSPeer {
46 public var publicEncryptionKey: _SFECPublicKey? {
47 return self.encryptionPubKey as? _SFECPublicKey
50 public var publicSigningKey: _SFECPublicKey? {
51 return self.signingPubKey as? _SFECPublicKey
54 public func matchesPeer(_ peer: CKKSPeer) -> Bool {
55 return self.peerID == peer.peerID