Skip to content

Commit

Permalink
refactor(metal): reorganize data structure into new types
Browse files Browse the repository at this point in the history
- for better get_constant.metal usage

- Moved BigInt and Jacobian struct definitions to a new types.metal file for better organization.
- Updated bigint.metal to include get_constant.metal instead of constants.metal.
- Removed unused struct definitions from jacobian.metal to streamline the code.
- Enhanced modularity by separating type definitions from function implementations.
  • Loading branch information
moven0831 committed Jan 9, 2025
1 parent 15aa8d5 commit 1556695
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
9 changes: 1 addition & 8 deletions mopro-msm/src/msm/metal_msm/shader/bigint/bigint.metal
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
// source: https://github.com/geometryxyz/msl-secp256k1

using namespace metal;
#include "../constants.metal"
#include "../misc/get_constant.metal"

struct BigInt {
array<uint, NUM_LIMBS> limbs;
};

struct BigIntWide {
array<uint, NUM_LIMBS_WIDE> limbs;
};

BigInt bigint_zero() {
BigInt s;
Expand Down
10 changes: 0 additions & 10 deletions mopro-msm/src/msm/metal_msm/shader/curve/jacobian.metal
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ using namespace metal;
#include <metal_math>
#include "../mont_backend/mont.metal"

struct Jacobian {
BigInt x;
BigInt y;
BigInt z;
};

struct Affine {
BigInt x;
BigInt y;
};

Jacobian jacobian_add_2007_bl(
Jacobian a,
Expand Down
3 changes: 2 additions & 1 deletion mopro-msm/src/msm/metal_msm/shader/misc/get_constant.metal
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using namespace metal;
#include <metal_stdlib>
#include "../bigint/bigint.metal"
#include "../constants.metal"
#include "../misc/types.metal"

BigInt get_mu() {
BigInt mu;
Expand Down
21 changes: 21 additions & 0 deletions mopro-msm/src/msm/metal_msm/shader/misc/types.metal
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using namespace metal;
#include <metal_stdlib>

struct BigInt {
array<uint, NUM_LIMBS> limbs;
};

struct BigIntWide {
array<uint, NUM_LIMBS_WIDE> limbs;
};

struct Jacobian {
BigInt x;
BigInt y;
BigInt z;
};

struct Affine {
BigInt x;
BigInt y;
};

0 comments on commit 1556695

Please sign in to comment.