From bae14c873feafc98af7a801a11dc62516bd8f2ba Mon Sep 17 00:00:00 2001 From: Salvatore Ingala <6681844+bigspider@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:03:58 +0100 Subject: [PATCH] Add packed attribute for unions; removed unnecessary anonymous struct --- src/musig/musig.h | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/musig/musig.h b/src/musig/musig.h index fd306d5e..9227561f 100644 --- a/src/musig/musig.h +++ b/src/musig/musig.h @@ -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 { @@ -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 {