Coverage Summary for Class: BN128G1 (co.rsk.crypto.altbn128java)

Class Class, % Method, % Line, %
BN128G1 0% (0/1) 0% (0/3) 0% (0/5)


1 /* 2  * This file is part of RskJ 3  * Copyright (C) 2019 RSK Labs Ltd. 4  * (derived from ethereumJ library, Copyright (c) 2016 <ether.camp>) 5  * 6  * This program is free software: you can redistribute it and/or modify 7  * it under the terms of the GNU Lesser General Public License as published by 8  * the Free Software Foundation, either version 3 of the License, or 9  * (at your option) any later version. 10  * 11  * This program is distributed in the hope that it will be useful, 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14  * GNU Lesser General Public License for more details. 15  * 16  * You should have received a copy of the GNU Lesser General Public License 17  * along with this program. If not, see <http://www.gnu.org/licenses/>. 18  */ 19  20 package co.rsk.crypto.altbn128java; 21  22 /** 23  * Implementation of specific cyclic subgroup of points belonging to {@link BN128Fp} <br/> 24  * Members of this subgroup are passed as a first param to pairing input {@link PairingCheck#addPair(BN128G1, BN128G2)} <br/> 25  * 26  * Subgroup generator G = (1; 2) 27  * 28  * @author Mikhail Kalinin 29  * @since 01.09.2017 30  */ 31 public class BN128G1 extends BN128Fp { 32  33  BN128G1(BN128<Fp> p) { 34  super(p.x, p.y, p.z); 35  } 36  37  @Override 38  public BN128G1 toAffine() { 39  return new BN128G1(super.toAffine()); 40  } 41  42  /** 43  * Checks whether point is a member of subgroup, 44  * returns a point if check has been passed and null otherwise 45  */ 46  public static BN128G1 create(byte[] x, byte[] y) { 47  48  BN128<Fp> p = BN128Fp.create(x, y); 49  50  if (p == null) {return null;} 51  52  // if (!isGroupMember(p)) return null; 53  // isGroupMember is always true so it is redundant, 54  // SonarCloud sees it as a bug so it is commented 55  // Formally we have to do this check 56  // but in our domain it's not necessary, 57  // thus always return true 58  59  return new BN128G1(p); 60  } 61  62 }