Partial keygen and encrypt