Skip to content

Commit

Permalink
add cmake option to reduce size
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-jentzsch committed Dec 30, 2019
1 parent 0415855 commit 0200572
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ OPTION(ETH_NANO "build minimal eth verification.(eth_getTransactionReceipt)" ON)
OPTION(ETH_BASIC "build basic eth verification.(all rpc-calls except eth_call)" ON)
OPTION(ETH_FULL "build full eth verification.(including eth_call)" ON)
OPTION(IN3API "build the USN-API which offer better interfaces and additional functions on top of the pure verification" ON)
OPTION(USE_PRECOMPUTED_EC "if true the secp256k1 curve uses precompiled tables to boost performance. turning this off makes ecrecover slower, but saves about 37kb." ON)

if (USE_PRECOMPUTED_EC)
ADD_DEFINITIONS(-DUSE_PRECOMPUTED_CP=1)
else()
ADD_DEFINITIONS(-DUSE_PRECOMPUTED_CP=0)
endif()
if(ETH_FULL)
ADD_DEFINITIONS(-DETH_FULL)
set(IN3_VERIFIER eth_full)
Expand Down
7 changes: 7 additions & 0 deletions docs/1_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ Default-Value: `-DTRANSPORTS=ON`
Default-Value: `-DUSE_CURL=ON`


#### USE_PRECOMPUTED_EC

if true the secp256k1 curve uses precompiled tables to boost performance. turning this off makes ecrecover slower, but saves about 37kb.

Default-Value: `-DUSE_PRECOMPUTED_EC=ON`


#### USE_SCRYPT

if scrypt is installed, it will link dynamicly to the shared scrypt lib.
Expand Down
12 changes: 6 additions & 6 deletions include/in3/bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ typedef struct {
bytes_t b; /**< the bytes struct */
} bytes_builder_t;

bytes_t* b_new(char* data, int len); /**< allocates a new byte array with 0 filled */
void b_print(bytes_t* a); /**< prints a the bytes as hex to stdout */
void ba_print(uint8_t* a, size_t l); /**< prints a the bytes as hex to stdout */
int b_cmp(bytes_t* a, bytes_t* b); /**< compares 2 byte arrays and returns 1 for equal and 0 for not equal*/
int bytes_cmp(bytes_t a, bytes_t b); /**< compares 2 byte arrays and returns 1 for equal and 0 for not equal*/
bytes_t* b_new(const char* data, int len); /**< allocates a new byte array with 0 filled */
void b_print(const bytes_t* a); /**< prints a the bytes as hex to stdout */
void ba_print(const uint8_t* a, size_t l); /**< prints a the bytes as hex to stdout */
int b_cmp(const bytes_t* a, const bytes_t* b); /**< compares 2 byte arrays and returns 1 for equal and 0 for not equal*/
int bytes_cmp(const bytes_t a, const bytes_t b); /**< compares 2 byte arrays and returns 1 for equal and 0 for not equal*/
void b_free(bytes_t* a); /**< frees the data */
bytes_t* b_dup(bytes_t* a); /**< clones a byte array*/
bytes_t* b_dup(const bytes_t* a); /**< clones a byte array*/
uint8_t b_read_byte(bytes_t* b, size_t* pos); /**< reads a byte on the current position and updates the pos afterwards. */
uint32_t b_read_int(bytes_t* b, size_t* pos); /**< reads a integer on the current position and updates the pos afterwards. */
uint64_t b_read_long(bytes_t* b, size_t* pos); /**< reads a long on the current position and updates the pos afterwards. */
Expand Down
6 changes: 3 additions & 3 deletions include/in3/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ d_token_t* d_get_at(d_token_t* item, const uint32_t index);
d_token_t* d_next(d_token_t* item); /**< returns the next sibling of an array or object */

void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */
json_ctx_t* parse_binary(bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */
json_ctx_t* parse_binary_str(char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */
json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */
json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */
json_ctx_t* parse_json(char* js); /**< parses json-data, which needs to be freed after usage! */
void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */
str_range_t d_to_json(d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */
str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */
char* d_create_json(d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/

json_ctx_t* json_create();
Expand Down
4 changes: 2 additions & 2 deletions include/in3/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bytes_t* hex_to_new_bytes(const char* buf, int len);
int bytes_to_hex(const uint8_t* buffer, int len, char* out);

/** hashes the bytes and creates a new bytes_t */
bytes_t* sha3(bytes_t* data);
bytes_t* sha3(const bytes_t* data);

/** writes 32 bytes to the pointer. */
int sha3_to(bytes_t* data, void* dst);
Expand All @@ -116,7 +116,7 @@ void long_to_bytes(uint64_t val, uint8_t* dst);
void int_to_bytes(uint32_t val, uint8_t* dst);

/** duplicate the string */
char* _strdupn(char* src, int len);
char* _strdupn(const char* src, int len);

/** calculate the min number of byte to represents the len */
int min_bytes_len(uint64_t val);
Expand Down

0 comments on commit 0200572

Please sign in to comment.