I've faced the next problem: I don't know where to get a byte array of private key for calling correct NTRUSigningPrivateKeyParameters.
Here is my code:
byte [] b = new byte[16];
Security.addProvider(new BouncyCastleProvider());
NTRUSigningKeyGenerationParameters ntruSigningKeyGenerationParameters = NTRUSigningKeyGenerationParameters.TEST157;
NTRUSigningPrivateKeyParameters ntruSigningPrivateKeyParameters = null;
NTRUSigner ntruSigner = new NTRUSigner(ntruSigningKeyGenerationParameters.getSigningParameters());
try {
ntruSigningPrivateKeyParameters = new NTRUSigningPrivateKeyParameters(b, ntruSigningKeyGenerationParameters); // here I need to get byte array from private key
} catch (IOException e) {
e.printStackTrace();
}
ntruSigner.init(true, ntruSigningPrivateKeyParameters);
byte [] res = ntruSigner.generateSignature();
Does anyone had the same problem?
Have your tried NTRUSigningKeyPairGenerator
, and calling getEncoded()
on the retrieved private key?
NTRUSigningKeyPairGenerator ntruSigningKeyPairGenerator = new NTRUSigningKeyPairGenerator();
NTRUSigningKeyGenerationParameters ntruSigningKeyGenerationParameters = NTRUSigningKeyGenerationParameters.TEST157;
ntruSigningKeyPairGenerator.init(ntruSigningKeyGenerationParameters);
AsymmetricCipherKeyPair asymmetricCipherKeyPair = ntruSigningKeyPairGenerator.generateKeyPair();
NTRUSigningPrivateKeyParameters params = (NTRUSigningPrivateKeyParameters) asymmetricCipherKeyPair.getPrivate();
System.out.println(Hex.encodeHexString(params.getEncoded()));