function recoverAddr(bytes32 hash, bytes sig) internal pure returns (address) {
		bytes32 r;
		bytes32 s;
		uint8 v;

		
		if (sig.length != 65) {
			return (address(0));
		}
		
		
        assembly {
          r := mload(add(sig, 33))
          s := mload(add(sig, 65))
          v := mload(add(sig, 1))
        }
        
        
        if (v < 27) {
          v += 27;
        }

		
		if (v != 27 && v != 28) {
			return (address(1));
		} else {
			return ecrecover(hash, v, r, s);
		}
	}