Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.9</source>
<target>1.9</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.math.BigInteger;

public class BN128Group extends BouncyCastleCurve {

public static final BigInteger TWO = new BigInteger("2");
public static final BigInteger P = new BigInteger("21888242871839275222246405745257275088696311157297823662689037894645226208583");
public static final BigInteger ORDER = new BigInteger("21888242871839275222246405745257275088548364400416034343698204186575808495617");

Expand All @@ -30,7 +30,7 @@ public BouncyCastleECPoint hashInto(BigInteger seed) {
seed = seed.add(BigInteger.ONE);
BigInteger ySquared = seed.pow(3).add(BigInteger.valueOf(3)).mod(P);
y = ySquared.modPow((P.add(BigInteger.ONE)).divide(BigInteger.valueOf(4)), P);
if (y.modPow(BigInteger.TWO, P).equals(ySquared)) {
if (y.modPow(TWO, P).equals(ySquared)) {
break;
}
} while (true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* Created by buenz on 7/1/17.
*/
public class SingleMultiExpRangeProofVerifier<T extends GroupElement<T>> implements Verifier<GeneratorParams<T>, T, RangeProof<T>> {
public static final BigInteger TWO = new BigInteger("2");


@Override
Expand Down Expand Up @@ -73,7 +74,7 @@ public void verify(GeneratorParams<T> params, T input, RangeProof<T> proof) thro
T r = rs.get(i);
BigInteger xIP = ProofUtils.computeChallenge(q, l, r);
challenges.add(xIP);
squareChallenges.add(xIP.modPow(BigInteger.TWO,q));
squareChallenges.add(xIP.modPow(TWO,q));


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.util.stream.Stream;

public class Playground {
public static final BigInteger TWO = new BigInteger("2");

@Test
public void testPlayGround() {
BigInteger q = new BigInteger("21888242871839275222246405745257275088696311157297823662689037894645226208583");
Expand Down Expand Up @@ -66,12 +68,12 @@ public void testSquareRoot() {
BigInteger sqrt = x.modPow((P.add(BigInteger.ONE)).divide(BigInteger.valueOf(4)), P);
System.out.println(x.modPow(P.min(BigInteger.ONE).shiftRight(1), P));
System.out.println(sqrt);
System.out.println(sqrt.modPow(BigInteger.TWO, P));
System.out.println(sqrt.modPow(TWO, P));
System.out.println(x);
System.out.println("Min x");
BigInteger minX = P.min(x);
BigInteger sqrtMin = minX.modPow(P.add(BigInteger.ONE).shiftRight(2), P);
System.out.println(sqrtMin.modPow(BigInteger.TWO, P));
System.out.println(sqrtMin.modPow(TWO, P));
System.out.println(minX);

}
Expand Down Expand Up @@ -102,7 +104,7 @@ public void testShift() {
BigInteger[] xs = new BigInteger[]{ProofUtils.hash("1"), ProofUtils.hash("2"), ProofUtils.hash("3"), ProofUtils.hash("4"), ProofUtils.hash("5")};
BigInteger P = new BigInteger("21888242871839275222246405745257275088548364400416034343698204186575808495617");
List<BigInteger> exponents = Stream.generate(() -> BigInteger.ONE).limit(32).collect(Collectors.toList());
String arrString= Arrays.stream(xs).map(bi->String.format("[\"0x%s\",\"0x%s\"]",bi.mod(P).toString(16),bi.modPow(BigInteger.TWO,P).toString(16))).collect(Collectors.joining(","));
String arrString= Arrays.stream(xs).map(bi->String.format("[\"0x%s\",\"0x%s\"]",bi.mod(P).toString(16),bi.modPow(TWO,P).toString(16))).collect(Collectors.joining(","));

System.out.println("["+arrString+"]");
int n = 32;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.util.stream.Collectors;

public class BN128InnerProduct {
public static final BigInteger TWO = new BigInteger("2");

@Test
public void createInnerProductProof() {
InnerProductProofSystem<BouncyCastleECPoint> system = new InnerProductProofSystem<>();
Expand All @@ -19,7 +21,7 @@ public void createInnerProductProof() {
base.getGs().getVector().map(BouncyCastleECPoint::getPoint).map(ECPoint::normalize).map(p -> "=[0x" + p.getXCoord() + " , 0x" + p.getYCoord() + "];").zipWithIndex().map(t -> "garr[" + t.v2 + "]" + t.v1).printOut();
base.getHs().getVector().map(BouncyCastleECPoint::getPoint).map(ECPoint::normalize).map(p -> "=[0x" + p.getXCoord() + " , 0x" + p.getYCoord() + "];").zipWithIndex().map(t -> "harr[" + t.v2 + "]" + t.v1).printOut();
System.out.println(base.getH());
FieldVector as = FieldVector.pow(BigInteger.TWO, 256, group.groupOrder());
FieldVector as = FieldVector.pow(TWO, 256, group.groupOrder());
// System.out.println(as);
FieldVector bs = FieldVector.pow(BigInteger.ONE, 256, group.groupOrder());
// System.out.println(bs);
Expand Down