Practical functional encryption for quadratic functions with applications to predicate encryption