IWKeyManager

This framework is written with Objective-C

Constructor

initWithName

- (instancetype)initWithName:(NSString *)name

Description

  • Please reset name by designating it

Parameter

Type

Parameter

Description

NSString

name

Name of KeyManager file

Return

  • Resetted IWKeyManager object

Security

isLocked

@property (nonatomic, readwrite) BOOL isLocked

Description

  • Returns whether Keyfile is locked or not

lock

- (BOOL)lock

Description

  • Encrypting the Privacy data

  • Changing the KeyFile state to lock

Return

  • YES, if the KeyFile is locked if not returns NO

unlockWithFinishBlock

- (void)unlockWithFinishBlock:(nullable NSString *)touchIdPrompt
                  finishBlock:(void(^)(BOOL result))finishBlock

Description

  • Use Bio-authentication of OS to unlock the Private Data of KeyFile.

  • To use this method, set [Face ID Usage Description] in info.plist.

    Cannot be used in combination with unlockWithPassword method

Parameters

Type

Parameter

Description

NSString

touchIdPrompt

displayed text ID when using the touch ID

finishBlock

finishBlock

Block/closer initiates on completion

finishBlock

Type

Parameter

Description

BOOL

result

reports unlock status

unlockWithPassword

- (void)unlockWithPassword:(NSString *)password
               finishBlock:(void(^)(BOOL result))finishBlock

Description

  • Use password to unlock Private Data of KeyFile

    Cannot be used in combination with [unlockWithFinishBlock] method

Parameters

Type

Parameter

Description

NSString

password

Password set by the user

finishBlock

finishBlock

Initiated Block/closer on completion

finishBlock

Type

Parameter

Description

BOOL

result

unlock status result

Key Management & Signing

isExistKeyForKeyId

- (BOOL)isExistKeyForKeyId:(NSString *)keyId

Description

  • checks the existences of the specific Key Id

    Status of Key Manager must be unlocked state

Parameters

Type

Parameter

Description

NSString

keyId

Key ID to check

Return Value

  • YES, if exists otherwise return, NO

addKey

- (BOOL)addKey:(IWKey *)key

Description

  • Add Key obect on the KeyFile. Status of Key Manager must be unlocked state

Parameters

Type

Parameter

Description

IWKey

key

IWKey

Return Value

  • YES, if added successfully otherwise return, NO

Please refer to IWKeyclass.

removeKeyForKeyId

- (BOOL)removeKeyForKeyId:(NSString *)keyId

Description

  • deletes the specified key Id

    Status of Key Manager must be unlocked state

Parameters

Type

Parameter

Description

NSString

keyId

keyID to delete

Return Value

  • YES, if added successfully otherwise return, NO

RemoveAllKeys

- (BOOL)removeAllKeys

Description

  • Remove all keyID

    Status of Key Manager must be unlocked state

Return Value

  • YES, if added successfully otherwise return, NO

getKeyIdList

- (nullable NSArray<NSString *> *)getKeyIdList

Description

  • Returns all stored keyID list to NSArray type

Return Value

  • KeyID list object of NSArray type

getPublicKeyForKeyId

- (nullable NSString *)getPublicKeyForKeyId:(NSString *)keyId

Description

  • Gets public key that corresponds to keyID

Parameters

Type

Parameter

Description

NSString

keyId

existing keyID

Return Value

  • Returns encoded public key with Base58 form

getSignForKeyId

- (nullable NSString *)getSignForKeyId:(NSString *)keyId
                                source:(NSData *)source

Description

  • Signs data with the specific key.

    Status of Key Manager must be unlocked state

Parameters

Type

Parameter

Description

NSString

keyId

keyID that corresponds to the key

NSData

source

data to be signed

Return Value

  • Encoded signature with Base 58 form

getSignDataForKeyId

- (nullable NSData *)getSignDataForKeyId:(NSString *)keyId
                                  source:(NSData *)source

Description

  • signs data with the specific Key.

    Status of Key Manager must be unlocked state

Parameters

Type

Parameter

