Skip to content

Commit

Permalink
unify key length defines
Browse files Browse the repository at this point in the history
  • Loading branch information
mkv-vcm committed Oct 11, 2021
1 parent 879221b commit 4d75bf4
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/cardano.h
Expand Up @@ -3,6 +3,7 @@

#include "common.h"
#include "bip44.h"
#include "keyDerivation.h"

// Just a trick to make the numbers readable
#define __CONCAT4(A,B,C,D) A ## B ## C ## D
Expand All @@ -23,7 +24,6 @@ STATIC_ASSERT(LOVELACE_MAX_SUPPLY < LOVELACE_INVALID, "bad LOVELACE_INVALID");
#define SCRIPT_HASH_LENGTH 28
#define SCRIPT_DATA_HASH_LENGTH 32
#define OUTPUT_DATUM_HASH_LENGTH 32
#define VKEY_LENGTH 32

#define MINTING_POLICY_ID_SIZE 28
#define ASSET_NAME_SIZE_MAX 32
Expand Down
1 change: 0 additions & 1 deletion src/keyDerivation.h
Expand Up @@ -5,7 +5,6 @@
#include "handlers.h"
#include "bip44.h"


#define PUBLIC_KEY_SIZE (32)
#define CHAIN_CODE_SIZE (32)
#define EXTENDED_PUBKEY_SIZE (CHAIN_CODE_SIZE + PUBLIC_KEY_SIZE)
Expand Down
4 changes: 2 additions & 2 deletions src/signTx.c
Expand Up @@ -1830,8 +1830,8 @@ static void signTx_handleRequiredSignerAPDU(uint8_t p2, uint8_t* wireDataBuffer,
TRACE_BUFFER(wireDataBuffer, wireDataSize);

read_view_t view = make_read_view(wireDataBuffer, wireDataBuffer + wireDataSize);
STATIC_ASSERT(SIZEOF(BODY_CTX->stageData.requiredSigner) == VKEY_LENGTH, "wrong vkey length");
view_copyWireToBuffer(BODY_CTX->stageData.requiredSigner, &view, VKEY_LENGTH);
STATIC_ASSERT(SIZEOF(BODY_CTX->stageData.requiredSigner) == PUBLIC_KEY_SIZE, "wrong vkey length");
view_copyWireToBuffer(BODY_CTX->stageData.requiredSigner, &view, PUBLIC_KEY_SIZE);
VALIDATE(view_remainingSize(&view) == 0, ERR_INVALID_DATA);
}

Expand Down
2 changes: 1 addition & 1 deletion src/signTx.h
Expand Up @@ -134,7 +134,7 @@ typedef struct {
uint64_t validityIntervalStart;
uint8_t scriptDataHash[SCRIPT_DATA_HASH_LENGTH];
sign_tx_transaction_input_t collateral;
uint8_t requiredSigner[VKEY_LENGTH];
uint8_t requiredSigner[PUBLIC_KEY_SIZE];
} stageData; // TODO rename to reflect single-APDU scope

union {
Expand Down
2 changes: 1 addition & 1 deletion src/txHashBuilder.c
Expand Up @@ -1355,7 +1355,7 @@ void txHashBuilder_addRequiredSigner(
// Unsigned[index]
// ]
{
ASSERT(vkeySize == VKEY_LENGTH);
ASSERT(vkeySize == PUBLIC_KEY_SIZE);
BUILDER_APPEND_CBOR(CBOR_TYPE_BYTES, vkeySize);
BUILDER_APPEND_DATA(vkeyBuffer, vkeySize);
}
Expand Down

0 comments on commit 4d75bf4

Please sign in to comment.