{"_id":"ec-key","_rev":"9-dcc79e71707bd5a10bda6a151cb71996","name":"ec-key","dist-tags":{"latest":"0.0.6"},"versions":{"0.0.0":{"name":"ec-key","version":"0.0.0","keywords":["ec","elliptic","curve","crypto","private","public","key","pem","spki","pkcs8","pem","rfc5208","rfc5280","rfc5915","openssl"],"author":{"name":"Pier Fumagalli","email":"pier@relocately.com"},"license":"MIT","_id":"ec-key@0.0.0","maintainers":[{"name":"pfumagalli","email":"pier@usrz.com"}],"contributors":[{"name":"Pier Fumagalli","email":"pier@relocately.com"}],"homepage":"https://github.com/relocately/ec-key","bugs":{"url":"https://github.com/relocately/ec-key/issues"},"dist":{"shasum":"33148744a688d0c0a9a35a06f99e79bb34c277a7","tarball":"https://registry.npmjs.org/ec-key/-/ec-key-0.0.0.tgz","integrity":"sha512-6cMOi2xMg6U1Bbql97BjBZbisku4syr+rSZz/gwNO5Kt+GNEHUsDNxTsmA33qhA9bxmUyN9YNcKKQlREDncLdA==","signatures":[{"sig":"MEQCIC26swZ56FoHosdhD0SdPoLDe/QPJ5GNPdPeaLXJNABeAiAqNnbEH4dMKWlTkCfY2vOUnP8jz+v3q51lylV5wSZP0A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"src/ec-key.js","_from":".","_shasum":"33148744a688d0c0a9a35a06f99e79bb34c277a7","engines":{"node":"~6.0."},"gitHead":"1f59991720622ba638f88619530cf5a49f59c8d2","scripts":{"test":"gulp test"},"_npmUser":{"name":"pfumagalli","email":"pier@usrz.com"},"repository":{"url":"git+https://github.com/relocately/ec-key.git","type":"git"},"_npmVersion":"3.10.10","description":"Wrapper around an Elliptic Curve private or public keys","directories":{},"_nodeVersion":"6.10.3","dependencies":{"asn1.js":"^1.0.4"},"devDependencies":{"chai":"^2.3.0","gulp":"^3.9.1","gulp-mocha":"^4.3.1"},"_npmOperationalInternal":{"tmp":"tmp/ec-key-0.0.0.tgz_1493921949622_0.30788478115573525","host":"packages-18-east.internal.npmjs.com"}},"0.0.1":{"name":"ec-key","version":"0.0.1","keywords":["ec","elliptic","curve","crypto","private","public","key","pem","spki","pkcs8","pem","rfc5208","rfc5280","rfc5915","openssl"],"author":{"name":"Pier Fumagalli","email":"pier@relocately.com"},"license":"MIT","_id":"ec-key@0.0.1","maintainers":[{"name":"pfumagalli","email":"pier@usrz.com"}],"contributors":[{"name":"Pier Fumagalli","email":"pier@relocately.com"}],"homepage":"https://github.com/relocately/ec-key","bugs":{"url":"https://github.com/relocately/ec-key/issues"},"dist":{"shasum":"6b92cf33349eb4567a43e57d4ba86739a6cdf285","tarball":"https://registry.npmjs.org/ec-key/-/ec-key-0.0.1.tgz","integrity":"sha512-orb2pBJPElaiasE3TzGGIm5AtJsJJZS7nQ5fK43yilQJfVObKhOpQkPXIL2kO0GGaDN9z1VYXp5j0TvL4eMhJw==","signatures":[{"sig":"MEUCICQnWevTJ+M7BVAy2Eu7qvyRKcSH9Hn/yO43b60IkHTBAiEAstWmeYV5LQjr3JM2wtoTo2q/4+W4wPpG8LbwCnYqSaQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"src/ec-key.js","_from":".","_shasum":"6b92cf33349eb4567a43e57d4ba86739a6cdf285","engines":{"node":"~6.0."},"gitHead":"9e8eae7f2969aeb356b002b381c4e53a699bad7a","scripts":{"test":"gulp test"},"_npmUser":{"name":"pfumagalli","email":"pier@usrz.com"},"repository":{"url":"git+https://github.com/relocately/ec-key.git","type":"git"},"_npmVersion":"4.2.0","description":"Wrapper around an Elliptic Curve private or public keys","directories":{},"_nodeVersion":"7.10.0","dependencies":{"asn1.js":"^1.0.4"},"devDependencies":{"chai":"^2.3.0","gulp":"^3.9.1","gulp-mocha":"^4.3.1"},"_npmOperationalInternal":{"tmp":"tmp/ec-key-0.0.1.tgz_1495458498486_0.28827222250401974","host":"s3://npm-registry-packages"}},"0.0.2":{"name":"ec-key","version":"0.0.2","keywords":["ec","elliptic","curve","crypto","private","public","key","pem","spki","pkcs8","pem","rfc5208","rfc5280","rfc5915","openssl"],"author":{"name":"Pier Fumagalli","email":"pier@relocately.com"},"license":"MIT","_id":"ec-key@0.0.2","maintainers":[{"name":"pfumagalli","email":"pier@usrz.com"}],"contributors":[{"name":"Pier Fumagalli","email":"pier@relocately.com"}],"homepage":"https://github.com/relocately/ec-key","bugs":{"url":"https://github.com/relocately/ec-key/issues"},"dist":{"shasum":"50052ae961abd6f18710c235a87f349a72468189","tarball":"https://registry.npmjs.org/ec-key/-/ec-key-0.0.2.tgz","integrity":"sha512-M+PEHc4pa5HeteOssJBwaT+Qc6ki8HoXTaLqj/Lv5AQA9nUEMlYLaVg6iwaWSX6pyPX1toMdIfdaDD/Gyut6pw==","signatures":[{"sig":"MEQCIBILpJt28urbAlcK7QBA5LNkTGp1G7WR8udRkqrYlFQuAiAkNWb6YKF+8gQxCLCVoZk/jpWxcPEFeOUL7lEk5hgTWg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"src/ec-key.js","_from":".","_shasum":"50052ae961abd6f18710c235a87f349a72468189","engines":{"node":"~6.0."},"gitHead":"16e552b9e4960e35648a3b11e68a0bf7faeae905","scripts":{"test":"gulp test"},"_npmUser":{"name":"pfumagalli","email":"pier@usrz.com"},"repository":{"url":"git+https://github.com/relocately/ec-key.git","type":"git"},"_npmVersion":"4.2.0","description":"Wrapper around an Elliptic Curve private or public keys","directories":{},"_nodeVersion":"7.10.0","dependencies":{"asn1.js":"^1.0.4"},"devDependencies":{"chai":"^2.3.0","gulp":"^3.9.1","gulp-mocha":"^4.3.1"},"_npmOperationalInternal":{"tmp":"tmp/ec-key-0.0.2.tgz_1496939444193_0.12182929879054427","host":"s3://npm-registry-packages"}},"0.0.3":{"name":"ec-key","version":"0.0.3","keywords":["ec","elliptic","curve","crypto","private","public","key","pem","spki","pkcs8","pem","rfc5208","rfc5280","rfc5915","openssl"],"author":{"name":"Pier Fumagalli","email":"pier@usrz.com"},"license":"MIT","_id":"ec-key@0.0.3","maintainers":[{"name":"pfumagalli","email":"pier@usrz.com"}],"contributors":[{"name":"Pier Fumagalli","email":"pier@usrz.com"}],"homepage":"https://github.com/usrz/ec-key","bugs":{"url":"https://github.com/usrz/ec-key/issues"},"dist":{"shasum":"1017d2e73130270e16121187678aa86e076f799f","tarball":"https://registry.npmjs.org/ec-key/-/ec-key-0.0.3.tgz","fileCount":28,"integrity":"sha512-qGdWYjbiKphcZ322VT8j2Y3wWCm9ffIKAP4At7k9/9P+7Iq2dhPSFvwrqVx6DDivYLGPb3zDkL3c9/j4lMOrqw==","signatures":[{"sig":"MEQCIFDbo5oYI3TWqGAfDosTAG+IF6dHUHK2o3+TlY7Jc9fiAiBeY6ApnpDe5nksLcE9lJ4aHagTHqBDQDSeIAwMRV4Xww==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":42802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdPwqgCRA9TVsSAnZWagAAtX0P/00VEMvoijipzIB9ngMk\nCtQO/9Bd+O3zc6AFF5wjHHfUz9ln8oH/BwQ4vOhfm1sqmg52fDQky6zinX1d\nLMQetHJYS8Upivqx4OhvUJBw2Bf64GNO8CYax6zC1Bog3yV0MAYQC3UOf2jt\ndtcE6Z8KNYasekAS3T+J2OIlzxp/e3HpYvWnpyh3gMmrkM9F16PwK4NAR05C\ngHtXxkjPbIdbJD9g8i8bfS+USW7S7XOUE6Qa58wcd/iyO4H16Q9LR68RUCLh\nvpfKIcYX/xQGx3zSxyCw18Gi2haLWLOMaPfrhbntuE601GF1R1ahJr1a9P9+\nD30uOdI38FLvNduMnLgCvXdGzqJw6EXe9zxWU0dMSLWXjIVUlXZiHvh0OXo0\nJ7h8isng9bzgKSLcYKYjlq2t2o8G20kIsRzbZibJeXXqCbFh2M/bUeOLKjtE\n2BDFPjLX444reShfde/dRAzr0mBa14A3tgf7ri6/rAw/s/K/LEv4dGH+bznC\nWNfRrwuto/t8+5ksmEEfKbhFd9dCUz6yCbWDL839ElQvMzQ/CbgIDIF23/x1\nKlKIPzHApFn1z06HIH0ROxPYStBvLqgSxUns9vs0z06VUgZXnHHCXDJMVdd2\nRQn2bKThNmCZUN3rd8Yec1xmQCvcGKnnb9vHrB/+nwYYKbLSVtPU01Joz/rg\nzd5q\r\n=XLpJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/ec-key.js","engines":{"node":">=6.0.0"},"gitHead":"c3488200fbbfe2cfc342d3c71cae7f4f58bdb1b8","scripts":{"test":"gulp test"},"_npmUser":{"name":"pfumagalli","email":"pier@usrz.com"},"repository":{"url":"git+https://github.com/usrz/ec-key.git","type":"git"},"_npmVersion":"6.9.0","description":"Wrapper around an Elliptic Curve private or public keys","directories":{},"_nodeVersion":"8.15.1","dependencies":{"asn1.js":"^1.0.4"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^2.3.0","gulp":"^3.9.1","gulp-mocha":"^4.3.1"},"_npmOperationalInternal":{"tmp":"tmp/ec-key_0.0.3_1564412576316_0.4962905959278956","host":"s3://npm-registry-packages"}},"0.0.4":{"name":"ec-key","version":"0.0.4","keywords":["ec","elliptic","curve","crypto","private","public","key","pem","spki","pkcs8","pem","rfc5208","rfc5280","rfc5915","openssl"],"author":{"name":"Pier Fumagalli","email":"pier@usrz.com"},"license":"MIT","_id":"ec-key@0.0.4","maintainers":[{"name":"pfumagalli","email":"pier@usrz.com"}],"contributors":[{"name":"Pier Fumagalli","email":"pier@usrz.com"}],"homepage":"https://github.com/usrz/ec-key","bugs":{"url":"https://github.com/usrz/ec-key/issues"},"dist":{"shasum":"afde86c3a6d7428510ea860ff834b9ed64ab8885","tarball":"https://registry.npmjs.org/ec-key/-/ec-key-0.0.4.tgz","fileCount":28,"integrity":"sha512-jJkzm7XWb4Bcu4TpuQnOZD/OGSW3Y35S0Qe0cpnJsricaJtC+Tl3I0OKwgQasxNiEFt0Czv89ncq7vrHSgMj/w==","signatures":[{"sig":"MEUCIHgPWfP64rGTuU0nLFnZZg5rDR7SuzhspcqJYCUAtHIbAiEAukd7CIu6vUqMlc3IWq86flmsip0t5LA/VVuq7ShSI2A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":42851,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdPxqsCRA9TVsSAnZWagAAdlEQAIQ3egjirfGQn6bgrXWR\ngkCxFyK30SClbCJ7HarnnWlKPITwIHaQnCdUW+yCk+URcBJA3e7c/YXJr6eG\nTbvFCeJnl5zKLV2VcaT51IRwO6uahfaFs8H759Sc7Kc1ENMWYiqLx84aY89d\nuwUYYfEWp14iHHrcG60WC2Mrc3nANIXY/uTuTn4CMYWxtgvPW5ZNVAqsKyVx\n2apG9zsxAYDW8XBUVpy3rflwWukyLCZtLcCu6WD+klzb2ojbi2Q/m3RdPqI2\n57hsfdKjszxd1Wqwml4lxud7W9DQQbRy8wdgY9xSwyWCjPm+gXOqfWALBj48\nnwXXGTm4fPRxwO1S7ePzdJG4nZ1rQuTY8DP1+FvaDiqDn2+OQP9IVpEDl8bm\nGr/hH00RP0tCiv+t+x3I5WrDQ6TrRzNhsBhxiK+znSGAgXK0rUzuIbmTAafw\nxFCFenzuiFH8WDImkpPRFBYy+tzbtTqm1mHNZCJhvhQBWStwH0zcM9VZaOyd\n662BOKL0afP8i65YjD46y61DYShOOD7X/gPB6RPO3moHuaHpu2EKQ3yYoJ23\nbHuzmKItkx4hixY53TQVLUO6JrzR58NJeravKYARhm7dXhY4qsLbkxXprUM9\nLxrpKIaj8fKPR2TQJr/mkPEVvVYx9RqnTGIt+8m01dCPwDsX2Q38TW5nytPJ\nkepL\r\n=gvU4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/ec-key.js","engines":{"node":">=6.0.0"},"gitHead":"23f4dd325d7dd520775041971f21880e7f773597","scripts":{"test":"gulp test"},"_npmUser":{"name":"pfumagalli","email":"pier@usrz.com"},"repository":{"url":"git+https://github.com/usrz/ec-key.git","type":"git"},"_npmVersion":"6.9.0","description":"Wrapper around an Elliptic Curve private or public keys","directories":{},"_nodeVersion":"8.15.1","dependencies":{"asn1.js":"^5.2.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.2.0","gulp":"^4.0.2","gulp-mocha":"^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/ec-key_0.0.4_1564416683614_0.3273644024402882","host":"s3://npm-registry-packages"}},"0.0.5":{"name":"ec-key","version":"0.0.5","keywords":["ec","elliptic","curve","crypto","private","public","key","pem","spki","pkcs8","pem","rfc5208","rfc5280","rfc5915","openssl"],"author":{"name":"Pier Fumagalli","email":"pier@usrz.com"},"license":"MIT","_id":"ec-key@0.0.5","maintainers":[{"name":"pfumagalli","email":"pier@usrz.com"}],"contributors":[{"name":"Pier Fumagalli","email":"pier@usrz.com"}],"homepage":"https://github.com/usrz/ec-key","bugs":{"url":"https://github.com/usrz/ec-key/issues"},"dist":{"shasum":"1de02fd391d0cfbd11dfbb88700a5c048842c633","tarball":"https://registry.npmjs.org/ec-key/-/ec-key-0.0.5.tgz","fileCount":5,"integrity":"sha512-LE5lCSGhIz4TjEvSPgaPBG8EpSwQ1ZnMJ/vVKNVYiTPSw0quBOXZcr0mRYCrMKAFgUEaZe619kcAjPl/JcVcVw==","signatures":[{"sig":"MEQCIDVXDnCLeOlChOgEUq3Vxz8kvZUQ5G1EHNGHvkBm+KdZAiA05Foe50oWfCPGRJPYIJ1XjA6xhlOJIrEnwod8VIXBxQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":34504},"main":"src/ec-key.js","types":"ec-key.d.ts","engines":{"node":">=10.0.0"},"gitHead":"cec0006b77653cca2ce5fd73bb6ed61fcb9fef5f","scripts":{"test":"mocha"},"_npmUser":{"name":"pfumagalli","email":"pier@usrz.com"},"repository":{"url":"git+https://github.com/usrz/ec-key.git","type":"git"},"_npmVersion":"10.8.1","description":"Wrapper around an Elliptic Curve private or public keys","directories":{},"_nodeVersion":"20.12.2","dependencies":{"asn1.js":"^5.4.1"},"_hasShrinkwrap":false,"devDependencies":{"chai":"<5","mocha":"^10.6.0"},"_npmOperationalInternal":{"tmp":"tmp/ec-key_0.0.5_1720534468402_0.15368820526651028","host":"s3://npm-registry-packages"}},"0.0.6":{"name":"ec-key","description":"Wrapper around an Elliptic Curve private or public keys","version":"0.0.6","main":"src/ec-key.js","types":"ec-key.d.ts","author":{"name":"Pier Fumagalli","email":"pier@usrz.com"},"homepage":"https://github.com/usrz/ec-key","bugs":{"url":"https://github.com/usrz/ec-key/issues"},"license":"MIT","contributors":[{"name":"Pier Fumagalli","email":"pier@usrz.com"}],"repository":{"type":"git","url":"git+https://github.com/usrz/ec-key.git"},"scripts":{"test":"mocha"},"keywords":["ec","elliptic","curve","crypto","private","public","key","pem","spki","pkcs8","pem","rfc5208","rfc5280","rfc5915","openssl"],"devDependencies":{"chai":"<5","mocha":"^10.6.0"},"dependencies":{"asn1.js":"^5.4.1"},"engines":{"node":">=10.0.0"},"_id":"ec-key@0.0.6","gitHead":"4bb960c919fa7dd45aabf338153e315af8a220b1","_nodeVersion":"20.12.2","_npmVersion":"10.8.1","dist":{"integrity":"sha512-mE4kVpGiUynHF4rbG78jjuRtFHJqq0/5RDxwURVfCijdLD3nSroxvC+f/fJGi2kQQ5Nn/zGwSUrtGW0aiVwyCw==","shasum":"3a5b5edd28407126f063d6f3b5d00f7eac5cfdde","tarball":"https://registry.npmjs.org/ec-key/-/ec-key-0.0.6.tgz","fileCount":5,"unpackedSize":34512,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAksTKEyZXCxCD1bCW5iJgQqGZOcg/qWrKEIqcaLfVTYAiEA8DTZ+3M1Joq15rWKZIzN/hulOwHtBQ0hq5dmST6YmJs="}]},"_npmUser":{"name":"pfumagalli","email":"pier@usrz.com"},"directories":{},"maintainers":[{"name":"pfumagalli","email":"pier@usrz.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ec-key_0.0.6_1720791759071_0.012184239444486877"},"_hasShrinkwrap":false}},"time":{"created":"2017-05-04T18:19:10.835Z","modified":"2024-07-12T13:42:39.439Z","0.0.0":"2017-05-04T18:19:10.835Z","0.0.1":"2017-05-22T13:08:19.496Z","0.0.2":"2017-06-08T16:30:45.294Z","0.0.3":"2019-07-29T15:02:56.475Z","0.0.4":"2019-07-29T16:11:23.749Z","0.0.5":"2024-07-09T14:14:28.538Z","0.0.6":"2024-07-12T13:42:39.282Z"},"bugs":{"url":"https://github.com/usrz/ec-key/issues"},"author":{"name":"Pier Fumagalli","email":"pier@usrz.com"},"license":"MIT","homepage":"https://github.com/usrz/ec-key","keywords":["ec","elliptic","curve","crypto","private","public","key","pem","spki","pkcs8","pem","rfc5208","rfc5280","rfc5915","openssl"],"repository":{"type":"git","url":"git+https://github.com/usrz/ec-key.git"},"description":"Wrapper around an Elliptic Curve private or public keys","contributors":[{"name":"Pier Fumagalli","email":"pier@usrz.com"}],"maintainers":[{"name":"pfumagalli","email":"pier@usrz.com"}],"readme":"Elliptic Curve Keys\n===================\n\nThis project defines a wrapper for Elliptic Curve (EC) private and public keys.\n\n* [Curves](#curves);\n* [Basic Construction](#basic-construction)\n  * [Randomly generated keys](#randomly-generated-keys)\n  * [Instantiating from encoded keys](#instantiating-from-encoded-keys)\n  * [Instantiating with objects](#instantiating-with-objects)\n* [ECKey properties](#eckey-properties)\n* [ECKey functions](#eckey-functions)\n  * [`asPublicECKey()`](#-aspubliceckey-)\n  * [`computeSecret(otherKey)`](#-computesecret-otherkey-)\n  * [`createECDH()`](#-createecdh-)\n  * [`createSign(hash)`](#-createsign-hash-)\n  * [`createVerify(hash)`](#-createverify-hash-)\n  * [`toBuffer(format)`](#-tobuffer-format-)\n  * [`toString(format)`](#-tostring-format-)\n  * [`toJSON()`](#-tojson-)\n* [MIT License](LICENSE.md)\n\n\n\n\nCurves\n------\n\nThis wrapper supports onl the three main curves listed below:\n\n| OpenSSL Curve Name | RFC-7518 (6.2.1.1)      | ASN.1 OID           |\n| ------------------ | ----------------------- | ------------------- |\n| `prime256v1`       | `P-256`                 | 1.2.840.10045.3.1.7 |\n| `secp384k1`        | `P-256K` _non standard_ | 1.3.132.0.10        |\n| `secp384r1`        | `P-384`                 | 1.3.132.0.34        |\n| `secp521r1`        | `P-521`                 | 1.3.132.0.35        |\n\nBoth the OpenSSL names and RFC-7518 (JWA/JWK) names can be used as parameters\nto the methods in the `ECKey` class.\n\nPlease be aware that _NodeJS_ (and _OpenSSL_) support a large number of curves\n(see `openssl ecparam -list_curves` for a full list), but for brevity this\nimplementation restricts to the three mentioned above.\n\n> *PLEASE NOTE:* The `P-256K` curve name (`crv` parameter) used when serializing\n> a key using the `secp384k1` curve is not standard, and *NOT* interoperable\n> with other systems.\n>\n> See the [IANA](https://www.iana.org/assignments/jose/jose.xhtml#web-key-elliptic-curve)\n> registry for all known (and interoperable) curve names.\n>\n> The `P-256K` name used might change at _ANY_ time.\n\n\nBasic construction\n------------------\n\nTo use, start importing the main `ECKey` class:\n\n```javascript\nconst ECKey = require('ec-key');\n```\n\n\n#### Randomly generated keys\n\nTo create a random `ECKey` instance simply call the `createECKey` static\nmethod, optionally specifying a curve name (defaults to `prime256v1`):\n\n```javascript\n// Create a new (random) ECKey instance using the secp521r1 curve\nvar randomKey = ECKey.createECKey('P-521');\n```\n\n\n#### Instantiating from encoded keys\n\nTo import an existing private or public key, simply invoke the constructor\nwith a `String` or a `Buffer` and the format in which the key is encoded:\n\n```javascript\n// Create a new ECKey instance from a base-64 spki string\nvar key = new ECKey('MFkwEw ... 3w06qg', 'spki');\n```\n\nFor `Buffer`s and _base64-encoded_ `String`s the constructor supports both the\n`pkcs8` (or `rfc5208`) and `spki` (or `rfc5280`) formats.\n\nAdditionally, the `pem` format is supported for _unencoded_ `String`s and\n`Buffer`s:\n\n```javascript\n// Load up a PEM file and wrap it into a\nvar pem = fs.readFileSync('./key.pem');\nvar key = new ECKey(pem, 'pem');\n```\n\n\n#### Instantiating with objects\n\nInstances of the `ECKey` class can also be created from very simple object.\n\nFor example JWKs can be used directly, and whereas in the example below the\n`crv`, `x` and `y` values will be considered, `kty` and `kid` will be ignored.\n\n```javascript\n/// Simply create from a JWK object\nvar key = new ECKey({\n  \"kty\":\"EC\",\n  \"crv\":\"P-256\",\n  \"x\":\"f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU\",\n  \"y\":\"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0\",\n  \"kid\":\"Public key used in JWS spec Appendix A.3 example\"\n})\n```\n\nThe following values are recognized:\n\n* **`curve`** or **`crv`**: the curve type for this key, identified either by\n  its _OpenSSL_ or its _RFC-7518 (JWA/JWK)_ name.\n\nWith regards to coordinates:\n\n* **`d`**: the private _d_ coordinate for the elliptic curve point, either as a\n  `Buffer`, or a _base64-encoded_ `String` of the coordinate's big endian\n  representation\n* **`x`**: the public _x_ coordinate for the elliptic curve point, either as a\n  `Buffer`, or a _base64-encoded_ `String` of the coordinate's big endian\n  representation\n* **`y`**: the public _y_ coordinate for the elliptic curve point, either as a\n  `Buffer`, or a _base64-encoded_ `String` of the coordinate's big endian\n  representation\n\nAnd also:\n\n* **`publicKey`**: the _uncompressed_ and _prefixed_ (0x04) concatenation of\n  the _x_ and _y_ public coordinates' big endian representation, as described\n  in [SEC-1 ECC](http://www.secg.org/sec1-v2.pdf) section 2.3.3\n* **`privateKey`**: the private _d_ coordinate for the elliptic curve point,\n  either as a `Buffer`, or a _base64-encoded_ `String` of the coordinate's big\n  endian representation\n\n\n\nECKey properties\n----------------\n\nThe following _enumerable_ properties are available for instances of `ECKey`:\n\n* **`curve`**: the EC key curve name in _OpenSSL_ format (e.g. `prime256v1`)\n* **`isPrivateECKey`**: a _boolean_ indicating whther this instance represents\n  a _private_ or _public_ EC key.\n* **`x`**: the public _x_ coordinate's big endian representation for the\n  elliptic curve point as a `Buffer`\n* **`y`**: the public _y_ coordinate's big endian representation for the\n  elliptic curve point as a `Buffer`\n* **`d`**: the private _d_ coordinate's big endian representation for the\n  elliptic curve point as a `Buffer`\n\nAdditionally the following properties are available, but not _enumerable_:\n\n* **`jsonCurve`**: the EC key curve name in _RFC-7518_ format (e.g. `P-256`)\n* **`publicCodePoint`**: the _uncompressed_ and _prefixed_ (0x04) concatenation of\n  the _x_ and _y_ public coordinates' big endian representation, as described\n  in [SEC-1 ECC](http://www.secg.org/sec1-v2.pdf) section 2.3.3.\n\n\n\nECKey functions\n---------------\n\n#### `asPublicECKey()`\n\nReturn `this` instance if this key is a _public_ key, or create a new `ECKey`\ninstance *not* including the _private_ components of the key.\n\n\n#### `computeSecret(otherKey)`\n\nA simple shortcut for `createECDH().computeSecret(otherKey)` as explained below.\n\n\n#### `createECDH()`\n\nCreate a standard Node [_ECDH_](https://nodejs.org/api/crypto.html#crypto_class_ecdh)\nobject instance whose [`computeSecret(...)`](https://nodejs.org/api/crypto.html#crypto_ecdh_computesecret_other_public_key_input_encoding_output_encoding)\nfunction accepts also `ECKey` (as in, this class) instances.\n\n\n#### `createSign(hash)`\n\nCreate a standard Node [_Sign_](https://nodejs.org/api/crypto.html#crypto_class_sign)\nobject whose [`sign(...)`](https://nodejs.org/api/crypto.html#crypto_sign_sign_private_key_output_format)\nfunction is automatically populated with this instance.\n\n* `hash`: the hashing function to use for generating the signature, normally one\n  of `SHA256`, `SHA384` or `SHA512`.\n\n```javascript\n// Create a signature of the message \"the quick brown fox\" with a random key\nvar message = \"the quick brown fox\";\nvar key = ECKey.createECKey('P-384');\nvar signature = key.createSign('SHA384')\n                   .update(message)\n                   .sign('base64');\n```\n\n\n#### `createVerify(hash)`\n\nCreate a standard Node [_Verify_](https://nodejs.org/api/crypto.html#crypto_class_verify)\nobject whose [`verify(...)`](https://nodejs.org/api/crypto.html#crypto_verifier_verify_object_signature_signature_format)\nfunction is automatically populated with this instance.\n\n* `hash`: the hashing function to use for generating the signature, normally one\n  of `SHA256`, `SHA384` or `SHA512`.\n\n```javascript\n// Verify the signature calcuated above\nkey.createVerify('SHA384')\n   .update(message)\n   .verify(signature, 'base64');\n```\n\n### `toBuffer(format)`\n\nEncode this EC key, optionally using the specified format (defaults to  `pem`).\n\nFormats supported are as follows:\n\n* **`pem`**: return a `Buffer` containing the `ascii` represtation of the\n  OpenSSL PEM format\n  * equivalent to `new Buffer(key.toString('pem'), 'ascii')` and provided for\n    convenience only\n* **`rfc5951`**: (_private_ keys only) returns the encoding of this key as\n  specified by [RFC-5951](https://tools.ietf.org/html/rfc5951)\n* **`pkcs8`** or **`rfc5208`**: (_private_ keys only) returns the PKCS8 encoding\n  of this key as specified by [RFC-5208](https://tools.ietf.org/html/rfc5208)\n* **`spki`** or **`rfc5280`**: (_public_ keys only) returns the SPKI encoding\n  of this key as specified by [RFC-5280](https://tools.ietf.org/html/rfc5280)\n\n\n\n### `toString(format)`\n\nEncode this EC key, optionally using the specified format (defaults to  `pem`).\n\nFormats supported are as follows:\n\n* **`pem`**: return the key in OpenSSL's PEM format\n* **`rfc5951`**: (_private_ keys only) returns the encoding of this key as\n  specified by [RFC-5951](https://tools.ietf.org/html/rfc5951), wrapped with\n  a header and footer as outlined in section 4\n* **`pkcs8`** or **`rfc5208`**: (_private_ keys only) returns the PKCS8 encoding\n  of this key as specified by [RFC-5208](https://tools.ietf.org/html/rfc5208)\n  encoded in _base64_\n* **`spki`** or **`rfc5280`**: (_public_ keys only) returns the SPKI encoding\n  of this key as specified by [RFC-5280](https://tools.ietf.org/html/rfc5280)\n  encoded in _base64_\n\n\n\n### `toJSON()`\n\nFormats this `ECKey` as a JSON Web Key as specified by\n[RFC-7517](https://tools.ietf.org/html/rfc7517).\n\nPlease note that his function will also be called by the `JSON.stringify(...)`\nfunction.\n\n```javascript\n// Convert a PEM to a JWK in one easy step\n\nvar pem = `-----BEGIN PRIVATE KEY-----\nMIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgzr+Twxehecu0VYoC\nXUBL1Z4h3H28gPnJ5MP0AcOixAOhRANCAAS6pMWMMndZxOPSC9ui6sUUbmeK6dIi\nk3ZwTmm0SE7G+tYon5C57aVek5qH4y4OipbSLfbsIQuOkt0G8Vu1KZ3u\n-----END PRIVATE KEY-----`;\n\nvar key = new ECKey(pem, 'pem');\n\nvar jwk = JSON.stringify(key, null, 2);\n\nconsole.log(jwk);\n\n// This will result in the following output:\n// {\n//   \"kty\": \"EC\",\n//   \"crv\": \"P-256\",\n//   \"x\": \"uqTFjDJ3WcTj0gvbourFFG5niunSIpN2cE5ptEhOxvo\",\n//   \"y\": \"1iifkLntpV6TmofjLg6KltIt9uwhC46S3QbxW7Upne4\",\n//   \"d\": \"zr-Twxehecu0VYoCXUBL1Z4h3H28gPnJ5MP0AcOixAM\"\n// }\n```\n","readmeFilename":"README.md"}