mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
7
web/node_modules/create-ecdh/.travis.yml
generated
vendored
Normal file
7
web/node_modules/create-ecdh/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- 6
|
||||
- 8
|
||||
- 9
|
||||
- 10
|
21
web/node_modules/create-ecdh/LICENSE
generated
vendored
Normal file
21
web/node_modules/create-ecdh/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017 createECDH contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
124
web/node_modules/create-ecdh/browser.js
generated
vendored
Normal file
124
web/node_modules/create-ecdh/browser.js
generated
vendored
Normal file
|
@ -0,0 +1,124 @@
|
|||
var elliptic = require('elliptic')
|
||||
var BN = require('bn.js')
|
||||
|
||||
module.exports = function createECDH (curve) {
|
||||
return new ECDH(curve)
|
||||
}
|
||||
|
||||
var aliases = {
|
||||
secp256k1: {
|
||||
name: 'secp256k1',
|
||||
byteLength: 32
|
||||
},
|
||||
secp224r1: {
|
||||
name: 'p224',
|
||||
byteLength: 28
|
||||
},
|
||||
prime256v1: {
|
||||
name: 'p256',
|
||||
byteLength: 32
|
||||
},
|
||||
prime192v1: {
|
||||
name: 'p192',
|
||||
byteLength: 24
|
||||
},
|
||||
ed25519: {
|
||||
name: 'ed25519',
|
||||
byteLength: 32
|
||||
},
|
||||
secp384r1: {
|
||||
name: 'p384',
|
||||
byteLength: 48
|
||||
},
|
||||
secp521r1: {
|
||||
name: 'p521',
|
||||
byteLength: 66
|
||||
}
|
||||
}
|
||||
|
||||
aliases.p224 = aliases.secp224r1
|
||||
aliases.p256 = aliases.secp256r1 = aliases.prime256v1
|
||||
aliases.p192 = aliases.secp192r1 = aliases.prime192v1
|
||||
aliases.p384 = aliases.secp384r1
|
||||
aliases.p521 = aliases.secp521r1
|
||||
|
||||
function ECDH (curve) {
|
||||
this.curveType = aliases[curve]
|
||||
if (!this.curveType) {
|
||||
this.curveType = {
|
||||
name: curve
|
||||
}
|
||||
}
|
||||
this.curve = new elliptic.ec(this.curveType.name) // eslint-disable-line new-cap
|
||||
this.keys = void 0
|
||||
}
|
||||
|
||||
ECDH.prototype.generateKeys = function (enc, format) {
|
||||
this.keys = this.curve.genKeyPair()
|
||||
return this.getPublicKey(enc, format)
|
||||
}
|
||||
|
||||
ECDH.prototype.computeSecret = function (other, inenc, enc) {
|
||||
inenc = inenc || 'utf8'
|
||||
if (!Buffer.isBuffer(other)) {
|
||||
other = new Buffer(other, inenc)
|
||||
}
|
||||
var otherPub = this.curve.keyFromPublic(other).getPublic()
|
||||
var out = otherPub.mul(this.keys.getPrivate()).getX()
|
||||
return formatReturnValue(out, enc, this.curveType.byteLength)
|
||||
}
|
||||
|
||||
ECDH.prototype.getPublicKey = function (enc, format) {
|
||||
var key = this.keys.getPublic(format === 'compressed', true)
|
||||
if (format === 'hybrid') {
|
||||
if (key[key.length - 1] % 2) {
|
||||
key[0] = 7
|
||||
} else {
|
||||
key[0] = 6
|
||||
}
|
||||
}
|
||||
return formatReturnValue(key, enc)
|
||||
}
|
||||
|
||||
ECDH.prototype.getPrivateKey = function (enc) {
|
||||
return formatReturnValue(this.keys.getPrivate(), enc)
|
||||
}
|
||||
|
||||
ECDH.prototype.setPublicKey = function (pub, enc) {
|
||||
enc = enc || 'utf8'
|
||||
if (!Buffer.isBuffer(pub)) {
|
||||
pub = new Buffer(pub, enc)
|
||||
}
|
||||
this.keys._importPublic(pub)
|
||||
return this
|
||||
}
|
||||
|
||||
ECDH.prototype.setPrivateKey = function (priv, enc) {
|
||||
enc = enc || 'utf8'
|
||||
if (!Buffer.isBuffer(priv)) {
|
||||
priv = new Buffer(priv, enc)
|
||||
}
|
||||
|
||||
var _priv = new BN(priv)
|
||||
_priv = _priv.toString(16)
|
||||
this.keys = this.curve.genKeyPair()
|
||||
this.keys._importPrivate(_priv)
|
||||
return this
|
||||
}
|
||||
|
||||
function formatReturnValue (bn, enc, len) {
|
||||
if (!Array.isArray(bn)) {
|
||||
bn = bn.toArray()
|
||||
}
|
||||
var buf = new Buffer(bn)
|
||||
if (len && buf.length < len) {
|
||||
var zeros = new Buffer(len - buf.length)
|
||||
zeros.fill(0)
|
||||
buf = Buffer.concat([zeros, buf])
|
||||
}
|
||||
if (!enc) {
|
||||
return buf
|
||||
} else {
|
||||
return buf.toString(enc)
|
||||
}
|
||||
}
|
3
web/node_modules/create-ecdh/index.js
generated
vendored
Normal file
3
web/node_modules/create-ecdh/index.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
var createECDH = require('crypto').createECDH
|
||||
|
||||
module.exports = createECDH || require('./browser')
|
19
web/node_modules/create-ecdh/node_modules/bn.js/LICENSE
generated
vendored
Normal file
19
web/node_modules/create-ecdh/node_modules/bn.js/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright Fedor Indutny, 2015.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
200
web/node_modules/create-ecdh/node_modules/bn.js/README.md
generated
vendored
Normal file
200
web/node_modules/create-ecdh/node_modules/bn.js/README.md
generated
vendored
Normal file
|
@ -0,0 +1,200 @@
|
|||
# <img src="./logo.png" alt="bn.js" width="160" height="160" />
|
||||
|
||||
> BigNum in pure javascript
|
||||
|
||||
[](http://travis-ci.org/indutny/bn.js)
|
||||
|
||||
## Install
|
||||
`npm install --save bn.js`
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const BN = require('bn.js');
|
||||
|
||||
var a = new BN('dead', 16);
|
||||
var b = new BN('101010', 2);
|
||||
|
||||
var res = a.add(b);
|
||||
console.log(res.toString(10)); // 57047
|
||||
```
|
||||
|
||||
**Note**: decimals are not supported in this library.
|
||||
|
||||
## Notation
|
||||
|
||||
### Prefixes
|
||||
|
||||
There are several prefixes to instructions that affect the way the work. Here
|
||||
is the list of them in the order of appearance in the function name:
|
||||
|
||||
* `i` - perform operation in-place, storing the result in the host object (on
|
||||
which the method was invoked). Might be used to avoid number allocation costs
|
||||
* `u` - unsigned, ignore the sign of operands when performing operation, or
|
||||
always return positive value. Second case applies to reduction operations
|
||||
like `mod()`. In such cases if the result will be negative - modulo will be
|
||||
added to the result to make it positive
|
||||
|
||||
### Postfixes
|
||||
|
||||
The only available postfix at the moment is:
|
||||
|
||||
* `n` - which means that the argument of the function must be a plain JavaScript
|
||||
Number. Decimals are not supported.
|
||||
|
||||
### Examples
|
||||
|
||||
* `a.iadd(b)` - perform addition on `a` and `b`, storing the result in `a`
|
||||
* `a.umod(b)` - reduce `a` modulo `b`, returning positive value
|
||||
* `a.iushln(13)` - shift bits of `a` left by 13
|
||||
|
||||
## Instructions
|
||||
|
||||
Prefixes/postfixes are put in parens at the of the line. `endian` - could be
|
||||
either `le` (little-endian) or `be` (big-endian).
|
||||
|
||||
### Utilities
|
||||
|
||||
* `a.clone()` - clone number
|
||||
* `a.toString(base, length)` - convert to base-string and pad with zeroes
|
||||
* `a.toNumber()` - convert to Javascript Number (limited to 53 bits)
|
||||
* `a.toJSON()` - convert to JSON compatible hex string (alias of `toString(16)`)
|
||||
* `a.toArray(endian, length)` - convert to byte `Array`, and optionally zero
|
||||
pad to length, throwing if already exceeding
|
||||
* `a.toArrayLike(type, endian, length)` - convert to an instance of `type`,
|
||||
which must behave like an `Array`
|
||||
* `a.toBuffer(endian, length)` - convert to Node.js Buffer (if available). For
|
||||
compatibility with browserify and similar tools, use this instead:
|
||||
`a.toArrayLike(Buffer, endian, length)`
|
||||
* `a.bitLength()` - get number of bits occupied
|
||||
* `a.zeroBits()` - return number of less-significant consequent zero bits
|
||||
(example: `1010000` has 4 zero bits)
|
||||
* `a.byteLength()` - return number of bytes occupied
|
||||
* `a.isNeg()` - true if the number is negative
|
||||
* `a.isEven()` - no comments
|
||||
* `a.isOdd()` - no comments
|
||||
* `a.isZero()` - no comments
|
||||
* `a.cmp(b)` - compare numbers and return `-1` (a `<` b), `0` (a `==` b), or `1` (a `>` b)
|
||||
depending on the comparison result (`ucmp`, `cmpn`)
|
||||
* `a.lt(b)` - `a` less than `b` (`n`)
|
||||
* `a.lte(b)` - `a` less than or equals `b` (`n`)
|
||||
* `a.gt(b)` - `a` greater than `b` (`n`)
|
||||
* `a.gte(b)` - `a` greater than or equals `b` (`n`)
|
||||
* `a.eq(b)` - `a` equals `b` (`n`)
|
||||
* `a.toTwos(width)` - convert to two's complement representation, where `width` is bit width
|
||||
* `a.fromTwos(width)` - convert from two's complement representation, where `width` is the bit width
|
||||
* `BN.isBN(object)` - returns true if the supplied `object` is a BN.js instance
|
||||
|
||||
### Arithmetics
|
||||
|
||||
* `a.neg()` - negate sign (`i`)
|
||||
* `a.abs()` - absolute value (`i`)
|
||||
* `a.add(b)` - addition (`i`, `n`, `in`)
|
||||
* `a.sub(b)` - subtraction (`i`, `n`, `in`)
|
||||
* `a.mul(b)` - multiply (`i`, `n`, `in`)
|
||||
* `a.sqr()` - square (`i`)
|
||||
* `a.pow(b)` - raise `a` to the power of `b`
|
||||
* `a.div(b)` - divide (`divn`, `idivn`)
|
||||
* `a.mod(b)` - reduct (`u`, `n`) (but no `umodn`)
|
||||
* `a.divRound(b)` - rounded division
|
||||
|
||||
### Bit operations
|
||||
|
||||
* `a.or(b)` - or (`i`, `u`, `iu`)
|
||||
* `a.and(b)` - and (`i`, `u`, `iu`, `andln`) (NOTE: `andln` is going to be replaced
|
||||
with `andn` in future)
|
||||
* `a.xor(b)` - xor (`i`, `u`, `iu`)
|
||||
* `a.setn(b)` - set specified bit to `1`
|
||||
* `a.shln(b)` - shift left (`i`, `u`, `iu`)
|
||||
* `a.shrn(b)` - shift right (`i`, `u`, `iu`)
|
||||
* `a.testn(b)` - test if specified bit is set
|
||||
* `a.maskn(b)` - clear bits with indexes higher or equal to `b` (`i`)
|
||||
* `a.bincn(b)` - add `1 << b` to the number
|
||||
* `a.notn(w)` - not (for the width specified by `w`) (`i`)
|
||||
|
||||
### Reduction
|
||||
|
||||
* `a.gcd(b)` - GCD
|
||||
* `a.egcd(b)` - Extended GCD results (`{ a: ..., b: ..., gcd: ... }`)
|
||||
* `a.invm(b)` - inverse `a` modulo `b`
|
||||
|
||||
## Fast reduction
|
||||
|
||||
When doing lots of reductions using the same modulo, it might be beneficial to
|
||||
use some tricks: like [Montgomery multiplication][0], or using special algorithm
|
||||
for [Mersenne Prime][1].
|
||||
|
||||
### Reduction context
|
||||
|
||||
To enable this tricks one should create a reduction context:
|
||||
|
||||
```js
|
||||
var red = BN.red(num);
|
||||
```
|
||||
where `num` is just a BN instance.
|
||||
|
||||
Or:
|
||||
|
||||
```js
|
||||
var red = BN.red(primeName);
|
||||
```
|
||||
|
||||
Where `primeName` is either of these [Mersenne Primes][1]:
|
||||
|
||||
* `'k256'`
|
||||
* `'p224'`
|
||||
* `'p192'`
|
||||
* `'p25519'`
|
||||
|
||||
Or:
|
||||
|
||||
```js
|
||||
var red = BN.mont(num);
|
||||
```
|
||||
|
||||
To reduce numbers with [Montgomery trick][0]. `.mont()` is generally faster than
|
||||
`.red(num)`, but slower than `BN.red(primeName)`.
|
||||
|
||||
### Converting numbers
|
||||
|
||||
Before performing anything in reduction context - numbers should be converted
|
||||
to it. Usually, this means that one should:
|
||||
|
||||
* Convert inputs to reducted ones
|
||||
* Operate on them in reduction context
|
||||
* Convert outputs back from the reduction context
|
||||
|
||||
Here is how one may convert numbers to `red`:
|
||||
|
||||
```js
|
||||
var redA = a.toRed(red);
|
||||
```
|
||||
Where `red` is a reduction context created using instructions above
|
||||
|
||||
Here is how to convert them back:
|
||||
|
||||
```js
|
||||
var a = redA.fromRed();
|
||||
```
|
||||
|
||||
### Red instructions
|
||||
|
||||
Most of the instructions from the very start of this readme have their
|
||||
counterparts in red context:
|
||||
|
||||
* `a.redAdd(b)`, `a.redIAdd(b)`
|
||||
* `a.redSub(b)`, `a.redISub(b)`
|
||||
* `a.redShl(num)`
|
||||
* `a.redMul(b)`, `a.redIMul(b)`
|
||||
* `a.redSqr()`, `a.redISqr()`
|
||||
* `a.redSqrt()` - square root modulo reduction context's prime
|
||||
* `a.redInvm()` - modular inverse of the number
|
||||
* `a.redNeg()`
|
||||
* `a.redPow(b)` - modular exponentiation
|
||||
|
||||
## LICENSE
|
||||
|
||||
This software is licensed under the MIT License.
|
||||
|
||||
[0]: https://en.wikipedia.org/wiki/Montgomery_modular_multiplication
|
||||
[1]: https://en.wikipedia.org/wiki/Mersenne_prime
|
3446
web/node_modules/create-ecdh/node_modules/bn.js/lib/bn.js
generated
vendored
Normal file
3446
web/node_modules/create-ecdh/node_modules/bn.js/lib/bn.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
36
web/node_modules/create-ecdh/node_modules/bn.js/package.json
generated
vendored
Normal file
36
web/node_modules/create-ecdh/node_modules/bn.js/package.json
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "bn.js",
|
||||
"version": "4.12.0",
|
||||
"description": "Big number implementation in pure javascript",
|
||||
"main": "lib/bn.js",
|
||||
"scripts": {
|
||||
"lint": "semistandard",
|
||||
"unit": "mocha --reporter=spec test/*-test.js",
|
||||
"test": "npm run lint && npm run unit"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:indutny/bn.js"
|
||||
},
|
||||
"keywords": [
|
||||
"BN",
|
||||
"BigNum",
|
||||
"Big number",
|
||||
"Modulo",
|
||||
"Montgomery"
|
||||
],
|
||||
"author": "Fedor Indutny <fedor@indutny.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/indutny/bn.js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/indutny/bn.js",
|
||||
"browser": {
|
||||
"buffer": false
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "^0.3.5",
|
||||
"mocha": "^2.1.0",
|
||||
"semistandard": "^7.0.4"
|
||||
}
|
||||
}
|
35
web/node_modules/create-ecdh/package.json
generated
vendored
Normal file
35
web/node_modules/create-ecdh/package.json
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "create-ecdh",
|
||||
"version": "4.0.4",
|
||||
"description": "createECDH but browserifiable",
|
||||
"main": "index.js",
|
||||
"browser": "browser.js",
|
||||
"scripts": {
|
||||
"test": "standard && node test.js | tspec"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/crypto-browserify/createECDH.git"
|
||||
},
|
||||
"keywords": [
|
||||
"diffie",
|
||||
"hellman",
|
||||
"diffiehellman",
|
||||
"ECDH"
|
||||
],
|
||||
"author": "Calvin Metcalf",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/crypto-browserify/createECDH/issues"
|
||||
},
|
||||
"homepage": "https://github.com/crypto-browserify/createECDH",
|
||||
"dependencies": {
|
||||
"bn.js": "^4.1.0",
|
||||
"elliptic": "^6.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap-spec": "^1.0.1",
|
||||
"tape": "^3.0.1",
|
||||
"standard": "^5.4.1"
|
||||
}
|
||||
}
|
4
web/node_modules/create-ecdh/readme.md
generated
vendored
Normal file
4
web/node_modules/create-ecdh/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
createECDH [](https://travis-ci.org/crypto-browserify/createECDH)
|
||||
====
|
||||
|
||||
In io.js or node >= 0.11 this module is just a shortcut to crypto.createECDH. In node <= 0.11 or the browser this is a pure JavaScript implimentation, more specifically a wrapper around [elliptic](https://github.com/indutny/elliptic), to give it the same API as node. `secp256k1`, `secp224r1` (aka p224), `prime256v1` (aka p256, secp256r1), `prime192v1` (aka p192, secp192r1), `secp384r1` (aka p384), `secp521r1` (aka p521) curves all work in both this library and node (though only the highlighted name will work in node).
|
Loading…
Add table
Add a link
Reference in a new issue