Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • a3483c2
  • /
  • bikel3
  • /
  • m4f
  • /
  • types.h
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:5bc89ba5b77e1c518120550c3532042c2b3e7f85
directory badge Iframe embedding
swh:1:dir:03923b55962c2e735997636bb556c266f41a3493
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
types.h
/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0"
 *
 * Written by Nir Drucker, Shay Gueron and Dusan Kostic,
 * AWS Cryptographic Algorithms Group.
 *
 * Modification: 2021 Ming-Shing Chen, Tung Chou, and Markus Krausz
 *
 */

#pragma once

#include <stddef.h>
#include <stdint.h>

#include "bike_defs.h"
#include "error.h"

typedef struct uint128_s {
  union {
    uint8_t  bytes[16]; // NOLINT
    uint32_t dw[4];     // NOLINT
    uint64_t qw[2];     // NOLINT
  } u;
} uint128_t;

// Make sure no compiler optimizations.
#pragma pack(push, 1)

typedef struct seed_s {
  uint8_t raw[SEED_BYTES];
} seed_t;

typedef struct seeds_s {
  seed_t seed[NUM_OF_SEEDS];
} seeds_t;

typedef struct r_s {
  uint8_t raw[R_BYTES];
} r_t;

typedef struct m_s {
  uint8_t raw[M_BYTES];
} m_t;

typedef struct e_s {
  r_t val[N0];
} e_t;

#define E0_RAW(e) ((e)->val[0].raw)
#define E1_RAW(e) ((e)->val[1].raw)

typedef struct ct_s {
  r_t c0;
  m_t c1;
} ct_t;

typedef r_t pk_t;

typedef struct ss_st {
  uint8_t raw[SS_BYTES];
} ss_t;

typedef uint32_t idx_t;

typedef struct compressed_idx_d_s {
  idx_t val[D];
} compressed_idx_d_t;

typedef compressed_idx_d_t compressed_idx_d_ar_t[N0];

// The secret key holds both representations, to avoid
// the compression in Decaps.
typedef struct sk_s {
  compressed_idx_d_ar_t wlist;
  r_t                   bin[N0];
  pk_t                  pk;
  m_t                   sigma;
} sk_t;

typedef ALIGN(sizeof(idx_t)) sk_t aligned_sk_t;

// Pad r to the next Block
typedef struct pad_r_s {
  r_t     val;
  uint8_t pad[R_PADDED_BYTES - sizeof(r_t)];
} ALIGN(ALIGN_BYTES) pad_r_t;

// Double padded r, required for multiplication and squaring
typedef struct dbl_pad_r_s {
  uint8_t raw[2 * R_PADDED_BYTES];
} ALIGN(ALIGN_BYTES) dbl_pad_r_t;

// Quadruple padded r, required for FFT multiplication
typedef struct quad_pad_r_s {
  uint8_t raw[4 * R_PADDED_BYTES];
} ALIGN(ALIGN_BYTES) quad_pad_r_t;

typedef struct pad_e_s {
  pad_r_t val[N0];
} ALIGN(ALIGN_BYTES) pad_e_t;

#define PE0_RAW(e) ((e)->val[0].val.raw)
#define PE1_RAW(e) ((e)->val[1].val.raw)

typedef struct func_k_s {
  m_t m;
  r_t c0;
  m_t c1;
} func_k_t;


#define _USE_CSHIFT_
//#define _USE_CMOV_

#if defined(_USE_CMOV_)||defined(_USE_CSHIFT_)
#include "rotr_cshift.h"
#if 12323 == R_BITS
typedef struct syndrome_s {
  //uint64_t qw[R_QWORDS + 2*128];
  //uint64_t qw[4*128];  // 32768 bits , for transposed rotation
  uint64_t qw[R_QWORDS*2];  // rotation with cmov
  //uint64_t qw[SIZE_MEMORY_CSHIFT_12323/2];  // rotation with cshift
} ALIGN(ALIGN_BYTES) syndrome_t;
#elif 24659 == R_BITS
typedef struct syndrome_s {
  //uint64_t qw[R_QWORDS + 2*256];
  //uint64_t qw[4*256];  // 65536 bits , transposed rotation
  uint64_t qw[R_QWORDS*2];  // rotation with cmov
  //uint64_t qw[SIZE_MEMORY_CSHIFT_24659/2];  // rotation with cshift
} ALIGN(ALIGN_BYTES) syndrome_t;
#endif
#else
//error : original syndrime_t
// For a faster rotate we triplicate the syndrome (into 3 copies)
typedef struct syndrome_s {
  uint64_t qw[3 * R_QWORDS];
} ALIGN(ALIGN_BYTES) syndrome_t;
#endif


#define _UPC_SMALL_MEM_

#if defined( _UPC_SMALL_MEM_ )
typedef struct upc_slice_s {
  union {
    r_t r;
    uint64_t qw[R_QWORDS];
  } u;
} upc_slice_t;
#else
typedef struct upc_slice_s {
  union {
    pad_r_t  r;
    uint64_t qw[sizeof(pad_r_t) / sizeof(uint64_t)];
  } ALIGN(ALIGN_BYTES) u;
} ALIGN(ALIGN_BYTES) upc_slice_t;
#endif



typedef struct upc_s {
  upc_slice_t slice[SLICES];
} upc_t;


typedef struct my_upc_s {
#if 71 == D
  upc_slice_t slice[16];
#elif 103 == D
  upc_slice_t slice[19];
#else
error: un-supported D
#endif
} my_upc_t;

#pragma pack(pop)

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top