@zilliqa-js/crypto
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -20,7 +20,7 @@ "use strict"; | ||
var pub = keyPair.getPublic(true, 'hex'); | ||
return hash_js_1.default | ||
return exports.toChecksumAddress(hash_js_1.default | ||
.sha256() | ||
.update(pub, 'hex') | ||
.digest('hex') | ||
.slice(24); | ||
.slice(24)); | ||
}; | ||
@@ -59,7 +59,7 @@ /** | ||
exports.getAddressFromPublicKey = function (publicKey) { | ||
return hash_js_1.default | ||
return exports.toChecksumAddress(hash_js_1.default | ||
.sha256() | ||
.update(publicKey, 'hex') | ||
.digest('hex') | ||
.slice(24); | ||
.slice(24)); | ||
}; | ||
@@ -66,0 +66,0 @@ /** |
{ | ||
"name": "@zilliqa-js/crypto", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "Core crypto utilities for signing/verification/hashing Zilliqa transactions.", | ||
@@ -32,3 +32,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "36aca1d0308845a83903e83de88eac3a8d92f1ed" | ||
"gitHead": "eda970c0dc8d05a602c9cbcf6275b69377918c1f" | ||
} |
@@ -21,7 +21,9 @@ import elliptic from 'elliptic'; | ||
return hashjs | ||
.sha256() | ||
.update(pub, 'hex') | ||
.digest('hex') | ||
.slice(24); | ||
return toChecksumAddress( | ||
hashjs | ||
.sha256() | ||
.update(pub, 'hex') | ||
.digest('hex') | ||
.slice(24), | ||
); | ||
}; | ||
@@ -63,7 +65,9 @@ | ||
export const getAddressFromPublicKey = (publicKey: string) => { | ||
return hashjs | ||
.sha256() | ||
.update(publicKey, 'hex') | ||
.digest('hex') | ||
.slice(24); | ||
return toChecksumAddress( | ||
hashjs | ||
.sha256() | ||
.update(publicKey, 'hex') | ||
.digest('hex') | ||
.slice(24), | ||
); | ||
}; | ||
@@ -70,0 +74,0 @@ |
@@ -12,6 +12,7 @@ import { addresses } from './address.fixtures'; | ||
const addressFromPub = crypto.getAddressFromPrivateKey(priv); | ||
const checksummedAddress = crypto.toChecksumAddress(address); | ||
expect(generatedPub.toUpperCase()).toEqual(pub); | ||
expect(addressFromPriv.toUpperCase()).toEqual(address); | ||
expect(addressFromPub.toUpperCase()).toEqual(address); | ||
expect(addressFromPriv).toEqual(checksummedAddress); | ||
expect(addressFromPub).toEqual(checksummedAddress); | ||
}); | ||
@@ -18,0 +19,0 @@ }); |
@@ -21,6 +21,6 @@ import { pairs } from './keypairs.fixtures'; | ||
pairs.forEach(({ public: pub, digest }) => { | ||
const expected = digest.slice(24); | ||
const expected = crypto.toChecksumAddress(digest.slice(24)); | ||
const actual = crypto.getAddressFromPublicKey(pub); | ||
expect(actual).toHaveLength(40); | ||
expect(actual).toHaveLength(42); | ||
expect(actual).toEqual(expected); | ||
@@ -37,3 +37,3 @@ }); | ||
expect(actual).toHaveLength(40); | ||
expect(actual).toHaveLength(42); | ||
expect(actual).toEqual(expected); | ||
@@ -49,4 +49,4 @@ }); | ||
expect(fromPrivateKey).toHaveLength(40); | ||
expect(fromPublicKey).toHaveLength(40); | ||
expect(fromPrivateKey).toHaveLength(42); | ||
expect(fromPublicKey).toHaveLength(42); | ||
expect(fromPublicKey).toEqual(fromPrivateKey); | ||
@@ -53,0 +53,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5005084
45682