quantum-coin-js-sdk 1.0.18 → 1.0.19

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/README.md CHANGED
@@ -110,6 +110,7 @@ Requires Node.js version v20.18.1 or higher
110
110
  * [~sendCoins(wallet, toAddress, coins, nonce)](#module_quantum-coin-js-sdk..sendCoins) ⇒ <code>Promise.&lt;SendResult&gt;</code>
111
111
  * [~publicKeyFromSignature(digest, signature)](#module_quantum-coin-js-sdk..publicKeyFromSignature) ⇒ <code>Array.&lt;number&gt;</code>
112
112
  * [~publicKeyFromPrivateKey(privateKey)](#module_quantum-coin-js-sdk..publicKeyFromPrivateKey) ⇒ <code>Array.&lt;number&gt;</code>
113
+ * [~addressFromPublicKey(publicKey)](#module_quantum-coin-js-sdk..addressFromPublicKey) ⇒ <code>string</code>
113
114
 
114
115
  <a name="module_quantum-coin-js-sdk..Config"></a>
115
116
 
@@ -1026,3 +1027,15 @@ The publicKeyFromPrivateKey extracts the public key from a private key.
1026
1027
  | --- | --- | --- |
1027
1028
  | privateKey | <code>Array.&lt;number&gt;</code> | An array of bytes containing the privateKey. |
1028
1029
 
1030
+ <a name="module_quantum-coin-js-sdk..addressFromPublicKey"></a>
1031
+
1032
+ ### quantum-coin-js-sdk~addressFromPublicKey(publicKey) ⇒ <code>string</code>
1033
+ The addressFromPublicKey returns the address corresponding to the public key.
1034
+
1035
+ **Kind**: inner method of [<code>quantum-coin-js-sdk</code>](#module_quantum-coin-js-sdk)
1036
+ **Returns**: <code>string</code> - - Returns a hex string corresponding to the public key. Returns null if the operation failed.
1037
+
1038
+ | Param | Type | Description |
1039
+ | --- | --- | --- |
1040
+ | publicKey | <code>Array.&lt;number&gt;</code> | An array of bytes containing the public key. |
1041
+
@@ -172,6 +172,14 @@ qcsdk.initialize(clientConfigVal).then((initResult) => {
172
172
  console.log("isAddressValid (expected true)" + qcsdk.isAddressValid(wallet1.address)); //should print true
173
173
  console.log("isAddressValid (expected false)" + qcsdk.isAddressValid("asfasdfasdfs")); //should print false
174
174
 
175
+ //Retrieve address from public key
176
+ let addressTemp = qcsdk.addressFromPublicKey(wallet2.publicKey);
177
+ console.log("addressFromPublicKey: " + addressTemp);
178
+ if (addressTemp !== wallet2.address) {
179
+ throw new Error("addressFromPublicKey doesn't match: " + addressTemp + " " + wallet2.publicKey);
180
+ }
181
+ return;
182
+
175
183
  //Send coins
176
184
  //First get account details nonce
177
185
  console.log("sendCoins getAccountDetails " + address);
@@ -10,7 +10,15 @@
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "ethers": "^6.13.4",
13
- "quantum-coin-js-sdk": "^1.0.17"
13
+ "quantum-coin-js-sdk": "file:.."
14
+ }
15
+ },
16
+ "..": {
17
+ "version": "1.0.19",
18
+ "license": "MIT",
19
+ "dependencies": {
20
+ "quantum-coin-pqc-js-sdk": "^1.0.0",
21
+ "seed-words": "^1.0.1"
14
22
  }
15
23
  },
16
24
  "node_modules/@adraffy/ens-normalize": {
@@ -87,26 +95,8 @@
87
95
  }
88
96
  },
89
97
  "node_modules/quantum-coin-js-sdk": {
90
- "version": "1.0.17",
91
- "resolved": "https://registry.npmjs.org/quantum-coin-js-sdk/-/quantum-coin-js-sdk-1.0.17.tgz",
92
- "integrity": "sha512-PhpNkNDXOmBHOyyakeUUsj8rBnJ/Tr3ZXmpgd6M8n7qvo1vsoiuBjSWEIJR2YvsIiPOpRCIJqq8E59sCJ9+1Zg==",
93
- "license": "MIT",
94
- "dependencies": {
95
- "quantum-coin-pqc-js-sdk": "^1.0.0",
96
- "seed-words": "^1.0.1"
97
- }
98
- },
99
- "node_modules/quantum-coin-pqc-js-sdk": {
100
- "version": "1.0.5",
101
- "resolved": "https://registry.npmjs.org/quantum-coin-pqc-js-sdk/-/quantum-coin-pqc-js-sdk-1.0.5.tgz",
102
- "integrity": "sha512-9P1YDkca5CqrO7++TnGJZzPvYlBjYARopHgxYbDcEHgPicP7+tA8zD+DE1BooHp7sLEWF9ObklMj6AdaDUjDVw==",
103
- "license": "MIT"
104
- },
105
- "node_modules/seed-words": {
106
- "version": "1.0.2",
107
- "resolved": "https://registry.npmjs.org/seed-words/-/seed-words-1.0.2.tgz",
108
- "integrity": "sha512-ia58deuPjcR8DpJ8uIgZ7gqDnIWD8vnjb4jX/sEsIDcuQaH/AJj9J8L3DXkUHfUGqAq9Y6pVMuG90t3XUJH90g==",
109
- "license": "MIT"
98
+ "resolved": "..",
99
+ "link": true
110
100
  },
111
101
  "node_modules/tslib": {
112
102
  "version": "2.7.0",
@@ -10,6 +10,6 @@
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "ethers": "^6.13.4",
13
- "quantum-coin-js-sdk": "^1.0.17"
13
+ "quantum-coin-js-sdk": "^1.0.19"
14
14
  }
15
15
  }
package/index.d.ts CHANGED
@@ -686,6 +686,14 @@ export function publicKeyFromSignature(digest: number[], signature: number[]): n
686
686
  * @return {number[]} - Returns a byte array containing the public key. Returns null if the operation failed.
687
687
  */
688
688
  export function publicKeyFromPrivateKey(privateKey: number[]): number[];
689
+ /**
690
+ * The addressFromPublicKey returns the address corresponding to the public key.
691
+ *
692
+ * @function addressFromPublicKey
693
+ * @param {number[]} publicKey - An array of bytes containing the public key.
694
+ * @return {string} - Returns a hex string corresponding to the public key. Returns null if the operation failed.
695
+ */
696
+ export function addressFromPublicKey(publicKey: number[]): string;
689
697
  /**
690
698
  * @class
691
699
  * @constructor
package/index.js CHANGED
@@ -1699,6 +1699,25 @@ function publicKeyFromPrivateKey(privateKey) {
1699
1699
  return base64ToBytes(publicKeyBase64);
1700
1700
  }
1701
1701
 
1702
+ /**
1703
+ * The addressFromPublicKey returns the address corresponding to the public key.
1704
+ *
1705
+ * @function addressFromPublicKey
1706
+ * @param {number[]} publicKey - An array of bytes containing the public key.
1707
+ * @return {string} - Returns a hex string corresponding to the public key. Returns null if the operation failed.
1708
+ */
1709
+ function addressFromPublicKey(publicKey) {
1710
+ if (isInitialized === false) {
1711
+ return -1000;
1712
+ }
1713
+
1714
+ if (publicKey === undefined || publicKey === null || publicKey.length === undefined || publicKey.length === null) {
1715
+ return null;
1716
+ }
1717
+
1718
+ return PublicKeyToAddress(publicKey);
1719
+ }
1720
+
1702
1721
  module.exports = {
1703
1722
  initialize,
1704
1723
  serializeWallet,
@@ -1731,5 +1750,6 @@ module.exports = {
1731
1750
  newWalletSeed,
1732
1751
  openWalletFromSeedWords,
1733
1752
  publicKeyFromSignature,
1734
- publicKeyFromPrivateKey
1753
+ publicKeyFromPrivateKey,
1754
+ addressFromPublicKey
1735
1755
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quantum-coin-js-sdk",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "Quantum Coin - Q SDK in JavaScript",
5
5
  "main": "index.js",
6
6
  "scripts": {