enhance EC method to support setting curve type when generating keys and add parameter encoding option (cherry picked from commit 24edfa9d)