meteor-node-stubs 1.2.17 → 1.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/@meteorjs/browserify-sign/browser/sign.js +1 -1
- package/node_modules/@meteorjs/browserify-sign/browser/verify.js +1 -1
- package/node_modules/@meteorjs/browserify-sign/elliptic/benchmarks/deps/jodid.js +82 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/benchmarks/deps/secp256k1.js +41 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/benchmarks/index.js +153 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/benchmarks/package.json +21 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/dist/.gitkeep +0 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/dist/elliptic.js +8961 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/dist/elliptic.min.js +1 -0
- package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic.js +1 -1
- package/node_modules/@meteorjs/browserify-sign/elliptic/test/api-test.js +20 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/test/curve-test.js +357 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/test/ecdh-test.js +43 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/test/ecdsa-test.js +547 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/test/ed25519-test.js +138 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/test/fixtures/derivation-fixtures.js +3842 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/test/fixtures/sign.input +1024 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/test/index.js +10 -0
- package/node_modules/@meteorjs/browserify-sign/elliptic/test/unittests.html +39 -0
- package/node_modules/@meteorjs/browserify-sign/package.json +22 -5
- package/node_modules/@meteorjs/create-ecdh/browser.js +1 -1
- package/node_modules/@meteorjs/create-ecdh/elliptic/README.md +238 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/benchmarks/deps/jodid.js +82 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/benchmarks/deps/secp256k1.js +41 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/benchmarks/index.js +153 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/benchmarks/package.json +21 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/dist/.gitkeep +0 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/dist/elliptic.js +8961 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/dist/elliptic.min.js +1 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/curve/base.js +381 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/curve/edwards.js +435 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/curve/index.js +8 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/curve/mont.js +178 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/curve/short.js +938 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/curves.js +206 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/ec/index.js +278 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/ec/key.js +121 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/ec/signature.js +176 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/eddsa/index.js +121 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/eddsa/key.js +95 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/eddsa/signature.js +66 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/precomputed/secp256k1.js +780 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic/utils.js +122 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/lib/elliptic.js +13 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/test/api-test.js +20 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/test/curve-test.js +357 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/test/ecdh-test.js +43 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/test/ecdsa-test.js +547 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/test/ed25519-test.js +138 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/test/fixtures/derivation-fixtures.js +3842 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/test/fixtures/sign.input +1024 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/test/index.js +10 -0
- package/node_modules/@meteorjs/create-ecdh/elliptic/test/unittests.html +39 -0
- package/node_modules/@meteorjs/create-ecdh/node_modules/bn.js/lib/bn.js +1 -0
- package/node_modules/@meteorjs/create-ecdh/node_modules/bn.js/package.json +1 -1
- package/node_modules/@meteorjs/create-ecdh/package.json +23 -5
- package/node_modules/asn1.js/node_modules/bn.js/lib/bn.js +6 -5
- package/node_modules/asn1.js/node_modules/bn.js/package.json +1 -1
- package/node_modules/asn1.js/node_modules/bn.js/util/genCombMulTo.js +65 -0
- package/node_modules/asn1.js/node_modules/bn.js/util/genCombMulTo10.js +65 -0
- package/node_modules/available-typed-arrays/.eslintrc +0 -4
- package/node_modules/available-typed-arrays/CHANGELOG.md +21 -0
- package/node_modules/available-typed-arrays/README.md +16 -13
- package/node_modules/available-typed-arrays/index.d.ts +8 -0
- package/node_modules/available-typed-arrays/index.js +4 -14
- package/node_modules/available-typed-arrays/package.json +26 -15
- package/node_modules/available-typed-arrays/tsconfig.json +49 -0
- package/node_modules/bn.js/README.md +11 -5
- package/node_modules/bn.js/lib/bn.js +6 -5
- package/node_modules/bn.js/package.json +1 -1
- package/node_modules/browserify-rsa/CHANGELOG.md +98 -0
- package/node_modules/browserify-rsa/README.md +0 -2
- package/node_modules/browserify-rsa/index.js +31 -28
- package/node_modules/browserify-rsa/package.json +64 -29
- package/node_modules/call-bind/CHANGELOG.md +13 -0
- package/node_modules/call-bind/index.js +6 -17
- package/node_modules/call-bind/package.json +14 -16
- package/node_modules/call-bind/test/index.js +4 -10
- package/node_modules/call-bind-apply-helpers/.eslintrc +17 -0
- package/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
- package/node_modules/call-bind-apply-helpers/.nycrc +9 -0
- package/node_modules/call-bind-apply-helpers/CHANGELOG.md +30 -0
- package/node_modules/{has-proto → call-bind-apply-helpers}/LICENSE +1 -1
- package/node_modules/call-bind-apply-helpers/README.md +62 -0
- package/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
- package/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
- package/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
- package/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
- package/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
- package/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
- package/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
- package/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
- package/node_modules/call-bind-apply-helpers/index.d.ts +64 -0
- package/node_modules/call-bind-apply-helpers/index.js +15 -0
- package/node_modules/call-bind-apply-helpers/package.json +85 -0
- package/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
- package/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
- package/node_modules/call-bind-apply-helpers/test/index.js +63 -0
- package/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
- package/node_modules/call-bound/.eslintrc +13 -0
- package/node_modules/call-bound/.github/FUNDING.yml +12 -0
- package/node_modules/call-bound/.nycrc +9 -0
- package/node_modules/call-bound/CHANGELOG.md +42 -0
- package/node_modules/{@meteorjs/browserify-sign/node_modules/bn.js → call-bound}/LICENSE +3 -1
- package/node_modules/call-bound/README.md +53 -0
- package/node_modules/call-bound/index.d.ts +94 -0
- package/node_modules/call-bound/index.js +19 -0
- package/node_modules/call-bound/package.json +99 -0
- package/node_modules/call-bound/test/index.js +61 -0
- package/node_modules/call-bound/tsconfig.json +10 -0
- package/node_modules/cipher-base/.eslintrc +24 -1
- package/node_modules/cipher-base/.github/FUNDING.yml +12 -0
- package/node_modules/cipher-base/CHANGELOG.md +66 -0
- package/node_modules/cipher-base/index.js +145 -77
- package/node_modules/cipher-base/package.json +60 -30
- package/node_modules/cipher-base/test/index.js +221 -0
- package/node_modules/des.js/lib/des/cipher.js +1 -0
- package/node_modules/des.js/lib/des/des.js +8 -0
- package/node_modules/des.js/package.json +3 -4
- package/node_modules/des.js/test/cbc-test.js +5 -5
- package/node_modules/des.js/test/des-test.js +9 -9
- package/node_modules/des.js/test/ede-test.js +39 -6
- package/node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js +6 -5
- package/node_modules/diffie-hellman/node_modules/bn.js/package.json +1 -1
- package/node_modules/diffie-hellman/node_modules/bn.js/util/genCombMulTo.js +65 -0
- package/node_modules/diffie-hellman/node_modules/bn.js/util/genCombMulTo10.js +65 -0
- package/node_modules/dunder-proto/.github/FUNDING.yml +12 -0
- package/node_modules/dunder-proto/.nycrc +13 -0
- package/node_modules/dunder-proto/CHANGELOG.md +24 -0
- package/node_modules/{@meteorjs/crypto-browserify/node_modules/hash-base → dunder-proto}/LICENSE +6 -6
- package/node_modules/dunder-proto/README.md +54 -0
- package/node_modules/dunder-proto/get.d.ts +5 -0
- package/node_modules/dunder-proto/get.js +30 -0
- package/node_modules/dunder-proto/package.json +76 -0
- package/node_modules/dunder-proto/set.d.ts +5 -0
- package/node_modules/dunder-proto/set.js +35 -0
- package/node_modules/dunder-proto/test/get.js +34 -0
- package/node_modules/dunder-proto/test/index.js +4 -0
- package/node_modules/dunder-proto/test/set.js +50 -0
- package/node_modules/dunder-proto/tsconfig.json +9 -0
- package/node_modules/es-define-property/CHANGELOG.md +14 -0
- package/node_modules/es-define-property/index.js +1 -3
- package/node_modules/es-define-property/package.json +12 -12
- package/node_modules/es-define-property/test/index.js +1 -0
- package/node_modules/es-define-property/tsconfig.json +2 -42
- package/node_modules/es-object-atoms/.eslintrc +16 -0
- package/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
- package/node_modules/es-object-atoms/CHANGELOG.md +37 -0
- package/node_modules/{elliptic/node_modules/bn.js → es-object-atoms}/LICENSE +3 -1
- package/node_modules/es-object-atoms/README.md +63 -0
- package/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
- package/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
- package/node_modules/es-object-atoms/ToObject.d.ts +7 -0
- package/node_modules/es-object-atoms/ToObject.js +10 -0
- package/node_modules/es-object-atoms/index.d.ts +3 -0
- package/node_modules/es-object-atoms/index.js +4 -0
- package/node_modules/es-object-atoms/isObject.d.ts +3 -0
- package/node_modules/es-object-atoms/isObject.js +6 -0
- package/node_modules/es-object-atoms/package.json +80 -0
- package/node_modules/es-object-atoms/test/index.js +38 -0
- package/node_modules/es-object-atoms/tsconfig.json +6 -0
- package/node_modules/for-each/.eslintrc +16 -2
- package/node_modules/{has-proto → for-each}/.github/FUNDING.yml +1 -1
- package/node_modules/for-each/.github/SECURITY.md +3 -0
- package/node_modules/for-each/.nycrc +8 -0
- package/node_modules/for-each/CHANGELOG.md +107 -0
- package/node_modules/for-each/README.md +0 -4
- package/node_modules/for-each/index.d.ts +35 -0
- package/node_modules/for-each/index.js +11 -4
- package/node_modules/for-each/package.json +47 -36
- package/node_modules/for-each/test/test.js +54 -12
- package/node_modules/for-each/tsconfig.json +8 -0
- package/node_modules/get-intrinsic/.eslintrc +4 -0
- package/node_modules/get-intrinsic/CHANGELOG.md +43 -0
- package/node_modules/get-intrinsic/index.js +40 -21
- package/node_modules/get-intrinsic/package.json +24 -20
- package/node_modules/get-intrinsic/test/GetIntrinsic.js +2 -2
- package/node_modules/get-proto/.eslintrc +10 -0
- package/node_modules/get-proto/.github/FUNDING.yml +12 -0
- package/node_modules/get-proto/.nycrc +9 -0
- package/node_modules/get-proto/CHANGELOG.md +21 -0
- package/node_modules/get-proto/LICENSE +21 -0
- package/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
- package/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
- package/node_modules/get-proto/README.md +50 -0
- package/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
- package/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
- package/node_modules/get-proto/index.d.ts +5 -0
- package/node_modules/get-proto/index.js +27 -0
- package/node_modules/{has-proto → get-proto}/package.json +33 -26
- package/node_modules/get-proto/test/index.js +68 -0
- package/node_modules/get-proto/tsconfig.json +9 -0
- package/node_modules/gopd/CHANGELOG.md +20 -0
- package/node_modules/gopd/gOPD.d.ts +1 -0
- package/node_modules/gopd/gOPD.js +4 -0
- package/node_modules/gopd/index.d.ts +5 -0
- package/node_modules/gopd/index.js +2 -3
- package/node_modules/gopd/package.json +16 -10
- package/node_modules/gopd/test/index.js +2 -1
- package/node_modules/gopd/tsconfig.json +9 -0
- package/node_modules/has-symbols/CHANGELOG.md +16 -0
- package/node_modules/has-symbols/index.d.ts +3 -0
- package/node_modules/has-symbols/index.js +1 -0
- package/node_modules/has-symbols/package.json +19 -9
- package/node_modules/has-symbols/shams.d.ts +3 -0
- package/node_modules/has-symbols/shams.js +5 -2
- package/node_modules/has-symbols/test/shams/core-js.js +1 -0
- package/node_modules/has-symbols/test/shams/get-own-property-symbols.js +1 -0
- package/node_modules/has-symbols/test/tests.js +4 -2
- package/node_modules/has-symbols/tsconfig.json +10 -0
- package/node_modules/has-tostringtag/.eslintrc +0 -6
- package/node_modules/has-tostringtag/.nycrc +13 -0
- package/node_modules/has-tostringtag/CHANGELOG.md +22 -0
- package/node_modules/has-tostringtag/index.d.ts +3 -0
- package/node_modules/has-tostringtag/index.js +1 -0
- package/node_modules/has-tostringtag/package.json +37 -13
- package/node_modules/has-tostringtag/shams.d.ts +3 -0
- package/node_modules/has-tostringtag/shams.js +1 -0
- package/node_modules/has-tostringtag/test/shams/core-js.js +3 -0
- package/node_modules/has-tostringtag/test/shams/get-own-property-symbols.js +2 -0
- package/node_modules/has-tostringtag/test/tests.js +2 -1
- package/node_modules/has-tostringtag/tsconfig.json +49 -0
- package/node_modules/hash-base/README.md +15 -15
- package/node_modules/hash-base/index.js +52 -9
- package/node_modules/hash-base/package.json +40 -40
- package/node_modules/hasown/CHANGELOG.md +20 -0
- package/node_modules/hasown/index.d.ts +3 -3
- package/node_modules/hasown/index.js +1 -1
- package/node_modules/hasown/package.json +16 -15
- package/node_modules/hasown/tsconfig.json +3 -46
- package/node_modules/is-arguments/.eslintrc +0 -1
- package/node_modules/is-arguments/CHANGELOG.md +22 -0
- package/node_modules/is-arguments/README.md +11 -11
- package/node_modules/is-arguments/index.d.ts +6 -0
- package/node_modules/is-arguments/index.js +19 -8
- package/node_modules/is-arguments/package.json +25 -11
- package/node_modules/is-arguments/test/index.js +4 -1
- package/node_modules/is-arguments/tsconfig.json +9 -0
- package/node_modules/is-generator-function/.eslintrc +1 -1
- package/node_modules/is-generator-function/CHANGELOG.md +21 -0
- package/node_modules/is-generator-function/index.d.ts +3 -0
- package/node_modules/is-generator-function/index.js +16 -7
- package/node_modules/is-generator-function/package.json +30 -11
- package/node_modules/is-generator-function/test/corejs.js +1 -0
- package/node_modules/is-generator-function/test/index.js +4 -7
- package/node_modules/is-generator-function/test/uglified.js +1 -0
- package/node_modules/is-generator-function/tsconfig.json +9 -0
- package/node_modules/is-regex/.editorconfig +23 -0
- package/node_modules/is-regex/.eslintrc +10 -0
- package/node_modules/is-regex/.nycrc +10 -0
- package/node_modules/is-regex/CHANGELOG.md +233 -0
- package/node_modules/is-regex/LICENSE +20 -0
- package/node_modules/is-regex/README.md +52 -0
- package/node_modules/is-regex/index.d.ts +3 -0
- package/node_modules/is-regex/index.js +69 -0
- package/node_modules/is-regex/package.json +104 -0
- package/node_modules/is-regex/test/index.js +121 -0
- package/node_modules/is-regex/tsconfig.json +9 -0
- package/node_modules/is-typed-array/CHANGELOG.md +32 -0
- package/node_modules/is-typed-array/index.d.ts +9 -0
- package/node_modules/is-typed-array/index.js +1 -0
- package/node_modules/is-typed-array/package.json +23 -10
- package/node_modules/is-typed-array/test/index.js +9 -1
- package/node_modules/is-typed-array/tsconfig.json +6 -0
- package/node_modules/math-intrinsics/.eslintrc +16 -0
- package/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
- package/node_modules/math-intrinsics/CHANGELOG.md +24 -0
- package/node_modules/math-intrinsics/LICENSE +21 -0
- package/node_modules/math-intrinsics/README.md +50 -0
- package/node_modules/math-intrinsics/abs.d.ts +1 -0
- package/node_modules/math-intrinsics/abs.js +4 -0
- package/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
- package/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
- package/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
- package/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
- package/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
- package/node_modules/math-intrinsics/constants/maxValue.js +5 -0
- package/node_modules/math-intrinsics/floor.d.ts +1 -0
- package/node_modules/math-intrinsics/floor.js +4 -0
- package/node_modules/math-intrinsics/isFinite.d.ts +3 -0
- package/node_modules/math-intrinsics/isFinite.js +12 -0
- package/node_modules/math-intrinsics/isInteger.d.ts +3 -0
- package/node_modules/math-intrinsics/isInteger.js +16 -0
- package/node_modules/math-intrinsics/isNaN.d.ts +1 -0
- package/node_modules/math-intrinsics/isNaN.js +6 -0
- package/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
- package/node_modules/math-intrinsics/isNegativeZero.js +6 -0
- package/node_modules/math-intrinsics/max.d.ts +1 -0
- package/node_modules/math-intrinsics/max.js +4 -0
- package/node_modules/math-intrinsics/min.d.ts +1 -0
- package/node_modules/math-intrinsics/min.js +4 -0
- package/node_modules/math-intrinsics/mod.d.ts +3 -0
- package/node_modules/math-intrinsics/mod.js +9 -0
- package/node_modules/math-intrinsics/package.json +86 -0
- package/node_modules/math-intrinsics/pow.d.ts +1 -0
- package/node_modules/math-intrinsics/pow.js +4 -0
- package/node_modules/math-intrinsics/round.d.ts +1 -0
- package/node_modules/math-intrinsics/round.js +4 -0
- package/node_modules/math-intrinsics/sign.d.ts +3 -0
- package/node_modules/math-intrinsics/sign.js +11 -0
- package/node_modules/math-intrinsics/test/index.js +192 -0
- package/node_modules/math-intrinsics/tsconfig.json +3 -0
- package/node_modules/miller-rabin/node_modules/bn.js/lib/bn.js +6 -5
- package/node_modules/miller-rabin/node_modules/bn.js/package.json +1 -1
- package/node_modules/miller-rabin/node_modules/bn.js/util/genCombMulTo.js +65 -0
- package/node_modules/miller-rabin/node_modules/bn.js/util/genCombMulTo10.js +65 -0
- package/node_modules/object-inspect/CHANGELOG.md +20 -0
- package/node_modules/object-inspect/index.js +27 -10
- package/node_modules/object-inspect/package.json +9 -8
- package/node_modules/object-inspect/test/quoteStyle.js +9 -0
- package/node_modules/object-inspect/test/values.js +50 -0
- package/node_modules/object-is/.eslintrc +1 -1
- package/node_modules/object-is/.nycrc +0 -4
- package/node_modules/object-is/CHANGELOG.md +25 -0
- package/node_modules/object-is/README.md +20 -20
- package/node_modules/object-is/package.json +23 -14
- package/node_modules/object.assign/CHANGELOG.md +21 -0
- package/node_modules/object.assign/dist/browser.js +495 -135
- package/node_modules/object.assign/implementation.js +6 -6
- package/node_modules/object.assign/package.json +14 -14
- package/node_modules/object.assign/test/tests.js +2 -2
- package/node_modules/possible-typed-array-names/.eslintrc +5 -0
- package/node_modules/possible-typed-array-names/.github/FUNDING.yml +12 -0
- package/node_modules/possible-typed-array-names/CHANGELOG.md +29 -0
- package/node_modules/possible-typed-array-names/LICENSE +21 -0
- package/node_modules/possible-typed-array-names/README.md +50 -0
- package/node_modules/possible-typed-array-names/index.d.ts +16 -0
- package/node_modules/possible-typed-array-names/index.js +17 -0
- package/node_modules/possible-typed-array-names/package.json +84 -0
- package/node_modules/possible-typed-array-names/test/index.js +19 -0
- package/node_modules/possible-typed-array-names/tsconfig.json +9 -0
- package/node_modules/public-encrypt/node_modules/bn.js/lib/bn.js +6 -5
- package/node_modules/public-encrypt/node_modules/bn.js/package.json +1 -1
- package/node_modules/public-encrypt/node_modules/bn.js/util/genCombMulTo.js +65 -0
- package/node_modules/public-encrypt/node_modules/bn.js/util/genCombMulTo10.js +65 -0
- package/node_modules/qs/.eslintrc +1 -0
- package/node_modules/qs/CHANGELOG.md +22 -0
- package/node_modules/qs/README.md +25 -1
- package/node_modules/qs/dist/qs.js +95 -44
- package/node_modules/qs/lib/parse.js +44 -12
- package/node_modules/qs/lib/stringify.js +11 -6
- package/node_modules/qs/lib/utils.js +7 -4
- package/node_modules/qs/package.json +9 -7
- package/node_modules/qs/test/parse.js +133 -27
- package/node_modules/qs/test/stringify.js +19 -11
- package/node_modules/qs/test/utils.js +126 -0
- package/node_modules/safe-regex-test/.eslintrc +9 -0
- package/node_modules/safe-regex-test/.github/FUNDING.yml +12 -0
- package/node_modules/safe-regex-test/.nycrc +13 -0
- package/node_modules/safe-regex-test/CHANGELOG.md +55 -0
- package/node_modules/safe-regex-test/LICENSE +21 -0
- package/node_modules/safe-regex-test/README.md +46 -0
- package/node_modules/safe-regex-test/index.d.ts +3 -0
- package/node_modules/safe-regex-test/index.js +17 -0
- package/node_modules/safe-regex-test/package.json +87 -0
- package/node_modules/safe-regex-test/test/index.js +41 -0
- package/node_modules/safe-regex-test/tsconfig.json +9 -0
- package/node_modules/side-channel/.eslintrc +1 -0
- package/node_modules/side-channel/CHANGELOG.md +15 -0
- package/node_modules/side-channel/README.md +60 -1
- package/node_modules/side-channel/index.d.ts +9 -22
- package/node_modules/side-channel/index.js +20 -106
- package/node_modules/side-channel/package.json +20 -19
- package/node_modules/side-channel/test/index.js +76 -55
- package/node_modules/side-channel/tsconfig.json +2 -43
- package/node_modules/side-channel-list/.editorconfig +9 -0
- package/node_modules/side-channel-list/.eslintrc +11 -0
- package/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
- package/node_modules/side-channel-list/.nycrc +13 -0
- package/node_modules/side-channel-list/CHANGELOG.md +15 -0
- package/node_modules/side-channel-list/LICENSE +21 -0
- package/node_modules/side-channel-list/README.md +62 -0
- package/node_modules/side-channel-list/index.d.ts +13 -0
- package/node_modules/side-channel-list/index.js +113 -0
- package/node_modules/side-channel-list/list.d.ts +14 -0
- package/node_modules/side-channel-list/package.json +77 -0
- package/node_modules/side-channel-list/test/index.js +104 -0
- package/node_modules/side-channel-list/tsconfig.json +9 -0
- package/node_modules/side-channel-map/.editorconfig +9 -0
- package/node_modules/side-channel-map/.eslintrc +11 -0
- package/node_modules/side-channel-map/.github/FUNDING.yml +12 -0
- package/node_modules/side-channel-map/.nycrc +13 -0
- package/node_modules/side-channel-map/CHANGELOG.md +22 -0
- package/node_modules/side-channel-map/LICENSE +21 -0
- package/node_modules/side-channel-map/README.md +62 -0
- package/node_modules/side-channel-map/index.d.ts +15 -0
- package/node_modules/side-channel-map/index.js +68 -0
- package/node_modules/side-channel-map/package.json +80 -0
- package/node_modules/side-channel-map/test/index.js +114 -0
- package/node_modules/side-channel-map/tsconfig.json +9 -0
- package/node_modules/side-channel-weakmap/.editorconfig +9 -0
- package/node_modules/side-channel-weakmap/.eslintrc +12 -0
- package/node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
- package/node_modules/side-channel-weakmap/.nycrc +13 -0
- package/node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
- package/node_modules/side-channel-weakmap/LICENSE +21 -0
- package/node_modules/side-channel-weakmap/README.md +62 -0
- package/node_modules/side-channel-weakmap/index.d.ts +15 -0
- package/node_modules/side-channel-weakmap/index.js +84 -0
- package/node_modules/side-channel-weakmap/package.json +87 -0
- package/node_modules/side-channel-weakmap/test/index.js +114 -0
- package/node_modules/side-channel-weakmap/tsconfig.json +9 -0
- package/node_modules/which-typed-array/.eslintrc +1 -0
- package/node_modules/which-typed-array/CHANGELOG.md +57 -0
- package/node_modules/which-typed-array/index.d.ts +62 -0
- package/node_modules/which-typed-array/index.js +50 -25
- package/node_modules/which-typed-array/package.json +28 -13
- package/node_modules/which-typed-array/test/index.js +7 -1
- package/node_modules/which-typed-array/tsconfig.json +9 -0
- package/package.json +2 -3
- package/node_modules/@meteorjs/browserify-sign/node_modules/bn.js/README.md +0 -214
- package/node_modules/@meteorjs/browserify-sign/node_modules/bn.js/lib/bn.js +0 -3547
- package/node_modules/@meteorjs/browserify-sign/node_modules/bn.js/package.json +0 -39
- package/node_modules/@meteorjs/browserify-sign/node_modules/hash-base/LICENSE +0 -21
- package/node_modules/@meteorjs/browserify-sign/node_modules/hash-base/README.md +0 -48
- package/node_modules/@meteorjs/browserify-sign/node_modules/hash-base/index.js +0 -138
- package/node_modules/@meteorjs/browserify-sign/node_modules/hash-base/package.json +0 -42
- package/node_modules/@meteorjs/crypto-browserify/node_modules/hash-base/README.md +0 -48
- package/node_modules/@meteorjs/crypto-browserify/node_modules/hash-base/index.js +0 -95
- package/node_modules/@meteorjs/crypto-browserify/node_modules/hash-base/package.json +0 -41
- package/node_modules/available-typed-arrays/.eslintignore +0 -1
- package/node_modules/bn.js/CHANGELOG.md +0 -51
- package/node_modules/cipher-base/.npmignore +0 -1
- package/node_modules/cipher-base/.travis.yml +0 -6
- package/node_modules/cipher-base/test.js +0 -111
- package/node_modules/elliptic/node_modules/bn.js/README.md +0 -200
- package/node_modules/elliptic/node_modules/bn.js/lib/bn.js +0 -3446
- package/node_modules/elliptic/node_modules/bn.js/package.json +0 -36
- package/node_modules/elliptic/package.json +0 -56
- package/node_modules/for-each/.travis.yml +0 -45
- package/node_modules/for-each/test/.eslintrc +0 -8
- package/node_modules/has-proto/CHANGELOG.md +0 -23
- package/node_modules/has-proto/README.md +0 -38
- package/node_modules/has-proto/index.js +0 -11
- package/node_modules/has-proto/test/index.js +0 -19
- package/node_modules/hasown/index.d.ts.map +0 -1
- package/node_modules/is-arguments/.eslintignore +0 -1
- package/node_modules/is-generator-function/.eslintignore +0 -1
- package/node_modules/object-is/.eslintignore +0 -1
- package/node_modules/object.assign/test.html +0 -18458
- package/node_modules/parse-asn1/node_modules/hash-base/LICENSE +0 -21
- package/node_modules/parse-asn1/node_modules/hash-base/README.md +0 -48
- package/node_modules/parse-asn1/node_modules/hash-base/index.js +0 -95
- package/node_modules/parse-asn1/node_modules/hash-base/package.json +0 -41
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/README.md +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/curve/base.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/curve/edwards.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/curve/index.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/curve/mont.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/curve/short.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/curves.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/ec/index.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/ec/key.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/ec/signature.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/eddsa/index.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/eddsa/key.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/eddsa/signature.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/precomputed/secp256k1.js +0 -0
- /package/node_modules/{elliptic → @meteorjs/browserify-sign/elliptic}/lib/elliptic/utils.js +0 -0
- /package/node_modules/{has-proto → dunder-proto}/.eslintrc +0 -0
|
@@ -0,0 +1,938 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('../utils');
|
|
4
|
+
var BN = require('bn.js');
|
|
5
|
+
var inherits = require('inherits');
|
|
6
|
+
var Base = require('./base');
|
|
7
|
+
|
|
8
|
+
var assert = utils.assert;
|
|
9
|
+
|
|
10
|
+
function ShortCurve(conf) {
|
|
11
|
+
Base.call(this, 'short', conf);
|
|
12
|
+
|
|
13
|
+
this.a = new BN(conf.a, 16).toRed(this.red);
|
|
14
|
+
this.b = new BN(conf.b, 16).toRed(this.red);
|
|
15
|
+
this.tinv = this.two.redInvm();
|
|
16
|
+
|
|
17
|
+
this.zeroA = this.a.fromRed().cmpn(0) === 0;
|
|
18
|
+
this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
|
|
19
|
+
|
|
20
|
+
// If the curve is endomorphic, precalculate beta and lambda
|
|
21
|
+
this.endo = this._getEndomorphism(conf);
|
|
22
|
+
this._endoWnafT1 = new Array(4);
|
|
23
|
+
this._endoWnafT2 = new Array(4);
|
|
24
|
+
}
|
|
25
|
+
inherits(ShortCurve, Base);
|
|
26
|
+
module.exports = ShortCurve;
|
|
27
|
+
|
|
28
|
+
ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
|
|
29
|
+
// No efficient endomorphism
|
|
30
|
+
if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
|
|
31
|
+
return;
|
|
32
|
+
|
|
33
|
+
// Compute beta and lambda, that lambda * P = (beta * Px; Py)
|
|
34
|
+
var beta;
|
|
35
|
+
var lambda;
|
|
36
|
+
if (conf.beta) {
|
|
37
|
+
beta = new BN(conf.beta, 16).toRed(this.red);
|
|
38
|
+
} else {
|
|
39
|
+
var betas = this._getEndoRoots(this.p);
|
|
40
|
+
// Choose the smallest beta
|
|
41
|
+
beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
|
|
42
|
+
beta = beta.toRed(this.red);
|
|
43
|
+
}
|
|
44
|
+
if (conf.lambda) {
|
|
45
|
+
lambda = new BN(conf.lambda, 16);
|
|
46
|
+
} else {
|
|
47
|
+
// Choose the lambda that is matching selected beta
|
|
48
|
+
var lambdas = this._getEndoRoots(this.n);
|
|
49
|
+
if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
|
|
50
|
+
lambda = lambdas[0];
|
|
51
|
+
} else {
|
|
52
|
+
lambda = lambdas[1];
|
|
53
|
+
assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Get basis vectors, used for balanced length-two representation
|
|
58
|
+
var basis;
|
|
59
|
+
if (conf.basis) {
|
|
60
|
+
basis = conf.basis.map(function(vec) {
|
|
61
|
+
return {
|
|
62
|
+
a: new BN(vec.a, 16),
|
|
63
|
+
b: new BN(vec.b, 16),
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
basis = this._getEndoBasis(lambda);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
beta: beta,
|
|
72
|
+
lambda: lambda,
|
|
73
|
+
basis: basis,
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
|
|
78
|
+
// Find roots of for x^2 + x + 1 in F
|
|
79
|
+
// Root = (-1 +- Sqrt(-3)) / 2
|
|
80
|
+
//
|
|
81
|
+
var red = num === this.p ? this.red : BN.mont(num);
|
|
82
|
+
var tinv = new BN(2).toRed(red).redInvm();
|
|
83
|
+
var ntinv = tinv.redNeg();
|
|
84
|
+
|
|
85
|
+
var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
|
|
86
|
+
|
|
87
|
+
var l1 = ntinv.redAdd(s).fromRed();
|
|
88
|
+
var l2 = ntinv.redSub(s).fromRed();
|
|
89
|
+
return [ l1, l2 ];
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
|
|
93
|
+
// aprxSqrt >= sqrt(this.n)
|
|
94
|
+
var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
|
|
95
|
+
|
|
96
|
+
// 3.74
|
|
97
|
+
// Run EGCD, until r(L + 1) < aprxSqrt
|
|
98
|
+
var u = lambda;
|
|
99
|
+
var v = this.n.clone();
|
|
100
|
+
var x1 = new BN(1);
|
|
101
|
+
var y1 = new BN(0);
|
|
102
|
+
var x2 = new BN(0);
|
|
103
|
+
var y2 = new BN(1);
|
|
104
|
+
|
|
105
|
+
// NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
|
|
106
|
+
var a0;
|
|
107
|
+
var b0;
|
|
108
|
+
// First vector
|
|
109
|
+
var a1;
|
|
110
|
+
var b1;
|
|
111
|
+
// Second vector
|
|
112
|
+
var a2;
|
|
113
|
+
var b2;
|
|
114
|
+
|
|
115
|
+
var prevR;
|
|
116
|
+
var i = 0;
|
|
117
|
+
var r;
|
|
118
|
+
var x;
|
|
119
|
+
while (u.cmpn(0) !== 0) {
|
|
120
|
+
var q = v.div(u);
|
|
121
|
+
r = v.sub(q.mul(u));
|
|
122
|
+
x = x2.sub(q.mul(x1));
|
|
123
|
+
var y = y2.sub(q.mul(y1));
|
|
124
|
+
|
|
125
|
+
if (!a1 && r.cmp(aprxSqrt) < 0) {
|
|
126
|
+
a0 = prevR.neg();
|
|
127
|
+
b0 = x1;
|
|
128
|
+
a1 = r.neg();
|
|
129
|
+
b1 = x;
|
|
130
|
+
} else if (a1 && ++i === 2) {
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
prevR = r;
|
|
134
|
+
|
|
135
|
+
v = u;
|
|
136
|
+
u = r;
|
|
137
|
+
x2 = x1;
|
|
138
|
+
x1 = x;
|
|
139
|
+
y2 = y1;
|
|
140
|
+
y1 = y;
|
|
141
|
+
}
|
|
142
|
+
a2 = r.neg();
|
|
143
|
+
b2 = x;
|
|
144
|
+
|
|
145
|
+
var len1 = a1.sqr().add(b1.sqr());
|
|
146
|
+
var len2 = a2.sqr().add(b2.sqr());
|
|
147
|
+
if (len2.cmp(len1) >= 0) {
|
|
148
|
+
a2 = a0;
|
|
149
|
+
b2 = b0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Normalize signs
|
|
153
|
+
if (a1.negative) {
|
|
154
|
+
a1 = a1.neg();
|
|
155
|
+
b1 = b1.neg();
|
|
156
|
+
}
|
|
157
|
+
if (a2.negative) {
|
|
158
|
+
a2 = a2.neg();
|
|
159
|
+
b2 = b2.neg();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return [
|
|
163
|
+
{ a: a1, b: b1 },
|
|
164
|
+
{ a: a2, b: b2 },
|
|
165
|
+
];
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
ShortCurve.prototype._endoSplit = function _endoSplit(k) {
|
|
169
|
+
var basis = this.endo.basis;
|
|
170
|
+
var v1 = basis[0];
|
|
171
|
+
var v2 = basis[1];
|
|
172
|
+
|
|
173
|
+
var c1 = v2.b.mul(k).divRound(this.n);
|
|
174
|
+
var c2 = v1.b.neg().mul(k).divRound(this.n);
|
|
175
|
+
|
|
176
|
+
var p1 = c1.mul(v1.a);
|
|
177
|
+
var p2 = c2.mul(v2.a);
|
|
178
|
+
var q1 = c1.mul(v1.b);
|
|
179
|
+
var q2 = c2.mul(v2.b);
|
|
180
|
+
|
|
181
|
+
// Calculate answer
|
|
182
|
+
var k1 = k.sub(p1).sub(p2);
|
|
183
|
+
var k2 = q1.add(q2).neg();
|
|
184
|
+
return { k1: k1, k2: k2 };
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
|
|
188
|
+
x = new BN(x, 16);
|
|
189
|
+
if (!x.red)
|
|
190
|
+
x = x.toRed(this.red);
|
|
191
|
+
|
|
192
|
+
var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
|
|
193
|
+
var y = y2.redSqrt();
|
|
194
|
+
if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
|
|
195
|
+
throw new Error('invalid point');
|
|
196
|
+
|
|
197
|
+
// XXX Is there any way to tell if the number is odd without converting it
|
|
198
|
+
// to non-red form?
|
|
199
|
+
var isOdd = y.fromRed().isOdd();
|
|
200
|
+
if (odd && !isOdd || !odd && isOdd)
|
|
201
|
+
y = y.redNeg();
|
|
202
|
+
|
|
203
|
+
return this.point(x, y);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
ShortCurve.prototype.validate = function validate(point) {
|
|
207
|
+
if (point.inf)
|
|
208
|
+
return true;
|
|
209
|
+
|
|
210
|
+
var x = point.x;
|
|
211
|
+
var y = point.y;
|
|
212
|
+
|
|
213
|
+
var ax = this.a.redMul(x);
|
|
214
|
+
var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
|
|
215
|
+
return y.redSqr().redISub(rhs).cmpn(0) === 0;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
ShortCurve.prototype._endoWnafMulAdd =
|
|
219
|
+
function _endoWnafMulAdd(points, coeffs, jacobianResult) {
|
|
220
|
+
var npoints = this._endoWnafT1;
|
|
221
|
+
var ncoeffs = this._endoWnafT2;
|
|
222
|
+
for (var i = 0; i < points.length; i++) {
|
|
223
|
+
var split = this._endoSplit(coeffs[i]);
|
|
224
|
+
var p = points[i];
|
|
225
|
+
var beta = p._getBeta();
|
|
226
|
+
|
|
227
|
+
if (split.k1.negative) {
|
|
228
|
+
split.k1.ineg();
|
|
229
|
+
p = p.neg(true);
|
|
230
|
+
}
|
|
231
|
+
if (split.k2.negative) {
|
|
232
|
+
split.k2.ineg();
|
|
233
|
+
beta = beta.neg(true);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
npoints[i * 2] = p;
|
|
237
|
+
npoints[i * 2 + 1] = beta;
|
|
238
|
+
ncoeffs[i * 2] = split.k1;
|
|
239
|
+
ncoeffs[i * 2 + 1] = split.k2;
|
|
240
|
+
}
|
|
241
|
+
var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
|
|
242
|
+
|
|
243
|
+
// Clean-up references to points and coefficients
|
|
244
|
+
for (var j = 0; j < i * 2; j++) {
|
|
245
|
+
npoints[j] = null;
|
|
246
|
+
ncoeffs[j] = null;
|
|
247
|
+
}
|
|
248
|
+
return res;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
function Point(curve, x, y, isRed) {
|
|
252
|
+
Base.BasePoint.call(this, curve, 'affine');
|
|
253
|
+
if (x === null && y === null) {
|
|
254
|
+
this.x = null;
|
|
255
|
+
this.y = null;
|
|
256
|
+
this.inf = true;
|
|
257
|
+
} else {
|
|
258
|
+
this.x = new BN(x, 16);
|
|
259
|
+
this.y = new BN(y, 16);
|
|
260
|
+
// Force redgomery representation when loading from JSON
|
|
261
|
+
if (isRed) {
|
|
262
|
+
this.x.forceRed(this.curve.red);
|
|
263
|
+
this.y.forceRed(this.curve.red);
|
|
264
|
+
}
|
|
265
|
+
if (!this.x.red)
|
|
266
|
+
this.x = this.x.toRed(this.curve.red);
|
|
267
|
+
if (!this.y.red)
|
|
268
|
+
this.y = this.y.toRed(this.curve.red);
|
|
269
|
+
this.inf = false;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
inherits(Point, Base.BasePoint);
|
|
273
|
+
|
|
274
|
+
ShortCurve.prototype.point = function point(x, y, isRed) {
|
|
275
|
+
return new Point(this, x, y, isRed);
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
|
|
279
|
+
return Point.fromJSON(this, obj, red);
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
Point.prototype._getBeta = function _getBeta() {
|
|
283
|
+
if (!this.curve.endo)
|
|
284
|
+
return;
|
|
285
|
+
|
|
286
|
+
var pre = this.precomputed;
|
|
287
|
+
if (pre && pre.beta)
|
|
288
|
+
return pre.beta;
|
|
289
|
+
|
|
290
|
+
var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
|
|
291
|
+
if (pre) {
|
|
292
|
+
var curve = this.curve;
|
|
293
|
+
var endoMul = function(p) {
|
|
294
|
+
return curve.point(p.x.redMul(curve.endo.beta), p.y);
|
|
295
|
+
};
|
|
296
|
+
pre.beta = beta;
|
|
297
|
+
beta.precomputed = {
|
|
298
|
+
beta: null,
|
|
299
|
+
naf: pre.naf && {
|
|
300
|
+
wnd: pre.naf.wnd,
|
|
301
|
+
points: pre.naf.points.map(endoMul),
|
|
302
|
+
},
|
|
303
|
+
doubles: pre.doubles && {
|
|
304
|
+
step: pre.doubles.step,
|
|
305
|
+
points: pre.doubles.points.map(endoMul),
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
return beta;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
Point.prototype.toJSON = function toJSON() {
|
|
313
|
+
if (!this.precomputed)
|
|
314
|
+
return [ this.x, this.y ];
|
|
315
|
+
|
|
316
|
+
return [ this.x, this.y, this.precomputed && {
|
|
317
|
+
doubles: this.precomputed.doubles && {
|
|
318
|
+
step: this.precomputed.doubles.step,
|
|
319
|
+
points: this.precomputed.doubles.points.slice(1),
|
|
320
|
+
},
|
|
321
|
+
naf: this.precomputed.naf && {
|
|
322
|
+
wnd: this.precomputed.naf.wnd,
|
|
323
|
+
points: this.precomputed.naf.points.slice(1),
|
|
324
|
+
},
|
|
325
|
+
} ];
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
Point.fromJSON = function fromJSON(curve, obj, red) {
|
|
329
|
+
if (typeof obj === 'string')
|
|
330
|
+
obj = JSON.parse(obj);
|
|
331
|
+
var res = curve.point(obj[0], obj[1], red);
|
|
332
|
+
if (!obj[2])
|
|
333
|
+
return res;
|
|
334
|
+
|
|
335
|
+
function obj2point(obj) {
|
|
336
|
+
return curve.point(obj[0], obj[1], red);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
var pre = obj[2];
|
|
340
|
+
res.precomputed = {
|
|
341
|
+
beta: null,
|
|
342
|
+
doubles: pre.doubles && {
|
|
343
|
+
step: pre.doubles.step,
|
|
344
|
+
points: [ res ].concat(pre.doubles.points.map(obj2point)),
|
|
345
|
+
},
|
|
346
|
+
naf: pre.naf && {
|
|
347
|
+
wnd: pre.naf.wnd,
|
|
348
|
+
points: [ res ].concat(pre.naf.points.map(obj2point)),
|
|
349
|
+
},
|
|
350
|
+
};
|
|
351
|
+
return res;
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
Point.prototype.inspect = function inspect() {
|
|
355
|
+
if (this.isInfinity())
|
|
356
|
+
return '<EC Point Infinity>';
|
|
357
|
+
return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
|
|
358
|
+
' y: ' + this.y.fromRed().toString(16, 2) + '>';
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
Point.prototype.isInfinity = function isInfinity() {
|
|
362
|
+
return this.inf;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
Point.prototype.add = function add(p) {
|
|
366
|
+
// O + P = P
|
|
367
|
+
if (this.inf)
|
|
368
|
+
return p;
|
|
369
|
+
|
|
370
|
+
// P + O = P
|
|
371
|
+
if (p.inf)
|
|
372
|
+
return this;
|
|
373
|
+
|
|
374
|
+
// P + P = 2P
|
|
375
|
+
if (this.eq(p))
|
|
376
|
+
return this.dbl();
|
|
377
|
+
|
|
378
|
+
// P + (-P) = O
|
|
379
|
+
if (this.neg().eq(p))
|
|
380
|
+
return this.curve.point(null, null);
|
|
381
|
+
|
|
382
|
+
// P + Q = O
|
|
383
|
+
if (this.x.cmp(p.x) === 0)
|
|
384
|
+
return this.curve.point(null, null);
|
|
385
|
+
|
|
386
|
+
var c = this.y.redSub(p.y);
|
|
387
|
+
if (c.cmpn(0) !== 0)
|
|
388
|
+
c = c.redMul(this.x.redSub(p.x).redInvm());
|
|
389
|
+
var nx = c.redSqr().redISub(this.x).redISub(p.x);
|
|
390
|
+
var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
|
|
391
|
+
return this.curve.point(nx, ny);
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
Point.prototype.dbl = function dbl() {
|
|
395
|
+
if (this.inf)
|
|
396
|
+
return this;
|
|
397
|
+
|
|
398
|
+
// 2P = O
|
|
399
|
+
var ys1 = this.y.redAdd(this.y);
|
|
400
|
+
if (ys1.cmpn(0) === 0)
|
|
401
|
+
return this.curve.point(null, null);
|
|
402
|
+
|
|
403
|
+
var a = this.curve.a;
|
|
404
|
+
|
|
405
|
+
var x2 = this.x.redSqr();
|
|
406
|
+
var dyinv = ys1.redInvm();
|
|
407
|
+
var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
|
|
408
|
+
|
|
409
|
+
var nx = c.redSqr().redISub(this.x.redAdd(this.x));
|
|
410
|
+
var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
|
|
411
|
+
return this.curve.point(nx, ny);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
Point.prototype.getX = function getX() {
|
|
415
|
+
return this.x.fromRed();
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
Point.prototype.getY = function getY() {
|
|
419
|
+
return this.y.fromRed();
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
Point.prototype.mul = function mul(k) {
|
|
423
|
+
k = new BN(k, 16);
|
|
424
|
+
if (this.isInfinity())
|
|
425
|
+
return this;
|
|
426
|
+
else if (this._hasDoubles(k))
|
|
427
|
+
return this.curve._fixedNafMul(this, k);
|
|
428
|
+
else if (this.curve.endo)
|
|
429
|
+
return this.curve._endoWnafMulAdd([ this ], [ k ]);
|
|
430
|
+
else
|
|
431
|
+
return this.curve._wnafMul(this, k);
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
|
|
435
|
+
var points = [ this, p2 ];
|
|
436
|
+
var coeffs = [ k1, k2 ];
|
|
437
|
+
if (this.curve.endo)
|
|
438
|
+
return this.curve._endoWnafMulAdd(points, coeffs);
|
|
439
|
+
else
|
|
440
|
+
return this.curve._wnafMulAdd(1, points, coeffs, 2);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
|
|
444
|
+
var points = [ this, p2 ];
|
|
445
|
+
var coeffs = [ k1, k2 ];
|
|
446
|
+
if (this.curve.endo)
|
|
447
|
+
return this.curve._endoWnafMulAdd(points, coeffs, true);
|
|
448
|
+
else
|
|
449
|
+
return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
Point.prototype.eq = function eq(p) {
|
|
453
|
+
return this === p ||
|
|
454
|
+
this.inf === p.inf &&
|
|
455
|
+
(this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
Point.prototype.neg = function neg(_precompute) {
|
|
459
|
+
if (this.inf)
|
|
460
|
+
return this;
|
|
461
|
+
|
|
462
|
+
var res = this.curve.point(this.x, this.y.redNeg());
|
|
463
|
+
if (_precompute && this.precomputed) {
|
|
464
|
+
var pre = this.precomputed;
|
|
465
|
+
var negate = function(p) {
|
|
466
|
+
return p.neg();
|
|
467
|
+
};
|
|
468
|
+
res.precomputed = {
|
|
469
|
+
naf: pre.naf && {
|
|
470
|
+
wnd: pre.naf.wnd,
|
|
471
|
+
points: pre.naf.points.map(negate),
|
|
472
|
+
},
|
|
473
|
+
doubles: pre.doubles && {
|
|
474
|
+
step: pre.doubles.step,
|
|
475
|
+
points: pre.doubles.points.map(negate),
|
|
476
|
+
},
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
return res;
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
Point.prototype.toJ = function toJ() {
|
|
483
|
+
if (this.inf)
|
|
484
|
+
return this.curve.jpoint(null, null, null);
|
|
485
|
+
|
|
486
|
+
var res = this.curve.jpoint(this.x, this.y, this.curve.one);
|
|
487
|
+
return res;
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
function JPoint(curve, x, y, z) {
|
|
491
|
+
Base.BasePoint.call(this, curve, 'jacobian');
|
|
492
|
+
if (x === null && y === null && z === null) {
|
|
493
|
+
this.x = this.curve.one;
|
|
494
|
+
this.y = this.curve.one;
|
|
495
|
+
this.z = new BN(0);
|
|
496
|
+
} else {
|
|
497
|
+
this.x = new BN(x, 16);
|
|
498
|
+
this.y = new BN(y, 16);
|
|
499
|
+
this.z = new BN(z, 16);
|
|
500
|
+
}
|
|
501
|
+
if (!this.x.red)
|
|
502
|
+
this.x = this.x.toRed(this.curve.red);
|
|
503
|
+
if (!this.y.red)
|
|
504
|
+
this.y = this.y.toRed(this.curve.red);
|
|
505
|
+
if (!this.z.red)
|
|
506
|
+
this.z = this.z.toRed(this.curve.red);
|
|
507
|
+
|
|
508
|
+
this.zOne = this.z === this.curve.one;
|
|
509
|
+
}
|
|
510
|
+
inherits(JPoint, Base.BasePoint);
|
|
511
|
+
|
|
512
|
+
ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
|
|
513
|
+
return new JPoint(this, x, y, z);
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
JPoint.prototype.toP = function toP() {
|
|
517
|
+
if (this.isInfinity())
|
|
518
|
+
return this.curve.point(null, null);
|
|
519
|
+
|
|
520
|
+
var zinv = this.z.redInvm();
|
|
521
|
+
var zinv2 = zinv.redSqr();
|
|
522
|
+
var ax = this.x.redMul(zinv2);
|
|
523
|
+
var ay = this.y.redMul(zinv2).redMul(zinv);
|
|
524
|
+
|
|
525
|
+
return this.curve.point(ax, ay);
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
JPoint.prototype.neg = function neg() {
|
|
529
|
+
return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
JPoint.prototype.add = function add(p) {
|
|
533
|
+
// O + P = P
|
|
534
|
+
if (this.isInfinity())
|
|
535
|
+
return p;
|
|
536
|
+
|
|
537
|
+
// P + O = P
|
|
538
|
+
if (p.isInfinity())
|
|
539
|
+
return this;
|
|
540
|
+
|
|
541
|
+
// 12M + 4S + 7A
|
|
542
|
+
var pz2 = p.z.redSqr();
|
|
543
|
+
var z2 = this.z.redSqr();
|
|
544
|
+
var u1 = this.x.redMul(pz2);
|
|
545
|
+
var u2 = p.x.redMul(z2);
|
|
546
|
+
var s1 = this.y.redMul(pz2.redMul(p.z));
|
|
547
|
+
var s2 = p.y.redMul(z2.redMul(this.z));
|
|
548
|
+
|
|
549
|
+
var h = u1.redSub(u2);
|
|
550
|
+
var r = s1.redSub(s2);
|
|
551
|
+
if (h.cmpn(0) === 0) {
|
|
552
|
+
if (r.cmpn(0) !== 0)
|
|
553
|
+
return this.curve.jpoint(null, null, null);
|
|
554
|
+
else
|
|
555
|
+
return this.dbl();
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
var h2 = h.redSqr();
|
|
559
|
+
var h3 = h2.redMul(h);
|
|
560
|
+
var v = u1.redMul(h2);
|
|
561
|
+
|
|
562
|
+
var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
|
|
563
|
+
var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
|
|
564
|
+
var nz = this.z.redMul(p.z).redMul(h);
|
|
565
|
+
|
|
566
|
+
return this.curve.jpoint(nx, ny, nz);
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
JPoint.prototype.mixedAdd = function mixedAdd(p) {
|
|
570
|
+
// O + P = P
|
|
571
|
+
if (this.isInfinity())
|
|
572
|
+
return p.toJ();
|
|
573
|
+
|
|
574
|
+
// P + O = P
|
|
575
|
+
if (p.isInfinity())
|
|
576
|
+
return this;
|
|
577
|
+
|
|
578
|
+
// 8M + 3S + 7A
|
|
579
|
+
var z2 = this.z.redSqr();
|
|
580
|
+
var u1 = this.x;
|
|
581
|
+
var u2 = p.x.redMul(z2);
|
|
582
|
+
var s1 = this.y;
|
|
583
|
+
var s2 = p.y.redMul(z2).redMul(this.z);
|
|
584
|
+
|
|
585
|
+
var h = u1.redSub(u2);
|
|
586
|
+
var r = s1.redSub(s2);
|
|
587
|
+
if (h.cmpn(0) === 0) {
|
|
588
|
+
if (r.cmpn(0) !== 0)
|
|
589
|
+
return this.curve.jpoint(null, null, null);
|
|
590
|
+
else
|
|
591
|
+
return this.dbl();
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
var h2 = h.redSqr();
|
|
595
|
+
var h3 = h2.redMul(h);
|
|
596
|
+
var v = u1.redMul(h2);
|
|
597
|
+
|
|
598
|
+
var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
|
|
599
|
+
var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
|
|
600
|
+
var nz = this.z.redMul(h);
|
|
601
|
+
|
|
602
|
+
return this.curve.jpoint(nx, ny, nz);
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
JPoint.prototype.dblp = function dblp(pow) {
|
|
606
|
+
if (pow === 0)
|
|
607
|
+
return this;
|
|
608
|
+
if (this.isInfinity())
|
|
609
|
+
return this;
|
|
610
|
+
if (!pow)
|
|
611
|
+
return this.dbl();
|
|
612
|
+
|
|
613
|
+
var i;
|
|
614
|
+
if (this.curve.zeroA || this.curve.threeA) {
|
|
615
|
+
var r = this;
|
|
616
|
+
for (i = 0; i < pow; i++)
|
|
617
|
+
r = r.dbl();
|
|
618
|
+
return r;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// 1M + 2S + 1A + N * (4S + 5M + 8A)
|
|
622
|
+
// N = 1 => 6M + 6S + 9A
|
|
623
|
+
var a = this.curve.a;
|
|
624
|
+
var tinv = this.curve.tinv;
|
|
625
|
+
|
|
626
|
+
var jx = this.x;
|
|
627
|
+
var jy = this.y;
|
|
628
|
+
var jz = this.z;
|
|
629
|
+
var jz4 = jz.redSqr().redSqr();
|
|
630
|
+
|
|
631
|
+
// Reuse results
|
|
632
|
+
var jyd = jy.redAdd(jy);
|
|
633
|
+
for (i = 0; i < pow; i++) {
|
|
634
|
+
var jx2 = jx.redSqr();
|
|
635
|
+
var jyd2 = jyd.redSqr();
|
|
636
|
+
var jyd4 = jyd2.redSqr();
|
|
637
|
+
var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
|
|
638
|
+
|
|
639
|
+
var t1 = jx.redMul(jyd2);
|
|
640
|
+
var nx = c.redSqr().redISub(t1.redAdd(t1));
|
|
641
|
+
var t2 = t1.redISub(nx);
|
|
642
|
+
var dny = c.redMul(t2);
|
|
643
|
+
dny = dny.redIAdd(dny).redISub(jyd4);
|
|
644
|
+
var nz = jyd.redMul(jz);
|
|
645
|
+
if (i + 1 < pow)
|
|
646
|
+
jz4 = jz4.redMul(jyd4);
|
|
647
|
+
|
|
648
|
+
jx = nx;
|
|
649
|
+
jz = nz;
|
|
650
|
+
jyd = dny;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
JPoint.prototype.dbl = function dbl() {
|
|
657
|
+
if (this.isInfinity())
|
|
658
|
+
return this;
|
|
659
|
+
|
|
660
|
+
if (this.curve.zeroA)
|
|
661
|
+
return this._zeroDbl();
|
|
662
|
+
else if (this.curve.threeA)
|
|
663
|
+
return this._threeDbl();
|
|
664
|
+
else
|
|
665
|
+
return this._dbl();
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
JPoint.prototype._zeroDbl = function _zeroDbl() {
|
|
669
|
+
var nx;
|
|
670
|
+
var ny;
|
|
671
|
+
var nz;
|
|
672
|
+
// Z = 1
|
|
673
|
+
if (this.zOne) {
|
|
674
|
+
// hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
|
|
675
|
+
// #doubling-mdbl-2007-bl
|
|
676
|
+
// 1M + 5S + 14A
|
|
677
|
+
|
|
678
|
+
// XX = X1^2
|
|
679
|
+
var xx = this.x.redSqr();
|
|
680
|
+
// YY = Y1^2
|
|
681
|
+
var yy = this.y.redSqr();
|
|
682
|
+
// YYYY = YY^2
|
|
683
|
+
var yyyy = yy.redSqr();
|
|
684
|
+
// S = 2 * ((X1 + YY)^2 - XX - YYYY)
|
|
685
|
+
var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
|
|
686
|
+
s = s.redIAdd(s);
|
|
687
|
+
// M = 3 * XX + a; a = 0
|
|
688
|
+
var m = xx.redAdd(xx).redIAdd(xx);
|
|
689
|
+
// T = M ^ 2 - 2*S
|
|
690
|
+
var t = m.redSqr().redISub(s).redISub(s);
|
|
691
|
+
|
|
692
|
+
// 8 * YYYY
|
|
693
|
+
var yyyy8 = yyyy.redIAdd(yyyy);
|
|
694
|
+
yyyy8 = yyyy8.redIAdd(yyyy8);
|
|
695
|
+
yyyy8 = yyyy8.redIAdd(yyyy8);
|
|
696
|
+
|
|
697
|
+
// X3 = T
|
|
698
|
+
nx = t;
|
|
699
|
+
// Y3 = M * (S - T) - 8 * YYYY
|
|
700
|
+
ny = m.redMul(s.redISub(t)).redISub(yyyy8);
|
|
701
|
+
// Z3 = 2*Y1
|
|
702
|
+
nz = this.y.redAdd(this.y);
|
|
703
|
+
} else {
|
|
704
|
+
// hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
|
|
705
|
+
// #doubling-dbl-2009-l
|
|
706
|
+
// 2M + 5S + 13A
|
|
707
|
+
|
|
708
|
+
// A = X1^2
|
|
709
|
+
var a = this.x.redSqr();
|
|
710
|
+
// B = Y1^2
|
|
711
|
+
var b = this.y.redSqr();
|
|
712
|
+
// C = B^2
|
|
713
|
+
var c = b.redSqr();
|
|
714
|
+
// D = 2 * ((X1 + B)^2 - A - C)
|
|
715
|
+
var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
|
|
716
|
+
d = d.redIAdd(d);
|
|
717
|
+
// E = 3 * A
|
|
718
|
+
var e = a.redAdd(a).redIAdd(a);
|
|
719
|
+
// F = E^2
|
|
720
|
+
var f = e.redSqr();
|
|
721
|
+
|
|
722
|
+
// 8 * C
|
|
723
|
+
var c8 = c.redIAdd(c);
|
|
724
|
+
c8 = c8.redIAdd(c8);
|
|
725
|
+
c8 = c8.redIAdd(c8);
|
|
726
|
+
|
|
727
|
+
// X3 = F - 2 * D
|
|
728
|
+
nx = f.redISub(d).redISub(d);
|
|
729
|
+
// Y3 = E * (D - X3) - 8 * C
|
|
730
|
+
ny = e.redMul(d.redISub(nx)).redISub(c8);
|
|
731
|
+
// Z3 = 2 * Y1 * Z1
|
|
732
|
+
nz = this.y.redMul(this.z);
|
|
733
|
+
nz = nz.redIAdd(nz);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
return this.curve.jpoint(nx, ny, nz);
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
JPoint.prototype._threeDbl = function _threeDbl() {
|
|
740
|
+
var nx;
|
|
741
|
+
var ny;
|
|
742
|
+
var nz;
|
|
743
|
+
// Z = 1
|
|
744
|
+
if (this.zOne) {
|
|
745
|
+
// hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
|
|
746
|
+
// #doubling-mdbl-2007-bl
|
|
747
|
+
// 1M + 5S + 15A
|
|
748
|
+
|
|
749
|
+
// XX = X1^2
|
|
750
|
+
var xx = this.x.redSqr();
|
|
751
|
+
// YY = Y1^2
|
|
752
|
+
var yy = this.y.redSqr();
|
|
753
|
+
// YYYY = YY^2
|
|
754
|
+
var yyyy = yy.redSqr();
|
|
755
|
+
// S = 2 * ((X1 + YY)^2 - XX - YYYY)
|
|
756
|
+
var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
|
|
757
|
+
s = s.redIAdd(s);
|
|
758
|
+
// M = 3 * XX + a
|
|
759
|
+
var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
|
|
760
|
+
// T = M^2 - 2 * S
|
|
761
|
+
var t = m.redSqr().redISub(s).redISub(s);
|
|
762
|
+
// X3 = T
|
|
763
|
+
nx = t;
|
|
764
|
+
// Y3 = M * (S - T) - 8 * YYYY
|
|
765
|
+
var yyyy8 = yyyy.redIAdd(yyyy);
|
|
766
|
+
yyyy8 = yyyy8.redIAdd(yyyy8);
|
|
767
|
+
yyyy8 = yyyy8.redIAdd(yyyy8);
|
|
768
|
+
ny = m.redMul(s.redISub(t)).redISub(yyyy8);
|
|
769
|
+
// Z3 = 2 * Y1
|
|
770
|
+
nz = this.y.redAdd(this.y);
|
|
771
|
+
} else {
|
|
772
|
+
// hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
|
|
773
|
+
// 3M + 5S
|
|
774
|
+
|
|
775
|
+
// delta = Z1^2
|
|
776
|
+
var delta = this.z.redSqr();
|
|
777
|
+
// gamma = Y1^2
|
|
778
|
+
var gamma = this.y.redSqr();
|
|
779
|
+
// beta = X1 * gamma
|
|
780
|
+
var beta = this.x.redMul(gamma);
|
|
781
|
+
// alpha = 3 * (X1 - delta) * (X1 + delta)
|
|
782
|
+
var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
|
|
783
|
+
alpha = alpha.redAdd(alpha).redIAdd(alpha);
|
|
784
|
+
// X3 = alpha^2 - 8 * beta
|
|
785
|
+
var beta4 = beta.redIAdd(beta);
|
|
786
|
+
beta4 = beta4.redIAdd(beta4);
|
|
787
|
+
var beta8 = beta4.redAdd(beta4);
|
|
788
|
+
nx = alpha.redSqr().redISub(beta8);
|
|
789
|
+
// Z3 = (Y1 + Z1)^2 - gamma - delta
|
|
790
|
+
nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
|
|
791
|
+
// Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
|
|
792
|
+
var ggamma8 = gamma.redSqr();
|
|
793
|
+
ggamma8 = ggamma8.redIAdd(ggamma8);
|
|
794
|
+
ggamma8 = ggamma8.redIAdd(ggamma8);
|
|
795
|
+
ggamma8 = ggamma8.redIAdd(ggamma8);
|
|
796
|
+
ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
return this.curve.jpoint(nx, ny, nz);
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
JPoint.prototype._dbl = function _dbl() {
|
|
803
|
+
var a = this.curve.a;
|
|
804
|
+
|
|
805
|
+
// 4M + 6S + 10A
|
|
806
|
+
var jx = this.x;
|
|
807
|
+
var jy = this.y;
|
|
808
|
+
var jz = this.z;
|
|
809
|
+
var jz4 = jz.redSqr().redSqr();
|
|
810
|
+
|
|
811
|
+
var jx2 = jx.redSqr();
|
|
812
|
+
var jy2 = jy.redSqr();
|
|
813
|
+
|
|
814
|
+
var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
|
|
815
|
+
|
|
816
|
+
var jxd4 = jx.redAdd(jx);
|
|
817
|
+
jxd4 = jxd4.redIAdd(jxd4);
|
|
818
|
+
var t1 = jxd4.redMul(jy2);
|
|
819
|
+
var nx = c.redSqr().redISub(t1.redAdd(t1));
|
|
820
|
+
var t2 = t1.redISub(nx);
|
|
821
|
+
|
|
822
|
+
var jyd8 = jy2.redSqr();
|
|
823
|
+
jyd8 = jyd8.redIAdd(jyd8);
|
|
824
|
+
jyd8 = jyd8.redIAdd(jyd8);
|
|
825
|
+
jyd8 = jyd8.redIAdd(jyd8);
|
|
826
|
+
var ny = c.redMul(t2).redISub(jyd8);
|
|
827
|
+
var nz = jy.redAdd(jy).redMul(jz);
|
|
828
|
+
|
|
829
|
+
return this.curve.jpoint(nx, ny, nz);
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
JPoint.prototype.trpl = function trpl() {
|
|
833
|
+
if (!this.curve.zeroA)
|
|
834
|
+
return this.dbl().add(this);
|
|
835
|
+
|
|
836
|
+
// hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
|
|
837
|
+
// 5M + 10S + ...
|
|
838
|
+
|
|
839
|
+
// XX = X1^2
|
|
840
|
+
var xx = this.x.redSqr();
|
|
841
|
+
// YY = Y1^2
|
|
842
|
+
var yy = this.y.redSqr();
|
|
843
|
+
// ZZ = Z1^2
|
|
844
|
+
var zz = this.z.redSqr();
|
|
845
|
+
// YYYY = YY^2
|
|
846
|
+
var yyyy = yy.redSqr();
|
|
847
|
+
// M = 3 * XX + a * ZZ2; a = 0
|
|
848
|
+
var m = xx.redAdd(xx).redIAdd(xx);
|
|
849
|
+
// MM = M^2
|
|
850
|
+
var mm = m.redSqr();
|
|
851
|
+
// E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
|
|
852
|
+
var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
|
|
853
|
+
e = e.redIAdd(e);
|
|
854
|
+
e = e.redAdd(e).redIAdd(e);
|
|
855
|
+
e = e.redISub(mm);
|
|
856
|
+
// EE = E^2
|
|
857
|
+
var ee = e.redSqr();
|
|
858
|
+
// T = 16*YYYY
|
|
859
|
+
var t = yyyy.redIAdd(yyyy);
|
|
860
|
+
t = t.redIAdd(t);
|
|
861
|
+
t = t.redIAdd(t);
|
|
862
|
+
t = t.redIAdd(t);
|
|
863
|
+
// U = (M + E)^2 - MM - EE - T
|
|
864
|
+
var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
|
|
865
|
+
// X3 = 4 * (X1 * EE - 4 * YY * U)
|
|
866
|
+
var yyu4 = yy.redMul(u);
|
|
867
|
+
yyu4 = yyu4.redIAdd(yyu4);
|
|
868
|
+
yyu4 = yyu4.redIAdd(yyu4);
|
|
869
|
+
var nx = this.x.redMul(ee).redISub(yyu4);
|
|
870
|
+
nx = nx.redIAdd(nx);
|
|
871
|
+
nx = nx.redIAdd(nx);
|
|
872
|
+
// Y3 = 8 * Y1 * (U * (T - U) - E * EE)
|
|
873
|
+
var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
|
|
874
|
+
ny = ny.redIAdd(ny);
|
|
875
|
+
ny = ny.redIAdd(ny);
|
|
876
|
+
ny = ny.redIAdd(ny);
|
|
877
|
+
// Z3 = (Z1 + E)^2 - ZZ - EE
|
|
878
|
+
var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
|
|
879
|
+
|
|
880
|
+
return this.curve.jpoint(nx, ny, nz);
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
JPoint.prototype.mul = function mul(k, kbase) {
|
|
884
|
+
k = new BN(k, kbase);
|
|
885
|
+
|
|
886
|
+
return this.curve._wnafMul(this, k);
|
|
887
|
+
};
|
|
888
|
+
|
|
889
|
+
JPoint.prototype.eq = function eq(p) {
|
|
890
|
+
if (p.type === 'affine')
|
|
891
|
+
return this.eq(p.toJ());
|
|
892
|
+
|
|
893
|
+
if (this === p)
|
|
894
|
+
return true;
|
|
895
|
+
|
|
896
|
+
// x1 * z2^2 == x2 * z1^2
|
|
897
|
+
var z2 = this.z.redSqr();
|
|
898
|
+
var pz2 = p.z.redSqr();
|
|
899
|
+
if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
|
|
900
|
+
return false;
|
|
901
|
+
|
|
902
|
+
// y1 * z2^3 == y2 * z1^3
|
|
903
|
+
var z3 = z2.redMul(this.z);
|
|
904
|
+
var pz3 = pz2.redMul(p.z);
|
|
905
|
+
return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
JPoint.prototype.eqXToP = function eqXToP(x) {
|
|
909
|
+
var zs = this.z.redSqr();
|
|
910
|
+
var rx = x.toRed(this.curve.red).redMul(zs);
|
|
911
|
+
if (this.x.cmp(rx) === 0)
|
|
912
|
+
return true;
|
|
913
|
+
|
|
914
|
+
var xc = x.clone();
|
|
915
|
+
var t = this.curve.redN.redMul(zs);
|
|
916
|
+
for (;;) {
|
|
917
|
+
xc.iadd(this.curve.n);
|
|
918
|
+
if (xc.cmp(this.curve.p) >= 0)
|
|
919
|
+
return false;
|
|
920
|
+
|
|
921
|
+
rx.redIAdd(t);
|
|
922
|
+
if (this.x.cmp(rx) === 0)
|
|
923
|
+
return true;
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
JPoint.prototype.inspect = function inspect() {
|
|
928
|
+
if (this.isInfinity())
|
|
929
|
+
return '<EC JPoint Infinity>';
|
|
930
|
+
return '<EC JPoint x: ' + this.x.toString(16, 2) +
|
|
931
|
+
' y: ' + this.y.toString(16, 2) +
|
|
932
|
+
' z: ' + this.z.toString(16, 2) + '>';
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
JPoint.prototype.isInfinity = function isInfinity() {
|
|
936
|
+
// XXX This code assumes that zero is always zero in red
|
|
937
|
+
return this.z.cmpn(0) === 0;
|
|
938
|
+
};
|