Bash ~_~ .... Azure 32-bit (+ fix BN inversion alternative path)

This commit is contained in:
Mamy André-Ratsimbazafy 2020-09-01 13:40:39 +02:00
parent 303ce5b74c
commit 437a61bd93
No known key found for this signature in database
GPG Key ID: 7B88AD1FE79492E1
3 changed files with 16 additions and 5 deletions

View File

@ -132,12 +132,12 @@ steps:
mkdir -p bin mkdir -p bin
cat < EOF > bin/gcc cat << EOF > bin/gcc
#!/bin/bash #!/bin/bash
exec $(which gcc) -m32 "\$@" exec $(which gcc) -m32 "\$@"
EOF EOF
cat < EOF > bin/g++ cat << EOF > bin/g++
#!/bin/bash #!/bin/bash
exec $(which g++) -m32 "\$@" exec $(which g++) -m32 "\$@"
EOF EOF

View File

@ -161,6 +161,9 @@ func inv*(r: var Fp, a: Fp) =
# neither for Secp256k1 nor BN curves # neither for Secp256k1 nor BN curves
# Performance is slower than GCD # Performance is slower than GCD
# To be revisited with faster squaring/multiplications # To be revisited with faster squaring/multiplications
when false: # Fp.C.canUse_BN_AddchainInversion():
r.invmod_addchain_bn(a)
else:
r.mres.steinsGCD(a.mres, Fp.C.getR2modP(), Fp.C.Mod, Fp.C.getPrimePlus1div2()) r.mres.steinsGCD(a.mres, Fp.C.getR2modP(), Fp.C.Mod, Fp.C.getPrimePlus1div2())
func inv*(a: var Fp) = func inv*(a: var Fp) =
@ -175,5 +178,5 @@ func inv*(a: var Fp) =
# Performance is slower than GCD # Performance is slower than GCD
# To be revisited with faster squaring/multiplications # To be revisited with faster squaring/multiplications
var t: typeof(a) # TODO: zero-init needed? var t: typeof(a) # TODO: zero-init needed?
t.mres.steinsGCD(a.mres, Fp.C.getR2modP(), Fp.C.Mod, Fp.C.getPrimePlus1div2()) t.inv(a)
a = t a = t

View File

@ -346,6 +346,14 @@ proc genMainConstants(defs: var seq[CurveParams]): NimNode =
exported($curve & "_BN_can_use_addchain_inversion"), exported($curve & "_BN_can_use_addchain_inversion"),
newLit true newLit true
) )
curveExtraStmts.add newConstStmt(
exported($curve & "_BN_param_u"),
newCall(
bindSym"fromHex",
nnkBracketExpr.newTree(bindSym"BigInt", curveDef.bn_u_bitwidth),
curveDef.bn_u
)
)
else: else:
curveExtraStmts.add newConstStmt( curveExtraStmts.add newConstStmt(
exported($curve & "_BN_can_use_addchain_inversion"), exported($curve & "_BN_can_use_addchain_inversion"),