File: workaround.c

package info (click to toggle)
opaque-store 0.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 404 kB
  • sloc: python: 599; ansic: 23; makefile: 16
file content (22 lines) | stat: -rw-r--r-- 680 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "oprf/tp-dkg.h"
#include "oprf/toprf.h"
#include <stdlib.h>
#include <string.h>

// zig cannot align data at 64Byte (or anything beyond 16 bytes really)
// see https://github.com/ziglang/zig/issues/8452

// thus we have to workaround this by allocating/freeing and accessing
// the data in c which the zig cc backend (clang) handles correctly.
TP_DKG_PeerState* new_peerstate(void) {
  return aligned_alloc(64,sizeof(TP_DKG_PeerState));
}

void extract_share(const TP_DKG_PeerState *ctx, uint8_t share[TOPRF_Share_BYTES]) {
  memcpy(share, &ctx->share, TOPRF_Share_BYTES);
}

void del_peerstate(TP_DKG_PeerState **peer) {
  if(*peer!=NULL) free(*peer);
  *peer = NULL;
}