%maven org.cryptimeleon:math:3.0.1 import org.cryptimeleon.math.structures.groups.elliptic.nopairing.Secp256k1; import org.cryptimeleon.math.structures.groups.lazy.LazyGroup; import org.cryptimeleon.math.structures.groups.*; Group group = new Secp256k1(); //this is a LazyGroup which evaluates group operations lazily (see later) var n = group.size(); System.out.println("group size() = " + n); var g = group.getUniformlyRandomNonNeutral(); var h = group.getUniformlyRandomNonNeutral(); System.out.println(g); System.out.println(h); g.precomputePow(); h.precomputePow(); System.out.println("Precomputation done."); var zn = group.getZn(); var m = zn.valueOf(23).mul(42); //simply the number 23*42 (mod p) System.out.println(m); var m = zn.getUniformlyRandomElement(); //a random number in Zn System.out.println(m); import org.cryptimeleon.math.structures.rings.zn.HashIntoZn; var m = new HashIntoZn(zn).hash("We attack at midnight! ⚔️"); //the hash of the given String into Zn System.out.println(m); var r = zn.getUniformlyRandomElement(); var C = g.pow(m).op(h.pow(r)); System.out.println(C); C.computeSync() //computes the value of C and blocks the caller until it's done. C.getRepresentation() group.restoreElement(C.getRepresentation()).equals(C) g.pow(m).op(h.pow(r)).equals(C) List commitments = new ArrayList<>(); for (int i=0;i<500;i++) { var commitment = g.pow(i).op(h.pow(zn.getUniformlyRandomElement())).compute(); //compute() returns immediately but starts computing the concrete value on a background thread. commitments.add(commitment); //what we add to the list here could technically be compared to a Future }