indutny / elliptic

Fast Elliptic Curve Cryptography in plain javascript
1.7k stars 381 forks source link

How to define curve secp224k1? #205

Open ahzf opened 5 years ago

ahzf commented 5 years ago

Hi,

for the following software I use elliptic to verify EC signatures using different curves: https://github.com/OpenChargingCloud/ChargyDesktopApp

Now I need to add curve secp224k1 which is currently not defined in elliptic. I read at https://www.secg.org/sec2-v2.pdf that the parameters of the curve are the following, but I'm not sure how to define the curve within curves.js:

defineCurve('secp224k1', {
                        type: 'short',
                        prime: 'p224',
                        p: 'ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffe56d',
                        a: '00000000 00000000 00000000 00000000 00000000 00000000 00000000',
                        b: '00000000 00000000 00000000 00000000 00000000 00000000 00000005',
                        n: '00000000 00000000 00000000 0001dce8 d2ec6184 caf0a971 769fb1f7',
                        h: 1,
                        hash: hash.sha256,
                        gRed: false,
                        g: [
                            'a1455b33 4df099df 30fc28a1 69a467e9 e47075a9 0f7e650e b6b7a45c',
                            '7e089fed 7fba3442 82cafbd6 f7e319f7 c0b0bd59 e2ca4bdb 556d61a5'
                        ]
                     });

I do not know if "type: 'short'," and "prime: 'p224'" makes sense, nor if "gRed: false" is correct. Currently it failes because of different assertions within short.js or BN.js.

Does anyone know how to make this work?

Thx! Achim