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
  • /
  • ring_ops.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:f3664ceba8a1ce69c99a48e1dc292e63644d7f50
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 ...
ring_ops.h
#ifndef _RING_OPS_H_
#define _RING_OPS_H_

#include "types.h"

// c = a+b mod (x^r - 1)
_INLINE_ void
ring_add(OUT r_t *c, IN const r_t *a, IN const r_t *b)
{
#if 1
  const uint64_t *a_qwords = (const uint64_t *)a;
  const uint64_t *b_qwords = (const uint64_t *)b;
  uint64_t *      c_qwords = (uint64_t *)c;

  for(size_t i = 0; i < R_QWORDS-1; i ++) {
    c_qwords[i] = a_qwords[i]^b_qwords[i];
  }

  const uint8_t *a_bytes = (const uint8_t *)a;
  const uint8_t *b_bytes = (const uint8_t *)b;
  uint8_t *      c_bytes = (uint8_t *)c;

  for(size_t i=(R_QWORDS-1)*8; i<R_BYTES;i++) {
    c_bytes[i] = a_bytes[i]^b_bytes[i];
  }
#else
  REG_T           va, vb;
  const uint64_t *a_qwords = (const uint64_t *)a;
  const uint64_t *b_qwords = (const uint64_t *)b;
  uint64_t *      c_qwords = (uint64_t *)c;

  for(size_t i = 0; i < R_PADDED_QWORDS; i += REG_QWORDS) {
    va = LOAD(&a_qwords[i]);
    vb = LOAD(&b_qwords[i]);

    STORE(&c_qwords[i], va ^ vb);
  }
#endif
}


#define _USE_BMUL2_

#if defined(_USE_BMUL2_)

#include "bmul2.h"
#define mul_internal_t        dbl_pad_r_t
#define mul_internal_cleanup  dbl_pad_r_cleanup

#else

#include "bitpolymul.h"
#define mul_internal_t        quad_pad_r_t
#define mul_internal_cleanup  quad_pad_r_cleanup

#endif


// c = a*b mod (x^r - 1)
void ring_mul(OUT pad_r_t *c, IN const pad_r_t *a, IN const pad_r_t *b);

void ring_mul_2(OUT pad_r_t *c, IN const pad_r_t *a, IN const mul_internal_t *b_fft);

void ring_mul_inputtransform(OUT mul_internal_t *ta, IN const pad_r_t *a);

void ring_mul_rep(OUT pad_r_t *c, IN const pad_r_t *a, IN const mul_internal_t *tb);


///////


// c = a^2 mod (x^r - 1)
void ring_squ(OUT pad_r_t *c, IN const pad_r_t *a);

#endif

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