secp256k1
secp256k1 copied to clipboard
Cross testing against a naïve implementation
Hi. I am an SoB intern working with @real-or-random as my mentor.
After reading #691 and going through the links provided there, I thought I could pick up where #641 left off. In particular, I am planning to transpile the Rust library to C.
I know of two approaches to transpile Rust to C:
The LLVM approach seems not to work (neither clang
nor gcc
are happy with the generated C). So mrustc
seems to be the way to go.
If anybody knows of a third way, I'd be happy to explore it too, just in case mrustc
fails midway
mrustc
has some parsing issues, but I haven't given up on it yet.
But I was thinking I could also emit assembly from cargo
and then decompile this assembly to C, but I am not sure how feasible this is. I'd appreciate it if somebody could suggest tools or readings that might help with this.
It turns out that using mrustc
to transpile ecc-scep356k1
is not feasible.
In order to use mrustc
's transpiled output, we have to:
- Either vendor the transpiled version of
libstd
along with the transpiledecc-scep356k1
(and this transpiled code is not cross-platform at that). This would bloat up the code added for cross-testing, and wouldn't be a very clean or maintainable solution. - Or we have to re-write
ecc-scep356k1
to not use anything fromlibcore
. And I don't think the (machine-dependent and unreadable) end result would incentivize such an endeavor.
So, @elichai, thank you for promptly removing the GMP dependency, but unfortunately I've reached a dead-end and will not continue using ecc-scep356k1
.
Moving forward, I am now planning on using libecc for cross-testing directly in C.