code: public static byte[] EncodeEcPrivateKey(byte[] oid, byte[] keyBytes, byte[] spki) throws CoseException
      {
          //  ECPrivateKey ::= SEQUENCE {
          //     version  INTEGER {1}
          //     privateKey OCTET STRING
          //     parameters [0] OBJECT IDENTIFIER = named curve
          //     public key [1] BIT STRING OPTIONAL
          //  }
          //
  
          ArrayList<byte[]> xxx = new ArrayList<byte[]>();
          xxx.add(new byte[]{2, 1, 1});
          xxx.add(OctetStringTag);
          xxx.add(ComputeLength(keyBytes.length));
          xxx.add(keyBytes);
          xxx.add(new byte[]{(byte)0xa0});
          xxx.add(ComputeLength(oid.length));
          xxx.add(oid);
          if (spki != null) {
              xxx.add(new byte[]{(byte)0xa1});
              xxx.add(ComputeLength(spki.length+1));
              xxx.add(new byte[]{0});
              xxx.add(spki);
          }
          
          byte[] ecPrivateKey = Sequence(xxx);
       
          return ecPrivateKey;
      }
docs: Encode an EC Private key
  @param oid - curve to use
  @param keyBytes - bytes of the key
  @param spki - optional SPKI
  @return encoded private key
  @throws CoseException - from lower level