Package org.bouncycastle.util
Class GF16
- java.lang.Object
-
- org.bouncycastle.util.GF16
-
public class GF16 extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description GF16()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
decode(byte[] input, byte[] output, int outputLen)
Decodes an encoded byte array.static void
decode(byte[] input, int inOff, byte[] output, int outOff, int outputLen)
static void
encode(byte[] input, byte[] output, int inputLen)
Encodes an array of 4-bit values into a byte array.static void
encode(byte[] input, byte[] output, int outOff, int inputLen)
static byte
innerProduct(byte[] a, int aOff, byte[] b, int bOff, int rank)
static byte
inv(byte a)
Computes the multiplicative inverse in GF(16) for a GF(16) element.static byte
mul(byte a, byte b)
GF(16) multiplication mod x^4 + x + 1.static int
mul(int a, int b)
GF(16) multiplication mod x^4 + x + 1.
-
-
-
Method Detail
-
mul
public static byte mul(byte a, byte b)
GF(16) multiplication mod x^4 + x + 1.This method multiplies two elements in GF(16) (represented as integers 0–15) using carryless multiplication followed by reduction modulo x^4 + x + 1. Please ensure a <= 0x0F and b <= 0x0F
- Parameters:
a
- an element in GF(16) (only the lower 4 bits are used)b
- an element in GF(16) (only the lower 4 bits are used)- Returns:
- the product a * b in GF(16)
-
mul
public static int mul(int a, int b)
GF(16) multiplication mod x^4 + x + 1.This method multiplies two elements in GF(16) (represented as integers 0–15) using carryless multiplication followed by reduction modulo x^4 + x + 1. Please ensure a <= 0x0F and b <= 0x0F
- Parameters:
a
- an element in GF(16) (only the lower 4 bits are used)b
- an element in GF(16) (only the lower 4 bits are used)- Returns:
- the product a * b in GF(16)
-
inv
public static byte inv(byte a)
Computes the multiplicative inverse in GF(16) for a GF(16) element.
-
decode
public static void decode(byte[] input, byte[] output, int outputLen)
Decodes an encoded byte array. Each byte in the input contains two nibbles (4-bit values); the lower nibble is stored first, followed by the upper nibble.- Parameters:
input
- the input byte array (each byte holds two 4-bit values)output
- the output array that will hold the decoded nibbles (one per byte)outputLen
- the total number of nibbles to decode
-
decode
public static void decode(byte[] input, int inOff, byte[] output, int outOff, int outputLen)
-
encode
public static void encode(byte[] input, byte[] output, int inputLen)
Encodes an array of 4-bit values into a byte array. Two 4-bit values are packed into one byte, with the first nibble stored in the lower 4 bits and the second nibble stored in the upper 4 bits.- Parameters:
input
- the input array of 4-bit values (stored as bytes, only lower 4 bits used)output
- the output byte array that will hold the encoded bytesinputLen
- the number of nibbles in the input array
-
encode
public static void encode(byte[] input, byte[] output, int outOff, int inputLen)
-
innerProduct
public static byte innerProduct(byte[] a, int aOff, byte[] b, int bOff, int rank)
-
-