New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-gf

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-gf

This is a native Node.js module (C/C++) that wraps James S. Plank's GF-Complete code

latest
Source
npmnpm
Version
1.1.7
Version published
Weekly downloads
12
Maintainers
1
Weekly downloads
 
Created
Source

node-gf

CircleCI

This is a native Node.js module (C/C++) that wraps James S. Plank's GF-Complete code

The main target of GF-complete is to enhance the multiplication of a region of data (buffer) and a symbol of the Galois field. We introduce APIs to facilitate the use of node-gf library:

  • Multiplication of a buffer with an array of symbols. Each result is stored or XORed to a buffer of destination array.
  • Multiplication of a array of buffers with an matrix of symbols. Results are stored or XORed to another array of buffers.
  • Same as the above case but the matrix of symbols are stored a-prior as a context. Only arrays of buffers are given for each operation. It is useful for encoding operations.

Moreover, multi-threads can be enable in such operations so that each multiplication of a buffer with a symbol is performed in a thread.

Prerequisite

GF-complete's source codes should be in the gf-complete directory of the project. You can get GF-complete from different sources. By default, we choose the source codes from Jerasure Library that is retrieved when the package is installed.

API

Import library

const NodeGF = require('node-gf');

Initialization

const gf = new NodeGF(opts);

where [opts] is optional parameters for generating GF-complete

  • [opts.gfDim] - Galois field dimension
  • [opts.multType] - multiplication type
  • [opts.divType] - division type
  • [opts.regionType] - multiplication region type
  • [opts.primPoly] - primitive polynomial
  • [opts.arg1] - argument1
  • [opts.arg2] - argument2

Available types of multiplication, division, region operations are the same as of the original GF-complete Library and shown as below.

node-gforigin GF-complete
Multiplication
defaultGF_MULT_DEFAULT
shiftGF_MULT_SHIFT
carray_freeGF_MULT_CARRY_FREE
carry_free_gkGF_MULT_CARRY_FREE_GK
groupGF_MULT_GROUP
bytwo_pGF_MULT_BYTWO_p
tableGF_MULT_TABLE
log_tableGF_MULT_LOG_TABLE
log_zeroGF_MULT_LOG_ZERO
log_zero_extGF_MULT_LOG_ZERO_EXT
splitGF_MULT_SPLIT_TABLE
compositeGF_MULT_COMPOSITE
Division
defaultGF_DIVIDE_DEFAULT
matrixGF_DIVIDE_MATRIX
euclidGF_DIVIDE_EUCLID
Region
defaultGF_REGION_DEFAULT
doubleGF_REGION_DOUBLE_TABLE
quadGF_REGION_QUAD_TABLE
lazyGF_REGION_LAZY
simdGF_REGION_SIMD
sseGF_REGION_SSE
noSimdGF_REGION_NOSIMD
noSseGF_REGION_NOSSE
altmapGF_REGION_ALTMAP
cauchyGF_REGION_CAUCHY

Note that not all combinations of multiplication/division/region types are correct. Please see manual for more details.

Without specific requirements, we recommend to generate GF-complete with the following options:

{
    gfDim: 8,
    multType: 'split',
    divType: 'default',
    regionType: 'default',
    arg1: 4,
    arg2: 8,
}

Addition

add(num1, num2)

Multiplication

multiply(num1, num2)

Division

divide(num1, num2)

Inversion

inverse(num)

Multiplication of a region with a GF symbol

multRegion(coef, src, dest, len, flag)

where

  • coef: a GF symbol
  • src: the source buffer
  • dest: the destination buffer
  • len: buffer length (bytes)
  • flag: operation flag indicating that the result: stored in dest (flag = 0) or XORed to actual dest (flag = 1)

Multiplication of a region with an array of GF symbols

multRegionArr(coefs, src, dest, destsNb, len, flag, offset)

For multi-thread operations:

multRegionArrThreads(coefs, src, dest, destsNb, len, flag, offset)

where

  • coefs: array of GF symbols
  • src: the source buffer
  • dest: the destination buffers
  • destsNb: number of destination buffers
  • len: buffer length (bytes)
  • flag: operation flag indicating that the result is stored in dest (flag = 0) or XORed to actual dest (flag = 1)
  • offset: offset of dest (bytes)

Multiplication of an array of regions with a matrix of GF symbols

multRegionMatrix(coefs, rowsNb, colsNb, src, dest, len, offset)

For multi-thread operations:

multRegionMatrixThreads(coefs, rowsNb, colsNb, src, dest, len, offset)

where

  • coefs: array of rowsNb x colsNb GF symbols
  • rowsNb: number of input regions
  • colsNb: number of output regions
  • src: the source buffers
  • dest: the destination buffers
  • len: buffer length (bytes)
  • offset: offset of dest (bytes)

Multiplication of an array of regions with a given context

multRegionMatrixContext(contextId, src, dest, len, offset)

For multi-thread operations:

multRegionMatrixThreadsContext(contextId, src, dest, len, offset)

where

  • contextId: identity of a context
  • src: the source buffers
  • dest: the destination buffers
  • len: buffer length (bytes) (optional)
  • offset: offset of dest (bytes) (optional)

A context identity is return from

initContext(coefs, rowsNb, colsNb, len)

where

  • coefs: array of rowsNb x colsNb GF symbols
  • rowsNb: number of input regions
  • colsNb: number of output regions
  • len: buffer length (bytes)

A context is deleted by

removeContext(contextId)

where

  • contextId: identity of a context

Keywords

gf-complete

FAQs

Package last updated on 22 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts