Skip to content

Commit

Permalink
Merge pull request #617 from Cypherock/feat/starknet/refactored/sign-txn
Browse files Browse the repository at this point in the history
  • Loading branch information
TejasvOnly authored Jan 8, 2025
2 parents bf7396f + d99c888 commit 44a4e78
Show file tree
Hide file tree
Showing 21 changed files with 1,574 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
fail-fast: false
matrix:
firmware: [main]
target: [release, dev]
target: [release]
platform: [device, simulator]
runs-on: ubuntu-latest

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "mini-gmp"]
path = vendor/mini-gmp
url = ../mini-gmp
[submodule "poseidon"]
path = vendor/poseidon
url = ../poseidon
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ file(GLOB_RECURSE PROTO_SRCS "generated/proto/*.*")
list(APPEND PROTO_SRCS "vendor/nanopb/pb_common.c" "vendor/nanopb/pb_decode.c" "vendor/nanopb/pb_encode.c" "vendor/nanopb/pb_common.h" "vendor/nanopb/pb_decode.h" "vendor/nanopb/pb_encode.h" "vendor/nanopb/pb.h")

list (APPEND MINI_GMP_SRCS "vendor/mini-gmp/mini-gmp-helpers.c" "vendor/mini-gmp/mini-gmp.c")
list (APPEND POSEIDON_SRCS "vendor/poseidon/sources/f251.c" "vendor/poseidon/sources/poseidon.c" "vendor/poseidon/sources/poseidon_rc.c")

OPTION(DEV_SWITCH "Additional features/logs to aid developers" OFF)
OPTION(UNIT_TESTS_SWITCH "Compile build for main firmware or unit tests" OFF)
Expand All @@ -51,7 +52,7 @@ else()
endif()

# Include nanopb source headers
target_include_directories( ${EXECUTABLE} PRIVATE vendor/nanopb generated/proto vendor/mini-gmp)
target_include_directories( ${EXECUTABLE} PRIVATE vendor/nanopb generated/proto vendor/mini-gmp vendor/poseidon/sources)

# Enable support for dynamically allocated fields in nanopb
# Ref: vendor/nanopb/pb.h
Expand Down
2 changes: 2 additions & 0 deletions apps/starknet_app/starknet_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
/// this makes length of 5 with a termination NULL byte
#define STARKNET_LONG_NAME_MAX_SIZE 9

#define STARKNET_BIGNUM_SIZE 32

/*****************************************************************************
* TYPEDEFS
*****************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion apps/starknet_app/starknet_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void starknet_main(usb_event_t usb_evt, const void *app_config) {
break;
}
case STARKNET_QUERY_SIGN_TXN_TAG: {
// starknet_sign_transaction(&query);
starknet_sign_transaction(&query);
break;
}

Expand Down
1 change: 1 addition & 0 deletions apps/starknet_app/starknet_pedersen.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

#include "coin_utils.h"
#include "mini-gmp-helpers.h"
#include "starknet_context.h"
#include "starknet_helpers.h"

/*****************************************************************************
Expand Down
3 changes: 1 addition & 2 deletions apps/starknet_app/starknet_pedersen.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include <stdint.h>

#include "mpz_pedersen.h"
#include "starknet_context.h"

/*****************************************************************************
* EXTERN VARIABLES
Expand All @@ -76,8 +77,6 @@
#define LOW_PART_BYTES (LOW_PART_BITS / 8)
#define LOW_PART_MASK ((1ULL << LOW_PART_BITS) - 1)

#define STARKNET_BIGNUM_SIZE \
32 ///< Max byte size of a bignum in starknet context
#define PEDERSEN_HASH_SIZE 32

#define CALL_DATA_PARAMETER_SIZE 3
Expand Down
Loading

0 comments on commit 44a4e78

Please sign in to comment.