Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jleni committed May 3, 2024
1 parent eeb91ce commit ea43db2
Show file tree
Hide file tree
Showing 29 changed files with 1,038 additions and 280 deletions.
11 changes: 11 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 120
DerivePointerAlignment: false
PointerAlignment: Right
AllowShortFunctionsOnASingleLine: None
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: true
AcrossComments: false

21 changes: 21 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Checks: "-*,
clang-analyzer-*,
clang-diagnostic-*,
cppcoreguidelines-init-variables,
google-readability-avoid-underscore-in-googletest-name,
google-runtime-int,
misc-*,
performance-*,
portability-*,
readability-*,
-misc-no-recursion,
-readability-function-cognitive-complexity
-readability-magic-numbers"
WarningsAsErrors: "*"
CheckOptions:
- key: readability-identifier-length.MinimumVariableNameLength
value: 2
- key: readability-identifier-length.MinimumParameterNameLength
value: 2
- key: readability-identifier-length.MinimumLoopCounterNameLength
value: 1
16 changes: 0 additions & 16 deletions .editorconfig

This file was deleted.

14 changes: 1 addition & 13 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
[submodule "deps/BLAKE2"]
path = deps/BLAKE2
url = https://github.com/BLAKE2/BLAKE2
[submodule "deps/nanos-secure-sdk"]
path = deps/nanos-secure-sdk
url = https://github.com/LedgerHQ/nanos-secure-sdk.git
[submodule "deps/nanox-secure-sdk"]
path = deps/nanox-secure-sdk
url = https://github.com/LedgerHQ/ledger-secure-sdk.git
[submodule "deps/nanosplus-secure-sdk"]
path = deps/nanosplus-secure-sdk
url = https://github.com/LedgerHQ/ledger-secure-sdk.git
[submodule "deps/ledger-zxlib"]
path = deps/ledger-zxlib
url = https://github.com/Zondax/ledger-zxlib.git
[submodule "deps/stax-secure-sdk"]
path = deps/stax-secure-sdk
url = https://github.com/LedgerHQ/ledger-secure-sdk.git
url = https://github.com/zondax/ledger-zxlib
18 changes: 0 additions & 18 deletions .sonarcloud.properties

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2018-2020 Zondax AG
Copyright 2018-2024 Zondax AG

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#*******************************************************************************
#* (c) 2018 -2022 Zondax AG
#* (c) 2019 - 2024 Zondax AG
#*
#* Licensed under the Apache License, Version 2.0 (the "License");
#* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ bin/app.sha256
bin/app.apdu

\output/app.*
pkg/installer_*.sh
pkg/*.sh
6 changes: 3 additions & 3 deletions app/Makefile.version
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is the major version of this release
APPVERSION_M=3
APPVERSION_M=4
# This is the minor version of this release
APPVERSION_N=3
APPVERSION_N=0
# This is the patch version of this release
APPVERSION_P=6
APPVERSION_P=0
File renamed without changes.
4 changes: 2 additions & 2 deletions app/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Zondax AG <[email protected]>"]
name = "rslib"
version = "0.1.0"
edition = "2018"
edition = "2021"
readme = "README.md"

[lib]
Expand All @@ -18,7 +18,7 @@ binary-ff1 = { version = "0.1.0", default-features = false }
aes = { version = "0.3", default-features = false }
byteorder = { version = "1", default-features = false }
hex = { version = "0.4.2", default-features = false }
nom = { version = "5.1.1", default-features = false }
nom = { version = "5.1", default-features = false }
group = { version = "0.12", default-features = false }

[dependencies.chacha20poly1305]
Expand Down
21 changes: 11 additions & 10 deletions app/src/c_api/rust.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#include <bolos_target.h>
#include <inttypes.h>
#include <zxformat.h>
#include <zxmacros.h>

#include "aes.h"
#include "coin.h"
#include "cx.h"
#include "jubjub.h"
#include "os.h"
#include <bolos_target.h>
#include <inttypes.h>
#include <zxformat.h>
#include <zxmacros.h>
#include "zcash_utils.h"
#include "zxerror.h"

#define CTX_REDJUBJUB "Zcash_RedJubjubH"
#define CTX_REDJUBJUB_LEN 16
#define CTX_REDJUBJUB_HASH_LEN 64
#define CTX_REDJUBJUB "Zcash_RedJubjubH"
#define CTX_REDJUBJUB_LEN 16
#define CTX_REDJUBJUB_HASH_LEN 64

#define CTX_EXPAND_SEED "Zcash_ExpandSeed"
#define CTX_EXPAND_SEED_LEN 16
#define CTX_EXPAND_SEED "Zcash_ExpandSeed"
#define CTX_EXPAND_SEED_LEN 16
#define CTX_EXPAND_SEED_HASH_LEN 64

#include <bolos_target.h>
Expand Down
8 changes: 5 additions & 3 deletions app/src/sighash.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
********************************************************************************/

