In this paper, we present a heuristic algorithm that computes the ideal class group and a generator of a principal ideal (PIP) in Q(ζps ) in time 2 O(n 1/2+ε ) for n := deg(Q(ζps )) and arbitrarily small ε > 0. We introduce practical improvements to enhance its run time, and we describe a variant that can compute a generator of a principal ideal I with N (I) ≤ 2 n b in time 2 O(n a+o(1) ) given a precomputation of the class group taking time 2 O(n 2−3a+ε ) for an arbitrarily small ε > 0 where b ≤ 7a−2 and 2 5 < a < 1 2 . In particular, this precomputation allows us to solve these instances of the PIP in with a run time lower than 2 O(n 1/2 ) . Relying on recent work from Cramer et al. [CDPR16], this yields an attack on all the cryptographic schemes relying on the hardness of finding a short generator of a principal ideal of Q(ζps ) such as the homomorphic encryption scheme of Vercauteren and Smart [SV10], and the multilinear maps of Garg, Gentry and Halevi [GGH13]. This attack (with and without precomputation) is asymptotically faster than the one relying on the work of Biasse and Fieker [Biab,BF14] which runs in time 2 O(n 2/3+ε ) for arbitrarily small ε > 0. In particular, the public keys of the multilinear maps of Garg, Gentry and Halevi [GGH13] satisfy the requirement on the input ideal to use our PIP algorithm with precomputation. By using a = 3/7, b = 1 + o(1), and given a precomputation of time 2 O(n 5/7+ε ) for arbitrarily small ε > 0 on Q(ζps ), our algorithm provides a key recovery attack in time 2 O(n 3/7+o(1) )