Description

NSString

keyId

keyID that corresponds to the key

NSData

source

data to be signed

Return Value

  • Signature of NSData type

Claim Management

addClaim

- (BOOL)addClaim:(NSString *)claim

Description

  • Add, verifiable JSON format, Claim(VC) String on KeyFile

  • On Key File add Claim(VC) String which is a verifiable JSON format Status of Key Manager must be unlocked state

Parameters

Type

Parameter

Description

NSString

claim

CLaim(VC) String of JSON format to be added

Return Value

  • YES, if added successfully otherwise return, NO

getClaims

- (nullable NSArray<IWClaimData *> *)getClaims

Description

  • Get all stored VC on NSArray.

Return

  • NSArray of IWClaimData object

Refer to: IWClaimData Class

Filtering Condition

filter conditions must comply with as bellow.
Must have a space between object, condition and value.

#object name condition
Objexts must be connected with "." as below

claim.id

#bool value action condition
== : Same value

#string object action condition
== : exactly same value
!= : Has no such value

#number value action condition
== : Same value
!= : non-equal value
>  : Exceed value
>= : More than
<  : Less than
<= : More than


e.g.
"id == somewhat"

getClaimsWithFilter

- (nullable NSArray<IWClaimData *> *)getClaimsWithFilter:(NSString *)filter

Description

  • Uses the filtering condition to get specific confirmable VC

Parameters

Type

Parameter

Description

NSString

filter

filtering condition

Return Value

  • NSArray that has the object of searched IWClaimData type

Refer to: IWClaimData Class

removeClaimAtIndex

- (BOOL)removeClaimAtIndex:(NSUInteger)index

Description

  • Uses an index to remove VC. Status of Key Manager must be unlocked state

Parameters

Type

Parameter

Description

NSUInteger

index

제거될 인덱스

Return Value

  • YES, if removed successfully otherwise return, NO

removeClaimObject

- (BOOL)removeClaimObject:(IWClaimData *)claim

Description

  • Removes the identical Claim as the VC object among identifiable claims Status of Key Manager must be unlocked state

Parameters

Type

Name

Description

IWClaimData

claim

Claim Object

Return Value

  • YES, if removed successfully otherwise return, NO

removeClaimsWithFilter

- (BOOL)removeClaimsWithFilter:(NSString *)filter

Description

  • Use the filtering condition to remove identifiable Claims Status of Key Manager must be unlocked state

Parameters

Type

Parameter

Description

NSString

filter

filtering condition

Return Value

  • YES, if removed successfully otherwise return, NO

removeAllClaims

- (BOOL)removeAllClaims

Description

  • Remove all VCs that are stored.

    Status of Key Manager must be unlocked state

Return Value

  • YES, if removed successfully otherwise return, NO

Elliptic Curve Integrated Encryption Scheme

getECIESEncryptData

- (nullable NSData *)getECIESEncryptData:(NSString *)keyId
                                   nonce:(NSData *)nonce
                               publicKey:(NSString *)publicKey
                                  source:(NSData *)source
                                 aesType:(AES_TYPE)aesType

Description

  • With the value obtained from the Elliptic Curve Cryptosystem get ENCRYPTED data after AES encryption.

    Status of Key Manager must be unlocked state

Parameters

Type

Parameter

Description

NSString

keyId

key ID for private key look-up

NSData

nonce

Unpredictable String (random value)

NSString

publicKey

public key of decryptor encoded with Base 58

NSData

source

data to encrypt

AES_TYPE

aesType

AES128 or AES256

Return Value

  • Encrypted data

Refer : AES_TYPE

getECIESDecryptData

- (nullable NSData *)getECIESDecryptData:(NSString *)keyId
                                   nonce:(NSData *)nonce
                               publicKey:(NSString *)publicKey
                                  source:(NSData *)source
                                 aesType:(AES_TYPE)aesType

Description

  • with a value obtained from the Elliptic Curve Cryptosystem get DECRYPTED data after AES encryption.

    Status of Key Manager must be unlocked state

