Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addition of native tokens, refactoring according to CIP-36 changes #34

Merged
merged 5 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ledger
bin
build
debug
dep
obj
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [6.0.2](TBD) - [TBD]
## [6.0.3](TBD) - [TBD]

Support for CIP-36 voting

Expand Down
81 changes: 0 additions & 81 deletions Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
APPNAME = "Cardano ADA"
APPVERSION_M = 6
APPVERSION_N = 0
APPVERSION_P = 2
APPVERSION_P = 3
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

ifeq ($(BOLOS_SDK),)
Expand Down Expand Up @@ -176,7 +176,7 @@ seed:
##############

format:
astyle --options=.astylerc "src/*.h" "src/*.c" --exclude=src/glyphs.h --exclude=src/glyphs.c
astyle --options=.astylerc "src/*.h" "src/*.c" --exclude=src/glyphs.h --exclude=src/glyphs.c --ignore-exclude-errors


##############
Expand Down
8 changes: 3 additions & 5 deletions doc/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
## Dependencies

- Install Docker
- Update [Dockerfile](../Dockerfile) if needed: check /~https://github.com/LedgerHQ/ledger-app-builder/blob/master/Dockerfile.
- Create Docker image

`docker build -t ledger-app-builder-cardano:latest .`
- Pull the required containers as discussed in /~https://github.com/LedgerHQ/ledger-app-builder/ (lite container is sufficient for a C build):

`sudo docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest`

## Compiling the app

Expand All @@ -19,7 +17,7 @@ Based on https://developers.ledger.com/docs/nano-app/build/.

- Create container with the image

`docker run --rm -ti -v "$(realpath .):/app" ledger-app-builder-cardano:latest`
`docker run --rm -ti -v "$(realpath .):/app" --user $(id -u $USER):$(id -g $USER) ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest`

- Run make commands

Expand Down
10 changes: 5 additions & 5 deletions doc/ins_sign_cip36_registration.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CIP36 Voting Key Registration
# CIP36 Vote Key Registration

## Description

Expand Down Expand Up @@ -34,7 +34,7 @@ P2 = `0x36`

---

**Voting key**
**Vote key**

A single APDU with voting key is sent if the number of delegations specified in the init APDU is 0 (otherwise no such APDU is allowed).

Expand All @@ -45,7 +45,7 @@ P2 = `0x30`
|Field| Length | Comments|
|-----|--------|---------|
|Key type | 1 | 0x01 or 0x02 if a 32-byte key or its derivation path follows |
|Voting public key: bytestring or BIP44 derivation path | | (depends on previous line) |
|Vote public key: bytestring or BIP44 derivation path | | (depends on previous line) |


**Delegation**
Expand All @@ -59,7 +59,7 @@ P2 = `0x37`
|Field| Length | Comments|
|-----|--------|---------|
|Key type | 1 | 0x01 or 0x02 if a 32-byte key or its derivation path follows |
|Voting public key: bytestring or BIP44 derivation path | | (depends on previous line) |
|Vote public key: bytestring or BIP44 derivation path | | (depends on previous line) |
|Weight | 4 | big endian |

---
Expand All @@ -76,7 +76,7 @@ P2 = `0x31`

---

**Voting rewards address**
**Voting rewards payment address**

P2 = `0x32`

Expand Down
4 changes: 2 additions & 2 deletions doc/ins_sign_tx.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ So only the hash is transferred and displayed and the user has to use other mean
| Auxiliary data type | 1 | `AUX_DATA_TYPE_ARBITRARY_HASH=0x00` |
| Auxiliary data hash | 32 | |

**Data for AUX_DATA_TYPE_CIP36_REGISTRATION**
**Data for AUX_DATA_TYPE_CVOTE_REGISTRATION**

|Field| Length | Comments|
|-----|--------|---------|
| Auxiliary data type | 1 | `AUX_DATA_TYPE_CIP36_REGISTRATION=0x01` |
| Auxiliary data type | 1 | `AUX_DATA_TYPE_CVOTE_REGISTRATION=0x01` |

This only describes the initial message. All the data for this type of auxiliary data are obtained via a series of additional APDU messages; see [CIP-36 Voting Registration](ins_sign_cip36_registration.md) for the details.

