mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Initial commit
This commit is contained in:
6
node_modules/curve25519-js/.prettierrc
generated
vendored
Normal file
6
node_modules/curve25519-js/.prettierrc
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"trailingComma": "all",
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2
|
||||
}
|
||||
19
node_modules/curve25519-js/LICENSE
generated
vendored
Normal file
19
node_modules/curve25519-js/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2019 Smart Guide Pty Ltd
|
||||
|
||||
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.
|
||||
111
node_modules/curve25519-js/README.md
generated
vendored
Normal file
111
node_modules/curve25519-js/README.md
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
# curve25519-js
|
||||
|
||||
Curve25519 signatures with X25519 keys.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm i curve25519-js
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { sharedKey } from 'curve25519-js';
|
||||
|
||||
const ALICE_PRIV = '77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a';
|
||||
const BOB_PUB = 'de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f';
|
||||
|
||||
const alicePriv = Uint8Array.from(Buffer.from(ALICE_PRIV, 'hex'));
|
||||
|
||||
const bobPub = Uint8Array.from(Buffer.from(BOB_PUB, 'hex'));
|
||||
|
||||
const secret = sharedKey(alicePriv, bobPub);
|
||||
|
||||
console.log('Secret:', Buffer.from(secret).toString('hex'))
|
||||
```
|
||||
|
||||
## Functions
|
||||
|
||||
### generateKeyPair
|
||||
Generates a new key pair from the given 32-byte secret seed (which should be generated with a CSPRNG) and returns it as object:
|
||||
```ts
|
||||
generateKeyPair(seed: Uint8Array(32)): {
|
||||
private: Uint8Array(32);
|
||||
public: Uint8Array(32);
|
||||
}
|
||||
```
|
||||
The returned keys can be used for signing and key agreement.
|
||||
|
||||
### sign
|
||||
|
||||
Signs the given message using the private key and returns signature.
|
||||
|
||||
```ts
|
||||
sign(secretKey: Uint8Array(32), message: any, [random: Uint8Array(64)]): Uint8Array(64)
|
||||
```
|
||||
|
||||
Optional random data argument (which must have 64 random bytes) turns on
|
||||
hash separation and randomization to make signatures non-deterministic.
|
||||
|
||||
### verify
|
||||
|
||||
Verifies the given signature for the message using the given private key.
|
||||
Returns `true` if the signature is valid, `false` otherwise.
|
||||
|
||||
```ts
|
||||
verify(publicKey: Uint8Array(32), message: any, signature: Uint8Array(64)): boolean
|
||||
```
|
||||
|
||||
### signMessage
|
||||
|
||||
Signs the given message using the private key and returns
|
||||
a signed message (signature concatenated with the message copy).
|
||||
|
||||
```ts
|
||||
signMessage(secretKey: Uint8Array(32), message: any, [random: Uint8Array(64)]): any
|
||||
```
|
||||
|
||||
Optional random data argument (which must have 64 random bytes) turns on
|
||||
hash separation and randomization to make signatures non-deterministic.
|
||||
|
||||
### openMessage
|
||||
|
||||
Verifies signed message with the public key and returns the original message
|
||||
without signature if it's correct or `null` if verification fails.
|
||||
|
||||
```ts
|
||||
openMessage(publicKey: Uint8Array(32), signedMessage: any): Message | null
|
||||
```
|
||||
|
||||
|
||||
### sharedKey
|
||||
Returns a raw shared key between own private key and peer's public key (in other words, this is an ECC Diffie-Hellman function X25519, performing scalar multiplication).
|
||||
|
||||
The result should not be used directly as a key, but should be processed with a one-way function (e.g. HSalsa20 as in NaCl, or any secure cryptographic hash function, such as SHA-256, or key derivation function, such as HKDF).
|
||||
```ts
|
||||
sharedKey(privateKey: Uint8Array(32), publicKey: Uint8Array(32)): Uint8Array(32)
|
||||
```
|
||||
|
||||
## How is it different from Ed25519?
|
||||
Axlsign allows calculating key agreement and signing using just a single X25519 key instead of two different X25519 and Ed25519 keys.
|
||||
|
||||
It uses keys in X25519 format (Montgomery), while Ed25519 uses keys in a different representation (Twisted Edwards). Internally, it converts keys to the correct format, but since such conversion would lose a sign bit, it also embeds the sign bit from public key into signature during signing, and puts it back into the key during verification.
|
||||
|
||||
Note: if signing and performing key agreement with a single key is needed, but using keys in X25519 format is not a requrement, a better choice is to use Ed25519 keys, and then convert them to X25519 keys for key agreement (e.g. using <https://github.com/dchest/ed2curve-js>). This allows using only an external conversion functions without changing signature algorithms and formats.
|
||||
|
||||
## Credits
|
||||
|
||||
Re-written in 2019 with TypeScript support by Harvey Connor.
|
||||
|
||||
Written in 2016 by Dmitry Chestnykh.
|
||||
You can use it under MIT or CC0 license.
|
||||
|
||||
Curve25519 signatures idea and math by Trevor Perrin
|
||||
<https://moderncrypto.org/mail-archive/curves/2014/000205.html>
|
||||
|
||||
Derived from TweetNaCl.js <https://tweetnacl.js.org>.
|
||||
Ported in 2014 by Dmitry Chestnykh and Devi Mandiri. Public domain.
|
||||
Implementation derived from TweetNaCl version 20140427
|
||||
<http://tweetnacl.cr.yp.to>
|
||||
69
node_modules/curve25519-js/lib/index.d.ts
generated
vendored
Normal file
69
node_modules/curve25519-js/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Returns a raw shared key between own private key and peer's public key (in other words, this is an ECC Diffie-Hellman function X25519, performing scalar multiplication).
|
||||
*
|
||||
* The result should not be used directly as a key, but should be processed with a one-way function (e.g. HSalsa20 as in NaCl, or any secure cryptographic hash function, such as SHA-256, or key derivation function, such as HKDF).
|
||||
*
|
||||
* @export
|
||||
* @param {Uint8Array} secretKey
|
||||
* @param {Uint8Array} publicKey
|
||||
* @returns Uint8Array
|
||||
*/
|
||||
export declare function sharedKey(secretKey: any, publicKey: any): Uint8Array;
|
||||
/**
|
||||
* Signs the given message using the private key and returns a signed message (signature concatenated with the message copy).
|
||||
*
|
||||
* Optional random data argument (which must have 64 random bytes) turns on hash separation and randomization to make signatures non-deterministic.
|
||||
*
|
||||
* @export
|
||||
* @param {Uint8Array} secretKey
|
||||
* @param {*} msg
|
||||
* @param {Uint8Array} opt_random
|
||||
* @returns
|
||||
*/
|
||||
export declare function signMessage(secretKey: any, msg: any, opt_random: any): Uint8Array;
|
||||
/**
|
||||
* Verifies signed message with the public key and returns the original message without signature if it's correct or null if verification fails.
|
||||
*
|
||||
* @export
|
||||
* @param {Uint8Array} publicKey
|
||||
* @param {*} signedMsg
|
||||
* @returns Message
|
||||
*/
|
||||
export declare function openMessage(publicKey: any, signedMsg: any): Uint8Array | null;
|
||||
/**
|
||||
* Signs the given message using the private key and returns signature.
|
||||
*
|
||||
* Optional random data argument (which must have 64 random bytes) turns on hash separation and randomization to make signatures non-deterministic.
|
||||
*
|
||||
* @export
|
||||
* @param {Uint8Array} secretKey
|
||||
* @param {*} msg
|
||||
* @param {Uint8Array} opt_random
|
||||
* @returns
|
||||
*/
|
||||
export declare function sign(secretKey: any, msg: any, opt_random: any): Uint8Array;
|
||||
/**
|
||||
* Verifies the given signature for the message using the given private key. Returns true if the signature is valid, false otherwise.
|
||||
*
|
||||
* @export
|
||||
* @param {Uint8Array} publicKey
|
||||
* @param {*} msg
|
||||
* @param {*} signature
|
||||
* @returns
|
||||
*/
|
||||
export declare function verify(publicKey: any, msg: any, signature: any): boolean;
|
||||
/**
|
||||
* Generates a new key pair from the given 32-byte secret seed (which should be generated with a CSPRNG) and returns it as object.
|
||||
*
|
||||
* The returned keys can be used for signing and key agreement.
|
||||
*
|
||||
* @export
|
||||
* @param {Uint8Array} seed required
|
||||
* @returns
|
||||
*/
|
||||
export declare function generateKeyPair(seed: any): {
|
||||
public: Uint8Array;
|
||||
private: Uint8Array;
|
||||
};
|
||||
declare const _default: {};
|
||||
export default _default;
|
||||
1669
node_modules/curve25519-js/lib/index.js
generated
vendored
Normal file
1669
node_modules/curve25519-js/lib/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
38
node_modules/curve25519-js/package.json
generated
vendored
Normal file
38
node_modules/curve25519-js/package.json
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "curve25519-js",
|
||||
"version": "0.0.4",
|
||||
"description": "Javascript implementation of Curve25519",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
||||
"lint": "tslint -p tsconfig.json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/harveyconnor/curve25519-js.git"
|
||||
},
|
||||
"author": "Harvey Connor <harvey@smartguide.com.au>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/harveyconnor/curve25519-js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/harveyconnor/curve25519-js#readme",
|
||||
"keywords": [
|
||||
"sign",
|
||||
"curve25519",
|
||||
"x25519",
|
||||
"ed25519"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.6.9",
|
||||
"prettier": "^1.18.2",
|
||||
"tslint": "^5.18.0",
|
||||
"tslint-config-prettier": "^1.18.0",
|
||||
"typescript": "^3.5.3"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/curve25519-js/-/curve25519-js-0.0.4.tgz"
|
||||
,"_integrity": "sha512-axn2UMEnkhyDUPWOwVKBMVIzSQy2ejH2xRGy1wq81dqRwApXfIzfbE3hIX0ZRFBIihf/KDqK158DLwESu4AK1w=="
|
||||
,"_from": "curve25519-js@0.0.4"
|
||||
}
|
||||
20
node_modules/curve25519-js/tsconfig.json
generated
vendored
Normal file
20
node_modules/curve25519-js/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "./lib",
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"declaration": true,
|
||||
"noUnusedLocals": false
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib",
|
||||
"examples"
|
||||
]
|
||||
}
|
||||
10
node_modules/curve25519-js/tslint.json
generated
vendored
Normal file
10
node_modules/curve25519-js/tslint.json
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": ["tslint:recommended", "tslint-config-prettier"],
|
||||
"linterOptions": {
|
||||
"exclude": ["node_modules/**/*.ts"]
|
||||
},
|
||||
"rules": {
|
||||
"no-bitwise": false,
|
||||
"no-console": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user