mirror of
https://github.com/codex-storage/constantine.git
synced 2025-02-04 23:13:50 +00:00
Bash ~_~ .... Azure 32-bit (+ fix BN inversion alternative path)
This commit is contained in:
parent
303ce5b74c
commit
437a61bd93
@ -131,13 +131,13 @@ steps:
|
||||
libffi-dev:i386
|
||||
|
||||
mkdir -p bin
|
||||
|
||||
cat < EOF > bin/gcc
|
||||
|
||||
cat << EOF > bin/gcc
|
||||
#!/bin/bash
|
||||
exec $(which gcc) -m32 "\$@"
|
||||
EOF
|
||||
|
||||
cat < EOF > bin/g++
|
||||
cat << EOF > bin/g++
|
||||
#!/bin/bash
|
||||
exec $(which g++) -m32 "\$@"
|
||||
EOF
|
||||
|
@ -161,7 +161,10 @@ func inv*(r: var Fp, a: Fp) =
|
||||
# neither for Secp256k1 nor BN curves
|
||||
# Performance is slower than GCD
|
||||
# To be revisited with faster squaring/multiplications
|
||||
r.mres.steinsGCD(a.mres, Fp.C.getR2modP(), Fp.C.Mod, Fp.C.getPrimePlus1div2())
|
||||
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())
|
||||
|
||||
func inv*(a: var Fp) =
|
||||
## Inversion modulo p
|
||||
@ -175,5 +178,5 @@ func inv*(a: var Fp) =
|
||||
# Performance is slower than GCD
|
||||
# To be revisited with faster squaring/multiplications
|
||||
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
|
||||
|
@ -346,6 +346,14 @@ proc genMainConstants(defs: var seq[CurveParams]): NimNode =
|
||||
exported($curve & "_BN_can_use_addchain_inversion"),
|
||||
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:
|
||||
curveExtraStmts.add newConstStmt(
|
||||
exported($curve & "_BN_can_use_addchain_inversion"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user