Expand Down
2 changes: 1 addition & 1 deletion fuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ set(SOURCES
../src/signTxOutput.c
../src/state.c
../src/signTxPoolRegistration.c
../src/signTxGovernanceVotingRegistration.c
../src/signTxCVoteRegistration.c
../src/signTxUtils.c
../src/textUtils.c
../src/txHashBuilder.c
Expand Down
2 changes: 1 addition & 1 deletion src/addressUtilsByron.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ size_t cborEncodePubkeyAddressInner(
if (protocolMagic == MAINNET_PROTOCOL_MAGIC) {
view_appendToken(&out, CBOR_TYPE_MAP, 0 /* addrAttributes is empty */);
} else {
/* addrAddtributes contains protocol magic for non-mainnet Byron addresses */
/* addrAttributes contains protocol magic for non-mainnet Byron addresses */
view_appendToken(&out, CBOR_TYPE_MAP, 1);
{
view_appendToken(&out, CBOR_TYPE_UNSIGNED, PROTOCOL_MAGIC_ADDRESS_ATTRIBUTE_KEY); /* map key for protocol magic */
Expand Down
9 changes: 9 additions & 0 deletions src/addressUtilsShelley_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,35 +126,41 @@ static void testAddressDerivation()
BASE_PAYMENT_KEY_STAKE_KEY, 0x03, (HD + 1852, HD + 1815, HD + 0, 0, 1),
STAKING_KEY_PATH, (HD + 1852, HD + 1815, HD + 0, 2, 0), NO_STAKING_KEY_HASH,
"035a53103829a7382c2ab76111fb69f13e69d616824c62058e44f1a8b31d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c"
/* cspell:disable-next-line */
// bech32: addr1qdd9xypc9xnnstp2kas3r7mf7ylxn4sksfxxypvwgnc63vcayfawlf9hwv2fzuygt2km5v92kvf8e3s3mk7ynxw77cwqdquehe
);
TESTCASE(
BASE_PAYMENT_KEY_STAKE_KEY, 0x00, (HD + 1852, HD + 1815, HD + 0, 0, 1),
STAKING_KEY_PATH, (HD + 1852, HD + 1815, HD + 0, 2, 0), NO_STAKING_KEY_HASH,
"005a53103829a7382c2ab76111fb69f13e69d616824c62058e44f1a8b31d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c"
/* cspell:disable-next-line */
// bech32: addr1qpd9xypc9xnnstp2kas3r7mf7ylxn4sksfxxypvwgnc63vcayfawlf9hwv2fzuygt2km5v92kvf8e3s3mk7ynxw77cwqhn8sgh
);
TESTCASE(
BASE_PAYMENT_KEY_STAKE_KEY, 0x00, (HD + 1852, HD + 1815, HD + 0, 0, 1),
STAKING_KEY_HASH, NO_STAKING_KEY_PATH, "1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c",
"005a53103829a7382c2ab76111fb69f13e69d616824c62058e44f1a8b31d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c"
/* cspell:disable-next-line */
// bech32: addr1qpd9xypc9xnnstp2kas3r7mf7ylxn4sksfxxypvwgnc63vcayfawlf9hwv2fzuygt2km5v92kvf8e3s3mk7ynxw77cwqhn8sgh
);
TESTCASE(
BASE_PAYMENT_KEY_STAKE_KEY, 0x03, (HD + 1852, HD + 1815, HD + 0, 0, 1),
STAKING_KEY_HASH, NO_STAKING_KEY_PATH, "122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277",
"035a53103829a7382c2ab76111fb69f13e69d616824c62058e44f1a8b3122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277"
/* cspell:disable-next-line */
// bech32: addr1qdd9xypc9xnnstp2kas3r7mf7ylxn4sksfxxypvwgnc63vcj922xhxkn6twlq2wn4q50q352annk3903tj00h45mgfmswz93l5
);

TESTCASE(
ENTERPRISE_KEY, 0x00, (HD + 1852, HD + 1815, HD + 0, 0, 1), NO_STAKING, NO_STAKING_KEY_PATH, NO_STAKING_KEY_HASH,
"605a53103829a7382c2ab76111fb69f13e69d616824c62058e44f1a8b3"
/* cspell:disable-next-line */
// bech32: addr1vpd9xypc9xnnstp2kas3r7mf7ylxn4sksfxxypvwgnc63vc93wyej
);
TESTCASE(
ENTERPRISE_KEY, 0x03, (HD + 1852, HD + 1815, HD + 0, 0, 1), NO_STAKING, NO_STAKING_KEY_PATH, NO_STAKING_KEY_HASH,
"635a53103829a7382c2ab76111fb69f13e69d616824c62058e44f1a8b3"
/* cspell:disable-next-line */
// bech32: addr1vdd9xypc9xnnstp2kas3r7mf7ylxn4sksfxxypvwgnc63vc9wh7em
);

Expand All @@ -172,16 +178,19 @@ static void testAddressDerivation()
TESTCASE_POINTER(
POINTER_KEY, 0x00, (HD + 1852, HD + 1815, HD + 0, 0, 1), (1, 2, 3),
"405a53103829a7382c2ab76111fb69f13e69d616824c62058e44f1a8b3010203"
/* cspell:disable-next-line */
// bech32: addr1gpd9xypc9xnnstp2kas3r7mf7ylxn4sksfxxypvwgnc63vcpqgpsh506pr
);
TESTCASE_POINTER(
POINTER_KEY, 0x03, (HD + 1852, HD + 1815, HD + 0, 0, 1), (24157, 177, 42),
"435a53103829a7382c2ab76111fb69f13e69d616824c62058e44f1a8b381bc5d81312a"
/* cspell:disable-next-line */
// bech32: addr1gdd9xypc9xnnstp2kas3r7mf7ylxn4sksfxxypvwgnc63vuph3wczvf288aeyu
);
TESTCASE_POINTER(
POINTER_KEY, 0x03, (HD + 1852, HD + 1815, HD + 0, 0, 1), (0, 0, 0),
"435a53103829a7382c2ab76111fb69f13e69d616824c62058e44f1a8b3000000"
/* cspell:disable-next-line */
// bech32: addr1gdd9xypc9xnnstp2kas3r7mf7ylxn4sksfxxypvwgnc63vcqqqqqnnd32q
);

Expand Down
Loading