-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Adding random tests against a naive implementation #641
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(co-reviewed with @jonasnick)
Approach ACK.
That's a nice start. I think this can be expanded a lot, e.g., using it for the corner case tests, (implementing deterministic verification and) comparing signatures byte-by-byte, comparing results of internal operations, etc... But all of this can be in a further PR if we agree here that we like this approach.
Makefile.am
Outdated
cd ecc-secp256k1 && cargo build --release --features=ffi | ||
cp ./ecc-secp256k1/target/release/libecc_secp256k1.a . | ||
cp ./ecc-secp256k1/ecc_secp256k1.h ./src/ | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs additional rules for make clean
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
Do you think we should use cargo clean
for cleanup or manually delete the target/
dir?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or should it just remove the whole ecc-secp256k1
directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. This could be useful - in particular if we want to fuzz test equality of signing (would require deterministic nonces in your lib) or scalar multiplication. Using your library seems fine as there are only few pure rust secp256k1 implementations (most projects seem to use rust-secp256k1 which are just bindings to C-libsecp).
Makefile.am
Outdated
|
||
if ENABLE_RUST_NAIVETESTS | ||
$(ECC_SECP): | ||
git clone https://github.com/elichai/ecc-secp256k1.git -b v0.1.0 2> /dev/null | true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makefile needs to check that this matches a fixed hash. Otherwise malicious code can be easily added to your repo which would then be run on our machines.
nit: ./configure could check if git and cargo are available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm so you suggest to hash the whole directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into checking that git and cargo are available, i'm pretty new to autotools so this was mostly me shooting in the dark :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be simpler to just vendor the library, i.e., copy the source code into a subfolder.
git clone https://github.com/elichai/ecc-secp256k1.git -b v0.1.0 2> /dev/null | true | ||
cd ecc-secp256k1 && cargo build --release --features=ffi | ||
cp ./ecc-secp256k1/target/release/libecc_secp256k1.a . | ||
cp ./ecc-secp256k1/ecc_secp256k1.h ./src/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copying libraries and header files around will be confusing. Can't you avoid it by directly linking to the files in the ecc-secp256k1
dir?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was simpler by yeah it's possible to link directly into the files there.
about the header, don't you want it to be under source control here?
The main reason I wrote that library was to learn so I tried to minimize dependencies and write everything myself, And then I'll add more tests in a later PR |
Two problems I have right now that I need to debug:
P.S. I need to try and play with travis see what's the best way to make it compile for C and Rust |
Fixed almost all the tests. |
I implemented deterministic nonce in my implementation so in a future PR i'll add a bit by bit signature comparison |
distcheck: Probably depends on whether we want to vendor (copy to our tree) the files |
I have no idea why configure fails on the HOST (cross-compiling) builds; this works for me locally. One issue: Your crate has a few dependencies, so we pull all of these whenever we build the test. That's potentially dangerous. |
Hmm, technically the dependencies get verified against the hashes in And that's kind of the situation right now generally in rust. |
@real-or-random I removed almost all the dependencies in my library.
|
That's super nice. I'm not saying that this is a strict requirement -- but I won't stop your motivation for removing them. :) @sipa @gmaxwell @apoelstra |
Closing this for now. Naive cross-testing of ecdsa and BIP 340 is already covered by CryptoFuzz (and Wycheproof). Also, if we add cross-testing then it would be much preferable to have a C implementation (which contradicts what I said above, sorry). |
Hi,
As suggested in #635
This adds ECDSA Signing + Verifying tests against a naive rust implementation (https://github.com/elichai/ecc-secp256k1)
What I added:
rust-naivetests
ecc-secp256k1
from sources in the Makefile.ecc-secp256k1
.ecc-secp256k1
and verifying with this library