Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cosmos-wallet

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cosmos-wallet - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

9

dist/cjs/helpers/utils.d.ts

@@ -1,3 +0,4 @@

import { Coin } from '@cosmjs/amino';
import { Coin, StdSignDoc } from '@cosmjs/amino';
import { AccountData } from '@cosmjs/proto-signing';
import { SignDoc } from '@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx';
export declare function getCosmosAddressPrefix(chainId?: string): string;

@@ -9,3 +10,3 @@ export declare function getCosmosAddress(publicKey: Uint8Array, chainId?: string): string;

export declare function parseSignDocValues(signDoc: any): any;
export declare function formatDirectSignDoc(fee: Coin[], pubkey: string, gasLimit: number, accountNumber: number, sequence: number, bodyBytes: string, chainId: string): import("@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx").SignDoc;
export declare function formatDirectSignDoc(fee: Coin[], pubkey: string, gasLimit: number, accountNumber: number, sequence: number, bodyBytes: string, chainId: string): SignDoc;
export declare function stringifyAccountDataValues(account: AccountData): {

@@ -17,2 +18,6 @@ pubkey: string;

export declare function parseAccountDataValues(account: any): any;
export declare function recoverSigningAddress(signature: string, hash: Uint8Array, recoveryIndex: number): Promise<string | null>;
export declare function verifySignature(address: string, signature: string, hash: Uint8Array): Promise<boolean>;
export declare const verifyDirectSignature: (address: string, signature: string, signDoc: SignDoc) => Promise<boolean>;
export declare const verifyAminoSignature: (address: string, signature: string, signDoc: StdSignDoc) => Promise<boolean>;
//# sourceMappingURL=utils.d.ts.map

@@ -15,7 +15,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const long_1 = __importDefault(require("long"));
const amino_1 = require("@cosmjs/amino");
const crypto_1 = require("@cosmjs/crypto");
const amino_1 = require("@cosmjs/amino");
const encoding_1 = require("@cosmjs/encoding");
const proto_signing_1 = require("@cosmjs/proto-signing");
const long_1 = __importDefault(require("long"));
const constants_1 = require("../constants");

@@ -79,2 +79,42 @@ function getCosmosAddressPrefix(chainId) {

exports.parseAccountDataValues = parseAccountDataValues;
function recoverSigningAddress(signature, hash, recoveryIndex) {
return __awaiter(this, void 0, void 0, function* () {
if (recoveryIndex > 3) {
throw new Error('Invalid recovery index');
}
const sig = crypto_1.Secp256k1Signature.fromFixedLength(encoding_1.fromBase64(signature));
const extendedSig = new crypto_1.ExtendedSecp256k1Signature(sig.r(), sig.s(), recoveryIndex);
try {
const recoveredPubKey = yield crypto_1.Secp256k1.recoverPubkey(extendedSig, hash);
return amino_1.pubkeyToAddress({
type: 'tendermint/PubKeySecp256k1',
value: encoding_1.toBase64(crypto_1.Secp256k1.compressPubkey(recoveredPubKey)),
}, 'cosmos');
}
catch (_a) {
return null;
}
});
}
exports.recoverSigningAddress = recoverSigningAddress;
function verifySignature(address, signature, hash) {
return __awaiter(this, void 0, void 0, function* () {
for (let i = 0; i < 4; i++) {
const recoveredAddress = yield recoverSigningAddress(signature, hash, i);
if (recoveredAddress === address) {
return true;
}
}
return false;
});
}
exports.verifySignature = verifySignature;
exports.verifyDirectSignature = (address, signature, signDoc) => {
const messageHash = crypto_1.sha256(proto_signing_1.makeSignBytes(signDoc));
return verifySignature(address, signature, messageHash);
};
exports.verifyAminoSignature = (address, signature, signDoc) => {
const messageHash = crypto_1.sha256(amino_1.serializeSignDoc(signDoc));
return verifySignature(address, signature, messageHash);
};
//# sourceMappingURL=utils.js.map

@@ -1,2 +0,2 @@

import { StdSignDoc, AminoSignResponse, AccountData } from '@cosmjs/amino';
import { AccountData, AminoSignResponse, StdSignDoc } from '@cosmjs/amino';
import { DirectSecp256k1Wallet, DirectSignResponse } from '@cosmjs/proto-signing';

@@ -3,0 +3,0 @@ import { SignDoc } from '@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx';

@@ -12,5 +12,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const amino_1 = require("@cosmjs/amino");
const crypto_1 = require("@cosmjs/crypto");
const encoding_1 = require("@cosmjs/encoding");
const amino_1 = require("@cosmjs/amino");
const proto_signing_1 = require("@cosmjs/proto-signing");

@@ -49,3 +49,3 @@ const helpers_1 = require("./helpers");

}
const message = new crypto_1.Sha256(amino_1.serializeSignDoc(signDoc)).digest();
const message = crypto_1.sha256(amino_1.serializeSignDoc(signDoc));
const sig = yield crypto_1.Secp256k1.createSignature(message, this.privkey);

@@ -52,0 +52,0 @@ const sigBytes = new Uint8Array([...sig.r(32), ...sig.s(32)]);

{
"name": "cosmos-wallet",
"description": "Cosmos Wallet with Direct and Amino signing",
"version": "1.1.0",
"version": "1.2.0",
"author": "Pedro Gomes <github.com/pedrouid>",

@@ -6,0 +6,0 @@ "license": "MIT",

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

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 too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc