1 Reply
      Latest reply on Jul 12, 2019 12:15 AM by sofacoder
      rybalko.oleg Level 1 Level 1 (0 points)

        I'm trying to create an app with the public-key encryption, so I need to add a private key to the keychain but I don't really know how to do it. Please help me)

        • Re: How to add Curve25519.Signing.PrivateKey() to the keychain?
          sofacoder Level 1 Level 1 (0 points)



          usually you would do it by storing the data representation of the key like this (working code, beta 3):


          let key = P256.Signing.PrivateKey()
          let keyData = key.x963Representation
          // Store the data in the key chain
          print("--- Org Key data ---")
          // Load the data from the keychain
          let keyFromData = try? P256.Signing.PrivateKey(x963Representation: keyData)
          if let keyFromData = keyFromData {
              print("--- Loaded Key data ---")


          But it it looks like that Curve25519 does not support key data represntation yet. Maybe this will come in a later Beta.