FixedPointUtil.smali

.class public Lorg/spongycastle/math/ec/FixedPointUtil;
.super Ljava/lang/Object;
.source "FixedPointUtil.java"


# static fields
.field public static final PRECOMP_NAME:Ljava/lang/String; = "bc_fixed_point"


# direct methods
.method public constructor <init>()V
    .registers 1

    .prologue
    .line 5
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static getCombSize(Lorg/spongycastle/math/ec/ECCurve;)I
    .registers 2

    .prologue
    .line 11
    invoke-virtual {p0}, Lorg/spongycastle/math/ec/ECCurve;->getOrder()Ljava/math/BigInteger;

    move-result-object v0

    .line 12
    if-nez v0, :cond_d

    invoke-virtual {p0}, Lorg/spongycastle/math/ec/ECCurve;->getFieldSize()I

    move-result v0

    add-int/lit8 v0, v0, 0x1

    :goto_c
    return v0

    :cond_d
    invoke-virtual {v0}, Ljava/math/BigInteger;->bitLength()I

    move-result v0

    goto :goto_c
.end method

.method public static getFixedPointPreCompInfo(Lorg/spongycastle/math/ec/PreCompInfo;)Lorg/spongycastle/math/ec/FixedPointPreCompInfo;
    .registers 2

    .prologue
    .line 17
    if-eqz p0, :cond_9

    instance-of v0, p0, Lorg/spongycastle/math/ec/FixedPointPreCompInfo;

    if-eqz v0, :cond_9

    .line 19
    check-cast p0, Lorg/spongycastle/math/ec/FixedPointPreCompInfo;

    .line 22
    :goto_8
    return-object p0

    :cond_9
    new-instance p0, Lorg/spongycastle/math/ec/FixedPointPreCompInfo;

    invoke-direct {p0}, Lorg/spongycastle/math/ec/FixedPointPreCompInfo;-><init>()V

    goto :goto_8
.end method

.method public static precompute(Lorg/spongycastle/math/ec/ECPoint;I)Lorg/spongycastle/math/ec/FixedPointPreCompInfo;
    .registers 13

    .prologue
    const/4 v9, 0x0

    const/4 v3, 0x1

    .line 27
    invoke-virtual {p0}, Lorg/spongycastle/math/ec/ECPoint;->getCurve()Lorg/spongycastle/math/ec/ECCurve;

    move-result-object v4

    .line 29
    shl-int v5, v3, p1

    .line 30
    const-string v0, "bc_fixed_point"

    invoke-virtual {v4, p0, v0}, Lorg/spongycastle/math/ec/ECCurve;->getPreCompInfo(Lorg/spongycastle/math/ec/ECPoint;Ljava/lang/String;)Lorg/spongycastle/math/ec/PreCompInfo;

    move-result-object v0

    invoke-static {v0}, Lorg/spongycastle/math/ec/FixedPointUtil;->getFixedPointPreCompInfo(Lorg/spongycastle/math/ec/PreCompInfo;)Lorg/spongycastle/math/ec/FixedPointPreCompInfo;

    move-result-object v6

    .line 31
    invoke-virtual {v6}, Lorg/spongycastle/math/ec/FixedPointPreCompInfo;->getPreComp()[Lorg/spongycastle/math/ec/ECPoint;

    move-result-object v0

    .line 33
    if-eqz v0, :cond_1b

    array-length v0, v0

    if-ge v0, v5, :cond_6f

    .line 35
    :cond_1b
    invoke-static {v4}, Lorg/spongycastle/math/ec/FixedPointUtil;->getCombSize(Lorg/spongycastle/math/ec/ECCurve;)I

    move-result v0

    .line 36
    add-int/2addr v0, p1

    add-int/lit8 v0, v0, -0x1

    div-int v1, v0, p1

    .line 38
    new-array v7, p1, [Lorg/spongycastle/math/ec/ECPoint;

    .line 39
    aput-object p0, v7, v9

    move v0, v3

    .line 40
    :goto_29
    if-ge v0, p1, :cond_38

    .line 42
    add-int/lit8 v2, v0, -0x1

    aget-object v2, v7, v2

    invoke-virtual {v2, v1}, Lorg/spongycastle/math/ec/ECPoint;->timesPow2(I)Lorg/spongycastle/math/ec/ECPoint;

    move-result-object v2

    aput-object v2, v7, v0

    .line 40
    add-int/lit8 v0, v0, 0x1

    goto :goto_29

    .line 45
    :cond_38
    invoke-virtual {v4, v7}, Lorg/spongycastle/math/ec/ECCurve;->normalizeAll([Lorg/spongycastle/math/ec/ECPoint;)V

    .line 47
    new-array v8, v5, [Lorg/spongycastle/math/ec/ECPoint;

    .line 48
    invoke-virtual {v4}, Lorg/spongycastle/math/ec/ECCurve;->getInfinity()Lorg/spongycastle/math/ec/ECPoint;

    move-result-object v0

    aput-object v0, v8, v9

    .line 50
    add-int/lit8 v0, p1, -0x1

    move v2, v0

    :goto_46
    if-ltz v2, :cond_61

    .line 52
    aget-object v9, v7, v2

    .line 54
    shl-int v1, v3, v2

    move v0, v1

    .line 55
    :goto_4d
    if-ge v0, v5, :cond_5d

    .line 57
    sub-int v10, v0, v1

    aget-object v10, v8, v10

    invoke-virtual {v10, v9}, Lorg/spongycastle/math/ec/ECPoint;->add(Lorg/spongycastle/math/ec/ECPoint;)Lorg/spongycastle/math/ec/ECPoint;

    move-result-object v10

    aput-object v10, v8, v0

    .line 55
    shl-int/lit8 v10, v1, 0x1

    add-int/2addr v0, v10

    goto :goto_4d

    .line 50
    :cond_5d
    add-int/lit8 v0, v2, -0x1

    move v2, v0

    goto :goto_46

    .line 61
    :cond_61
    invoke-virtual {v4, v8}, Lorg/spongycastle/math/ec/ECCurve;->normalizeAll([Lorg/spongycastle/math/ec/ECPoint;)V

    .line 63
    invoke-virtual {v6, v8}, Lorg/spongycastle/math/ec/FixedPointPreCompInfo;->setPreComp([Lorg/spongycastle/math/ec/ECPoint;)V

    .line 64
    invoke-virtual {v6, p1}, Lorg/spongycastle/math/ec/FixedPointPreCompInfo;->setWidth(I)V

    .line 66
    const-string v0, "bc_fixed_point"

    invoke-virtual {v4, p0, v0, v6}, Lorg/spongycastle/math/ec/ECCurve;->setPreCompInfo(Lorg/spongycastle/math/ec/ECPoint;Ljava/lang/String;Lorg/spongycastle/math/ec/PreCompInfo;)V

    .line 69
    :cond_6f
    return-object v6
.end method