org.bouncycastle.pqc.crypto.ntruprime.NTRULPRimePublicKeyParameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk15to18 Show documentation
Show all versions of bcprov-jdk15to18 Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8.
package org.bouncycastle.pqc.crypto.ntruprime;
import org.bouncycastle.util.Arrays;
public class NTRULPRimePublicKeyParameters
extends NTRULPRimeKeyParameters
{
private final byte[] seed;
private final byte[] roundEncA;
public NTRULPRimePublicKeyParameters(NTRULPRimeParameters params, byte[] encoding)
{
super(false, params);
this.seed = Arrays.copyOfRange(encoding, 0, 32);
this.roundEncA = Arrays.copyOfRange(encoding, seed.length, encoding.length);
}
NTRULPRimePublicKeyParameters(NTRULPRimeParameters params, byte[] seed, byte[] roundEncA)
{
super(false, params);
this.seed = Arrays.clone(seed);
this.roundEncA = Arrays.clone(roundEncA);
}
byte[] getSeed()
{
return seed;
}
byte[] getRoundEncA()
{
return roundEncA;
}
public byte[] getEncoded()
{
byte[] key = new byte[getParameters().getPublicKeyBytes()];
System.arraycopy(seed, 0, key, 0, seed.length);
System.arraycopy(roundEncA, 0, key, seed.length, roundEncA.length);
return key;
}
}