Parameters

Type

Parameter

Description

NSString

keyId

Key ID for private key look-up

NSData

nonce

unpredictable Sring (random value)

NSString

publicKey

public key of decryptor encoded with Base 58

NSData

source

Data to decrypt

AES_TYPE

aesType

AES128 or AES256

Return Value

  • Decrypted data

Refer to : AES_TYPE

File Management

getHeader

- (nullable IWKeyStoreHeadElement *)getHeader

Description

  • Gets the Header object of the key file.

Return Value

  • Header object of the file (IWKeyStoreHeadElement)

Refer to: IWKeyStoreHeadElement

checkWalletFileExists

- (BOOL)checkWalletFileExists

Description

  • Checks the existence of KeyFile.

Return Value

  • YESif exists, otherwise returns NO

deleteWalletFile

- (void)deleteWalletFile

Description

  • Deletes the key file.

resetWalletFile

- (void)resetWalletFile

Description

  • Resets the wallet files and settings.

EOS KEY Convert

getEOSPublicKeyWithKeyId

- (nullable NSString *)getEOSPublicKeyWithKeyId:(NSString *)keyId

Description

  • Uses keyId to get EOSPublicKey

Parameters

Type

Parameter

Description

NSString

keyId

Alias of the key to find

Return Value

  • EOSPublicKey(Wallet Import Format)

getEOSPrivateKeyWithKeyId

- (nullable NSString *)getEOSPrivateKeyWithKeyId:(NSString *)keyId

Description

  • Uses KeyId to get EOSPrivateKey.

    Status of Key Manager must be an unlocked state.

Parameters

Type

Parameter

Description

NSString

keyId

Alias of the key to find

Return Value

  • EOSPriavteKey(Wallet Import Format)

Zero Knowledge Proof

genZKPMasterSecret

-(NSString *)genZKPMasterSecret

Description

  • Create the master secret for zero-knowledge proof. SDK manages the master secret and App returns only the master secret ID.

Return Value

  • master secret ID of NSString type

removeAllMasterSecrets

-(BOOL)removeAllMasterSecrets;

Description

  • Removes all the master secrets that is stored.

Return Value

  • YES , if removes successfully and returns NOif fails

verifyCredentialOffer:withPublicKey:completeHandler:failureHandler:

-(void)verifyCredentialOffer:(CredentialOfferData *)credentialOfferData
               withPublicKey:(ZKPPublicKeyData *)pubKey
             completeHandler:(void(^)(void))completeHandler
              failureHandler:(void(^)(int errorCode))failureHandler

Description

  • verifies the CredentialOffer

Parameters

Type

Parameter

Description

CredentialOfferData

credentialOfferData

CredentialOffer model

ZKPPublicKeyData

pubKey

PublicKeymodel for ZKP

void(^)(void)

completeHandler

Verification success block

void(^)(int)

failureHandler

Verification failed block

failureHandler

Type

Parameter

Description

int

errorCode

Error code

errorCode

errorCode

Description

1

Verification failed

generateZKPCredentialRequest:withDID:withMasterSecretId:withCredentialOffer:withNonce:completeHander:failureHandler:

-(void)generateZKPCredentialRequest:(ZKPPublicKeyData *)pubKey
                            withDID:(NSString *)did
                 withMasterSecretId:(NSString *)masterSecretId
                withCredentialOffer:(CredentialOfferData *)credOffer
                          withNonce:(NSString *)nonce
                    completeHandler:(void(^)(NSString *zkpCredentialRequest))completeHandler
                     failureHandler:(void(^)(int errorCode))failureHandler

Description

  • Generates ZKPCredentialRequest to receive ZKPCredential(VC).

Parameters

Type

Parameter

Description

ZKPPublicKeyData

pubkey

ZKPPublicKeyData

NSString

did

User DID

NSString

masterSecretId

MasterSecret ID

CredentialOfferData

credOffer

CredentialOfferData

NSString

nonce

Unpredictable String (random value)

