@ocap/mcrypto 1.18.35 → 1.18.36
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/lib/signer/secp256k1.js
CHANGED
|
@@ -25,6 +25,9 @@ class Secp256k1Signer extends signer_1.default {
|
|
|
25
25
|
this.pkCompressed = false;
|
|
26
26
|
}
|
|
27
27
|
isValidSK(sk) {
|
|
28
|
+
if (sk.byteLength !== 32) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
28
31
|
const bn = new util_1.BN(sk);
|
|
29
32
|
return bn.cmp(secp256k1.curve.n) < 0 && !bn.isZero();
|
|
30
33
|
}
|
|
@@ -50,6 +53,9 @@ class Secp256k1Signer extends signer_1.default {
|
|
|
50
53
|
* Get publicKey from secretKey
|
|
51
54
|
*/
|
|
52
55
|
getPublicKey(sk, encoding = 'hex') {
|
|
56
|
+
if (!this.isValidSK((0, util_1.toUint8Array)(sk))) {
|
|
57
|
+
throw new Error('Invalid secret key');
|
|
58
|
+
}
|
|
53
59
|
let pk = secp256k1.keyFromPrivate((0, util_1.toBuffer)(sk)).getPublic(this.pkCompressed, 'hex');
|
|
54
60
|
if (this.pkHasFormatPrefix === false) {
|
|
55
61
|
pk = pk.slice(2);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/mcrypto",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.36",
|
|
4
4
|
"description": "Crypto lib that provides signer,crypter,hasher interface",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"crypto",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"url": "https://github.com/ArcBlock/asset-chain/issues"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@ocap/util": "1.18.
|
|
59
|
+
"@ocap/util": "1.18.36",
|
|
60
60
|
"bn.js": "5.2.1",
|
|
61
61
|
"crypto-js": "^4.1.1",
|
|
62
62
|
"elliptic": "^6.5.4",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"bn.js": "5.2.1",
|
|
73
73
|
"elliptic": "6.5.3"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "507eaab0fc94d92a88c49c2e3441c5f6b0e3788f"
|
|
76
76
|
}
|