ZDCRestManager

@interface ZDCRestManager : NSObject

Facilitates access to the REST API of the ZeroDark.cloud servers.

  • API Gateway URLS have the following form:

    • https://{apiGatewayID}.execute-api.{region}.amazonaws.com/{stage}

    This method returns the API Gateway ID that matches the region & stage.

    For example: rsuraaljlh

    Declaration

    Objective-C

    - (nullable NSString *)apiGatewayIDForRegion:(AWSRegion)region
                                           stage:(nonnull NSString *)stage;

    Swift

    func apiGatewayID(for region: AWSRegion, stage: String) -> String?
  • API Gateway URLS have the following form:

    • https://{apiGatewayID}.execute-api.{region}.amazonaws.com/{stage}

    This method fills out the URL for you, and returns a (configurable) NSURLComponents instance.

    Your path property should NOT include the stage component. This will be added for you automatically.

    Declaration

    Objective-C

    - (nullable NSURLComponents *)apiGatewayForRegion:(AWSRegion)region
                                                stage:(nonnull NSString *)stage
                                                 path:(nonnull NSString *)path;

    Swift

    func apiGateway(for region: AWSRegion, stage: String, path: String) -> URLComponents?
  • Fetches configuration information from the server.

    This is a JSON file that describes information such as the list of supported social providers.

    Declaration

    Objective-C

    - (void)
        fetchConfigWithCompletionQueue:(nullable dispatch_queue_t)completionQueue
                       completionBlock:
                           (nonnull void (^)(NSDictionary *_Nullable,
                                             NSError *_Nullable))completionBlock;

    Swift

    func fetchConfig(withCompletionQueue completionQueue: DispatchQueue?, completionBlock: @escaping ([AnyHashable : Any]?, Error?) -> Void)
  • Configures the user’s account, which includes tasks such as creating the user’s bucket.

    This method is used during user setup & activation. As such, it does not require the given ZDCLocalUser or ZDCLocalUserAuth to be stored in the database.

    Declaration

    Objective-C

    - (void)setupAccountForLocalUser:(nonnull ZDCLocalUser *)localUser
                            withAuth:(nonnull ZDCLocalUserAuth *)auth
                             treeIDs:(nonnull NSArray<NSString *> *)treeIDs
                     completionQueue:(nullable dispatch_queue_t)completionQueue
                     completionBlock:
                         (nonnull void (^)(NSString *_Nullable, NSString *_Nullable,
                                           NSString *_Nullable, NSDate *_Nullable,
                                           NSError *_Nullable))completionBlock;

    Swift

    func setupAccount(for localUser: ZDCLocalUser, with auth: ZDCLocalUserAuth, treeIDs: [String], completionQueue: DispatchQueue?, completionBlock: @escaping (String?, String?, String?, Date?, Error?) -> Void)

    Parameters

    localUser

    The localUser we’re setting up.

    auth

    Valid authentication for the localUser.

    treeIDs

    A list of treeID’s that we’re activating for the user.

    completionQueue

    The dispatch queue on which to invoke the completionBlock. If not specified, the main thread is used.

    completionBlock

    The block to invoke with the results of the request.

  • Registers the given iOS/macOS pushToken with the server.

    This method is invoked during account setup.

    Declaration

    Objective-C

    - (void)registerPushTokenForLocalUser:(nonnull ZDCLocalUser *)localUser
                          completionQueue:(nullable dispatch_queue_t)completionQueue
                          completionBlock:
                              (nonnull void (^)(NSURLResponse *_Nullable,
                                                id _Nullable,
                                                NSError *_Nullable))completion;

    Swift

    func registerPushToken(for localUser: ZDCLocalUser, completionQueue: DispatchQueue?, completionBlock completion: @escaping (URLResponse?, Any?, Error?) -> Void)
  • Unregisters the given iOS/macOS pushToken with the server.

    This method is invoked:

    • when deleting a localUser from the device
    • if we ever receive a push notification for an unknown localUserID

    Declaration

    Objective-C

    - (void)unregisterPushToken:(nonnull NSString *)pushToken
                      forUserID:(nonnull NSString *)userID
                         region:(AWSRegion)region
                completionQueue:(nullable dispatch_queue_t)completionQueue
                completionBlock:(nullable void (^)(NSURLResponse *_Nonnull,
                                                   NSError *_Nullable))completion;

    Swift

    func unregisterPushToken(_ pushToken: String, forUserID userID: String, region: AWSRegion, completionQueue: DispatchQueue?, completionBlock completion: ((URLResponse, Error?) -> Void)? = nil)
  • Fetches the user’s info from the server, which includes:

    • region (NSString)
    • bucket (NSString)
    • stage (NSString)
    • created (NSDate)

    Uses ephemeralSessionConfiguration. Does not require the given ZDCLocalUser or ZDCLocalUserAuth to be stored in the database.

    Declaration

    Objective-C

    - (void)fetchInfoForLocalUser:(nonnull ZDCLocalUser *)user
                         withAuth:(nonnull ZDCLocalUserAuth *)auth
                  completionQueue:(nullable dispatch_queue_t)completionQueue
                  completionBlock:
                      (nonnull void (^)(NSDictionary *_Nullable,
                                        NSError *_Nullable))completionBlock;

    Swift

    func fetchInfo(for user: ZDCLocalUser, with auth: ZDCLocalUserAuth, completionQueue: DispatchQueue?, completionBlock: @escaping ([AnyHashable : Any]?, Error?) -> Void)
  • Documentation ?

    Declaration

    Objective-C

    - (void)
        fetchAuth0ProfileForLocalUserID:(nonnull NSString *)localUserID
                        completionQueue:(nonnull dispatch_queue_t)completionQueue
                        completionBlock:
                            (nonnull void (^)(NSURLResponse *_Nonnull, id _Nonnull,
                                              NSError *_Nonnull))completionBlock;

    Swift

    func fetchAuth0Profile(forLocalUserID localUserID: String, completionQueue: DispatchQueue, completionBlock: @escaping (URLResponse, Any, Error) -> Void)
    • Fetches the remote user’s info from the server, which includes: *
    • - region (NSString)
    • - bucket (NSString)

    Declaration

    Objective-C

    - (void)fetchInfoForRemoteUserID:(nonnull NSString *)remoteUserID
                         requesterID:(nonnull NSString *)localUserID
                     completionQueue:(nullable dispatch_queue_t)completionQueue
                     completionBlock:
                         (nonnull void (^)(NSDictionary *_Nullable,
                                           NSError *_Nullable))completionBlock;

    Swift

    func fetchInfo(forRemoteUserID remoteUserID: String, requesterID localUserID: String, completionQueue: DispatchQueue?, completionBlock: @escaping ([AnyHashable : Any]?, Error?) -> Void)
    • Queries the server to see if the given user still exists.
    • E.g. user’s free trial expired (without becoming a customer), or user stopped paying their bill.

    Declaration

    Objective-C

    - (void)fetchUserExists:(nonnull NSString *)userID
            completionQueue:(nullable dispatch_queue_t)completionQueue
            completionBlock:
                (nonnull void (^)(BOOL, NSError *_Nullable))completionBlock;

    Swift

    func fetchUserExists(_ userID: String, completionQueue: DispatchQueue?, completionBlock: @escaping (Bool, Error?) -> Void)
  • Downloads & parses the given user’s publicKey file from the server.

    Declaration

    Objective-C

    - (void)fetchPubKeyForUser:(nonnull ZDCUser *)user
                   requesterID:(nonnull NSString *)localUserID
               completionQueue:(nullable dispatch_queue_t)completionQueue
               completionBlock:
                   (nonnull void (^)(ZDCPublicKey *_Nullable,
                                     NSError *_Nullable))completionBlock;

    Swift

    func fetchPubKey(for user: ZDCUser, requesterID localUserID: String, completionQueue: DispatchQueue?, completionBlock: @escaping (ZDCPublicKey?, Error?) -> Void)

    Parameters

    user

    The user whose publicKey you wish to fetch.

    localUserID

    The localUser with which to perform the HTTP request.

    completionQueue

    The dispatch_queue to use when invoking the completionBlock If you pass nil, the main thread will automatically be used.

    completionBlock

    Invoked with the result of the request.

  • Attempts to set the user’s privateKey/publicKey pair. If the user doesn’t already have a set of keys, the server will accept the pair. Otherwise, the server will reject the request, and return the existing pair.

    • The privKey file should be a PBKDF2 wrapped private key (i.e. requires accessKey to decrypt)
    • The pubKey file should be JSON
    • The files get stored in the root of the user’s bucket, and are named .privKey & .pubKey.
    • The .privKey file is only readable by the bucket owner (in terms of S3 permissions)
    • The .pubKey file is world-readable

    This method is used during user setup & activation. As such, it does not require the given ZDCLocalUser or ZDCLocalUserAuth to be stored in the database.

    Declaration

    Objective-C

    - (void)uploadPrivKey:(nonnull NSData *)privKey
                   pubKey:(nonnull NSData *)pubKey
             forLocalUser:(nonnull ZDCLocalUser *)localUser
                 withAuth:(nonnull ZDCLocalUserAuth *)auth
          completionQueue:(nullable dispatch_queue_t)completionQueue
          completionBlock:(nonnull void (^)(NSData *_Nullable,
                                            NSURLResponse *_Nullable,
                                            NSError *_Nullable))completionBlock;

    Swift

    func uploadPrivKey(_ privKey: Data, pubKey: Data, for localUser: ZDCLocalUser, with auth: ZDCLocalUserAuth, completionQueue: DispatchQueue?, completionBlock: @escaping (Data?, URLResponse?, Error?) -> Void)

    Parameters

    privKey

    Serialzed PBKDF2 wrapped private key (i.e. requires accessKey to decrypt)

    pubKey

    Serialized JSON that contains public key information.

    localUser

    The localUser for which we should upload the key pairs.

    auth

    A valid authentication instance - required to authenticate the request.

    completionQueue

    The dispatch_queue to use when invoking the completionBlock If you pass nil, the main thread will automatically be used.

    completionBlock

    Invoked with the result of the request.

  • Update the publicKey for the user.

    This method is used when updating the list of attached social identities. The list is signed by the private key, and added to the pubKey JSON file.

    Note: The server allows us to update this (signed) list, but doesn’t allow us to actually change the publicKey value.

    Declaration

    Objective-C

    - (void)updatePubKeySigs:(nonnull NSData *)pubKey
              forLocalUserID:(nonnull NSString *)localUserID
             completionQueue:(nullable dispatch_queue_t)completionQueue
             completionBlock:(nonnull void (^)(NSURLResponse *_Nullable,
                                               id _Nullable,
                                               NSError *_Nullable))completionBlock;

    Swift

    func updatePubKeySigs(_ pubKey: Data, forLocalUserID localUserID: String, completionQueue: DispatchQueue?, completionBlock: @escaping (URLResponse?, Any?, Error?) -> Void)
  • Updates a user’s avatar on the server, either by uploading a new avatar or deleting whatever is there.

    This only works for non-social identities. That is, a user can link multiple identities to their account, including Facebook, LinkedIn, etc. All of these social identities (such as Facebook) have their own system for managing avatars. However, the user is also allowed to create a traditional account using only a username/password. This traditional account is referred to as a non-social account. And it’s these non-social accounts that this method is designed for. It allows the user to associate an avatar with the non-social account.

    Declaration

    Objective-C

    - (void)updateAvatar:(nullable NSData *)avatarData
             contentType:(nonnull NSString *)contentType
            previousETag:(nullable NSString *)previousETag
          forLocalUserID:(nonnull NSString *)localUserID
                 auth0ID:(nonnull NSString *)auth0ID
         completionQueue:(nullable dispatch_queue_t)completionQueue
         completionBlock:(nonnull void (^)(NSURLResponse *_Nullable, id _Nullable,
                                           NSError *_Nullable))completionBlock;

    Swift

    func updateAvatar(_ avatarData: Data?, contentType: String, previousETag: String?, forLocalUserID localUserID: String, auth0ID: String, completionQueue: DispatchQueue?, completionBlock: @escaping (URLResponse?, Any?, Error?) -> Void)

    Parameters

    avatarData

    The raw image data (serialized in PNG, JPEG, or some other commonly supported image format). You’re encouraged to stick with image formats that will be supported on every major OS.

    contentType

    The HTTP-style Content-Type for the image data. Common values include image/png, image/jpg, etc.

    previousETag

    The server will only allow you to update the avatar if you know the previous eTag value. This acts as a simple sync mechanism, and ensures that your app is up-to-date before replacing the current avatar.

    localUserID

    The user for which we’re replacing the avatar. This must be a user that’s logged in (i.e. there’s a valid ZDCLocalUser & ZDCLocalUserAuth in the database).

    auth0ID

    The identifier of the non-social account. The string is expected to be of the form auth0|

    completionQueue

    The dispatch queue on which to invoke the completion block. If unspecified, the main thread is used.

    completionBlock

    Invoked with the raw response from the server.

  • Multipart-complete proxy, facilitated by ZeroDark server.

    Sending a multipart complete command directly to the server is problematic. If multipart was being used, the assumption is that the file is pretty big, and it took a considerable amount of time to upload to the server. And you only get one shot with S3’s multipart complete command. That is, invoking it a second time will result in an error code from the server. And the error code is indistinguishable from other errors, such as an expired multipart.

    This edge case doesn’t sit well with us, so we take a different approch. We use the server to cache multipart complete requests, so that we can get the same response code for subsequent requests.

    Declaration

    Objective-C

    - (nonnull NSMutableURLRequest *)
        multipartComplete:(nonnull NSString *)key
             withUploadID:(nonnull NSString *)uploadID
                    eTags:(nonnull NSArray<NSString *> *)eTags
                 inBucket:(nonnull NSString *)bucket
                   region:(AWSRegion)region
           forLocalUserID:(nonnull NSString *)localUserID
                 withAuth:(nonnull ZDCLocalUserAuth *)auth;

    Swift

    func multipartComplete(_ key: String, withUploadID uploadID: String, eTags: [String], inBucket bucket: String, region: AWSRegion, forLocalUserID localUserID: String, with auth: ZDCLocalUserAuth) -> NSMutableURLRequest
  • The permissions on S3 only allow the bucket’s owner to list the items within the bucket. That is, only Alice has permission to list all the items in her bucket. Bob does not. So if Alice shares a directory with Bob, then Bob needs some mechanism to get the list of items within Alice’s bucket. That mechanism is the server’s list-proxy service, which will return a list of item’s within Alice’s bucket for which Bob has permission.

    This list-proxy request is rooted at a particular node. So Bob must first know the node path for which he has read permissions. And the server will then recursively enumerate the sub-nodes for which Bob has read access.

    Declaration

    Objective-C

    - (nonnull NSMutableURLRequest *)
        listProxyWithPaths:(nonnull NSArray<NSString *> *)paths
                    treeID:(nonnull NSString *)treeID
                    pullID:(nonnull NSString *)pullID
            continuationID:(nullable NSString *)continuationID
        continuationOffset:(nullable NSNumber *)continuationOffset
         continuationToken:(nullable NSString *)continuationToken
                  inBucket:(nonnull NSString *)bucket
                    region:(AWSRegion)region
            forLocalUserID:(nonnull NSString *)localUserID
                  withAuth:(nonnull ZDCLocalUserAuth *)auth;

    Swift

    func listProxy(withPaths paths: [String], treeID: String, pullID: String, continuationID: String?, continuationOffset: NSNumber?, continuationToken: String?, inBucket bucket: String, region: AWSRegion, forLocalUserID localUserID: String, with auth: ZDCLocalUserAuth) -> NSMutableURLRequest
  • Used during grafting if the target node cannot be located.

    In some cases, a node may get renamed or moved, which results in its cloudPath changing as well. When this happens, previously issued collaboration requests would contain an out-of-date cloudPath. However, the server keeps an partial index that maps from cloudID to cloudPath. So the client can ask the server to lookup the correct cloudPath.

    The server will return a result if:

    • the node still exists in the given bucket
    • the requester has read-permission for the node

    Declaration

    Objective-C

    - (void)lostAndFound:(nonnull NSString *)cloudID
                  bucket:(nonnull NSString *)bucket
                  region:(AWSRegion)region
             requesterID:(nonnull NSString *)localUserID
         completionQueue:(nullable dispatch_queue_t)completionQueue
         completionBlock:(nonnull void (^)(NSURLResponse *_Nonnull, id _Nullable,
                                           NSError *_Nullable))completionBlock;

    Swift

    func lostAndFound(_ cloudID: String, bucket: String, region: AWSRegion, requesterID localUserID: String, completionQueue: DispatchQueue?, completionBlock: @escaping (URLResponse, Any?, Error?) -> Void)

    Parameters

    cloudID

    The correct cloudID for the target node.

    bucket

    The correct bucket that contains the target node.

    region

    The correct region for the bucket.

    localUserID

    The localUserID that will be used to send the request. The request will be authenticated with this user’s information.

    completionQueue

    The dispatch queue on which to invoke the completion block. If unspecified, the main thread is used.

    completionBlock

    Invoked with the raw response from the server.

  • Fetches the user’s public info via the API Gateway.

    This information includes:

    • userID
    • user’s region
    • user’s bucket
    • list of linked identities

    Declaration

    Objective-C

    - (void)fetchFilteredAuth0Profile:(nonnull NSString *)remoteUserID
                          requesterID:(nonnull NSString *)localUserID
                      completionQueue:(nullable dispatch_queue_t)completionQueue
                      completionBlock:
                          (nullable void (^)(NSURLResponse *_Nonnull, id _Nullable,
                                             NSError *_Nullable))completion;

    Swift

    func fetchFilteredAuth0Profile(_ remoteUserID: String, requesterID localUserID: String, completionQueue: DispatchQueue?, completionBlock completion: ((URLResponse, Any?, Error?) -> Void)? = nil)
  • User search API.

    Declaration

    Objective-C

    - (void)searchUserMatch:(nonnull NSString *)queryString
                   provider:(nullable NSString *)provider
                     treeID:(nonnull NSString *)treeID
                requesterID:(nonnull NSString *)localUserID
            completionQueue:(nullable dispatch_queue_t)completionQueue
            completionBlock:(nullable void (^)(NSURLResponse *_Nonnull,
                                               id _Nullable,
                                               NSError *_Nullable))completionBlock;

    Swift

    func searchUserMatch(_ queryString: String, provider: String?, treeID: String, requesterID localUserID: String, completionQueue: DispatchQueue?, completionBlock: ((URLResponse, Any?, Error?) -> Void)? = nil)

    Parameters

    queryString

    The search query.

    provider

    Pass a non-nil value if you want to limit your search query to a specific provider. For example, you could search only for matches within Facebook. Pass nil if you’d like to search across all providers.

    localUserID

    A local user is required to perform the search. The user’s authentication info will be used to sign the request.

    completionQueue

    The dispatch queue on which to invoke the completionBlock. If non is specified, the main thread will be used.

    completionBlock

    Will be invoked with the result.

  • REST API to link a normal auth0 identity to a recovery profile.

    Known response codes:

    • 200 : OK The linking was successful.

    • 400 : Bad request Detailed information will be in response.

    • 401 : Unauthorized Permissions problem.

    • 404 : Not found Either the recovery or standard auth_id doesn’t appear to exist.

    Declaration

    Objective-C

    - (void)linkAuth0ID:(nonnull NSString *)linkAuth0ID
           toRecoveryID:(nonnull NSString *)recoveryAuth0ID
                forUser:(nonnull NSString *)localUserID
        completionQueue:(nullable dispatch_queue_t)completionQueue
        completionBlock:(nullable void (^)(NSURLResponse *_Nonnull, id _Nullable,
                                           NSError *_Nullable))completion;

    Swift

    func linkAuth0ID(_ linkAuth0ID: String, toRecoveryID recoveryAuth0ID: String, forUser localUserID: String, completionQueue: DispatchQueue?, completionBlock completion: ((URLResponse, Any?, Error?) -> Void)? = nil)
  • Uses the server API to link a secondary auth0 identity to the user’s auth0 profile.

    • If response is non-nil:

      • response[@statusCode] contains an HTTP statusCode
        • 200 - OK The linking was successful.
        • 400 - Bad request User doesn’t own primary auth0_id, or secondary auth0_id is already linked to another account.
        • 401 - Unauthorized Permissions problem.
        • 404 - Not found Either the primary or secondary auth_id doesn’t exist.

    Declaration

    Objective-C

    - (void)linkAuth0ID:(nonnull NSString *)linkAuth0ID
                forUser:(nonnull ZDCLocalUser *)user
        completionQueue:(nullable dispatch_queue_t)completionQueue
        completionBlock:(nullable void (^)(NSURLResponse *_Nonnull, id _Nullable,
                                           NSError *_Nullable))completion;

    Swift

    func linkAuth0ID(_ linkAuth0ID: String, for user: ZDCLocalUser, completionQueue: DispatchQueue?, completionBlock completion: ((URLResponse, Any?, Error?) -> Void)? = nil)
  • Uses the server API to unlink a secondary auth0 identity from the user’s auth0 profile.

    Declaration

    Objective-C

    - (void)unlinkAuth0ID:(nonnull NSString *)unlinkAuth0ID
                  forUser:(nonnull ZDCLocalUser *)user
          completionQueue:(nullable dispatch_queue_t)completionQueue
          completionBlock:(nullable void (^)(NSURLResponse *_Nonnull, id _Nullable,
                                             NSError *_Nullable))completion;

    Swift

    func unlinkAuth0ID(_ unlinkAuth0ID: String, for user: ZDCLocalUser, completionQueue: DispatchQueue?, completionBlock completion: ((URLResponse, Any?, Error?) -> Void)? = nil)
  • Queries the server to see if the user has transitioned from free user to paying customer.

    Note

    The server also sends a push notification for this change.

    Declaration

    Objective-C

    - (void)fetchIsCustomer:(nonnull NSString *)localUserID
            completionQueue:(nullable dispatch_queue_t)completionQueue
            completionBlock:
                (nonnull void (^)(BOOL, NSError *_Nullable))completionBlock;

    Swift

    func fetchIsCustomer(_ localUserID: String, completionQueue: DispatchQueue?, completionBlock: @escaping (Bool, Error?) -> Void)
  • Queries the server for the current balance of the user.

    Note: The server also sends a push notification for this change. But if push notifications are disabled, this method should be consulted on-demand.

    Declaration

    Objective-C

    - (void)fetchCurrentBalance:(nonnull NSString *)localUserID
                completionQueue:(nullable dispatch_queue_t)completionQueue
                completionBlock:
                    (nonnull void (^)(double, NSError *_Nullable))completionBlock;

    Swift

    func fetchCurrentBalance(_ localUserID: String, completionQueue: DispatchQueue?, completionBlock: @escaping (Double, Error?) -> Void)
  • Queries the server for the user’s billing info.

    The result will include billing & usage information for the user’s account, as well as detailed information on a per-app basis.

    Declaration

    Objective-C

    - (void)fetchCurrentBilling:(nonnull NSString *)localUserID
                completionQueue:(nullable dispatch_queue_t)completionQueue
                completionBlock:
                    (nonnull void (^)(ZDCUserBill *_Nullable,
                                      NSError *_Nullable))completionBlock;

    Swift

    func fetchCurrentBilling(_ localUserID: String, completionQueue: DispatchQueue?, completionBlock: @escaping (ZDCUserBill?, Error?) -> Void)
  • Queries the server for the user’s billing info.

    The result will include billing & usage information for the user’s account, as well as detailed information on a per-app basis.

    Declaration

    Objective-C

    - (void)fetchPreviousBilling:(nonnull NSString *)localUserID
                        withYear:(NSInteger)year
                           month:(NSInteger)month
                 completionQueue:(nullable dispatch_queue_t)completionQueue
                 completionBlock:
                     (nonnull void (^)(ZDCUserBill *_Nullable,
                                       NSError *_Nullable))completionBlock;

    Swift

    func fetchPreviousBilling(_ localUserID: String, withYear year: Int, month: Int, completionQueue: DispatchQueue?, completionBlock: @escaping (ZDCUserBill?, Error?) -> Void)
  • /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    Declaration

    Objective-C

    - (void)productPurchasedByUser:(nonnull NSString *)localUserID
                 productIdentifier:(nonnull NSString *)productIdentifier
             transactionIdentifier:(nonnull NSString *)transactionIdentifier
                   appStoreReceipt:(nonnull NSData *)appStoreReceipt
                   completionQueue:(nullable dispatch_queue_t)completionQueue
                   completionBlock:
                       (nonnull void (^)(NSURLResponse *_Nonnull, id _Nullable,
                                         NSError *_Nullable))completionBlock;

    Swift

    func productPurchased(byUser localUserID: String, productIdentifier: String, transactionIdentifier: String, appStoreReceipt: Data, completionQueue: DispatchQueue?, completionBlock: @escaping (URLResponse, Any?, Error?) -> Void)
  • Downloads the merkle tree JSON file from the server. This is part of the flow of verifying a user’s publicKey:

    • Query the Ethereum blockchain for a specific userID
    • If the response includes a merkleTreeRoot, then
    • Download the corresponding merkleTreeFile
    • Verify the publicKey in the merkleTreeFile matches what you expect
    • Verify the merkleTreeFile itself

    More detailed information on how this works can be found here: https://zerodarkcloud.readthedocs.io/en/latest/overview/ethereum/

    Declaration

    Objective-C

    - (void)fetchMerkleTreeFile:(nonnull NSString *)merkleTreeRoot
                completionQueue:(nullable dispatch_queue_t)completionQueue
                completionBlock:
                    (nonnull void (^)(NSURLResponse *_Nullable,
                                      ZDCMerkleTree *_Nullable,
                                      NSError *_Nullable))completionBlock;

    Swift

    func fetchMerkleTreeFile(_ merkleTreeRoot: String, completionQueue: DispatchQueue?, completionBlock: @escaping (URLResponse?, ZDCMerkleTree?, Error?) -> Void)

    Parameters

    merkleTreeRoot

    A merkleTreeRoot value, as returned from the blockchain. This is typically a sha256 string, in hex format. For example: 0xcd59b7bda6dc1dd82cb173d0cdfa408db30e9a747d4366eb5b60597899eb69c1

    completionQueue

    The dispatch_queue on which to invoke the completionBlock.

    completionBlock

    Invoked with the results of the query. If the merkleTree parameter is non-nil, you’ll want to (1) verify the included publicKey info, and (2) verify the merkleTree file itself (via merkleTree.hashAndVerify()).