@injectivelabs/sdk-ts 1.0.51 → 1.0.54

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.
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { PublicKey } from './PublicKey';
2
3
  import { Address } from '../classes/Address';
3
4
  /**
@@ -49,11 +50,29 @@ export declare class PrivateKey {
49
50
  * @returns {string}
50
51
  **/
51
52
  toBech32(): string;
53
+ /**
54
+ * Sign the given message using the wallet's _signingKey function.
55
+ * @param {string} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
56
+ * @returns {Uint8Array} a signature of this private key over the given message
57
+ */
58
+ sign(messageBytes: Buffer): Promise<Uint8Array>;
59
+ /**
60
+ * Sign the given message using the edcsa sign_deterministic function.
61
+ * @param {Buffer} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
62
+ * @returns {Uint8Array} a signature of this private key over the given message
63
+ */
64
+ signEcda(messageBytes: Buffer): Promise<Uint8Array>;
65
+ /**
66
+ * Sign the given message using the wallet's _signingKey function.
67
+ * @param {string} messageHashedBytes: the message that will be signed, a Buffer made of bytes
68
+ * @returns {Uint8Array} a signature of this private key over the given message
69
+ */
70
+ signHashed(messageHashedBytes: Buffer): Promise<Uint8Array>;
52
71
  /**
53
72
  * Sign the given message using the edcsa sign_deterministic function.
54
- * @param {any} message: the message that will be hashed and signed
55
- * @returns {string} a signature of this private key over the given message
73
+ * @param {Buffer} messageHashedBytes: the message that will be signed, a Buffer made of bytes
74
+ * @returns {Uint8Array} a signature of this private key over the given message
56
75
  */
57
- sign(message: any): Promise<Uint8Array>;
76
+ signHashedEcda(messageHashedBytes: Buffer): Promise<Uint8Array>;
58
77
  }
59
78
  //# sourceMappingURL=PrivateKey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrivateKey.d.ts","sourceRoot":"","sources":["../../src/local/PrivateKey.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM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MAAM,GAAG,UAAU;IAIrD;;;OAGG;IACH,KAAK,IAAI,MAAM;IAMf;;;QAGI;IACJ,WAAW,IAAI,SAAS;IAIxB;;;QAGI;IACJ,SAAS,IAAI,OAAO;IAIpB;;;QAGI;IACJ,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAYrD;;;;OAIG;IACG,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAazD;;;;OAIG;IACG,UAAU,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAWjE;;;;OAIG;IACG,cAAc,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAWtE"}
@@ -1,4 +1,23 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
22
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
23
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -20,6 +39,7 @@ const keccak256_1 = __importDefault(require("keccak256"));
20
39
  const constants_1 = require("../utils/constants");
21
40
  const PublicKey_1 = require("./PublicKey");
22
41
  const Address_1 = require("../classes/Address");
42
+ const BytesUtils = __importStar(require("@ethersproject/bytes"));
23
43
  /**
24
44
  * Class for wrapping SigningKey that is used for signature creation and public key derivation.
25
45
  */
@@ -88,15 +108,29 @@ class PrivateKey {
88
108
  toBech32() {
89
109
  return Address_1.Address.fromHex(this.toHex()).toBech32();
90
110
  }
111
+ /**
112
+ * Sign the given message using the wallet's _signingKey function.
113
+ * @param {string} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
114
+ * @returns {Uint8Array} a signature of this private key over the given message
115
+ */
116
+ sign(messageBytes) {
117
+ return __awaiter(this, void 0, void 0, function* () {
118
+ const { wallet } = this;
119
+ const msgHash = (0, keccak256_1.default)(messageBytes);
120
+ const signature = yield wallet._signingKey().signDigest(msgHash);
121
+ const splitSignature = BytesUtils.splitSignature(signature);
122
+ return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
123
+ });
124
+ }
91
125
  /**
92
126
  * Sign the given message using the edcsa sign_deterministic function.
93
- * @param {any} message: the message that will be hashed and signed
94
- * @returns {string} a signature of this private key over the given message
127
+ * @param {Buffer} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
128
+ * @returns {Uint8Array} a signature of this private key over the given message
95
129
  */
96
- sign(message) {
130
+ signEcda(messageBytes) {
97
131
  return __awaiter(this, void 0, void 0, function* () {
98
132
  const { wallet } = this;
99
- const msgHash = (0, keccak256_1.default)(Buffer.from(message));
133
+ const msgHash = (0, keccak256_1.default)(messageBytes);
100
134
  const privateKeyHex = wallet.privateKey.startsWith('0x')
101
135
  ? wallet.privateKey.slice(2)
102
136
  : wallet.privateKey;
@@ -105,6 +139,35 @@ class PrivateKey {
105
139
  return signature;
106
140
  });
107
141
  }
142
+ /**
143
+ * Sign the given message using the wallet's _signingKey function.
144
+ * @param {string} messageHashedBytes: the message that will be signed, a Buffer made of bytes
145
+ * @returns {Uint8Array} a signature of this private key over the given message
146
+ */
147
+ signHashed(messageHashedBytes) {
148
+ return __awaiter(this, void 0, void 0, function* () {
149
+ const { wallet } = this;
150
+ const signature = yield wallet._signingKey().signDigest(messageHashedBytes);
151
+ const splitSignature = BytesUtils.splitSignature(signature);
152
+ return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
153
+ });
154
+ }
155
+ /**
156
+ * Sign the given message using the edcsa sign_deterministic function.
157
+ * @param {Buffer} messageHashedBytes: the message that will be signed, a Buffer made of bytes
158
+ * @returns {Uint8Array} a signature of this private key over the given message
159
+ */
160
+ signHashedEcda(messageHashedBytes) {
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ const { wallet } = this;
163
+ const privateKeyHex = wallet.privateKey.startsWith('0x')
164
+ ? wallet.privateKey.slice(2)
165
+ : wallet.privateKey;
166
+ const privateKey = Uint8Array.from(Buffer.from(privateKeyHex, 'hex'));
167
+ const { signature } = secp256k1_1.default.ecdsaSign(messageHashedBytes, privateKey);
168
+ return signature;
169
+ });
170
+ }
108
171
  }
109
172
  exports.PrivateKey = PrivateKey;
110
173
  //# sourceMappingURL=PrivateKey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrivateKey.js","sourceRoot":"","sources":["../../src/local/PrivateKey.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAyB;AACzB,mCAA+B;AAC/B,0DAAiC;AACjC,0DAAiC;AACjC,kDAA4D;AAC5D,2CAAuC;AACvC,gDAA4C;AAE5C;;GAEG;AACH,MAAa,UAAU;IAGrB,YAAoB,MAAc;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,QAAQ;QACb,MAAM,QAAQ,GAAG,eAAK,CAAC,gBAAgB,EAAE,CAAA;QACzC,MAAM,UAAU,GAAG,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;Q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CAAC,CAAA;YAEzE,OAAO,SAAS,CAAA;QAClB,CAAC;KAAA;CACF;AAlJD,gCAkJC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/sdk-ts",
3
3
  "description": "SDK in TypeScript for building Injective applications in a Node environment.",
4
- "version": "1.0.51",
4
+ "version": "1.0.54",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Bojan Angjelkoski",
@@ -57,5 +57,5 @@
57
57
  "shx": "^0.3.2",
58
58
  "snakecase-keys": "^5.4.1"
59
59
  },
60
- "gitHead": "3a07487368eb5052b0228988ae50d4b8305edaaa"
60
+ "gitHead": "e475836319dfaa89bef733d6eb17217eee3b4931"
61
61
  }