Top Description Fields Constructors Methods
org.bouncycastle.pqc.legacy.crypto.rainbow

public Class RainbowKeyPairGenerator

extends Object
implements AsymmetricCipherKeyPairGenerator
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator
Imports
java.security.SecureRandom, org.bouncycastle.crypto.AsymmetricCipherKeyPair, .AsymmetricCipherKeyPairGenerator, .CryptoServicesRegistrar, .KeyGenerationParameters, org.bouncycastle.pqc.legacy.crypto.rainbow.util.ComputeInField, .GF2Field

This class implements AsymmetricCipherKeyPairGenerator. It is used as a generator for the private and public key of the Rainbow Signature Scheme.

Detailed information about the key generation is to be found in the paper of Jintai Ding, Dieter Schmidt: Rainbow, a New Multivariable Polynomial Signature Scheme. ACNS 2005: 164-175 (https://dx.doi.org/10.1007/11496137_12)

Field Summary

Modifier and TypeField and Description
private short[][]
private short[][]
private short[][]
private short[][]
private short[]
private short[]
private boolean
private Layer[]
private int
private short[][]
private short[]
private short[][]
private RainbowKeyGenerationParameters
private SecureRandom
private int[]

Constructor Summary

AccessConstructor and Description
public
RainbowKeyPairGenerator()

The standard constructor tries to generate the Rainbow algorithm identifier with the corresponding OID.

Method Summary

Modifier and TypeMethod and Description
private void
compactPublicKey(short[][][]
3-dimensional array containing a n x n Matrix for each of the n - v1 polynomials
coeff_quadratic_to_compact
)

The quadratic (or mixed) terms of the public key are compacted from a n x n matrix per polynomial to an upper diagonal matrix stored in one integer array of n (n + 1) / 2 elements per polynomial.

private void
computePublicKey()

This function computes the public key from the private key.

private void
generateF()

This function generates the private map F, which consists of u-1 layers.

public AsymmetricCipherKeyPair
generateKeyPair()

Implements org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator.generateKeyPair.

return an AsymmetricCipherKeyPair containing the generated keys.

private void
generateL1()

This function generates the invertible affine linear map L1 = A1*x + b1

The translation part b1, is stored in a separate array.

private void
generateL2()

This function generates the invertible affine linear map L2 = A2*x + b2

The translation part b2, is stored in a separate array.

public AsymmetricCipherKeyPair

Returns:

the generated key pair
genKeyPair
()

This function generates a Rainbow key pair.

public void
init(KeyGenerationParameters
the parameters the key pair is to be initialised with.
param
)

Implements org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator.init.

intialise the key pair generator.

public void
private void
private void
keygen()

This function calls the functions for the random generation of the coefficients and the matrices needed for the private key and the method for computing the public key.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

A1back to summary
private short[][] A1
A1invback to summary
private short[][] A1inv
A2back to summary
private short[][] A2
A2invback to summary
private short[][] A2inv
b1back to summary
private short[] b1
b2back to summary
private short[] b2
initializedback to summary
private boolean initialized
layersback to summary
private Layer[] layers
numOfLayersback to summary
private int numOfLayers
pub_quadraticback to summary
private short[][] pub_quadratic
pub_scalarback to summary
private short[] pub_scalar
pub_singularback to summary
private short[][] pub_singular
rainbowParamsback to summary
private RainbowKeyGenerationParameters rainbowParams
srback to summary
private SecureRandom sr
viback to summary
private int[] vi

Constructor Detail

RainbowKeyPairGeneratorback to summary
public RainbowKeyPairGenerator()

The standard constructor tries to generate the Rainbow algorithm identifier with the corresponding OID.

Method Detail

compactPublicKeyback to summary
private void compactPublicKey(short[][][] coeff_quadratic_to_compact)

The quadratic (or mixed) terms of the public key are compacted from a n x n matrix per polynomial to an upper diagonal matrix stored in one integer array of n (n + 1) / 2 elements per polynomial. The ordering of elements is lexicographic and the result is updating this.pub_quadratic, which stores the quadratic elements of the public key.

Parameters
coeff_quadratic_to_compact:short[][][]

3-dimensional array containing a n x n Matrix for each of the n - v1 polynomials

computePublicKeyback to summary
private void computePublicKey()

This function computes the public key from the private key.

The composition of F with L2 is computed, followed by applying L1 to the composition's result. The singular and scalar values constitute to the public key as is, the quadratic terms are compacted in compactPublicKey()

generateFback to summary
private void generateF()

This function generates the private map F, which consists of u-1 layers. Each layer consists of oi polynomials where oi = vi[i+1]-vi[i].

The methods for the generation of the coefficients of these polynomials are called here.

generateKeyPairback to summary
public AsymmetricCipherKeyPair generateKeyPair()

Implements org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator.generateKeyPair.

Doc from org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator.generateKeyPair.

return an AsymmetricCipherKeyPair containing the generated keys.

Returns:AsymmetricCipherKeyPair

an AsymmetricCipherKeyPair containing the generated keys.

generateL1back to summary
private void generateL1()

This function generates the invertible affine linear map L1 = A1*x + b1

The translation part b1, is stored in a separate array. The inverse of the matrix-part of L1 A1inv is also computed here.

This linear map hides the output of the map F. It is on k^(n-v1).

generateL2back to summary
private void generateL2()

This function generates the invertible affine linear map L2 = A2*x + b2

The translation part b2, is stored in a separate array. The inverse of the matrix-part of L2 A2inv is also computed here.

This linear map hides the output of the map F. It is on k^(n).

genKeyPairback to summary
public AsymmetricCipherKeyPair genKeyPair()

This function generates a Rainbow key pair.

Returns:AsymmetricCipherKeyPair

the generated key pair

initback to summary
public void init(KeyGenerationParameters param)

Implements org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator.init.

Doc from org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator.init.

intialise the key pair generator.

Parameters
param:KeyGenerationParameters

the parameters the key pair is to be initialised with.

initializeback to summary
public void initialize(KeyGenerationParameters param)
initializeDefaultback to summary
private void initializeDefault()
keygenback to summary
private void keygen()

This function calls the functions for the random generation of the coefficients and the matrices needed for the private key and the method for computing the public key.