Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assembly backend for >= 384-bit primes #106

Open
mratsim opened this issue Oct 13, 2020 · 3 comments
Open

Assembly backend for >= 384-bit primes #106

mratsim opened this issue Oct 13, 2020 · 3 comments

Comments

@mratsim
Copy link
Owner

mratsim commented Oct 13, 2020

The current assembly backend is restricted to up to 384-bit primes (6 limbs) as otherwise it requires register spilling.

when canUseNoCarryMontyMul:
when UseASM_X86_64 and a.len in {2 .. 6}: # TODO: handle spilling
if ({.noSideEffect.}: hasBmi2()) and ({.noSideEffect.}: hasAdx()):
montMul_CIOS_nocarry_asm_adx_bmi2(r, a, b, M, m0ninv)
else:
montMul_CIOS_nocarry_asm(r, a, b, M, m0ninv)
else:
montyMul_CIOS_nocarry(r, a, b, M, m0ninv)
else:
montyMul_FIPS(r, a, b, M, m0ninv)

For Zero-Knowledge one-layer proof composition, a curve needs to be embedded in another as in it's modulus should be the order of the other, for example this is the case of BLS12-377 + CP6-782 (Zexe) or BLS12-377 + BW6-761 (Celo) see #93, the embedding curve has a large prime field for which there is no assembly at the moment.

Similarly, the curve MNT4-753 and MNT6-753 for recursive proofs are also much larger than 384-bit.

@jon-chuang
Copy link

jon-chuang commented Oct 14, 2020

Kilic's impl produces very good results for these limbs > 6

@mratsim
Copy link
Owner Author

mratsim commented Oct 14, 2020

Did you measure the performance against Goff? It seems quite simple https://github.com/ConsenSys/goff/blob/fa7dd55e/asm/amd64/element_mul.go#L70-L83

@jon-chuang
Copy link

Goff's method is naive push and pop, so I assume slow. Kilic splits up the inner loop so there is less data movement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants