             handshakeState = .roundOneSent
             //server will respond with data for roundOneRead
         } else {
-            handshakeState = .failed
-            self.delegate?.handshakeDidFail(sender: self, error: .FailedToCreateRoundOne)
+            fail(withReason: .FailedToCreateRoundOne)
         }
     }
 
     private func readRoundOne(_ data: Data) {
-        NSLog("Handshake: readRoundOne")
+        log("Handshake: readRoundOne")
         let result = ecJPakeWrapper.readRoundOne(data)
 
         if (result == 0) {

            handshakeState = .roundTwoRead
            sendRoundTwo()
        } else {
            handshakeState = .failed
            self.delegate?.handshakeDidFail(sender: self, error: .FailedToReadRoundTwo)
        }
    }


    private func sendRoundTwo() {
        NSLog("Handshake: sendRoundTwo")
        let data = ecJPakeWrapper.writeRoundTwo()

        if let data = data {

    case FailedToDeriveSecret
    case FailedToCreateConfirmation
    case FailedToVerifySecret

    public var description: String {
        switch self {
            case .FailedToInitializeEcJPake : return "Unable to initialize EC-JPake"
            case .FailedToCreateRoundOne : return "Unable to create handshake local round 1 data"
            case .FailedToCreateRoundTwo : return "Unable to create handshake local round 2 data"
            case .FailedToReadRoundOne : return "Unable to read handshake remote round 1 data"
            case .FailedToReadRoundTwo : return "Unable to read handshake remote round 2 data"
            case .FailedToDeriveSecret : return "Unable to derive secret"
            case .FailedToCreateConfirmation : return "Unable to create confirmation data"
            case .FailedToVerifySecret : return "Unable to verify secret"
        }
    }
}

enum HandshakeState: Int {
