Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of new (draft) hash-to-G2 #898

Merged
merged 43 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0fa36b1
Initial implementation of new hash-to-G2
benjaminion Sep 16, 2019
0588446
Keep errorprone quiet
benjaminion Sep 16, 2019
33a7255
More errorprone nitpicks
benjaminion Sep 17, 2019
d18610e
Errorprone once more...
benjaminion Sep 17, 2019
e703f6e
SpotlessApply
benjaminion Sep 17, 2019
077baf6
Minor tidy up
benjaminion Sep 17, 2019
75fe90c
Restructure helper functions into a new class
benjaminion Sep 20, 2019
4bff76c
Add reference tests for hashToG2
benjaminion Sep 20, 2019
9a9f9cc
errorprone
benjaminion Sep 20, 2019
ae837af
errorprone
benjaminion Sep 20, 2019
022ebae
Stream individual test cases
benjaminion Sep 20, 2019
13aa3fc
errorprone nitpicks...
benjaminion Sep 20, 2019
cf71ea4
Change test format to a single line per test
benjaminion Sep 20, 2019
aea99d3
Errorprone doesn't like String.split()
benjaminion Sep 20, 2019
2b25cbc
Add benchmark
benjaminion Sep 22, 2019
ccd0156
Tidy up and deal with last TODOs
benjaminion Sep 22, 2019
167d58f
Fix error found in fuzz testing
benjaminion Sep 23, 2019
8480660
Add defensive checks to HKDF_Expand
benjaminion Sep 23, 2019
a142bf2
Fix BouncyCastle issue tat was slowing things down
benjaminion Oct 7, 2019
8b2984f
Add JMH benchmark for new hashToCurve
benjaminion Oct 14, 2019
888d3e2
Improve FP2Immutable's equals method
benjaminion Oct 14, 2019
f6a6adf
Remove JMH plugin version to keep Spotless happy
benjaminion Oct 14, 2019
d087576
Use addition chain for the massive exponentiation
benjaminion Oct 15, 2019
dbe97e8
Reinstate comments in addChain
benjaminion Oct 15, 2019
5e161d0
Remove now redundant benchmark code
benjaminion Oct 16, 2019
6e1def9
Introduce scalar multiplication for field elements
benjaminion Oct 16, 2019
b3475c7
Make BigInteger modulus static final
benjaminion Oct 16, 2019
1126472
Replace BigInteger use with Milagro's DBIG
benjaminion Oct 20, 2019
941fb62
Refactor Frobenius shortcuts for a big speedup
benjaminion Oct 21, 2019
443b39d
Favour FP over BIG where it makes sense
benjaminion Oct 21, 2019
c06c780
Minor tidy up
benjaminion Oct 22, 2019
c72c6cf
Micro-optimise some expressions for a few percent extra speed
benjaminion Oct 23, 2019
347ef61
Update to latest spec and test cases
benjaminion Dec 31, 2019
59ec114
spotlessApply
benjaminion Dec 31, 2019
bda1822
Final reorg and tests
benjaminion Jan 1, 2020
ca4f055
Improve conversion between ECP2 and Jacobian points
benjaminion Jan 2, 2020
a7af808
Typo
benjaminion Jan 2, 2020
9d83d1d
Improve a couple of tests
benjaminion Jan 2, 2020
ec7d9e3
Add reference comment on sgn0 function
benjaminion Jan 3, 2020
3cf8c29
Typo
benjaminion Jan 3, 2020
01ebc2f
Expand comment on the GLV patent workaround
benjaminion Jan 4, 2020
059a4d7
Use asserts in hashToG2, capitalise class HashToCurve
benjaminion Jan 8, 2020
b5d256d
SpotlessApply...
benjaminion Jan 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions util/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id 'me.champeau.gradle.jmh'
}

dependencies {
api 'org.bouncycastle:bcprov-jdk15on'

Expand Down
53 changes: 53 additions & 0 deletions util/src/jmh/java/tech/pegasys/artemis/util/bench/BenchBLS.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2019 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.artemis.util.bench;

import java.util.concurrent.TimeUnit;
import org.apache.tuweni.bytes.Bytes;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;
import tech.pegasys.artemis.util.hashToG2.HashToCurve;
import tech.pegasys.artemis.util.mikuli.G2Point;

@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
@Fork(value = 1)
@Warmup(iterations = 2, time = 10)
@Measurement(iterations = 8, time = 10)
public class BenchBLS {

private Bytes message;
private Bytes suite = Bytes.fromHexString("0x02");

@Setup
public void setup() {
message = Bytes.random(32);
}

@Benchmark
public void hashToCurve(Blackhole blackhole) {
G2Point result = new G2Point(HashToCurve.hashToG2(message, suite));
blackhole.consume(result);
}
}
Loading