Skip to content

Commit

Permalink
Merge pull request #557 from GridPlus/dev
Browse files Browse the repository at this point in the history
v2.6.0
  • Loading branch information
netbonus authored Jul 10, 2024
2 parents c4dd6f7 + 647c138 commit c012d31
Show file tree
Hide file tree
Showing 117 changed files with 17,561 additions and 26,951 deletions.
5 changes: 3 additions & 2 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
REUSE_KEY=0
APP_NAME="SDK Test"
DEVICE_ID=""
PASSWORD=""

ENC_PW=
ETHERSCAN_KEY=""
name="SDK Test"
baseUrl="https://signing.gridpl.us"
54 changes: 27 additions & 27 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"env": {
"es6": false,
"mocha": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true,
"globals": {
"expect": true,
"shallow": true,
"render": true,
"mount": true,
"beforeAll": true,
"cy": true
},
"rules": {
"eqeqeq": ["error"],
"no-var": ["warn"],
"no-duplicate-imports": ["error"],
"prefer-const": ["error"],
"prefer-spread": ["error"],
"no-console": ["off"],
"quotes": ["error", "single"],
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-explicit-any": "off"
"env": {
"es6": false,
"mocha": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true,
"globals": {
"expect": true,
"shallow": true,
"render": true,
"mount": true,
"beforeAll": true,
"cy": true
},
"rules": {
"eqeqeq": ["error"],
"no-var": ["warn"],
"no-duplicate-imports": ["error"],
"prefer-const": ["error"],
"prefer-spread": ["error"],
"no-console": ["off"],
"quotes": ["error", "single"],
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-explicit-any": "off"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/docs-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 18.x

- name: Install NPM packages for SDK
run: npm ci
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
docs/_build
docs/docs/reference
.DS_Store
dist
node_modules
coverage
.env
*.temp
~/node_modules
~/node_modules
cache
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "forge/lib/forge-std"]
path = forge/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "forge/lib/openzeppelin-contracts"]
path = forge/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
24 changes: 12 additions & 12 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"overrides": [
{
"files": "**/src/*.ts",
"options": {
"parser": "typescript"
}
}
],
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
"overrides": [
{
"files": "**/src/*.ts",
"options": {
"parser": "typescript"
}
}
],
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ formats: all
python:
version: 3.7
install:
- requirements: docs/requirements.txt
- requirements: docs/requirements.txt
18 changes: 9 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"editor.codeActionsOnSave": {
"source.addMissingImports": true,
"source.organizeImports": true,
"source.formatDocument": true,
"source.fixAll": true
},
"editor.showUnused": true,
"editor.formatOnPaste": true,
"editor.formatOnSave": true
"editor.codeActionsOnSave": {
"source.addMissingImports": true,
"source.fixAll": true,
"source.formatDocument": true,
"source.organizeImports": true
},
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.showUnused": true
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# GridPlus Lattice1 SDK

* **For help with this SDK, see the [GridPlus SDK Documentation](https://gridplus.github.io/gridplus-sdk)**
* **For help with your Lattice1 hardware, see the [Lattice1 Documentation](https://docs.gridplus.io)**
- **For help with this SDK, see the [GridPlus SDK Documentation](https://gridplus.github.io/gridplus-sdk)**
- **For help with your Lattice1 hardware, see the [Lattice1 Documentation](https://docs.gridplus.io)**

This SDK is designed to facilitate communication with a user's [Lattice1 hardware wallet](https://gridplus.io/lattice). Once paired to a given Lattice, an instance of this SDK is used to make encrypted requests for things like getting addresses/public keys and making signatures.

Expand Down
68 changes: 28 additions & 40 deletions docs/docs/addresses.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
id: "addresses"
id: 'addresses'
sidebar_position: 2
---

# 🔑 Addresses and Public Keys

Once your `Client` instance is connected, you can request a few different addresses and key types from the Lattice.
Once your connection is established, you can request a few different addresses and key types from the Lattice.

:::note

Expand All @@ -17,7 +17,7 @@ This section uses the following notation when discussing BIP32 derivation paths:

These addresses are 20-byte hex strings prefixed with `0x`. Lattice firmware places some restrictions based on derivation path, specifically that the `coin_type` must be supported (Ethereum uses coin type `60'`).

In practice, most apps just use the standard Ethereum `coin_type` (`60'`) when requesting addresses for other networks, but we do support some others (a vestige of an integration -- you probably won't ever need to use these):
In practice, most apps just use the standard Ethereum `coin_type` (`60'`) when requesting addresses for other networks, but we do support some others (a vestige of an integration -- you probably won't ever need to use these):

> `966', 700', 9006', 9005', 1007', 178', 137', 3731', 1010', 61', 108', 40', 889', 1987', 820', 6060', 1620', 1313114', 76', 246529', 246785', 1001', 227', 916', 464', 2221', 344', 73799', 246'`
Expand All @@ -27,44 +27,40 @@ Keep in mind that changing the `coin_type` will change all the requested address

```ts
const reqData = {
startPath: [ // Derivation path of the first requested address
0x80000000 + 44,
0x80000000 + 60,
0x80000000,
0,
0,
],
n: 5, // Number of sequential addresses on specified path to return (max 10)
startPath: [
// Derivation path of the first requested address
0x80000000 + 44,
0x80000000 + 60,
0x80000000,
0,
0,
],
n: 5, // Number of sequential addresses on specified path to return (max 10)
};

const addrs = await client.getAddresses(reqData);
const addrs = await fetchAddresses(reqData);
```

## ₿ Bitcoin addresses

The Lattice can also export Bitcoin formatted addresses. There are three types of addresses that can be fetched and the type is determined by the `purpose` index of the BIP32 derivation path.

* If `purpose = 44'`, *legacy* addresses (beginning with `1`) will be returned
* If `purpose = 49'`, *wrapped segwit* addresses (beginning with `3`) will be returned
* If `purpose = 84'`, *segwit v1* addresses (beginning with `bc1`) will be returned
- If `purpose = 44'`, _legacy_ addresses (beginning with `1`) will be returned
- If `purpose = 49'`, _wrapped segwit_ addresses (beginning with `3`) will be returned
- If `purpose = 84'`, _segwit v1_ addresses (beginning with `bc1`) will be returned

Keep in mind that `coin_type` `0'` is required when requesting BTC addresses.

### Example: requesting BTC segwit addresses

```ts
const reqData = {
startPath: [ // Derivation path of the first requested address
0x80000000 + 84,
0x80000000,
0x80000000,
0,
0,
]
// Derivation path of the first requested address
startPath: [0x80000000 + 84, 0x80000000, 0x80000000, 0, 0],
};

// `n` will be set to 1 if not specified -> 1 address returned
const addr0 = await client.getAddresses(reqData);
// `n` will be set to 10 if not specified -> 10 addresses returned
const addr0 = await fetchAddresses(reqData);
```

## 🗝️ Public Keys
Expand All @@ -78,7 +74,7 @@ Currently the derivation path must be at least 2 indices deep, but this restrict
For requesting public keys it is best to import `Constants` with:

```ts
import { Client, Constants } from 'gridplus-sdk'
import { Constants } from 'gridplus-sdk';
```

### 1️⃣ `secp256k1` curve
Expand All @@ -93,18 +89,13 @@ The public key has two 32 byte components and is of format: `04{X}{Y}`, meaning

```ts
const req = {
startPath: [ // Derivation path of the first requested pubkey
0x80000000 + 44,
0x80000000 + 60,
0x80000000,
0,
0,
],
// Derivation path of the first requested pubkey
startPath: [0x80000000 + 44, 0x80000000 + 60, 0x80000000, 0, 0],
n: 3,
flag: Constants.GET_ADDR_FLAGS.SECP256K1_PUB,
};

const pubkeys = await client.getAddresses(req);
const pubkeys = await fetchAddresses(req);
```

:::note
Expand All @@ -113,7 +104,7 @@ Since `startPath` is the same, this example returns public keys which can be con

### 2️⃣ `ed25519` curve

Used by Solana and a few others. ***Ed25519 requires all derivation path indices be hardened.***
Used by Solana and a few others. **_Ed25519 requires all derivation path indices be hardened._**

**Pubkey size: 32 bytes**

Expand All @@ -123,14 +114,11 @@ Some libraries prefix these keys with a `00` byte (making them 33 bytes), but we

```ts
const req = {
startPath: [ // Derivation path of the first requested pubkey
0x80000000 + 44,
0x80000000 + 60,
0x80000000,
],
// Derivation path of the first requested pubkey
startPath: [0x80000000 + 44, 0x80000000 + 60, 0x80000000],
n: 3,
flag: Constants.GET_ADDR_FLAGS.ED25519_PUB,
};

const pubkeys = await client.getAddresses(req);
const pubkeys = await fetchAddresses(req);
```
Loading

0 comments on commit c012d31

Please sign in to comment.