ZDCPublicKey

@interface ZDCPublicKey <NSCoding, NSCopying>

The PublicKey class holds the information necessary to create a public key within the S4Crypto library. It may optionally hold the information for the corresponding private key (if the key is for a local user).

  • Generates a random public/private key pair.

    Declaration

    Objective-C

    + (nonnull instancetype)privateKeyWithOwner:(nonnull NSString *)userID
                                     storageKey:(id)storageKey
                                      algorithm:(id)algorithm;

    Swift

    class func privateKey(withOwner userID: Any!, storageKey: Any!, algorithm: Any!) -> Self!
  • Creates a new PublicKey instance from the given parameters.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithUserID:(nonnull NSString *)userID
                                pubKeyJSON:(nonnull NSString *)pubKeyJSON;

    Swift

    init!(userID: Any!, pubKeyJSON: Any!)

    Parameters

    userID

    The corresponding userID (userID == ZDCUser.uuid)

    pubKeyJSON

    A string that contains the serialized JSON parameters which can be used to create the public key. This information contains information such as the ECC curve, and other such parameters needed for the type of public key.

  • Creates a new PublicKey instance from the given parameters. If a privKeyJSON parameter is passed, the key will also contain the corresponding private key.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithUserID:(nonnull NSString *)userID
                                pubKeyJSON:(nonnull NSString *)pubKeyJSON
                               privKeyJSON:(nullable NSString *)privKeyJSON;

    Swift

    init!(userID: Any!, pubKeyJSON: Any!, privKeyJSON: Any!)

    Parameters

    userID

    The corresponding userID (userID == ZDCUser.uuid)

    pubKeyJSON

    A string that contains the serialized JSON parameters which can be used to create the public key. This contains information such as the ECC curve, and other such parameters needed for the type of public key.

    privKeyJSON

    A string that contains the serialized JSON parameters which can be used to create the private key. This contains information such as the ECC curve, and other such parameters needed for the type of public key.

  • Creates a new PublicKey instance from the given parameters. If a privKeyDict parameter is passed, the key will also contain the corresponding private key.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithUserID:(nonnull NSString *)userID
                                pubKeyDict:(nonnull NSDictionary *)pubKeyDict
                               privKeyDict:(nullable NSDictionary *)privKeyDict;

    Swift

    init!(userID: Any!, pubKeyDict: Any!, privKeyDict: Any!)

    Parameters

    userID

    The corresponding userID (userID == ZDCUser.uuid)

    pubKeyDict

    A dictionary that contains the parameters which can be used to create the public key. This contains information such as the ECC curve, and other such parameters needed for the type of public key.

    privKeyDict

    A dictionary that contains the parameters which can be used to create the private key. This contains information such as the ECC curve, and other such parameters needed for the type of public key.

  • Every PublicKey instance has a randomly generated UUID. This is commonly referred to as the pubKeyID.

    This is also the key used to store the item in the database (within collection kZDCCollection_PublicKey).

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) NSString *_Nonnull uuid;

    Swift

    var uuid: UnsafeMutablePointer<Int32>! { get }
  • A reference to the user who owns this public key. (userID == ZDCUser.uuid)

    The inverse relationship can be found via -[ZDCUser publicKeyID]

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) NSString *_Nonnull userID;

    Swift

    var userID: UnsafeMutablePointer<Int32>! { get }
  • A string that contains the serialized JSON parameters that can be used to create the public key.

    This contains information such as the ECC curve, and other such parameters needed for the type of public key.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) NSString *_Nonnull pubKeyJSON;

    Swift

    var pubKeyJSON: UnsafeMutablePointer<Int32>! { get }
  • A string that contains the serialized JSON parameters that can be used to create the private key.

    This contains information such as the ECC curve, and other such parameters needed for the type of public key.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *privKeyJSON;

    Swift

    var privKeyJSON: UnsafeMutablePointer<Int32>? { get }
  • Returns YES if privKeyJSON is non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL isPrivateKey;

    Swift

    var isPrivateKey: Int32 { get }
  • Returns a parsed version of pubKeyJSON. The parsed version is kept cached in memory for performance.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSDictionary *_Nonnull keyDict;

    Swift

    var keyDict: UnsafeMutablePointer<Int32>! { get }
  • Reads & returns the pubKey value from the keyDict. This is the raw pubKey bits, encoded using base64.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSString *pubKey;

    Swift

    var pubKey: UnsafeMutablePointer<Int32>? { get }
  • Reads & returns the keyID value from the keyDict.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSString *keyID;

    Swift

    var keyID: UnsafeMutablePointer<Int32>? { get }
  • Performs self-test by attempting to create an S4KeyContext from the pubKeyJSON.

    Declaration

    Objective-C

    - (BOOL)checkKeyValidityWithError:(NSError *_Nullable *_Nullable)errorOut;

    Swift

    func checkValidityWithError(_ errorOut: Any!) -> Any!
  • Modifies the pubKeyJSON and/or privKeyJSON by setting the given property.

    Declaration

    Objective-C

    - (BOOL)updateKeyProperty:(nonnull NSString *)propertyID
                        value:(nonnull NSData *)value
                   storageKey:(id)storageKey
                        error:(NSError *_Nullable *_Nullable)errorOut;

    Swift

    func updateProperty(_ propertyID: Any!, value: Any!, storageKey: Any!, error errorOut: Any!) -> Any!
  • Used when migrating a PrivateKey to a PublicKey.

    Declaration

    Objective-C

    - (void)copyToPublicKey:(nonnull ZDCPublicKey *)copy;

    Swift

    func copy(to copy: ZDCPublicKey!)