@Test public void parallelExecutionSign() throws Exception { ExecutorService single = Executors.newSingleThreadExecutor(); ExecutorService multiple = Executors.newCachedThreadPool(); byte[] data = "Hello world".getBytes(); PrivateKey k = new PrivateKey(2048); for(int i=0; i<200; i++) ExtendedSignature.sign(k, data); double t1 = parallelize(single, 1, ()-> { for(int i=0; i<100; i++) ExtendedSignature.sign(k, data); }); System.out.println(t1); double t2 = parallelize(multiple, 4, ()-> { for(int i=0; i<100; i++) ExtendedSignature.sign(k, data); }); System.out.println(t2); assertThat(Math.abs(t1-t2), is(lessThan(0.15))); }
static public byte[] sign(PrivateKey key, byte[] data) { return sign(key, data, true); }
ExtendedSignature { static public byte[] sign(PrivateKey key, byte[] data) { return sign(key, data, true); } }
ExtendedSignature { static public byte[] sign(PrivateKey key, byte[] data) { return sign(key, data, true); }  }
ExtendedSignature { static public byte[] sign(PrivateKey key, byte[] data) { return sign(key, data, true); }  Bytes getKeyId(); ZonedDateTime getCreatedAt(); PublicKey getPublicKey(); static byte[] sign(PrivateKey key, byte[] data); static byte[] sign(PrivateKey key, byte[] data, boolean savePublicKey); static byte[] createTargetSignature(PublicKey publicKey, byte[] data, boolean savePublicKey); @Deprecated static byte[] of(byte[] targetSignature, byte[] sign, byte[] sign2); static byte[] ofSha512AndSha3_384(byte[] targetSignature, byte[] sign512, byte[] sign3_384); static Bytes keyId(AbstractKey key); static Bytes extractKeyId(byte[] signature); static PublicKey extractPublicKey(byte[] signature); byte[] getSignature(); static ExtendedSignature verify(PublicKey key, byte[] signature, byte[] data); }
ExtendedSignature { static public byte[] sign(PrivateKey key, byte[] data) { return sign(key, data, true); }  Bytes getKeyId(); ZonedDateTime getCreatedAt(); PublicKey getPublicKey(); static byte[] sign(PrivateKey key, byte[] data); static byte[] sign(PrivateKey key, byte[] data, boolean savePublicKey); static byte[] createTargetSignature(PublicKey publicKey, byte[] data, boolean savePublicKey); @Deprecated static byte[] of(byte[] targetSignature, byte[] sign, byte[] sign2); static byte[] ofSha512AndSha3_384(byte[] targetSignature, byte[] sign512, byte[] sign3_384); static Bytes keyId(AbstractKey key); static Bytes extractKeyId(byte[] signature); static PublicKey extractPublicKey(byte[] signature); byte[] getSignature(); static ExtendedSignature verify(PublicKey key, byte[] signature, byte[] data);  }