@usecapsule/core-sdk
Advanced tools
Comparing version 1.24.0-dev.0 to 1.24.0-dev.1
@@ -9,5 +9,6 @@ "use strict"; | ||
const encoding_1 = require("@cosmjs/encoding"); | ||
const amino_1 = require("@cosmjs/amino"); | ||
const sha256_1 = require("@noble/hashes/sha256"); | ||
const ripemd160_1 = require("@noble/hashes/ripemd160"); | ||
const elliptic_1 = __importDefault(require("elliptic")); | ||
const secp256k1 = new elliptic_1.default.ec("secp256k1"); | ||
const secp256k1 = new elliptic_1.default.ec('secp256k1'); | ||
function hexStringToBase64(hexString) { | ||
@@ -56,12 +57,18 @@ if (hexString.substring(0, 2) === '0x') { | ||
case 65: | ||
return Uint8Array.from(secp256k1.keyFromPublic(pubkey).getPublic(true, "array")); | ||
return Uint8Array.from(secp256k1.keyFromPublic(pubkey).getPublic(true, 'array')); | ||
default: | ||
throw new Error("Invalid pubkey length"); | ||
throw new Error('Invalid pubkey length'); | ||
} | ||
} | ||
function rawSecp256k1PubkeyToRawAddress(pubkeyData) { | ||
if (pubkeyData.length !== 33) { | ||
throw new Error(`Invalid Secp256k1 pubkey length (compressed): ${pubkeyData.length}`); | ||
} | ||
return (0, ripemd160_1.ripemd160)((0, sha256_1.sha256)(pubkeyData)); | ||
} | ||
function getCosmosAddress(publicKey, prefix) { | ||
const uncompressedPublicKey = new Uint8Array(Buffer.from(publicKey.startsWith('0x') ? publicKey.slice(2) : publicKey, 'hex')); | ||
const compressedPublicKey = compressPubkey(uncompressedPublicKey); | ||
return (0, encoding_1.toBech32)(prefix, (0, amino_1.rawSecp256k1PubkeyToRawAddress)(compressedPublicKey)); | ||
return (0, encoding_1.toBech32)(prefix, rawSecp256k1PubkeyToRawAddress(compressedPublicKey)); | ||
} | ||
exports.getCosmosAddress = getCosmosAddress; |
import { WalletType } from '@usecapsule/user-management-client'; | ||
import { toBech32 } from '@cosmjs/encoding'; | ||
import { rawSecp256k1PubkeyToRawAddress } from '@cosmjs/amino'; | ||
import elliptic from "elliptic"; | ||
const secp256k1 = new elliptic.ec("secp256k1"); | ||
import { sha256 } from '@noble/hashes/sha256'; | ||
import { ripemd160 } from '@noble/hashes/ripemd160'; | ||
import elliptic from 'elliptic'; | ||
const secp256k1 = new elliptic.ec('secp256k1'); | ||
export function hexStringToBase64(hexString) { | ||
@@ -43,7 +44,13 @@ if (hexString.substring(0, 2) === '0x') { | ||
case 65: | ||
return Uint8Array.from(secp256k1.keyFromPublic(pubkey).getPublic(true, "array")); | ||
return Uint8Array.from(secp256k1.keyFromPublic(pubkey).getPublic(true, 'array')); | ||
default: | ||
throw new Error("Invalid pubkey length"); | ||
throw new Error('Invalid pubkey length'); | ||
} | ||
} | ||
function rawSecp256k1PubkeyToRawAddress(pubkeyData) { | ||
if (pubkeyData.length !== 33) { | ||
throw new Error(`Invalid Secp256k1 pubkey length (compressed): ${pubkeyData.length}`); | ||
} | ||
return ripemd160(sha256(pubkeyData)); | ||
} | ||
export function getCosmosAddress(publicKey, prefix) { | ||
@@ -50,0 +57,0 @@ const uncompressedPublicKey = new Uint8Array(Buffer.from(publicKey.startsWith('0x') ? publicKey.slice(2) : publicKey, 'hex')); |
{ | ||
"name": "@usecapsule/core-sdk", | ||
"version": "1.24.0-dev.0", | ||
"version": "1.24.0-dev.1", | ||
"main": "dist/cjs/index.js", | ||
@@ -11,4 +11,4 @@ "module": "dist/esm/index.js", | ||
"@celo/utils": "^6.0.1", | ||
"@cosmjs/amino": "^0.32.4", | ||
"@cosmjs/encoding": "^0.32.4", | ||
"@noble/hashes": "^1.5.0", | ||
"@usecapsule/user-management-client": "1.21.0-dev.0", | ||
@@ -15,0 +15,0 @@ "base64url": "^3.0.1", |
307333
6596
+ Added@noble/hashes@^1.5.0
+ Added@scure/base@1.1.9(transitive)
- Removed@cosmjs/amino@^0.32.4
- Removed@cosmjs/amino@0.32.4(transitive)
- Removed@cosmjs/crypto@0.32.4(transitive)
- Removed@cosmjs/math@0.32.4(transitive)
- Removed@cosmjs/utils@0.32.4(transitive)
- Removed@scure/base@1.1.8(transitive)
- Removedlibsodium-sumo@0.7.15(transitive)
- Removedlibsodium-wrappers-sumo@0.7.15(transitive)