(void(^)(NSString *)

completeHandler

Generation complete block

(void(^)(int))

failureHand

Generation failed block

completeHandler

Type

Parameter

Description

NSString

zkpCredentialReqest

required NSString of JSON format necessary to receive ZKPCredential

failureHandler

Type

Parameter

Description

int

errorCode

failed error code

errorCode

errorCode

Description

1

relevant masterSecret ID does not exist

zkpCredentialVerifierWithSignatureCredential:withSignCredProof:withValues:withPublicKey:withMasterSecretKeyId:withVPrime:withNonce:completeHander:failureHandler:

-(void)zkpCredentialVerifierWithSignatureCredential:(ZKPSignatureCredential *)signCred
                                  withSignCredProof:(ZKPSignatureCorrectnessProof *)proof
                                         withValues:(NSMutableDictionary *)values
                                      withPublicKey:(ZKPPublicKeyData *)pubKey
                              withMasterSecretKeyId:(NSString *)masterSecretId
                                         withVprime:(NSString *)vPrime
                                          withNonce:(NSString *)nonce
                                    completeHandler:(void(^)(void))completeHandler
                                     failureHandler:(void(^)(int errorCode))failureHandler;

Description

  • Verifies the received ZKP Credential(VC).

Parameters

Type

Parameter

Description

ZKPSignatureCredential

signCred

ZKPSignatureCredential

ZKPSignatureCorrectnessProof

proof

ZKPSignatureCorrectnessProof

NSMutableDictionary

values

Credential values

ZKPPublicKeyData

pubKey

ZKPPublicKeyData

NSString

masterSecretId

Master secret ID

NSString

vPrime

vPrime value of the credential

NSString

nonce

Unpredictable String (random value)

void(^)(void)

completeHandler

Verification success block

void(^)(int)

failureHandler

Verification failed block

failureHandler

Type

Parameter

Description

int

errorCode

failed error code

errorCode

errorCode

Description

1

Key-value of r and values does not match

2

Abnormal public key

3

cred failed

4

proof failed

5

Relevant masterSecret ID does not exist

saveZKPCredentialWithID:withOriginCredential:withVPrime

-(BOOL)saveZKPCredentialWithID:(NSString *)credDefId
           withOriginCredential:(NSString *)credentialJsonString
                     withVPrime:(NSString *)vPrime

Description

  • Saves the received zkpCredential(VC).

Parameters

Type

Parameter

Description

NSString

credDefID

credentialDefinitionID

NSString

credentialJsonString

JSON format String of ZKPCredential

NSString

vPrime

vPrime value of a 0credential

getZKPCredential:withError:

-(ZKPCredential *)getZKPCredential:(NSString *)credDefId
                    withError:(NSError **)error

Description

  • Gets all the stored ZKPCredential.

Parameters

Type

Parameter

Description

NSString

credDefId

credentialDefinitionID

NSError *

error

a pointer of NSError type

completeHandler

Type

Parameter

Description

NSString

backedUpData

backed-up date

failureHandler

Type

Parameter

Description

NSString

errorMessage

failed message

NSUInteger

errorCode

failed error code

getAllZKPCredentials

-(NSDictionary*)getAllZKpCredentials

Description

  • Gets all the ZKP Credential.

Return Value

  • NSDictionary which has the ZKP Credential

removeAllZKPClaims

-(NSDictionary*)getAllZKpCredentials

Description

  • Removes all the ZKP Credential.

Return Value

  • YES, if removed successfully and returns NOwhen failed

getZKPCredentialsList

-(NSArray *)getZKPCredentialsList

Description

  • Gets file list of stored ZKP Credential

Return Value

  • file list NSArray

makeZkpVerifyProof:withCredential:withMasterSecretId:withPublicKey:completehandler:failureHandler:

-(void)makeZkpVerifyProof:(ZKPProofRequest *)zkpProofRequest
        withCredential:(ZKPCredential *)credential
    withMasterSecretId:(NSString *)masterSecretId
         withPublicKey:(ZKPPublicKeyData*)pubKey
       completeHandler:(void(^)(NSString *zkpVerifyRequestString))completeHandler
        failureHandler:(void(^)(int errorCode))failureHandler

Description

  • Creates Request to verify the ZKP Credential(VC)

Parameters

Type

Parameter

Description

ZKPProofRequest

zkpProofRequest

ZKPProofRequest

ZKPCredential

credential

ZKPCredential

NSString

masterSecretId

masterSecret ID

ZKPPublicKeyData

pubKey

ZKPPublicKeyData

void(^)(NSString *)

completeHandler

Creation completed block

void(^)(int)

failureHanlder

Creation failed block

completeHandler

Type

Parameter

Description

NSString

zkpVerifyRequestString

JSON format string to verify the ZKP Credential(VC)

failureHandler

Type

Parameter

Description

int

errorCode

Fail error code

errorCode

errorCode

Description

1

relevant masterSecretId does not exist

101

the key which trying to hide (unrevealed Attrs) does not exist in the [r] values of the public key.

102

the key which trying to hide does not exist in the mTilde value

151

the delta value is not valid

152

the key value of unrevealedAttrs does not contain the key value of mTilde

153

key-value of uTilde is not normal

154

key-value of rTilde is not normal

155

the delta value of rTilde does not exist

156

the value of t is not normal

157

the value of uTilde is not normal

158

The Credential(VC) value and key of the input-value does not match

201

The value of initProof is null

202

cList of initProof is null

203

tList of initProof is null

204

nonce of ZKPProofRequest does not exist

205

value of challenge is null

206

value of tList is null

207

equalProof object does not exist.

208

key-value of unrevealedAttrs does not contain in the key -value of mTilde

209

the value of Credential(VC) and key of the input-value does not match

210

the value of Credential(VC) and key of the input-value does not match

makeZkpVerifyProof:withCredentialJsonString:withMasterSecretId:withPublicKey:completehandler:failureHandler:

-(void)makeZkpVerifyProof:(ZKPProofRequest *)zkpProofRequest
 withCredentialJsonString:(NSString *)credentialJsonString
       withMasterSecretId:(NSString *)masterSecretId
            withPublicKey:(ZKPPublicKeyData*)pubKey
          completeHandler:(void(^)(NSString *zkpVerifyRequestString))completeHandler
           failureHandler:(void(^)(int errorCode))failureHandler

Description

  • Create a Request to verify the ZKP Credential(VC).

Parameters

Type

Parameter

Description

ZKPProofRequest

zkpProofRequest

ZKPProofRequest

NSString

credentialJsonString

JSON format NSString value of the ZKPCredential

NSString

masterSecretId

masterSecret Id

ZKPPublicKeyData

pubKey

ZKPPublicKeyData

void(^)(NSString *)

completeHandler

Creation completed block

void(^)(int)

failureHanlder

Creation failed block

completeHandler

Type

Parameter

Description

NSString

zkpVerifyRequestString

JSON format String to verify ZKP Credential(VC)

failureHandler

Type

Parameter

Description

int

errorCode

failed error code

errorCode

errorCode

Description

1

relevant masterSecretId does not exist

101

the key which trying to hide (unrevealed Attrs) does not exist in the [r] values of the public key.

102

the key which trying to hide does not exist in the mTilde value

151

the delta value is not valid

152

the key value of unrevealedAttrs does not contain the key value of mTilde

153

key-value of uTilde is not normal

154

key-value of rTilde is not normal

155

the delta value of rTilde does not exist

156

the value of t is not normal

157

the value of uTilde is not normal

158

The Credential(VC) value and key of the input-value does not match

201

The value of initProof is null

202

cList of initProof is null

203

tList of initProof is null

204

nonce of ZKPProofRequest does not exist

205

value of challenge is null

206

value of tList is null

207

equalProof object does not exist.

208

key-value of unrevealedAttrs does not contain in the key -value of mTilde

209

the value of Credential(VC) and key of the input-value does not match

210

the value of Credential(VC) and key of the input-value does not match

Last updated