@degenerate/generic 0.3.2 → 0.6.0
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/dist/_settings/cryptography-settings.d.ts +5 -1
- package/dist/_settings/cryptography-settings.d.ts.map +1 -1
- package/dist/_settings/cryptography-settings.js +5 -1
- package/dist/_settings/database-settings.d.ts +3 -0
- package/dist/_settings/database-settings.d.ts.map +1 -1
- package/dist/_settings/database-settings.js +3 -0
- package/dist/crypto/index.d.ts +5 -9
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js +7 -9
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.d.ts +22 -0
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.d.ts.map +1 -0
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.js +65 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.d.ts +11 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.d.ts.map +1 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.js +15 -0
- package/dist/crypto/signature/create-ed25519-signature.d.ts +16 -0
- package/dist/crypto/signature/create-ed25519-signature.d.ts.map +1 -0
- package/dist/crypto/signature/create-ed25519-signature.js +26 -0
- package/dist/crypto/signature/ed25519-primitives.d.ts +25 -0
- package/dist/crypto/signature/ed25519-primitives.d.ts.map +1 -0
- package/dist/crypto/signature/ed25519-primitives.js +65 -0
- package/dist/crypto/signature/verify-ed25519-signature.d.ts +13 -0
- package/dist/crypto/signature/verify-ed25519-signature.d.ts.map +1 -0
- package/dist/crypto/signature/verify-ed25519-signature.js +31 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +1 -0
- package/dist/errors/settlement/settlement-errors.d.ts +74 -0
- package/dist/errors/settlement/settlement-errors.d.ts.map +1 -0
- package/dist/errors/settlement/settlement-errors.js +93 -0
- package/dist/errors/share-data/share-data-errors.d.ts +13 -0
- package/dist/errors/share-data/share-data-errors.d.ts.map +1 -1
- package/dist/errors/share-data/share-data-errors.js +19 -1
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +1 -0
- package/dist/models/safe/transactions/sharedata-transactions-models.d.ts +10 -0
- package/dist/models/safe/transactions/sharedata-transactions-models.d.ts.map +1 -1
- package/dist/models/settlement/settlement-models.d.ts +221 -0
- package/dist/models/settlement/settlement-models.d.ts.map +1 -0
- package/dist/models/settlement/settlement-models.js +152 -0
- package/dist/models/share-data/share-data-crypto-models.d.ts +37 -0
- package/dist/models/share-data/share-data-crypto-models.d.ts.map +1 -1
- package/dist/models/share-data/share-data-crypto-models.js +41 -1
- package/dist/models/share-data/share-data-persistence-models.d.ts +12 -2
- package/dist/models/share-data/share-data-persistence-models.d.ts.map +1 -1
- package/dist/models/share-data/share-data-persistence-models.js +9 -2
- package/dist/models/shareblock/shareblock-models.d.ts +395 -10
- package/dist/models/shareblock/shareblock-models.d.ts.map +1 -1
- package/dist/models/shareblock/shareblock-models.js +275 -10
- package/package.json +3 -4
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts +0 -12
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.js +0 -54
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts +0 -11
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.js +0 -50
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts +0 -11
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.js +0 -51
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts +0 -10
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.js +0 -51
- package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts +0 -11
- package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/generate-key-pair.js +0 -49
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts +0 -15
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.js +0 -21
- package/dist/crypto/signature/create-crypto-signature.d.ts +0 -20
- package/dist/crypto/signature/create-crypto-signature.d.ts.map +0 -1
- package/dist/crypto/signature/create-crypto-signature.js +0 -26
- package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts +0 -17
- package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts.map +0 -1
- package/dist/crypto/signature/verify-crypto-signature-by-data.js +0 -61
- package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts +0 -17
- package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts.map +0 -1
- package/dist/crypto/signature/verify-crypto-signature-by-hash.js +0 -58
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-key-pair.d.ts","sourceRoot":"","sources":["../../../../src/crypto/private-public-keys/generation/generate-key-pair.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAC/G,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC;;;;;GAKG;AACH,QAAA,MAAM,eAAe,GAAI,OAAO,uBAAuB,GAAG,0BAA0B,EAAE,YAAY,MAAM,EACpG,SAAS,MAAM,KAAG,QAAQ,CAAC,EAAE,CAAC,OAMjC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.generateKeyPair = void 0;
|
|
37
|
-
const Elliptic = __importStar(require("elliptic"));
|
|
38
|
-
/**
|
|
39
|
-
* This function generates a key pair from a private key and entropy using the elliptic library.
|
|
40
|
-
*
|
|
41
|
-
* @param privateKey the private key in hexadecimal format
|
|
42
|
-
* @param entropy the entropy in hexadecimal format
|
|
43
|
-
*/
|
|
44
|
-
const generateKeyPair = (curve, privateKey, entropy) => {
|
|
45
|
-
const ellipticalCurve = new Elliptic.ec(curve);
|
|
46
|
-
const keyPair = ellipticalCurve.genKeyPair({ pers: privateKey, entropy: entropy });
|
|
47
|
-
return keyPair;
|
|
48
|
-
};
|
|
49
|
-
exports.generateKeyPair = generateKeyPair;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as Elliptic from 'elliptic';
|
|
2
|
-
/**
|
|
3
|
-
* This function gets the private key from a key pair.
|
|
4
|
-
*
|
|
5
|
-
* @param keyPair the key pair to get the private key from
|
|
6
|
-
*/
|
|
7
|
-
declare const getPrivateKeyFromKeyPair: (keyPair: Elliptic.ec.KeyPair) => string;
|
|
8
|
-
/**
|
|
9
|
-
* This function gets the public key from a key pair.
|
|
10
|
-
*
|
|
11
|
-
* @param keyPair the key pair to get the public key from
|
|
12
|
-
*/
|
|
13
|
-
declare const getPublicKeyFromKeyPair: (keyPair: Elliptic.ec.KeyPair) => string;
|
|
14
|
-
export { getPrivateKeyFromKeyPair, getPublicKeyFromKeyPair };
|
|
15
|
-
//# sourceMappingURL=get-private-public-key-from-keypair.d.ts.map
|
package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-private-public-key-from-keypair.d.ts","sourceRoot":"","sources":["../../../../src/crypto/private-public-keys/generation/get-private-public-key-from-keypair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC;;;;GAIG;AACH,QAAA,MAAM,wBAAwB,GAAI,SAAS,QAAQ,CAAC,EAAE,CAAC,OAAO,KAAG,MAEhE,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,uBAAuB,GAAI,SAAS,QAAQ,CAAC,EAAE,CAAC,OAAO,KAAG,MAE/D,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPublicKeyFromKeyPair = exports.getPrivateKeyFromKeyPair = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* This function gets the private key from a key pair.
|
|
6
|
-
*
|
|
7
|
-
* @param keyPair the key pair to get the private key from
|
|
8
|
-
*/
|
|
9
|
-
const getPrivateKeyFromKeyPair = (keyPair) => {
|
|
10
|
-
return keyPair.getPrivate('hex');
|
|
11
|
-
};
|
|
12
|
-
exports.getPrivateKeyFromKeyPair = getPrivateKeyFromKeyPair;
|
|
13
|
-
/**
|
|
14
|
-
* This function gets the public key from a key pair.
|
|
15
|
-
*
|
|
16
|
-
* @param keyPair the key pair to get the public key from
|
|
17
|
-
*/
|
|
18
|
-
const getPublicKeyFromKeyPair = (keyPair) => {
|
|
19
|
-
return keyPair.getPublic('hex');
|
|
20
|
-
};
|
|
21
|
-
exports.getPublicKeyFromKeyPair = getPublicKeyFromKeyPair;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as Elliptic from 'elliptic';
|
|
2
|
-
/**
|
|
3
|
-
* This function creates a signature for a hash using an elliptical curve.
|
|
4
|
-
* @param keyPair the key pair to use for signing.
|
|
5
|
-
* @param hashToSign the hash to sign.
|
|
6
|
-
*
|
|
7
|
-
* Implementation note: `elliptic.ec(curve).keyPair.sign(msg)` treats `msg`
|
|
8
|
-
* as a hex string, parses it to a BigInt, then truncates to the curve's
|
|
9
|
-
* `n.bitLength()` (~253 bits for `'ed25519'`) by right-shifting, discarding
|
|
10
|
-
* the LOW bits. For inputs longer than ~63 hex characters that means the
|
|
11
|
-
* signature only commits to the leading high bits of the input — bytes near
|
|
12
|
-
* the end of `hashToSign` contribute nothing to the signature. We always
|
|
13
|
-
* re-hash with SHA-256 first so the input handed to `sign` is a fixed-size
|
|
14
|
-
* 256-bit digest whose every bit depends on every input bit (avalanche),
|
|
15
|
-
* making the 3-bit ECDSA truncation harmless. `verifyCryptoSignatureByHash`
|
|
16
|
-
* mirrors this transformation.
|
|
17
|
-
*/
|
|
18
|
-
declare const createEllipticalCurveSignature: (keyPair: Elliptic.ec.KeyPair, hashToSign: string) => string;
|
|
19
|
-
export { createEllipticalCurveSignature };
|
|
20
|
-
//# sourceMappingURL=create-crypto-signature.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-crypto-signature.d.ts","sourceRoot":"","sources":["../../../src/crypto/signature/create-crypto-signature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAGrC;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,8BAA8B,GAAI,SAAS,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,MAAM,KAAG,MAI1F,CAAC;AAEF,OAAO,EAAE,8BAA8B,EAAE,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createEllipticalCurveSignature = void 0;
|
|
4
|
-
const calculate_hash_1 = require("../calculate-hash");
|
|
5
|
-
/**
|
|
6
|
-
* This function creates a signature for a hash using an elliptical curve.
|
|
7
|
-
* @param keyPair the key pair to use for signing.
|
|
8
|
-
* @param hashToSign the hash to sign.
|
|
9
|
-
*
|
|
10
|
-
* Implementation note: `elliptic.ec(curve).keyPair.sign(msg)` treats `msg`
|
|
11
|
-
* as a hex string, parses it to a BigInt, then truncates to the curve's
|
|
12
|
-
* `n.bitLength()` (~253 bits for `'ed25519'`) by right-shifting, discarding
|
|
13
|
-
* the LOW bits. For inputs longer than ~63 hex characters that means the
|
|
14
|
-
* signature only commits to the leading high bits of the input — bytes near
|
|
15
|
-
* the end of `hashToSign` contribute nothing to the signature. We always
|
|
16
|
-
* re-hash with SHA-256 first so the input handed to `sign` is a fixed-size
|
|
17
|
-
* 256-bit digest whose every bit depends on every input bit (avalanche),
|
|
18
|
-
* making the 3-bit ECDSA truncation harmless. `verifyCryptoSignatureByHash`
|
|
19
|
-
* mirrors this transformation.
|
|
20
|
-
*/
|
|
21
|
-
const createEllipticalCurveSignature = (keyPair, hashToSign) => {
|
|
22
|
-
const digest = (0, calculate_hash_1.calculateHash)(hashToSign);
|
|
23
|
-
const signature = keyPair.sign(digest).toDER('hex');
|
|
24
|
-
return signature;
|
|
25
|
-
};
|
|
26
|
-
exports.createEllipticalCurveSignature = createEllipticalCurveSignature;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { EllipticalCurvesSigning, EllipticalCurvesEncryption } from '../../_settings/cryptography-settings';
|
|
2
|
-
/**
|
|
3
|
-
* This function verifies the signature of the data using the public key
|
|
4
|
-
*
|
|
5
|
-
* @param curve the curve used for the signature
|
|
6
|
-
* @param data the data to verify
|
|
7
|
-
* @param signature the signature to verify
|
|
8
|
-
* @param publicKey the public key to verify the signature
|
|
9
|
-
* @returns
|
|
10
|
-
*
|
|
11
|
-
* Mirrors the `calculateHash`-before-sign step from
|
|
12
|
-
* `createEllipticalCurveSignature` so both sides see the same fixed-size
|
|
13
|
-
* 256-bit digest. See that function for the rationale.
|
|
14
|
-
*/
|
|
15
|
-
declare const verifyCryptoSignatureByData: (curve: EllipticalCurvesSigning | EllipticalCurvesEncryption, data: any, signature: string, publicKey: string) => Promise<boolean>;
|
|
16
|
-
export { verifyCryptoSignatureByData };
|
|
17
|
-
//# sourceMappingURL=verify-crypto-signature-by-data.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"verify-crypto-signature-by-data.d.ts","sourceRoot":"","sources":["../../../src/crypto/signature/verify-crypto-signature-by-data.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAG5G;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,2BAA2B,GAAU,OAAO,uBAAuB,GAAG,0BAA0B,EAAE,MAAM,GAAG,EAAE,WAAW,MAAM,EAChI,WAAW,MAAM,KAAG,OAAO,CAAC,OAAO,CAOtC,CAAC;AAEF,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.verifyCryptoSignatureByData = void 0;
|
|
37
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
38
|
-
const elliptic = __importStar(require("elliptic"));
|
|
39
|
-
const calculate_hash_1 = require("../calculate-hash");
|
|
40
|
-
/**
|
|
41
|
-
* This function verifies the signature of the data using the public key
|
|
42
|
-
*
|
|
43
|
-
* @param curve the curve used for the signature
|
|
44
|
-
* @param data the data to verify
|
|
45
|
-
* @param signature the signature to verify
|
|
46
|
-
* @param publicKey the public key to verify the signature
|
|
47
|
-
* @returns
|
|
48
|
-
*
|
|
49
|
-
* Mirrors the `calculateHash`-before-sign step from
|
|
50
|
-
* `createEllipticalCurveSignature` so both sides see the same fixed-size
|
|
51
|
-
* 256-bit digest. See that function for the rationale.
|
|
52
|
-
*/
|
|
53
|
-
const verifyCryptoSignatureByData = async (curve, data, signature, publicKey) => {
|
|
54
|
-
// convert data to a string.
|
|
55
|
-
const stringified = JSON.stringify(data);
|
|
56
|
-
// eslint-disable-next-line new-cap
|
|
57
|
-
const key = new elliptic.ec(curve).keyFromPublic(publicKey, 'hex');
|
|
58
|
-
const digest = (0, calculate_hash_1.calculateHash)(stringified);
|
|
59
|
-
return key.verify(digest, signature);
|
|
60
|
-
};
|
|
61
|
-
exports.verifyCryptoSignatureByData = verifyCryptoSignatureByData;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { EllipticalCurvesSigning, EllipticalCurvesEncryption } from '../../_settings/cryptography-settings';
|
|
2
|
-
/**
|
|
3
|
-
* This function verifies the signature of the data using the public key
|
|
4
|
-
*
|
|
5
|
-
* @param curve the curve used for the signature
|
|
6
|
-
* @param hash the hash to verify
|
|
7
|
-
* @param signature the signature to verify
|
|
8
|
-
* @param publicKey the public key to verify the signature
|
|
9
|
-
* @returns
|
|
10
|
-
*
|
|
11
|
-
* Mirrors the `calculateHash`-before-sign step from
|
|
12
|
-
* `createEllipticalCurveSignature` so both sides see the same fixed-size
|
|
13
|
-
* 256-bit digest. See that function for the rationale.
|
|
14
|
-
*/
|
|
15
|
-
declare const verifyCryptoSignatureByHash: (curve: EllipticalCurvesSigning | EllipticalCurvesEncryption, hash: string, signature: string, publicKey: string) => Promise<boolean>;
|
|
16
|
-
export { verifyCryptoSignatureByHash };
|
|
17
|
-
//# sourceMappingURL=verify-crypto-signature-by-hash.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"verify-crypto-signature-by-hash.d.ts","sourceRoot":"","sources":["../../../src/crypto/signature/verify-crypto-signature-by-hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAG5G;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,2BAA2B,GAAU,OAAO,uBAAuB,GAAG,0BAA0B,EAAE,MAAM,MAAM,EAAE,WAAW,MAAM,EACnI,WAAW,MAAM,KAAG,OAAO,CAAC,OAAO,CAKtC,CAAC;AAEF,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.verifyCryptoSignatureByHash = void 0;
|
|
37
|
-
const elliptic = __importStar(require("elliptic"));
|
|
38
|
-
const calculate_hash_1 = require("../calculate-hash");
|
|
39
|
-
/**
|
|
40
|
-
* This function verifies the signature of the data using the public key
|
|
41
|
-
*
|
|
42
|
-
* @param curve the curve used for the signature
|
|
43
|
-
* @param hash the hash to verify
|
|
44
|
-
* @param signature the signature to verify
|
|
45
|
-
* @param publicKey the public key to verify the signature
|
|
46
|
-
* @returns
|
|
47
|
-
*
|
|
48
|
-
* Mirrors the `calculateHash`-before-sign step from
|
|
49
|
-
* `createEllipticalCurveSignature` so both sides see the same fixed-size
|
|
50
|
-
* 256-bit digest. See that function for the rationale.
|
|
51
|
-
*/
|
|
52
|
-
const verifyCryptoSignatureByHash = async (curve, hash, signature, publicKey) => {
|
|
53
|
-
// eslint-disable-next-line new-cap
|
|
54
|
-
const key = new elliptic.ec(curve).keyFromPublic(publicKey, 'hex');
|
|
55
|
-
const digest = (0, calculate_hash_1.calculateHash)(hash);
|
|
56
|
-
return key.verify(digest, signature);
|
|
57
|
-
};
|
|
58
|
-
exports.verifyCryptoSignatureByHash = verifyCryptoSignatureByHash;
|