Skip to content

Commit

Permalink
Add packed attribute for unions; removed unnecessary anonymous struct
Browse files Browse the repository at this point in the history
  • Loading branch information
bigspider committed Jan 10, 2025
1 parent ddbf49e commit bae14c8
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/musig/musig.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ typedef uint8_t xonly_pk_t[32];

// An uncompressed pubkey, encoded as 04||x||y, where x and y are 32-byte big-endian coordinates.
// If the first byte (prefix) is 0, encodes the point at infinity.
typedef struct {
union {
uint8_t raw[65];
struct {
uint8_t prefix; // 0 for the point at infinity, otherwise 4.
uint8_t x[32];
uint8_t y[32];
};
};
typedef union {
uint8_t raw[65];
struct {
uint8_t prefix; // 0 for the point at infinity, otherwise 4.
uint8_t x[32];
uint8_t y[32];
} __attribute__((packed));
} point_t;

typedef struct musig_keyagg_context_s {
Expand All @@ -37,14 +35,12 @@ typedef struct musig_secnonce_s {
uint8_t pk[33];
} musig_secnonce_t;

typedef struct musig_pubnonce_s {
union {
struct {
uint8_t R_s1[33];
uint8_t R_s2[33];
};
uint8_t raw[66];
};
typedef union {
struct {
uint8_t R_s1[33];
uint8_t R_s2[33];
} __attribute__((packed));
uint8_t raw[66];
} musig_pubnonce_t;

typedef struct musig_session_context_s {
Expand Down

0 comments on commit bae14c8

Please sign in to comment.