{"name":"noble-ed25519","version":"0.3.0","description":"Noble ed25519 & ristretto255. High-security, easily auditable, 0-dep, 1-file pubkey, scalarmult & EDDSA.","main":"index.js","scripts":{"compile":"tsc -d","test":"jest","bench":"node benchmark.js"},"jest":{"testRegex":"/.*?\\.test.ts","transform":{"^.+\\.ts$":"ts-jest"},"useStderr":true,"bail":2},"author":{"name":"Paul Miller","url":"https://paulmillr.com"},"homepage":"https://github.com/paulmillr/noble-ed25519","repository":{"type":"git","url":"git+https://github.com/paulmillr/noble-ed25519.git"},"license":"MIT","devDependencies":{"@types/jest":"^24.0.21","@types/node":"^12.12.5","benchmark":"^2.1.4","fast-check":"^1.18.1","jest":"^24.9.0","ts-jest":"^24.1.0","typescript":"^3.7.2"},"keywords":["ed25519","edwards","ristretto255","decaf","curve25519","x25519","elliptic","elliptic curve","curve","signature","ecc","eddsa","ecdsa","cryptography","security"],"gitHead":"70c9dc6da411c59d553c8347448c4ce8d02fb5f4","bugs":{"url":"https://github.com/paulmillr/noble-ed25519/issues"},"_id":"noble-ed25519@0.3.0","_nodeVersion":"12.12.0","_npmVersion":"6.13.0","dist":{"integrity":"sha512-y614/poT11gm7LtG7STniPfkMkW5KTcYenQEry+jKmItklHcToGUmMXq6dWntiuozjMxcFQQUIEXo70KfpFN9A==","shasum":"46e419f4443a414feff99a589692a535feea6c19","tarball":"http://registry-npm.ywwl.com/noble-ed25519/download/noble-ed25519-0.3.0.tgz","fileCount":7,"unpackedSize":45551,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdxUFMCRA9TVsSAnZWagAAUjQP/1J9RhCHMsVe3wfCdeHI\n9zneY5fEfmbTbPfgWZt+lPNDsSOf2Y9i4DK5YmOeIvp9f7xgJrfaL3DURSn4\nGwwhYfpgDj5mbpDZYXXGn7kszt4xQkdNiFhPpobBPdoWBUwMiuxZ5diC3032\nXJZoIh/QR1HlvagiRj1j5CHKwxE+3bg0tYfLPvhkn/MBkgfAzh6rl/uIFlQo\nsaKj9C+JZHmTkCENiPJgBTQxBCBTuk0lZIeufspzE+YRcH79KznD+UlkD2Xz\n5VkzM8KLEAfUa4by0gbWkHkA6t59rVQe9gmRDrLVqVpyRykY+qIrSN2We3dw\nmr9Xaoynhd4ZEoCVjwNyD23FDh6X4zEor1YnLPEmzvyxBE6XVC4kzuzphWYy\nXOp3jgYA+1MZmVs0Y/cCQVPbOhKVH+yIoTaM+V7EbImxyb2sLCoCWTAsaWTv\nZ//j3e4x3z62p5EHBepL7/ic6dEEJzOawGSewBueroikMvt9cB3G/kf/jCaF\nVs9iSlK+F+K11ttGjpEpAaYnO0ANI1ugFyDBwXNvE313CbctJMwVK4ZurQ8M\n4iH8rMsrLh/fM8JQZwSbMVyk+0KwLjC4ZOEUUkFhIrqID3eGxwGWHo4uMvik\nLRVSugIgrSLY1zt87AtIh4sOu/xPidcIWSu4SCwohtBFZbfIXqspmXJYHSgF\nEvgS\r\n=6RGy\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDjvCjhkB1U7VMI3rDMpFp0nNjVN+ck7A9+CjXw8iHvVgIgMLH2YIVJSyl4q9SXj/KCX+ra8nZpHfFLdUPx+ddrX6Y="}],"size":10966,"noattachment":false,"key":"/noble-ed25519/-/noble-ed25519-0.3.0.tgz"},"maintainers":[{"name":"paulmillr","email":"paul@paulmillr.com"}],"_npmUser":{"name":"paulmillr","email":"paul@paulmillr.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/noble-ed25519_0.3.0_1573208395903_0.7743333977362921"},"_hasShrinkwrap":false,"deprecated":"Switch to \"@noble/ed25519\" for security updates","readme":"# noble-ed25519 ![Node CI](https://github.com/paulmillr/noble-ed25519/workflows/Node%20CI/badge.svg) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\nFastest JS implementation of [ed25519](https://en.wikipedia.org/wiki/EdDSA), an elliptic curve that could be used for asymmetric encryption and EDDSA signature scheme. Algorithmically resistant to timing attacks, conforms to [RFC8032](https://tools.ietf.org/html/rfc8032).\n\nIncludes [ristretto255](https://ristretto.group) support. Ristretto is a technique for constructing prime order elliptic curve groups with non-malleable encodings.\n\nCheck out [the online demo](https://paulmillr.com/ecc).\n\n### This library belongs to *noble* crypto\n\n> **noble-crypto** — high-security, easily auditable set of contained cryptographic libraries and tools.\n\n- No dependencies, one small file\n- Easily auditable TypeScript/JS code\n- Supported in all major browsers and stable node.js versions\n- All releases are signed with PGP keys\n- Check out all libraries:\n  [secp256k1](https://github.com/paulmillr/noble-secp256k1),\n  [ed25519](https://github.com/paulmillr/noble-ed25519),\n  [bls12-381](https://github.com/paulmillr/noble-bls12-381),\n  [hashes](https://github.com/paulmillr/noble-hashes)\n\n## Usage\n\nUse NPM in node.js / browser, or include single file from\n[GitHub's releases page](https://github.com/paulmillr/noble-ed25519/releases):\n\n> npm install noble-ed25519\n\n```js\nimport * as ed from 'noble-ed25519';\n// if you're using single file, use global variable nobleEd25519\n\nconst privateKey = ed.utils.randomPrivateKey(); // 32-byte Uint8Array or string.\nconst msgHash = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef';\n(async () => {\n  const publicKey = await ed.getPublicKey(privateKey);\n  const signature = await ed.sign(msgHash, privateKey);\n  const isSigned = await ed.verify(signature, msgHash, publicKey);\n})();\n```\n\nTo use with Deno:\n\n```typescript\nimport * as ed from 'https://deno.land/x/ed25519/mod.ts';\nconst privateKey = ed.utils.randomPrivateKey();\nconst publicKey = await ed.getPublicKey(privateKey);\n```\n\n## API\n\n- [`getPublicKey(privateKey)`](#getpublickeyprivatekey)\n- [`sign(hash, privateKey)`](#signhash-privatekey)\n- [`verify(signature, hash, publicKey)`](#verifysignature-hash-publickey)\n- [Helpers & Point](#helpers--point)\n\n##### `getPublicKey(privateKey)`\n```typescript\nfunction getPublicKey(privateKey: Uint8Array): Promise<Uint8Array>;\nfunction getPublicKey(privateKey: string): Promise<string>;\nfunction getPublicKey(privateKey: bigint): Promise<Uint8Array>;\n```\n- `privateKey: Uint8Array | string | bigint` will be used to generate public key.\n  Public key is generated by executing scalar multiplication of a base Point(x, y) by a fixed\n  integer. The result is another `Point(x, y)` which we will by default encode to hex Uint8Array.\n- Returns:\n    * `Promise<Uint8Array>` if `Uint8Array` was passed\n    * `Promise<string>` if hex `string` was passed\n    * Uses **promises**, because ed25519 uses SHA internally; and we're using built-in browser `window.crypto`, which returns `Promise`.\n\n- Use `Point.fromPrivateKey(privateKey)` if you want `Point` instance instead\n- Use `Point.fromHex(publicKey)` if you want to convert hex / bytes into Point.\n  It will use decompression algorithm 5.1.3 of RFC 8032.\n\n##### `sign(hash, privateKey)`\n```typescript\nfunction sign(hash: Uint8Array, privateKey: Uint8Array): Promise<Uint8Array>;\nfunction sign(hash: string, privateKey: string): Promise<string>;\n```\n- `hash: Uint8Array | string` - message hash which would be signed\n- `privateKey: Uint8Array | string` - private key which will sign the hash\n- Returns EdDSA signature. You can consume it with `Signature.fromHex()` method:\n    - `Signature.fromHex(ed25519.sign(hash, privateKey))`\n\n##### `verify(signature, hash, publicKey)`\n```typescript\nfunction verify(\n  signature: Uint8Array | string | Signature,\n  hash: Uint8Array | string,\n  publicKey: Uint8Array | string | Point\n): Promise<boolean>\n```\n- `signature: Uint8Array | string | Signature` - returned by the `sign` function\n- `hash: Uint8Array | string` - message hash that needs to be verified\n- `publicKey: Uint8Array | string | Point` - e.g. that was generated from `privateKey` by `getPublicKey`\n- Returns `Promise<boolean>`: `Promise<true>` if `signature == hash`; otherwise `Promise<false>`\n\n##### Ristretto255\n\nTo use Ristretto, simply use `fromRistrettoHash()` and `toRistrettoBytes()` methods.\n\n```typescript\n// The hash-to-group operation applies Elligator twice and adds the results.\nExtendedPoint.fromRistrettoHash(hash: Uint8Array): ExtendedPoint;\n\n// Decode a byte-string s_bytes representing a compressed Ristretto point into extended coordinates.\nExtendedPoint.fromRistrettoBytes(bytes: Uint8Array): ExtendedPoint;\n\n// Encode a Ristretto point represented by the point (X:Y:Z:T) in extended coordinates to Uint8Array.\nExtendedPoint.toRistrettoBytes(): Uint8Array\n```\n\nIt extends Mike Hamburg's Decaf approach to cofactor elimination to support cofactor-8 curves such as Curve25519.\n\nIn particular, this allows an existing Curve25519 library to implement a prime-order group with only a thin abstraction layer, and makes it possible for systems using Ed25519 signatures to be safely extended with zero-knowledge protocols, with no additional cryptographic assumptions and minimal code changes.\n\n##### Helpers & Point\n\n`utils.randomPrivateKey()`\n\nReturns cryptographically random `Uint8Array` that could be used as Private Key.\n\n`utils.precompute(W = 8, point = Point.BASE)`\n\nReturns cached point which you can use to `#multiply` by it.\n\nThis is done by default, no need to run it unless you want to\ndisable precomputation or change window size.\n\nWe're doing scalar multiplication (used in getPublicKey etc) with\nprecomputed BASE_POINT values.\n\nThis slows down first getPublicKey() by milliseconds (see Speed section),\nbut allows to speed-up subsequent getPublicKey() calls up to 20x.\n\nYou may want to precompute values for your own point.\n\n`utils.TORSION_SUBGROUP`\n\nThe 8-torsion subgroup ℰ8. Those are \"buggy\" points, if you multiply them by 8, you'll receive Point.ZERO.\n\nUseful to check implementations for signature malleability. See [the link](https://moderncrypto.org/mail-archive/curves/2017/000866.html)\n\n`Point#toX25519`\n\nYou can use the method to use ed25519 keys for curve25519 encryption.\n\nhttps://blog.filippo.io/using-ed25519-keys-for-encryption\n\n```typescript\ned25519.CURVE.P // 2 ** 255 - 19\ned25519.CURVE.n // 2 ** 252 - 27742317777372353535851937790883648493\ned25519.Point.BASE // new ed25519.Point(Gx, Gy) where\n// Gx = 15112221349535400772501151409588531511454012693041857206046113283949847762202n\n// Gy = 46316835694926478169428394003475163141307993866256225615783033603165251855960n;\n\n\n// Elliptic curve point in Affine (x, y) coordinates.\ned25519.Point {\n  constructor(x: bigint, y: bigint);\n  static fromY(y: bigint);\n  static fromHex(hash: string);\n  static fromPrivateKey(privateKey: string | Uint8Array);\n  toX25519(): bigint; // Converts to Curve25519\n  toRawBytes(): Uint8Array;\n  toHex(): string; // Compact representation of a Point\n  equals(other: Point): boolean;\n  negate(): Point;\n  add(other: Point): Point;\n  subtract(other: Point): Point;\n  multiply(scalar: bigint): Point;\n}\n// Elliptic curve point in Extended (x, y, z, t) coordinates.\ned25519.ExtendedPoint {\n  constructor(x: bigint, y: bigint, z: bigint, t: bigint);\n  static fromAffine(point: Point): ExtendedPoint;\n  static fromRistrettoHash(hash: Uint8Array): ExtendedPoint;\n  static fromRistrettoBytes(bytes: Uint8Array): ExtendedPoint;\n  toRistrettoBytes(): Uint8Array;\n  toAffine(): Point;\n}\ned25519.Signature {\n  constructor(r: bigint, s: bigint);\n  toHex(): string;\n}\n\n// Precomputation helper\nutils.precompute(W, point);\n```\n\n## Security\n\nNoble is production-ready.\n\n1. No public audits have been done yet. Our goal is to crowdfund the audit.\n2. It was developed in a very similar fashion to\n[noble-secp256k1](https://github.com/paulmillr/noble-secp256k1), which **was** audited by a third-party firm.\n3. It was fuzzed by [Guido Vranken's cryptofuzz](https://github.com/guidovranken/cryptofuzz),\nno serious issues have been found. You can run the fuzzer by yourself to check it.\n\nWe're using built-in JS `BigInt`, which is \"unsuitable for use in cryptography\" as [per official spec](https://github.com/tc39/proposal-bigint#cryptography). This means that the lib is potentially vulnerable to [timing attacks](https://en.wikipedia.org/wiki/Timing_attack). But, *JIT-compiler* and *Garbage Collector* make \"constant time\" extremely hard to achieve in a scripting language. Which means *any other JS library doesn't use constant-time bigints*. Including bn.js or anything else. Even statically typed Rust, a language without GC, [makes it harder to achieve constant-time](https://www.chosenplaintext.ca/open-source/rust-timing-shield/security) for some cases. If your goal is absolute security, don't use any JS lib — including bindings to native ones. Use low-level libraries & languages.\n\nWe however consider infrastructure attacks like rogue NPM modules very important; that's why it's crucial to minimize the amount of 3rd-party dependencies & native bindings. If your app uses 500 dependencies, any dep could get hacked and you'll be downloading rootkits with every `npm install`. Our goal is to minimize this attack vector.\n\n## Speed\n\nBenchmarks done with Apple M1.\n\n```\ngetPublicKey(utils.randomPrivateKey()) x 6,790 ops/sec @ 147μs/op\nsign x 3,247 ops/sec @ 307μs/op\nverify x 726 ops/sec @ 1ms/op\nverifyBatch x 842 ops/sec @ 1ms/op\nPoint.fromHex decompression x 11,332 ops/sec @ 88μs/op\nristretto255#fromHash x 5,428 ops/sec @ 184μs/op\nristretto255 round x 2,461 ops/sec @ 406μs/op\n```\n\nCompare to alternative implementations:\n\n```\n# tweetnacl-fast@1.0.3\ngetPublicKey x 920 ops/sec @ 1ms/op # aka scalarMultBase\nsign x 519 ops/sec @ 2ms/op\n\n# ristretto255@0.1.1\ngetPublicKey x 877 ops/sec @ 1ms/op # aka scalarMultBase\n\n# sodium-native@3.2.1, native bindings to libsodium, node.js-only\nsodium-native#sign x 58,661 ops/sec @ 17μs/op\n```\n\n## Contributing\n\n1. Clone the repository.\n2. `npm install` to install build dependencies like TypeScript\n3. `npm run compile` to compile TypeScript code\n4. `npm run test` to run jest on `test/index.ts`\n\n## License\n\nMIT (c) Paul Miller [(https://paulmillr.com)](https://paulmillr.com), see LICENSE file.\n","publish_time":1573208396118,"_cnpm_publish_time":1573208396118,"dist-tags":{"latest":"1.2.6"}}