private static SupportedGroup negotiateNamedCurve(ClientHello clientHello){
  SupportedGroup result=null;
  List<SupportedGroup> preferredGroups=SupportedGroup.getPreferredGroups();
  SupportedEllipticCurvesExtension extension=clientHello.getSupportedEllipticCurvesExtension();
  if (extension == null) {
    if (!preferredGroups.isEmpty()) {
      result=preferredGroups.get(0);
    }
  }
 else {
    for (    Integer preferredGroupId : extension.getSupportedGroupIds()) {
      SupportedGroup group=SupportedGroup.fromId(preferredGroupId);
      if (group != null && group.isUsable() && preferredGroups.contains(group)) {
        result=group;
        break;
      }
    }
  }
  return result;
}

private static SupportedGroup negotiateNamedCurve ( ClientHello clientHello ) { SupportedGroup result = null ; List < SupportedGroup > preferredGroups = SupportedGroup . getPreferredGroups ( ) ; SupportedEllipticCurvesExtension extension = clientHello . getSupportedEllipticCurvesExtension ( ) ; if ( extension == null ) { if ( ! preferredGroups . isEmpty ( ) ) { result = preferredGroups . get ( 0 ) ; } } else { for ( Integer preferredGroupId : extension . getSupportedGroupIds ( ) ) { SupportedGroup group = SupportedGroup . fromId ( preferredGroupId ) ; if ( group != null && group . isUsable ( ) && preferredGroups . contains ( group ) ) { result = group ; break ; } } } return result ; }
determines the elliptic curve to use during the ec based dh key exchange .
