Skip to content

Commit

Permalink
✨ Added recoverPublicKey util fn (#114)
Browse files Browse the repository at this point in the history
* Added hashMessage to exports

* ✨ Added splitSignature util fn

* make gas price less flakey

* ✨ Added `computeAddress` util fn (#116)

* Added initial computeAddress fn, relies on ethers at the moment

* Init computePublicKey util fn

* ✨ Added computePublicKey util fn

* 📝 Added documenation to computePublicKey

* ⬆ Pre-commit hook package bump, added @noble/secp256k1

* ✨ Added `computePublicKey` util fn (#118)

* Init computePublicKey util fn

* ✨ Added computePublicKey util fn

* 📝 Added documenation to computePublicKey

* ⬆ Pre-commit hook package bump, added @noble/secp256k1

* 🧪 Pass computeAddress test

* 📝 Add docs for computeAddress

* 📝 Pre-commit script update readme and chains

* 🧪 Pass tests with recoverPublicKey

* 📝 Pre-commit script readme update

Co-authored-by: daws.eth <dawsonbotsford@gmail.com>
  • Loading branch information
arimgibson and dawsbot authored May 5, 2022
1 parent b75c9b8 commit cb73951
Show file tree
Hide file tree
Showing 13 changed files with 1,129 additions and 2,051 deletions.
1,949 changes: 331 additions & 1,618 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@
},
"devDependencies": {
"@types/body-parser": "^1.19.1",
"@types/eslint": "^8.4.1",
"@types/eslint": "^8.4.2",
"@types/express": "^4.17.13",
"@types/jest": "^27.4.1",
"@types/jest-dev-server": "^5.0.0",
"@types/node": "^16.10.1",
"@types/prettier": "^2.4.4",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.22.0",
"body-parser": "^1.19.0",
"dotenv": "^16.0.0",
"eslint": "^8.14.0",
"eslint-plugin-jest": "^26.1.5",
"ethers": "^5.6.4",
"ethers": "^5.6.5",
"express": "^4.17.1",
"husky": "^7.0.4",
"jest": "^27.5.1",
Expand All @@ -63,6 +63,7 @@
"web3": "^1.7.3"
},
"dependencies": {
"@noble/secp256k1": "^1.5.5",
"@types/big.js": "^6.1.3",
"big.js": "^6.1.1",
"isomorphic-unfetch": "^3.1.0",
Expand Down
62 changes: 62 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
- [Install](#install)
- [🛠 Utils](#-utils)
- [`arrayify`](#arrayify)
- [`computeAddress`](#computeaddress)
- [`computePublicKey`](#computepublickey)
- [`concat`](#concat)
- [`etherToGwei`](#ethertogwei)
- [`etherToWei`](#ethertowei)
Expand All @@ -66,7 +68,9 @@
- [`jsonRpcProvider`](#jsonrpcprovider)
- [`keccak256`](#keccak256)
- [`pack`](#pack)
- [`recoverPublicKey`](#recoverpublickey)
- [`solidityKeccak256`](#soliditykeccak256)
- [`splitSignature`](#splitsignature)
- [`stripZeros`](#stripzeros)
- [`tinyBig`](#tinybig)
- [`toChecksumAddress`](#tochecksumaddress)
Expand Down Expand Up @@ -147,6 +151,22 @@ arrayify('0x1', { hexPad: 'right' });

<br/>

#### [`computeAddress`](https://essential-eth.vercel.app/docs/api/modules#computeaddress)

```typescript
computeAddress(key: string): string
```

<br/>

#### [`computePublicKey`](https://essential-eth.vercel.app/docs/api/modules#computepublickey)

```typescript
computePublicKey(privKey: BytesLike): string
```

<br/>

#### [`concat`](https://essential-eth.vercel.app/docs/api/modules#concat)

```typescript
Expand Down Expand Up @@ -561,6 +581,14 @@ pack(types: Array<string>, values: Array<any>): string

<br/>

#### [`recoverPublicKey`](https://essential-eth.vercel.app/docs/api/modules#recoverpublickey)

```typescript
recoverPublicKey(digest: BytesLike, signature: SignatureLike): string
```

<br/>

#### [`solidityKeccak256`](https://essential-eth.vercel.app/docs/api/modules#soliditykeccak256)

```typescript
Expand Down Expand Up @@ -598,6 +626,40 @@ solidityKeccak256(types, values);

<br/>

#### [`splitSignature`](https://essential-eth.vercel.app/docs/api/modules#splitsignature)

```typescript
splitSignature(signature: SignatureLike): Signature
```

<details>
<summary>View Example</summary>

```js
import { splitSignature } from 'essential-eth';

// or in a require environment
const { splitSignature } = require('essential-eth');
```

```javascript
const signature = '0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee331b';
splitSignature(signature);
{
r: "0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b39716",
s: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
_vs: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
recoveryParam: 0,
v: 27,
yParityAndS: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
compact: "0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33"
}
```

</details>

<br/>

#### [`stripZeros`](https://essential-eth.vercel.app/docs/api/modules#stripzeros)

```typescript
Expand Down
Loading

0 comments on commit cb73951

Please sign in to comment.