Skip to content

Commit

Permalink
fix: spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
janmazak committed Feb 27, 2023
1 parent 890a42d commit 44fb5b5
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 29 deletions.
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
1 change: 1 addition & 0 deletions src/base58.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#define MAX_BUFFER_SIZE 124

/* cspell:disable-next-line */
static const char BASE58ALPHABET[] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";

size_t base58_encode(
Expand Down
1 change: 1 addition & 0 deletions src/base58_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void run_base58_test()

{
"82d818582183581ce63175c654dfd93a9290342a067158dc0f57a1108ddbd8cace3839bda0001a0a0e41ce",
/* cspell:disable-next-line */
"Ae2tdPwUPEZKmwoy3AU3cXb5Chnasj6mvVNxV1H11997q3VW5ihbSfQwGpm"
},

Expand Down
1 change: 1 addition & 0 deletions src/bech32.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ uint32_t bech32_polymod_step(uint32_t pre)
(-((b >> 3) & 1) & 0x3d4233ddUL) ^ (-((b >> 4) & 1) & 0x2a1462b3UL);
}

/* cspell:disable-next-line */
static const char* charset = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";

/** Encode a Bech32 string
Expand Down
2 changes: 2 additions & 0 deletions src/bech32_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ void run_bech32_test()
const char* inputBytesHex;
const char* expectedHex;
} testVectors[] = {
/* cspell:disable */
{"a", "", "a12uel5l"},
{"an83characterlonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio", "", "an83characterlonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1tt5tgs"},
{"abcdef", "00443214c74254b635cf84653a56d7c675be77df", "abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw"},
{"1", "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j"},
{"split", "c5f38b70305f519bf66d85fb6cf03058f3dde463ecd7918f2dc743918f2d", "split1checkupstagehandshakeupstreamerranterredcaperred2y9e3w"},
{"addr", "009493315cd92eb5d8c4304e67b7e16ae36d61d34502694657811a2c8e32c728d3861e164cab28cb8f006448139c8f1740ffb8e7aa9e5232dc", "addr1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwqcyl47r"}
/* cspell:enable */
};
ITERATE(it, testVectors) {
testcase_bech32(PTR_PIC(it->hrp), PTR_PIC(it->inputBytesHex), PTR_PIC(it->expectedHex));
Expand Down
2 changes: 1 addition & 1 deletion src/bip44.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ typedef enum {
PATH_ORDINARY_SPENDING_KEY,
PATH_MULTISIG_SPENDING_KEY,

// hd wallet reward adress, withdrawal witness, pool owner
// hd wallet reward address, withdrawal witness, pool owner
PATH_ORDINARY_STAKING_KEY,
PATH_MULTISIG_STAKING_KEY,

Expand Down
2 changes: 1 addition & 1 deletion src/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define H_CARDANO_APP_ERRORS

enum {
// Successfull responses
// Successful responses
SUCCESS = 0x9000,

// Start of error which trigger automatic response
Expand Down
6 changes: 3 additions & 3 deletions src/securityPolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,13 +976,13 @@ security_policy_t policyForSignTxCertificate(

case SIGN_TX_SIGNINGMODE_PLUTUS_TX:
case SIGN_TX_SIGNINGMODE_ORDINARY_TX:
// pool registration is allowed only in POOL_REGISTRATION signging modes
// pool registration is allowed only in POOL_REGISTRATION signing modes
DENY_IF(certificateType == CERTIFICATE_TYPE_STAKE_POOL_REGISTRATION);
ALLOW();
break;

case SIGN_TX_SIGNINGMODE_MULTISIG_TX:
// pool registration is allowed only in POOL_REGISTRATION signging modes
// pool registration is allowed only in POOL_REGISTRATION signing modes
DENY_IF(certificateType == CERTIFICATE_TYPE_STAKE_POOL_REGISTRATION);
// pool retirement is impossible with multisig keys
DENY_IF(certificateType == CERTIFICATE_TYPE_STAKE_POOL_RETIREMENT);
Expand Down Expand Up @@ -1590,7 +1590,7 @@ security_policy_t policyForSignTxMintConfirm(security_policy_t mintInitPolicy)
break;

case POLICY_SHOW_BEFORE_RESPONSE:
// all minted coins were shown, show a final cofirmation prompt as well
// all minted coins were shown, show a final confirmation prompt as well
PROMPT();
break;

Expand Down
4 changes: 2 additions & 2 deletions src/signTx.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ static void signTx_handleInit_ui_runStep()
// technically, no pool reg. certificate as well, but the UI message would be too long
ui_displayPaginatedText(
"Warning:",
"cannot verify network id: no outputs or withrawals",
"cannot verify network id: no outputs or withdrawals",
this_fn
);
}
Expand Down Expand Up @@ -901,7 +901,7 @@ static void constructInputLabel(const char* prefix, uint16_t index)
char* label = BODY_CTX->stageData.input.label;
const size_t labelSize = SIZEOF(BODY_CTX->stageData.input.label);
explicit_bzero(label, labelSize);
// indexed from 0 as agreed with IOHK on Slack
// indexed from 0 as agreed with IOG on Slack
snprintf(label, labelSize, "%s #%u", prefix, index);
// make sure all the information is displayed to the user
ASSERT(strlen(label) + 1 < labelSize);
Expand Down
4 changes: 2 additions & 2 deletions src/signTxMint.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static void signTxMint_handleAssetGroupAPDU(const uint8_t* wireDataBuffer, size_
}

{
// add tokengroup to tx
// add token group to tx
TRACE("Adding token group hash to tx hash");
txHashBuilder_addMint_tokenGroup(
&BODY_CTX->txHashBuilder,
Expand Down Expand Up @@ -312,7 +312,7 @@ static void signTxMint_handleTokenAPDU(const uint8_t* wireDataBuffer, size_t wir
}

{
// add tokengroup to tx
// add token group to tx
TRACE("Adding token group hash to tx hash");
txHashBuilder_addMint_token(
&BODY_CTX->txHashBuilder,
Expand Down
6 changes: 3 additions & 3 deletions src/signTxOutput.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ static void handleCollateralOutput_addressBytes()
.includeRefScript = subctx->includeRefScript,
};

// TODO maybe restric to specific address types? we don't support datum in coll ret outputs
// TODO maybe restrict to specific address types? we don't support datum in coll ret outputs
security_policy_t policy = policyForSignTxCollateralOutputAddressBytes(
&output,
commonTxData->txSigningMode,
Expand Down Expand Up @@ -753,7 +753,7 @@ static void handleAssetGroupAPDU(const uint8_t* wireDataBuffer, size_t wireDataS
VALIDATE(view_remainingSize(&view) == 0, ERR_INVALID_DATA);
}
{
// add tokengroup to tx
// add token group to tx
TRACE("Adding token group hash to tx hash");

switch (ctx->stage) {
Expand Down Expand Up @@ -871,7 +871,7 @@ static void handleTokenAPDU(const uint8_t* wireDataBuffer, size_t wireDataSize)
VALIDATE(view_remainingSize(&view) == 0, ERR_INVALID_DATA);
}
{
// add tokengroup to tx
// add token group to tx
TRACE("Adding token group hash to tx hash");
switch (ctx->stage) {

Expand Down
4 changes: 2 additions & 2 deletions src/signTxPoolRegistration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ static void signTxPoolRegistration_handlePoolMetadataAPDU(const uint8_t* wireDat
{
md->urlSize = view_remainingSize(&view);
VALIDATE(md->urlSize <= POOL_METADATA_URL_LENGTH_MAX, ERR_INVALID_DATA);
STATIC_ASSERT(SIZEOF(md->url) >= POOL_METADATA_URL_LENGTH_MAX, "wrong pool metada url size");
STATIC_ASSERT(SIZEOF(md->url) >= POOL_METADATA_URL_LENGTH_MAX, "wrong pool metadata url size");
view_parseBuffer(md->url, &view, md->urlSize);

// whitespace not allowed
Expand Down Expand Up @@ -1334,7 +1334,7 @@ static void signTxPoolRegistration_handleConfirm_ui_runStep()

UI_STEP_BEGIN(subctx->ui_step, this_fn);

// we display potencially suspicious facts about the certificate
// we display potentially suspicious facts about the certificate
// that have not been explicitly shown to the user before:
// missing owners or relays
UI_STEP(HANDLE_CONFIRM_STEP_FINAL_NO_OWNERS) {
Expand Down
1 change: 1 addition & 0 deletions src/textUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ bool str_isAllowedDnsName(const uint8_t* buffer, size_t bufferSize)

#ifdef DEVEL

/* cspell:disable-next-line */
// converts a text to bytes (suitable for CBORization) and validates if chars are allowed
size_t str_textToBuffer(const char* text, uint8_t* buffer, size_t bufferSize)
{
Expand Down
22 changes: 11 additions & 11 deletions src/tokens_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ typedef struct {
char expectedMint[50];
} token_testcase_t;

const token_testcase_t tokenTestcases[] = {
const token_testcase_t tokenTestCases[] = {
{
{ 0x94, 0xcb, 0xb4, 0xfc, 0xbc, 0xaa, 0x29, 0x75, 0x77, 0x9f, 0x27, 0x3b, 0x26, 0x3e, 0xb3, 0xb5, 0xf2, 0x4a, 0x99, 0x51, 0xe4, 0x46, 0xd6, 0xdc, 0x4c, 0x13, 0x58, 0x64 },
{ 0x52, 0x45, 0x56, 0x55 },
4,
234,
"0.00000234 REVU",
"0.00000234 REVU", // cspell:disable-line
-234,
"-0.00000234 REVU"
"-0.00000234 REVU" // cspell:disable-line
},
{
// no decimal places in our table
Expand All @@ -96,26 +96,26 @@ const token_testcase_t tokenTestcases[] = {

void test_decimalPlaces()
{
for (size_t i = 0; i < ARRAY_LEN(tokenTestcases); i++) {
for (size_t i = 0; i < ARRAY_LEN(tokenTestCases); i++) {
char tokenAmountStr[60];
token_group_t group;
memcpy(group.policyId, tokenTestcases[i].policyId, MINTING_POLICY_ID_SIZE);
memcpy(group.policyId, tokenTestCases[i].policyId, MINTING_POLICY_ID_SIZE);

str_formatTokenAmountOutput(
&group,
tokenTestcases[i].assetNameBytes, tokenTestcases[i].assetNameSize,
tokenTestcases[i].amountOutput,
tokenTestCases[i].assetNameBytes, tokenTestCases[i].assetNameSize,
tokenTestCases[i].amountOutput,
tokenAmountStr, SIZEOF(tokenAmountStr)
);
EXPECT_EQ(strcmp(tokenAmountStr, tokenTestcases[i].expectedOutput), 0);
EXPECT_EQ(strcmp(tokenAmountStr, tokenTestCases[i].expectedOutput), 0);

str_formatTokenAmountMint(
&group,
tokenTestcases[i].assetNameBytes, tokenTestcases[i].assetNameSize,
tokenTestcases[i].amountMint,
tokenTestCases[i].assetNameBytes, tokenTestCases[i].assetNameSize,
tokenTestCases[i].amountMint,
tokenAmountStr, SIZEOF(tokenAmountStr)
);
EXPECT_EQ(strcmp(tokenAmountStr, tokenTestcases[i].expectedMint), 0);
EXPECT_EQ(strcmp(tokenAmountStr, tokenTestCases[i].expectedMint), 0);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/txHashBuilder.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static void addTokenGroup(
{
// Bytes[policyId]
// Map(numTokens)[
// // entries added later { * asset_name => auint }
// // entries added later { * asset_name => uint }
// ]
{
BUILDER_APPEND_CBOR(CBOR_TYPE_BYTES, policyIdSize);
Expand Down Expand Up @@ -474,7 +474,7 @@ static void addToken(
ASSERT(assetNameSize <= ASSET_NAME_SIZE_MAX);
{
// add a map entry:
// Bytes[assetname]
// Bytes[asset_name]
// Unsigned[Amount]
{
BUILDER_APPEND_CBOR(CBOR_TYPE_BYTES, assetNameSize);
Expand Down
3 changes: 2 additions & 1 deletion src/txHashBuilder_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ static void addPoolRegistrationCertificate(tx_hash_builder_t* builder)
pool_relay_t relay1;
relay1.format = 1;
relay1.port.isNull = true;
// a valid DNS AAAA record, since dnsName actually is suppposed to be an A or AAAA record
// a valid DNS AAAA record, since dnsName actually is supposed to be an A or AAAA record
const char* dnsName = "AAAA 2400:cb00:2049:1::a29f:1804";
relay1.dnsNameSize = str_textToBuffer(dnsName, relay1.dnsName, SIZEOF(relay1.dnsName));
txHashBuilder_addPoolRegistrationCertificate_addRelay(builder, &relay1);
Expand Down Expand Up @@ -499,6 +499,7 @@ void run_txHashBuilder_test()
}
// ? 7 : auxiliary_data_hash
{
/* cspell:disable-next-line */
const char auxDataHashHex[] = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
uint8_t tmp[AUX_DATA_HASH_LENGTH] = {0};
size_t tmpSize = decode_hex(auxDataHashHex, tmp, SIZEOF(tmp));
Expand Down

0 comments on commit 44fb5b5

Please sign in to comment.