package org.bouncycastle.math.ec; import java.math.BigInteger; /* loaded from: classes6.dex */ public class MixedNafR2LMultiplier extends AbstractECMultiplier { protected int additionCoord; protected int doublingCoord; @Override // org.bouncycastle.math.ec.AbstractECMultiplier protected ECPoint multiplyPositive(ECPoint eCPoint, BigInteger bigInteger) { ECCurve curve = eCPoint.getCurve(); ECCurve configureCurve = configureCurve(curve, this.additionCoord); ECCurve configureCurve2 = configureCurve(curve, this.doublingCoord); int[] generateCompactNaf = WNafUtil.generateCompactNaf(bigInteger); ECPoint infinity = configureCurve.getInfinity(); ECPoint importPoint = configureCurve2.importPoint(eCPoint); int i = 0; ECPoint eCPoint2 = infinity; int i2 = 0; while (i < generateCompactNaf.length) { int i3 = generateCompactNaf[i]; importPoint = importPoint.timesPow2(i2 + (65535 & i3)); ECPoint importPoint2 = configureCurve.importPoint(importPoint); if ((i3 >> 16) < 0) { importPoint2 = importPoint2.negate(); } eCPoint2 = eCPoint2.add(importPoint2); i++; i2 = 1; } return curve.importPoint(eCPoint2); } protected ECCurve configureCurve(ECCurve eCCurve, int i) { if (eCCurve.getCoordinateSystem() == i) { return eCCurve; } if (eCCurve.supportsCoordinateSystem(i)) { return eCCurve.configure().setCoordinateSystem(i).create(); } StringBuilder sb = new StringBuilder("Coordinate system "); sb.append(i); sb.append(" not supported by this curve"); throw new IllegalArgumentException(sb.toString()); } public MixedNafR2LMultiplier(int i, int i2) { this.additionCoord = i; this.doublingCoord = i2; } public MixedNafR2LMultiplier() { this(2, 4); } }