@degenerate/generic 0.4.0 → 0.7.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.
Files changed (166) hide show
  1. package/dist/_settings/cryptography-settings.d.ts +5 -1
  2. package/dist/_settings/cryptography-settings.d.ts.map +1 -1
  3. package/dist/_settings/cryptography-settings.js +5 -1
  4. package/dist/crypto/index.d.ts +5 -9
  5. package/dist/crypto/index.d.ts.map +1 -1
  6. package/dist/crypto/index.js +7 -9
  7. package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.d.ts +22 -0
  8. package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.d.ts.map +1 -0
  9. package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.js +65 -0
  10. package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.d.ts +11 -0
  11. package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.d.ts.map +1 -0
  12. package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.js +15 -0
  13. package/dist/crypto/signature/create-ed25519-signature.d.ts +16 -0
  14. package/dist/crypto/signature/create-ed25519-signature.d.ts.map +1 -0
  15. package/dist/crypto/signature/create-ed25519-signature.js +26 -0
  16. package/dist/crypto/signature/ed25519-primitives.d.ts +25 -0
  17. package/dist/crypto/signature/ed25519-primitives.d.ts.map +1 -0
  18. package/dist/crypto/signature/ed25519-primitives.js +65 -0
  19. package/dist/crypto/signature/verify-ed25519-signature.d.ts +13 -0
  20. package/dist/crypto/signature/verify-ed25519-signature.d.ts.map +1 -0
  21. package/dist/crypto/signature/verify-ed25519-signature.js +31 -0
  22. package/dist/errors/index.d.ts +2 -0
  23. package/dist/errors/index.d.ts.map +1 -1
  24. package/dist/errors/index.js +2 -0
  25. package/dist/errors/library/library-errors.d.ts +101 -0
  26. package/dist/errors/library/library-errors.d.ts.map +1 -0
  27. package/dist/errors/library/library-errors.js +133 -0
  28. package/dist/errors/settlement/settlement-errors.d.ts +74 -0
  29. package/dist/errors/settlement/settlement-errors.d.ts.map +1 -0
  30. package/dist/errors/settlement/settlement-errors.js +93 -0
  31. package/dist/errors/share-data/share-data-errors.d.ts +21 -0
  32. package/dist/errors/share-data/share-data-errors.d.ts.map +1 -1
  33. package/dist/errors/share-data/share-data-errors.js +30 -1
  34. package/dist/helpers/apply-share-function.d.ts +23 -0
  35. package/dist/helpers/apply-share-function.d.ts.map +1 -0
  36. package/dist/helpers/apply-share-function.js +32 -0
  37. package/dist/helpers/index.d.ts +1 -0
  38. package/dist/helpers/index.d.ts.map +1 -1
  39. package/dist/helpers/index.js +1 -0
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +2 -0
  43. package/dist/library/authorize-library.d.ts +17 -0
  44. package/dist/library/authorize-library.d.ts.map +1 -0
  45. package/dist/library/authorize-library.js +39 -0
  46. package/dist/library/build-library.d.ts +49 -0
  47. package/dist/library/build-library.d.ts.map +1 -0
  48. package/dist/library/build-library.js +119 -0
  49. package/dist/library/caching-library-store.d.ts +19 -0
  50. package/dist/library/caching-library-store.d.ts.map +1 -0
  51. package/dist/library/caching-library-store.js +56 -0
  52. package/dist/library/canonical-json.d.ts +12 -0
  53. package/dist/library/canonical-json.d.ts.map +1 -0
  54. package/dist/library/canonical-json.js +30 -0
  55. package/dist/library/compile-rule-source.d.ts +21 -0
  56. package/dist/library/compile-rule-source.d.ts.map +1 -0
  57. package/dist/library/compile-rule-source.js +91 -0
  58. package/dist/library/evaluate-library-rules.d.ts +36 -0
  59. package/dist/library/evaluate-library-rules.d.ts.map +1 -0
  60. package/dist/library/evaluate-library-rules.js +47 -0
  61. package/dist/library/evaluate-library.d.ts +34 -0
  62. package/dist/library/evaluate-library.d.ts.map +1 -0
  63. package/dist/library/evaluate-library.js +66 -0
  64. package/dist/library/in-memory-library-store.d.ts +22 -0
  65. package/dist/library/in-memory-library-store.d.ts.map +1 -0
  66. package/dist/library/in-memory-library-store.js +92 -0
  67. package/dist/library/index.d.ts +18 -0
  68. package/dist/library/index.d.ts.map +1 -0
  69. package/dist/library/index.js +33 -0
  70. package/dist/library/library-hash.d.ts +9 -0
  71. package/dist/library/library-hash.d.ts.map +1 -0
  72. package/dist/library/library-hash.js +14 -0
  73. package/dist/library/library-models.d.ts +134 -0
  74. package/dist/library/library-models.d.ts.map +1 -0
  75. package/dist/library/library-models.js +84 -0
  76. package/dist/library/library-proof.d.ts +40 -0
  77. package/dist/library/library-proof.d.ts.map +1 -0
  78. package/dist/library/library-proof.js +44 -0
  79. package/dist/library/library-reference.d.ts +75 -0
  80. package/dist/library/library-reference.d.ts.map +1 -0
  81. package/dist/library/library-reference.js +98 -0
  82. package/dist/library/library-server.d.ts +17 -0
  83. package/dist/library/library-server.d.ts.map +1 -0
  84. package/dist/library/library-server.js +45 -0
  85. package/dist/library/library-store.d.ts +37 -0
  86. package/dist/library/library-store.d.ts.map +1 -0
  87. package/dist/library/library-store.js +2 -0
  88. package/dist/library/remote-library-models.d.ts +54 -0
  89. package/dist/library/remote-library-models.d.ts.map +1 -0
  90. package/dist/library/remote-library-models.js +2 -0
  91. package/dist/library/remote-library-store.d.ts +15 -0
  92. package/dist/library/remote-library-store.d.ts.map +1 -0
  93. package/dist/library/remote-library-store.js +59 -0
  94. package/dist/library/verify-library.d.ts +21 -0
  95. package/dist/library/verify-library.d.ts.map +1 -0
  96. package/dist/library/verify-library.js +86 -0
  97. package/dist/models/functions/share-data-function-models.d.ts +6 -74
  98. package/dist/models/functions/share-data-function-models.d.ts.map +1 -1
  99. package/dist/models/functions/share-data-function-models.js +7 -65
  100. package/dist/models/index.d.ts +1 -0
  101. package/dist/models/index.d.ts.map +1 -1
  102. package/dist/models/index.js +1 -0
  103. package/dist/models/safe/transactions/sharedata-transactions-models.d.ts +5 -0
  104. package/dist/models/safe/transactions/sharedata-transactions-models.d.ts.map +1 -1
  105. package/dist/models/settlement/settlement-models.d.ts +221 -0
  106. package/dist/models/settlement/settlement-models.d.ts.map +1 -0
  107. package/dist/models/settlement/settlement-models.js +152 -0
  108. package/dist/models/share-data/share-data-models.d.ts +12 -0
  109. package/dist/models/share-data/share-data-models.d.ts.map +1 -1
  110. package/dist/models/share-data/share-data-persistence-models.d.ts +3 -0
  111. package/dist/models/share-data/share-data-persistence-models.d.ts.map +1 -1
  112. package/dist/models/shareblock/shareblock-models.d.ts +179 -3
  113. package/dist/models/shareblock/shareblock-models.d.ts.map +1 -1
  114. package/dist/models/shareblock/shareblock-models.js +99 -7
  115. package/dist/sandbox/in-process-executor.d.ts +13 -0
  116. package/dist/sandbox/in-process-executor.d.ts.map +1 -0
  117. package/dist/sandbox/in-process-executor.js +31 -0
  118. package/dist/sandbox/index.d.ts +8 -0
  119. package/dist/sandbox/index.d.ts.map +1 -0
  120. package/dist/sandbox/index.js +23 -0
  121. package/dist/sandbox/remote-sandbox-executor.d.ts +12 -0
  122. package/dist/sandbox/remote-sandbox-executor.d.ts.map +1 -0
  123. package/dist/sandbox/remote-sandbox-executor.js +49 -0
  124. package/dist/sandbox/remote-sandbox-models.d.ts +37 -0
  125. package/dist/sandbox/remote-sandbox-models.d.ts.map +1 -0
  126. package/dist/sandbox/remote-sandbox-models.js +2 -0
  127. package/dist/sandbox/rule-evaluator.d.ts +32 -0
  128. package/dist/sandbox/rule-evaluator.d.ts.map +1 -0
  129. package/dist/sandbox/rule-evaluator.js +23 -0
  130. package/dist/sandbox/run-sandboxed.d.ts +24 -0
  131. package/dist/sandbox/run-sandboxed.d.ts.map +1 -0
  132. package/dist/sandbox/run-sandboxed.js +88 -0
  133. package/dist/sandbox/sandbox-models.d.ts +40 -0
  134. package/dist/sandbox/sandbox-models.d.ts.map +1 -0
  135. package/dist/sandbox/sandbox-models.js +2 -0
  136. package/dist/sandbox/sandbox-server.d.ts +22 -0
  137. package/dist/sandbox/sandbox-server.d.ts.map +1 -0
  138. package/dist/sandbox/sandbox-server.js +62 -0
  139. package/package.json +3 -4
  140. package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts +0 -12
  141. package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts.map +0 -1
  142. package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.js +0 -54
  143. package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts +0 -11
  144. package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts.map +0 -1
  145. package/dist/crypto/private-public-keys/create-key-pair-from-private-key.js +0 -50
  146. package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts +0 -11
  147. package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts.map +0 -1
  148. package/dist/crypto/private-public-keys/create-key-pair-from-public-key.js +0 -51
  149. package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts +0 -10
  150. package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts.map +0 -1
  151. package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.js +0 -51
  152. package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts +0 -11
  153. package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts.map +0 -1
  154. package/dist/crypto/private-public-keys/generation/generate-key-pair.js +0 -49
  155. package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts +0 -15
  156. package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts.map +0 -1
  157. package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.js +0 -21
  158. package/dist/crypto/signature/create-crypto-signature.d.ts +0 -20
  159. package/dist/crypto/signature/create-crypto-signature.d.ts.map +0 -1
  160. package/dist/crypto/signature/create-crypto-signature.js +0 -26
  161. package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts +0 -17
  162. package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts.map +0 -1
  163. package/dist/crypto/signature/verify-crypto-signature-by-data.js +0 -61
  164. package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts +0 -17
  165. package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts.map +0 -1
  166. package/dist/crypto/signature/verify-crypto-signature-by-hash.js +0 -58
@@ -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
@@ -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;