#include "sighash.h"

#include <zxformat.h>
#include <zxmacros.h>

#include "cx.h"
#include "index_sapling.h"
#include "nvdata.h"
#include "os.h"
#include "txid.h"
#include <zxformat.h>
#include <zxmacros.h>
#include "zcash_utils.h"
#include "zxerror.h"

const uint8_t PERSONALIZATION_SIZE = 16;
const uint8_t ZCASH_PREVOUTS_HASH_PERSONALIZATION[] = "ZcashPrevoutHash";
Expand Down
5 changes: 3 additions & 2 deletions app/src/sighash.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
#pragma once

#include <stdint.h>

#include "zxerror.h"

typedef enum {
transparent = 0,
shielded = 1,
transparent = 0,
shielded = 1,
} signable_input;

zxerr_t sapling_transparent_prevouts_hash(const uint8_t *input, uint8_t *output);
Expand Down
37 changes: 19 additions & 18 deletions app/src/txid.c
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
#include <inttypes.h>
#include <zxformat.h>
#include <zxmacros.h>

#include "constants.h"
#include "cx.h"
#include "index_NU5.h"
#include "index_sapling.h"
#include "nvdata.h"
#include "os.h"
#include "sighash.h"
#include <inttypes.h>
#include <zxformat.h>
#include <zxmacros.h>
#include "zcash_utils.h"
#include "zxerror.h"

#define PERSONALIZATION_SIZE 16

// TxId level 1 node personalization
#define ZCASH_HEADERS_HASH_PERSONALIZATION "ZTxIdHeadersHash"
#define ZCASH_HEADERS_HASH_PERSONALIZATION "ZTxIdHeadersHash"
#define ZCASH_TRANSPARENT_HASH_PERSONALIZATION "ZTxIdTranspaHash"
#define ZCASH_SAPLING_HASH_PERSONALIZATION "ZTxIdSaplingHash"
#define ZCASH_ORCHARD_HASH_PERSONALIZATION "ZTxIdOrchardHash"
#define ZCASH_SAPLING_HASH_PERSONALIZATION "ZTxIdSaplingHash"
#define ZCASH_ORCHARD_HASH_PERSONALIZATION "ZTxIdOrchardHash"

// TxId transparent level 2 node personalization
#define ZCASH_PREVOUTS_HASH_PERSONALIZATION "ZTxIdPrevoutHash"
#define ZCASH_SEQUENCE_HASH_PERSONALIZATION "ZTxIdSequencHash"
#define ZCASH_OUTPUTS_HASH_PERSONALIZATION "ZTxIdOutputsHash"
#define ZCASH_OUTPUTS_HASH_PERSONALIZATION "ZTxIdOutputsHash"

// TxId sapling level 2 node personalization
#define ZCASH_SAPLING_SPENDS_HASH_PERSONALIZATION "ZTxIdSSpendsHash"
#define ZCASH_SAPLING_SPENDS_COMPACT_HASH_PERSONALIZATION "ZTxIdSSpendCHash"
#define ZCASH_SAPLING_SPENDS_NONCOMPACT_HASH_PERSONALIZATION "ZTxIdSSpendNHash"
#define ZCASH_SAPLING_SPENDS_HASH_PERSONALIZATION "ZTxIdSSpendsHash"
#define ZCASH_SAPLING_SPENDS_COMPACT_HASH_PERSONALIZATION "ZTxIdSSpendCHash"
#define ZCASH_SAPLING_SPENDS_NONCOMPACT_HASH_PERSONALIZATION "ZTxIdSSpendNHash"

#define ZCASH_SAPLING_OUTPUTS_HASH_PERSONALIZATION "ZTxIdSOutputHash"
#define ZCASH_SAPLING_OUTPUTS_COMPACT_HASH_PERSONALIZATION "ZTxIdSOutC__Hash"
#define ZCASH_SAPLING_OUTPUTS_MEMOS_HASH_PERSONALIZATION "ZTxIdSOutM__Hash"
#define ZCASH_SAPLING_OUTPUTS_HASH_PERSONALIZATION "ZTxIdSOutputHash"
#define ZCASH_SAPLING_OUTPUTS_COMPACT_HASH_PERSONALIZATION "ZTxIdSOutC__Hash"
#define ZCASH_SAPLING_OUTPUTS_MEMOS_HASH_PERSONALIZATION "ZTxIdSOutM__Hash"
#define ZCASH_SAPLING_OUTPUTS_NONCOMPACT_HASH_PERSONALIZATION "ZTxIdSOutN__Hash"

