Skip to content

PrivateKey parameters and RFC 5915 #493

@richardschneider

Description

@richardschneider

The PrivateKey.parameters produced by ec_privkey_export_der currently contain the curve parameters. According to RFC 5915 section 3, it should contain the curve name (OID).

Is it possible to change this method, or add a ec_privkey.export_RFC5480

parameters specifies the elliptic curve domain parameters
associated to the private key. The type ECParameters is discussed
in [RFC5480]. As specified in [RFC5480], only the namedCurve
CHOICE is permitted. namedCurve is an object identifier that
fully identifies the required values for a particular set of
elliptic curve domain parameters. Though the ASN.1 indicates that
the parameters field is OPTIONAL, implementations that conform to
this document MUST always include the parameters field.

Expected

SEQUENCE(4 elem)
  INTEGER 1
  OCTET STRING(32 byte) FD1DFE200F8133418031877BF9B54A816D9066011C426ACD46E1B8C16863FEA9
  [0](1 elem)
     OBJECT IDENTIFIER 1.3.132.0.10 secp256k1 (SECG (Certicom) named elliptic curve)
  [1](1 elem)
     BIT STRING(264 bit) 0000001110001111011111001101110011101011001100011011010111110010001101…

Actual

SEQUENCE(4 elem)
  INTEGER 1
  OCTET STRING(32 byte) FD1DFE200F8133418031877BF9B54A816D9066011C426ACD46E1B8C16863FEA9
  [0](1 elem)
    SEQUENCE(6 elem)
      INTEGER 1
      SEQUENCE(2 elem)
        OBJECT IDENTIFIER 1.2.840.10045.1.1 prime-field (ANSI X9.62 field type)
        INTEGER(256 bit) 1157920892373161954235709850086879078532699846656405640394575840079088…
     SEQUENCE(2 elem) 
       OCTET STRING(1 byte) 00
       OCTET STRING(1 byte) 07
     OCTET STRING(33 byte) 0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798
     INTEGER(256 bit) 1157920892373161954235709850086879078528375642790749043826051631415181…
     INTEGER 1
  [1](1 elem)
     BIT STRING(264 bit) 0000001110001111011111001101110011101011001100011011010111110010001101…

This was first raised in cryptocoinjs/secp256k1-node#123

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions