Search code examples
javacompiler-errorsbouncycastle

Calculation of SHA3 hash value with bouncycastle - `error: cannot find symbol`


I have taken example from here: bouncycastle_example

It is the second answer, not the one accepted!

And it works fine in Java 8 and Java 11, though the latter is not supported as stated on maven central.

Now my own project has copied the same line as in the example and gives the error message stated in the title.

Having a running example, I wonder why the exact same code does not work in my project...

//Klassenattribute (transient):
//transient BigInteger message;
transient byte[] message;

transient SHA3.DigestSHA3 digestSHA3 = new SHA3.Digest512();


//Konstruktor:
public Signature_Path (byte[] message) {//Done: BigInteger message 
//Klassenattribute initialisieren:
path= new Vector<Node>();

//Klassenattribute initialisieren (GEHEIM):
sk = new Secret_Key ();
std_rnd = new Random (); //Zufallszahlgenerator

//Klassenattribute initialisieren (privat):
k = 0;//Bitlaenge der Zufallszahlen p, q 
//Klassenattribute initialisieren (transient):
byte[] digest = digestSHA3.digest(message.getBytes());
this.message = digest;

}

I expect to calculate variable digest with bouncy castle method digestSHA3.digest.

I get a compiler marker the latter is not available.

UPDATE_20190212: compiled with java8 and java11 and got the very same error message.

This is from my pom.xml:

<dependency>
           <groupId>org.bouncycastle</groupId>
           <artifactId>bcprov-jdk15on</artifactId>
           <version>1.60</version>
</dependency>

Solution

  • Though the compiler marker is outside of the parentheses, the offending expression is not digestSHA3.digest, but message.getBytes(). message already is a byte[], so removing .getBytes() solves the problem.