Skip to content

Commit

Permalink
Revamped app with a lot of fix's
Browse files Browse the repository at this point in the history
- Remove unnecessary dependencies.
- Added Commands example
- Fixed deserialize
- Fixed Types
- Fixed Display
  • Loading branch information
TeknoPT committed Dec 6, 2023
1 parent 91b36d9 commit 44cc4f5
Show file tree
Hide file tree
Showing 24 changed files with 692 additions and 1,434 deletions.
87 changes: 87 additions & 0 deletions doc/COMMANDS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Phantasma commands

## Overview

| Command name | INS | Description |
| --- | --- | --- |
| `GET_VERSION` | 0x03 | Get application version as `MAJOR`, `MINOR`, `PATCH` |
| `GET_APP_NAME` | 0x04 | Get ASCII encoded application name |
| `GET_PUBLIC_KEY` | 0x05 | Get public key given BIP32 path |
| `SIGN_TX` | 0x06 | Sign transaction given BIP32 path and raw transaction |

## GET_VERSION

### Command

| CLA | INS | P1 | P2 | Lc | CData |
| --- | --- | --- | --- | --- | --- |
| 0xE0 | 0x03 | 0x00 | 0x00 | 0x00 | - |

### Response

| Response length (bytes) | SW | RData |
| --- | --- | --- |
| 3 | 0x9000 | `MAJOR (1)` \|\| `MINOR (1)` \|\| `PATCH (1)` |

## GET_APP_NAME

### Command

| CLA | INS | P1 | P2 | Lc | CData |
| --- | --- | --- | --- | --- | --- |
| 0xE0 | 0x04 | 0x00 | 0x00 | 0x00 | - |

### Response

| Response length (bytes) | SW | RData |
| --- | --- | --- |
| var | 0x9000 | `APPNAME (var)` |

## GET_PUBLIC_KEY

### Command

| CLA | INS | P1 | P2 | Lc | CData |
| --- | --- | --- | --- | --- | --- |
| 0xE0 | 0x05 | 0x00 (no display) <br> 0x01 (display) | 0x00 | 1 + 4n | `len(bip32_path) (1)` \|\|<br> `bip32_path{1} (4)` \|\|<br>`...` \|\|<br>`bip32_path{n} (4)` |

### Response

| Response length (bytes) | SW | RData |
| --- | --- | --- |
| var | 0x9000 | `len(public_key) (1)` \|\|<br> `public_key (var)` \|\|<br> `len(chain_code) (1)` \|\|<br> `chain_code (var)` |

## SIGN_TX

### Command

| CLA | INS | P1 | P2 | Lc | CData |
| --- | --- | --- | --- | --- | --- |
| 0xE0 | 0x06 | 0x00-0x03 (chunk index) | 0x00 (more) <br> 0x80 (last) | 1 + 4n | `len(bip32_path) (1)` \|\|<br> `bip32_path{1} (4)` \|\|<br>`...` \|\|<br>`bip32_path{n} (4)` |

### Response

| Response length (bytes) | SW | RData |
| --- | --- | --- |
| var | 0x9000 | `len(signature) (1)` \|\| <br> `signature (var)` \|\| <br> `v (1)`|


## Status Words

| SW | SW name | Description |
| --- | --- | --- |
| 0x6985 | `SW_DENY` | Rejected by user |
| 0x6A86 | `SW_WRONG_P1P2` | Either `P1` or `P2` is incorrect |
| 0x6A87 | `SW_WRONG_DATA_LENGTH` | `Lc` or minimum APDU lenght is incorrect |

Check failure on line 75 in doc/COMMANDS.md

View workflow job for this annotation

GitHub Actions / Check misspellings

lenght ==> length
| 0x6D00 | `SW_INS_NOT_SUPPORTED` | No command exists with `INS` |
| 0x6E00 | `SW_CLA_NOT_SUPPORTED` | Bad `CLA` used for this application |
| 0xB000 | `SW_WRONG_RESPONSE_LENGTH` | Wrong response lenght (buffer size problem) |

Check failure on line 78 in doc/COMMANDS.md

View workflow job for this annotation

GitHub Actions / Check misspellings

lenght ==> length
| 0xB001 | `SW_DISPLAY_BIP32_PATH_FAIL` | BIP32 path conversion to string failed |
| 0xB002 | `SW_DISPLAY_ADDRESS_FAIL` | Address conversion to string failed |
| 0xB003 | `SW_DISPLAY_AMOUNT_FAIL` | Amount conversion to string failed |
| 0xB004 | `SW_WRONG_TX_LENGTH` | Wrong raw transaction lenght |

Check failure on line 82 in doc/COMMANDS.md

View workflow job for this annotation

GitHub Actions / Check misspellings

lenght ==> length
| 0xB005 | `SW_TX_PARSING_FAIL` | Failed to parse raw transaction |
| 0xB006 | `SW_TX_HASH_FAIL` | Failed to compute hash digest of raw transaction |
| 0xB007 | `SW_BAD_STATE` | Security issue with bad state |
| 0xB008 | `SW_SIGNATURE_FAIL` | Signature of raw transaction failed |
| 0x9000 | `OK` | Success |
6 changes: 3 additions & 3 deletions src/address.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

#include "address.h"

#include "common/base58.h"
#include "common/format.h"
#include "base58.h"
#include "format.h"

#include "transaction/types.h"

bool address_from_pubkey(const uint8_t public_key[static 64], uint8_t *out, size_t out_len) {
bool address_from_pubkey(const uint8_t public_key[static 65], uint8_t *out, size_t out_len) {
/*uint8_t address[32] = {0};
cx_sha3_t keccak256;
Expand Down
2 changes: 1 addition & 1 deletion src/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
* @return true if success, false otherwise.
*
*/
bool address_from_pubkey(const uint8_t public_key[static 64], uint8_t *out, size_t out_len);
bool address_from_pubkey(const uint8_t public_key[static 65], uint8_t *out, size_t out_len);
155 changes: 0 additions & 155 deletions src/common/base58.c

This file was deleted.

52 changes: 0 additions & 52 deletions src/common/base58.h

This file was deleted.

Loading

0 comments on commit 44cc4f5

Please sign in to comment.