Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/summa-tx/satmask
🛰️🎭
https://github.com/summa-tx/satmask
Last synced: 2 months ago
JSON representation
🛰️🎭
- Host: GitHub
- URL: https://github.com/summa-tx/satmask
- Owner: summa-tx
- License: other
- Created: 2020-03-15T19:41:33.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-12T14:31:23.000Z (almost 4 years ago)
- Last Synced: 2023-03-02T19:15:43.156Z (almost 2 years ago)
- Language: JavaScript
- Size: 958 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE2.md
Awesome Lists containing this project
README
# SatMask
Proof of Concept code for signing Bitcoin transactions via MetaMask.
DO NOT USE THIS CODE IN PRODUCTION.
### How it works
MetaMask's `eth_sign` api allows the user to sign arbitrary digests. Unlike
geth, it does not modify or hash the argument. This means we can calculate the
sighash of a Bitcoin transaction and pass it to `eth_sign`. After that, we
need to translate the signature from Ethereum's hex-encoded RSV standard to
Bitcoin's DER-Encoded RS format, and add the signature to the transaction.Calculating the sighash requires knowledge of the public key that will sign,
so an extra `personal_sign` call is made. This generates a signature from which
we can recover the users' pubkey to use in the sighash algorithm.The current version signs only transactions with 1 witness pubkeyhash input and
one witness pubkeyhash output. The resulting transaction is logged to console.### A brief tour of the codebase
- `src/tx.js` handles transaction datastructure manipulation. This includes
construction, sighash serialization, and adding the signature to the
transaction (inside a witness).- `src/sigs.js` handles interfacing with MetaMask, retrieving the signature,
and translating from RSV to DER.- `src/App.js` is a simple react app that provides a convenient interface for
specifying a transaction. All credit to [@tynes](https://github.com/tynes/) for
this part :)### How to run it
Don't. Like really don't. Read the code, but don't run it.