Skip to content

Commit

Permalink
Remove unused big uint utilities from plugin sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeutin-ledger committed Jan 18, 2024
1 parent 0deb948 commit fb19951
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/stark_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "shared_context.h"
#include "stark_utils.h"
#include "uint256.h"
#include "common_utils.h"

extraInfo_t *getKnownToken(uint8_t *contractAddress);
Expand Down
18 changes: 18 additions & 0 deletions src_common/uint128.c → src/uint128.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,21 @@ bool tostring128_signed(const uint128_t *const number,
}
return tostring128(number, base, out, out_length); // positive value
}

void convertUint64BEto128(const uint8_t *const data, uint32_t length, uint128_t *const target) {
uint8_t tmp[INT128_LENGTH];
int64_t value;

value = u64_from_BE(data, length);
memset(tmp, ((value < 0) ? 0xff : 0), sizeof(tmp) - length);
memmove(tmp + sizeof(tmp) - length, data, length);
readu128BE(tmp, target);
}

void convertUint128BE(const uint8_t *const data, uint32_t length, uint128_t *const target) {
uint8_t tmp[INT128_LENGTH];

memset(tmp, 0, sizeof(tmp) - length);
memmove(tmp + sizeof(tmp) - length, data, length);
readu128BE(tmp, target);
}
2 changes: 2 additions & 0 deletions src_common/uint128.h → src/uint128.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@ bool tostring128_signed(const uint128_t *const number,
uint32_t base,
char *const out,
uint32_t out_length);
void convertUint64BEto128(const uint8_t *const data, uint32_t length, uint128_t *const target);
void convertUint128BE(const uint8_t *const data, uint32_t length, uint128_t *const target);

#endif // _UINT128_H_
8 changes: 8 additions & 0 deletions src_common/uint256.c → src/uint256.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,11 @@ bool tostring256_signed(const uint256_t *const number,
}
return tostring256(number, base, out, out_length); // positive value
}

void convertUint256BE(const uint8_t *const data, uint32_t length, uint256_t *const target) {
uint8_t tmp[INT256_LENGTH];

memset(tmp, 0, sizeof(tmp) - length);
memmove(tmp + sizeof(tmp) - length, data, length);
readu256BE(tmp, target);
}
1 change: 1 addition & 0 deletions src_common/uint256.h → src/uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ bool tostring256_signed(const uint256_t *const number,
uint32_t base,
char *const out,
uint32_t out_length);
void convertUint256BE(const uint8_t *const data, uint32_t length, uint256_t *const target);

#endif // _UINT256_H_
File renamed without changes.
File renamed without changes.
28 changes: 0 additions & 28 deletions src_common/common_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include <stdint.h>
#include <string.h>

#include "uint128.h"
#include "uint256.h"
#include "asset_info.h"
#include "common_utils.h"

Expand All @@ -32,32 +30,6 @@ void array_hexstr(char *strbuf, const void *bin, unsigned int len) {
*strbuf = 0; // EOS
}

void convertUint64BEto128(const uint8_t *const data, uint32_t length, uint128_t *const target) {
uint8_t tmp[INT128_LENGTH];
int64_t value;

value = u64_from_BE(data, length);
memset(tmp, ((value < 0) ? 0xff : 0), sizeof(tmp) - length);
memmove(tmp + sizeof(tmp) - length, data, length);
readu128BE(tmp, target);
}

void convertUint128BE(const uint8_t *const data, uint32_t length, uint128_t *const target) {
uint8_t tmp[INT128_LENGTH];

memset(tmp, 0, sizeof(tmp) - length);
memmove(tmp + sizeof(tmp) - length, data, length);
readu128BE(tmp, target);
}

void convertUint256BE(const uint8_t *const data, uint32_t length, uint256_t *const target) {
uint8_t tmp[INT256_LENGTH];

memset(tmp, 0, sizeof(tmp) - length);
memmove(tmp + sizeof(tmp) - length, data, length);
readu256BE(tmp, target);
}

uint64_t u64_from_BE(const uint8_t *in, uint8_t size) {
uint8_t i = 0;
uint64_t res = 0;
Expand Down
5 changes: 0 additions & 5 deletions src_common/common_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "os.h"
#include "cx.h"
#include "uint256.h"

#define WEI_TO_ETHER 18

Expand All @@ -38,10 +37,6 @@ static const char HEXDIGITS[] = "0123456789abcdef";

void array_hexstr(char *strbuf, const void *bin, unsigned int len);

void convertUint128BE(const uint8_t *const data, uint32_t length, uint128_t *const target);
void convertUint256BE(const uint8_t *const data, uint32_t length, uint256_t *const target);
void convertUint64BEto128(const uint8_t *const data, uint32_t length, uint128_t *const target);

uint64_t u64_from_BE(const uint8_t *in, uint8_t size);

bool u64_to_string(uint64_t src, char *dst, uint8_t dst_size);
Expand Down
3 changes: 0 additions & 3 deletions src_common/eth_plugin_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#include "common_utils.h"
#include "plugin_utils.h"
#include "tx_content.h"
#include "uint128.h"
#include "uint256.h"
#include "uint_common.h"

/*************************************************************************************************
* Comments provided in this file are quick reminders on the usage of the plugin interface *
Expand Down
1 change: 1 addition & 0 deletions src_features/signTx/logic_signTx.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifdef HAVE_STARKWARE
#include "stark_utils.h"
#endif
#include "uint256.h"
#include "eth_plugin_handler.h"
#include "network.h"
#include "common_ui.h"
Expand Down
1 change: 1 addition & 0 deletions src_plugins/starkware/starkware_plugin.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <string.h>
#include "os_io_seproxyhal.h"
#include "uint256.h"
#include "eth_plugin_interface.h"
#include "shared_context.h" // TODO : rewrite as independant code
#include "eth_plugin_internal.h" // TODO : rewrite as independant code
Expand Down

0 comments on commit fb19951

Please sign in to comment.