ZDCMerkleTree

@interface ZDCMerkleTree : NSObject

Utility class for parsing & reading merkingTree files, as downloaded from ZDC servers.

  • Attempts to parse the given dictionary. If the file doesn’t contain the proper key/value pairs, returns nil & sets error.

    Declaration

    Objective-C

    + (nullable instancetype)parseFile:(nonnull NSDictionary *)file
                                 error:(NSError *_Nullable *_Nullable)outError;

    Swift

    class func parseFile(_ file: [AnyHashable : Any]) throws -> Self
  • This method performs a self-verify operation:

    • parses all the contained values
    • rebuilds the tree
    • verifies that the hashes match
    • verifies that the root hash value is correct

    Declaration

    Objective-C

    - (BOOL)hashAndVerify:(NSError *_Nullable *_Nullable)outError;

    Swift

    func hashAndVerify() throws
  • Returns the merkleTree root value, as specified within the JSON. This value is only valid IF the hashAndVerify method returns true.

    Declaration

    Objective-C

    - (nonnull NSString *)rootHash;

    Swift

    func rootHash() -> String
  • Returns the set of userID’s contained within the merkle tree file.

    Declaration

    Objective-C

    - (nonnull NSSet<NSString *> *)userIDs;

    Swift

    func userIDs() -> Set<String>
  • Extracts the pubKey & keyID values from the JSON.

    Declaration

    Objective-C

    - (BOOL)getPubKey:(NSString *_Nullable *_Nullable)outPubKey
                keyID:(NSString *_Nullable *_Nullable)outKeyID
            forUserID:(nonnull NSString *)userID;

    Swift

    func getPubKey(_ outPubKey: AutoreleasingUnsafeMutablePointer<NSString?>?, keyID outKeyID: AutoreleasingUnsafeMutablePointer<NSString?>?, forUserID userID: String) -> Bool