From 1f5519454be4baeaa0f92fead58dd04aeb209850 Mon Sep 17 00:00:00 2001 From: Retheesh Sasikumar <42141331+retheeshskumar@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:38:37 +0100 Subject: [PATCH] Bump bs58 from 4.0.1 to 6.0.0 --- common/package.json | 2 +- common/src/hedera-modules/hashing.ts | 4 ++-- common/src/helpers/vc-helper.ts | 10 +++++----- common/src/wallet/wallet.ts | 4 ++-- guardian-service/package.json | 1 - indexer-service/package.json | 2 +- policy-service/package.json | 1 - 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/common/package.json b/common/package.json index d5da9115c..445d9b436 100644 --- a/common/package.json +++ b/common/package.json @@ -27,7 +27,7 @@ "ajv": "^8.10.0", "ajv-formats": "^2.1.1", "axios": "^1.3.6", - "bs58": "^4.0.1", + "bs58": "^6.0.0", "bson": "^6.5.0", "dotenv": "^16.0.0", "exceljs": "^4.4.0", diff --git a/common/src/hedera-modules/hashing.ts b/common/src/hedera-modules/hashing.ts index 4424c5830..c7f4fb430 100644 --- a/common/src/hedera-modules/hashing.ts +++ b/common/src/hedera-modules/hashing.ts @@ -13,8 +13,8 @@ export class Hashing { encode: (data: Uint8Array): string => { return bs58.encode(data); }, - decode: (data: string): Uint8Array => { - return bs58.decode(data); + decode: (data: string): Buffer => { + return Buffer.from(bs58.decode(data)); } } /** diff --git a/common/src/helpers/vc-helper.ts b/common/src/helpers/vc-helper.ts index ef5fb7bc6..051a9ebee 100644 --- a/common/src/helpers/vc-helper.ts +++ b/common/src/helpers/vc-helper.ts @@ -43,7 +43,7 @@ import { KeyType, Users, Wallet } from '../helpers/index.js'; import { IAuthUser } from '../interfaces/index.js'; import { Ed25519VerificationKey2018 } from '@transmute/ed25519-signature-2018'; import { bls12_381 } from '@noble/curves/bls12-381'; -import bs58 from 'bs58'; +import { Hashing } from '../hedera-modules/hashing.js'; import { DatabaseServer } from '../database-modules/index.js'; /** @@ -501,10 +501,10 @@ export class VcHelper extends VCJS { const option = method.toObject(true) as any; switch (option.type) { case 'Ed25519VerificationKey2018': { - const privateKeyHex = bs58 + const privateKeyHex = Hashing.base58 .decode(option.privateKeyBase58) .toString('hex') - const publicKeyHex = bs58 + const publicKeyHex = Hashing.base58 .decode(option.publicKeyBase58) .toString('hex') if (!privateKeyHex.endsWith(publicKeyHex)) { @@ -516,12 +516,12 @@ export class VcHelper extends VCJS { case 'Bls12381G2Key2020': { const privateKeyBase58 = option.privateKeyBase58; const publicKeyBase58 = option.publicKeyBase58; - const privateKeyHex = bs58 + const privateKeyHex = Hashing.base58 .decode(privateKeyBase58) .toString('hex') .toUpperCase(); const publicKey = bls12_381.getPublicKeyForShortSignatures(privateKeyHex); - if (publicKeyBase58 !== bs58.encode(publicKey)) { + if (publicKeyBase58 !== Hashing.base58.encode(publicKey)) { return false; } keyPair = await Bls12381G2KeyPair.from(option); diff --git a/common/src/wallet/wallet.ts b/common/src/wallet/wallet.ts index 96f489075..4c04512a0 100644 --- a/common/src/wallet/wallet.ts +++ b/common/src/wallet/wallet.ts @@ -1,6 +1,6 @@ import { SecretManager, SecretManagerBase, SecretManagerType } from '../secret-manager/index.js'; import crypto from 'crypto'; -import * as bs58 from 'bs58'; +import { Hashing } from '../hedera-modules/hashing.js'; import { AzureSecretManager } from '../secret-manager/azure/azure-secret-manager.js'; import { GcpSecretManager } from '../secret-manager/gcp/gcp-secret-manager.js'; @@ -64,7 +64,7 @@ export class Wallet { // convert hashedKey from hex to Base58 to shoeten key length, Azure does not accept keys longet than 128 chars // convert hashedKey from hex to Base58 to shoeten key length, GCP does not accept keys longet than 255 chars const buffer = Buffer.from(hashedKey, 'hex'); - const hashedKeyBase58 = bs58.encode(buffer); + const hashedKeyBase58 = Hashing.base58.encode(buffer); return hashedKeyBase58; } diff --git a/guardian-service/package.json b/guardian-service/package.json index 79cce7411..e38a0c235 100644 --- a/guardian-service/package.json +++ b/guardian-service/package.json @@ -36,7 +36,6 @@ "ajv": "^8.10.0", "ajv-formats": "^2.1.1", "axios": "^1.3.6", - "bs58": "^4.0.1", "bson": "^6.5.0", "cors": "^2.8.5", "cron": "^2.0.0", diff --git a/indexer-service/package.json b/indexer-service/package.json index be95a3c2d..a7fc1c5d1 100644 --- a/indexer-service/package.json +++ b/indexer-service/package.json @@ -11,7 +11,7 @@ "@nestjs/core": "^9.4.1", "@nestjs/microservices": "^9.4.1", "axios": "^1.7.2", - "bs58": "^4.0.1", + "bs58": "^6.0.0", "axios-retry": "^3.2.4", "cron": "^3.1.7", "cross-blob": "^2.0.1", diff --git a/policy-service/package.json b/policy-service/package.json index c253470e2..74cdce22f 100644 --- a/policy-service/package.json +++ b/policy-service/package.json @@ -35,7 +35,6 @@ "ajv": "^8.10.0", "ajv-formats": "^2.1.1", "axios": "^1.3.6", - "bs58": "^4.0.1", "bson": "^6.5.0", "cors": "^2.8.5", "cron": "^2.0.0",