I'm writing a chat application for iOS using Swift. To reach this, I'm using Multipeer Connectivity. As soon as a new peer connects, he should be given the session key. Therefore the new peer has to send his public key (which is of type SecKey) to the peer that encrypts the session key (which is a string).
So, my problem is sending another peer my public Key (of type SecKey), because
session.sendData(data, toPeers: self.session.connectedPeers, withMode: MCSessionSendDataMode.Unreliable, error: &error);
only allows the data to be of type NSData. So either I need a way to send a SecKey without this method, or the SecKey has to be converted to a NSData which then can be converted into the right SecKey again. Does anyone of you know how to do this? Looking forward to any answer that could help!