{"id":13573033,"url":"https://github.com/tendermint/sig","last_synced_at":"2025-04-14T07:31:43.495Z","repository":{"id":38976359,"uuid":"213674093","full_name":"tendermint/sig","owner":"tendermint","description":"A signing library for Cosmos.","archived":false,"fork":false,"pushed_at":"2023-01-24T11:44:59.000Z","size":720,"stargazers_count":28,"open_issues_count":34,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-21T22:12:07.474Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://cosmos.github.io/sig/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tendermint.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-08T14:57:21.000Z","updated_at":"2024-04-23T20:38:54.000Z","dependencies_parsed_at":"2023-02-13T21:00:59.147Z","dependency_job_id":null,"html_url":"https://github.com/tendermint/sig","commit_stats":null,"previous_names":["cosmos/sig"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tendermint%2Fsig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tendermint%2Fsig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tendermint%2Fsig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tendermint%2Fsig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tendermint","download_url":"https://codeload.github.com/tendermint/sig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248839424,"owners_count":21169814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:00:27.644Z","updated_at":"2025-04-14T07:31:43.089Z","avatar_url":"https://github.com/tendermint.png","language":"TypeScript","funding_links":[],"categories":["Client Libraries"],"sub_categories":["JavaScript"],"readme":"# Sig\n\nSig is a signing library for Cosmos, supported in Node.js and browsers.\n\nSig provides JavaScript functions and TypeScript types for\n\n  - Deriving a wallet (private key, public key, and address) from a mnemonic\n  - Deriving an address from a public key\n  - Structuring a transaction\n  - Signing a transaction\n  - Verifying signatures for a transaction\n  - Preparing a transaction for broadcast\n\nSig **does not** provide functions for\n\n  - Generating a mnemonic\n  - Storing keys or other secrets\n  - Obtaining data from a chain\n  - Broadcasting transactions\n\nSig is designed to work well with other libraries like\n  - [`bip39`](https://github.com/bitcoinjs/bip39)\n  - [`bip32`](https://github.com/bitcoinjs/bip32)\n  - [`@tendermint/amino-js`](https://github.com/cosmos/amino-js)\n\nSig is experimental and not recommended for use in production yet. Please help us test and improve it!\n\nAs always, please be careful to protect any mnemonic phrases, passwords, and private keys.\n\n### Demo\n\n  - [Node.js](https://repl.it/repls/DodgerblueAshamedTest)\n  - [Browser](https://jsfiddle.net/pbc6zkeh/)\n\n### Documentation\n\n**https://cosmos.github.io/sig/**\n\n### Install\n\nPlease note that the NPM package name is `@tendermint/sig` rather than `@cosmos/sig`.\n\n#### Yarn\n```shell\nyarn add @tendermint/sig\n```\n\n#### NPM\n```shell\nnpm install --save @tendermint/sig\n```\n\n### Usage\n\n#### Derive a wallet (private key, public key, and address) from a mnemonic\n\n```typescript\nimport { createWalletFromMnemonic } from '@tendermint/sig';\n\nconst mnemonic = 'trouble salon husband push melody usage fine ensure blade deal miss twin';\n\nconst wallet = createWalletFromMnemonic(mnemonic); // BIP39 mnemonic string\n/*\n{\n    address:    'cosmos1asm039pzjkkg9ghlvj267p5g3whtxd2t4leg5c',\n    privateKey: Uint8Array [\n        202,  60, 140, 106, 178, 180,  60,   1,\n        186,  68, 206, 224, 207, 179,  79,  81,\n        119,  98,  98,   1, 207, 170, 209, 161,\n          1, 124, 151, 236, 205, 151,   3, 229\n    ],\n    publicKey:  Uint8Array [\n          3, 159,  35,  41, 130,  48,   3, 247,\n        139, 242, 113,  41, 200, 176,  73,  27,\n        102, 232, 113, 226,  80, 184, 107, 144,\n        217,  88, 151,  21,  22, 185,  68,  28,\n        211\n    ]\n}\n*/\n```\n\n#### Derive a Bech32 address from a public key\n\n```typescript\nimport { createAddress } from '@tendermint/sig';\n\nconst address = createAddress(publicKey); // Buffer or Uint8Array\n// 'cosmos1asm039pzjkkg9ghlvj267p5g3whtxd2t4leg5c'\n```\n\n#### Sign a transaction\n\n```typescript\nimport { signTx } from '@tendermint/sig';\n\nconst tx = {\n    fee:  {\n        amount: [{ amount: '0', denom: '' }],\n        gas:    '10000'\n    },\n    memo: '',\n    msg:  [{\n        type:  'cosmos-sdk/MsgSend',\n        value: {\n            from_address: 'cosmos1qperwt9wrnkg5k9e5gzfgjppzpqhyav5j24d66',\n            to_address:   'cosmos1yeckxz7tapz34kjwnjxvmxzurerquhtrmxmuxt',\n            amount:       [{ amount: '1', denom: 'STAKE' }]\n        }\n    }]\n};\n\nconst signMeta = {\n    account_number: '1',\n    chain_id:       'cosmos',\n    sequence:       '0'\n};\n\nconst stdTx = signTx(tx, signMeta, wallet); // Wallet or privateKey / publicKey pair; see example above\n/*\n{\n    fee:        {\n        amount: [{\n            amount: '0',\n            denom:  ''\n        }],\n        gas:    '10000'\n    },\n    memo:       '',\n    msg:        [{\n        type:  'cosmos-sdk/MsgSend',\n        value: {\n            from_address: 'cosmos1qperwt9wrnkg5k9e5gzfgjppzpqhyav5j24d66',\n            to_address:   'cosmos1yeckxz7tapz34kjwnjxvmxzurerquhtrmxmuxt',\n            amount:       [{\n                amount: '1',\n                denom:  'STAKE'\n            }]\n        }\n    }],\n    signatures: [{\n        signature: 'GLhQW+t36tjJW83avsBz6e7WUpkJyeAsmkrCJsnk/fkfA4q5nIVVwTF5HPQhFdkhMfAVKPFuvDmigRp+VQCwtg==',\n        pub_key:   {\n            type:  'tendermint/PubKeySecp256k1',\n            value: 'A58jKYIwA/eL8nEpyLBJG2boceJQuGuQ2ViXFRa5RBzT'\n        }\n    }]\n}\n*/\n```\n\n#### Verify a transaction\n\n```typescript\nimport { verifyTx } from '@tendermint/sig';\n\nconst valid = verifyTx(stdTx, signMeta); // signed transaction and metadata; see example above\n// true\n```\n\nPlease see the [documentation](https://cosmos.github.io/sig/) for the full API.\n\n### Building\n\n```shell\ngit clone https://github.com/cosmos/sig.git\ncd sig\nyarn install\nyarn setup\nyarn test\n```\n\n### Contributing\n\nSig is very new! Questions, feedback, use cases, issues, and code are all very, very welcome.\n\nThank you for helping us help you help us all. 🎁\n\n### Alternatives\n\nA number of other projects exist that help with signing for Cosmos.\n\nPlease check them out and see if they are right for you!\n\n- [`@lunie/cosmos-keys`](https://github.com/luniehq/cosmos-keys)\n- [`@cosmostation/cosmosjs`](https://github.com/cosmostation/cosmosjs)\n- [`@iov/cosmos`](https://github.com/iov-one/iov-core/tree/1220-cosmos-codec/packages/iov-cosmos)\n- [`@everett-protocol/cosmosjs`](https://github.com/everett-protocol/cosmosjs)\n- [`js-cosmos-wallet`](https://github.com/okwme/js-cosmos-wallet)\n- [`cosmos-client-ts`](https://github.com/lcnem/cosmos-client-ts)\n- [`lotion`](https://github.com/nomic-io/lotion)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftendermint%2Fsig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftendermint%2Fsig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftendermint%2Fsig/lists"}