#define ZCASH_TRANSPARENT_INPUT_HASH_PERSONALIZATION "Zcash___TxInHash"
#define ZCASH_TRANSPARENT_AMOUNTS_HASH_PERSONALIZATION "ZTxTrAmountsHash"
#define ZCASH_TRANSPARENT_SCRIPTS_HASH_PERSONALIZATION "ZTxTrScriptsHash"
#define ZCASH_TRANSPARENT_INPUT_HASH_PERSONALIZATION "Zcash___TxInHash"
#define ZCASH_TRANSPARENT_AMOUNTS_HASH_PERSONALIZATION "ZTxTrAmountsHash"
#define ZCASH_TRANSPARENT_SCRIPTS_HASH_PERSONALIZATION "ZTxTrScriptsHash"

#define SIGHASH_ALL 0x01
#define SIGHASH_ALL 0x01

zxerr_t nu5_transparent_prevouts_hash(const uint8_t *input, uint8_t *output) {
zemu_log_stack("nu5_transparent_prevouts_hash\n");
Expand Down
28 changes: 14 additions & 14 deletions app/src/zcash_apdu_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
#pragma once

// Specific APDU error codes for ZCash
#define APDU_CODE_DATA_TOO_LONG 0x6988
#define APDU_CODE_DATA_TOO_LONG 0x6988
#define APDU_CODE_EXTRACT_TRANSACTION_FAIL 0x6989
#define APDU_CODE_HASH_MSG_BUF_FAIL 0x6990
#define APDU_CODE_UNPROCESSED_TX 0x6991
#define APDU_CODE_PREVOUT_INVALID 0x6992
#define APDU_CODE_SEQUENCE_INVALID 0x6993
#define APDU_CODE_OUTPUTS_INVALID 0x6994
#define APDU_CODE_JOINSPLIT_INVALID 0x6995
#define APDU_CODE_SPEND_INVALID 0x6996
#define APDU_CODE_OUTPUT_CONTENT_INVALID 0x6997
#define APDU_CODE_ENCRYPTION_INVALID 0x6998
#define APDU_CODE_CHECK_SIGN_TR_FAIL 0x6999
#define APDU_SIGN_SPEND_FAIL 0x69A0
#define APDU_CODE_BAD_VALUEBALANCE 0x69A1
#define APDU_CODE_UNHANDLED_TX_VERSION 0x69A2
#define APDU_CODE_HASH_MSG_BUF_FAIL 0x6990
#define APDU_CODE_UNPROCESSED_TX 0x6991
#define APDU_CODE_PREVOUT_INVALID 0x6992
#define APDU_CODE_SEQUENCE_INVALID 0x6993
#define APDU_CODE_OUTPUTS_INVALID 0x6994
#define APDU_CODE_JOINSPLIT_INVALID 0x6995
#define APDU_CODE_SPEND_INVALID 0x6996
#define APDU_CODE_OUTPUT_CONTENT_INVALID 0x6997
#define APDU_CODE_ENCRYPTION_INVALID 0x6998
#define APDU_CODE_CHECK_SIGN_TR_FAIL 0x6999
#define APDU_SIGN_SPEND_FAIL 0x69A0
#define APDU_CODE_BAD_VALUEBALANCE 0x69A1
#define APDU_CODE_UNHANDLED_TX_VERSION 0x69A2
37 changes: 0 additions & 37 deletions app/src/zcash_utils.h

This file was deleted.

1 change: 0 additions & 1 deletion deps/nanos-secure-sdk
Submodule nanos-secure-sdk deleted from 68c5bf
1 change: 0 additions & 1 deletion deps/nanosplus-secure-sdk
Submodule nanosplus-secure-sdk deleted from 212327
1 change: 0 additions & 1 deletion deps/nanox-secure-sdk
Submodule nanox-secure-sdk deleted from 212327
1 change: 0 additions & 1 deletion deps/stax-secure-sdk
Submodule stax-secure-sdk deleted from 212327
Loading

0 comments on commit ea43db2

Please sign in to comment.