Comments (9)
If the only goal is to validate Ed points and that's it, then I think you need a super fine grained slice of this crate. I think the most appropriate thing might be to just copy the u32 backend, copy the decompress::step_1
function, and that's it.
If we had feature gates that fine, we'd have a lot of feature gates
from curve25519-dalek.
I have noticed I have some crates that need only the decompress::step_1 function in curve25519-dalek
Your use case sounds rather atypical
but they have to pull in the whole dependency, which takes a long time to compile
Timing a build of both curve25519-dalek
and ed25519-dalek
from a fresh clone with no target/
directory to reuse on my machine:
$ time cargo build --release
Updating crates.io index
Compiling version_check v0.9.4
Compiling typenum v1.17.0
Compiling semver v1.0.21
Compiling libc v0.2.152
Compiling platforms v3.3.0
Compiling cfg-if v1.0.0
Compiling subtle v2.5.0
Compiling signature v2.2.0
Compiling zeroize v1.7.0
Compiling ed25519 v2.2.3
Compiling generic-array v0.14.7
Compiling rustc_version v0.4.0
Compiling curve25519-dalek v4.1.1 (/private/tmp/curve25519-dalek/curve25519-dalek)
Compiling cpufeatures v0.2.12
Compiling block-buffer v0.10.4
Compiling crypto-common v0.1.6
Compiling digest v0.10.7
Compiling sha2 v0.10.8
Compiling ed25519-dalek v2.1.0 (/private/tmp/curve25519-dalek/ed25519-dalek)
Finished release [optimized] target(s) in 2.42s
cargo build --release 5.52s user 0.69s system 249% cpu 2.485 total
2.4 seconds on my computer. I wouldn't consider that "a long time".
from curve25519-dalek.
On my computer it takes 8.8 seconds. And I find GitHub Actions tends to be about 4x slower than my machine.
Compiling proc-macro2 v1.0.78
Compiling version_check v0.9.4
Compiling unicode-ident v1.0.12
Compiling typenum v1.17.0
Compiling semver v1.0.21
Compiling platforms v3.3.0
Compiling cfg-if v1.0.0
Compiling cpufeatures v0.2.12
Compiling subtle v2.5.0
Compiling signature v2.2.0
Compiling rand_core v0.6.4
Compiling ed25519 v2.2.3
Compiling generic-array v0.14.7
Compiling rustc_version v0.4.0
Compiling curve25519-dalek v4.1.1 (/home/user/tmp/curve25519-dalek/curve25519-dalek)
Compiling quote v1.0.35
Compiling syn v2.0.48
Compiling crypto-common v0.1.6
Compiling block-buffer v0.10.4
Compiling digest v0.10.7
Compiling sha2 v0.10.8
Compiling zeroize_derive v1.4.2
Compiling curve25519-dalek-derive v0.1.1 (/home/user/tmp/curve25519-dalek/curve25519-dalek-derive)
Compiling zeroize v1.7.0
Compiling x25519-dalek v2.0.0 (/home/user/tmp/curve25519-dalek/x25519-dalek)
Compiling ed25519-dalek v2.1.0 (/home/user/tmp/curve25519-dalek/ed25519-dalek)
Finished release [optimized] target(s) in 8.83s
Your use case sounds rather atypical
The use case is the Solana Pubkey type, which needs to check if bytes are a curve point but otherwise doesn't need curve25519-dalek
from curve25519-dalek.
If that's all you need, you shouldn't be using ed25519-dalek
at all. You can decompress an Edwards curve point with curve25519-dalek
alone.
I'm not sure how your proposed solution would help either. You seem more in need of feature gating than more crates.
More crates help improve parallelism and can reduce the algorithmic complexity of compiling any one crate, and we do use them in spades as part of the @RustCrypto project, to the point people complain about the sheer number of dependencies. But at the end of the day, you're still compiling the same amount of code.
To really micro-optimize for your use case, you'd probably need feature gating to be able to pull in just the field implementation alone. But that's also something we deliberately avoid exposing the FieldElement
type.
from curve25519-dalek.
curve25519-dalek takes 7.5 seconds to compile on my machine:
Compiling semver v1.0.21
Compiling proc-macro2 v1.0.78
Compiling unicode-ident v1.0.12
Compiling platforms v3.3.0
Compiling cfg-if v1.0.0
Compiling cpufeatures v0.2.12
Compiling subtle v2.5.0
Compiling zeroize v1.7.0
Compiling rustc_version v0.4.0
Compiling curve25519-dalek v4.1.1 (/home/user/tmp/curve25519-dalek/curve25519-dalek)
Compiling quote v1.0.35
Compiling syn v2.0.48
Compiling curve25519-dalek-derive v0.1.1 (/home/user/tmp/curve25519-dalek/curve25519-dalek-derive)
Finished release [optimized] target(s) in 7.54s
I'm not sure how your proposed solution would help either. You seem more in need of feature gating than more crates.
Features can also achieve the end result but I personally find that crates are cleaner and have fewer footguns (e.g. it's easy to forget to check a certain crate feature)
But at the end of the day, you're still compiling the same amount of code.
This is about being able to compile less code, by having a more lightweight dependency than curve25519-dalek
from curve25519-dalek.
Again, the only way we could micro-optimize for your use case is by creating a crate that contains something we're deliberately trying to avoid exposing
from curve25519-dalek.
One way I've seen projects address this shortcoming in Rust visibility is to publish an "internals" crate and put a notice in the README that you shouldn't use the crate directly e.g. polars-core.
Additionally, an internals crate could have a default feature that prints a warning if someone tries to use the crate without disabling the feature.
from curve25519-dalek.
@kevinheavey you haven't mentioned specifically what you're doing beyond needing decompress::step_1
, but it seems like e.g. solving the curve equation for a FieldElement
isn't really going to be useful without the higher level types in curve25519-dalek
.
What are you doing exactly?
from curve25519-dalek.
@kevinheavey you haven't mentioned specifically what you're doing beyond needing
decompress::step_1
, but it seems like e.g. solving the curve equation for aFieldElement
isn't really going to be useful without the higher level types incurve25519-dalek
.What are you doing exactly?
@tarcieri the Solana Pubkey struct has a find_program_address method that iterates until it finds an address that is not on the ed25519 curve and hence cannot have an associated private key. The only part of curve25519-dalek it uses for this is:
curve25519_dalek::edwards::CompressedEdwardsY::from_slice(_bytes.as_ref())
.decompress()
.is_some()
and if you pare that down a bit further it turns out it only needs the step_1 function. Or even more specifically, just the first element of the tuple returned by that function
from curve25519-dalek.
Related Issues (20)
- Pointer width detection in `build.rs` may break for obscure platforms HOT 1
- ed25519_dalek No generate function HOT 2
- `curve25519_dalek::SubgroupPoint`: missing traits
- Build fails on nightly-2024-02-05 HOT 2
- Crate fails with `nightly-2024-02-06` HOT 3
- How to check a VerifyingKey point is within the prime order subgroup HOT 3
- Support NIST validation criteria for Edwards points HOT 2
- ed25519: support PKCS#8 v1 (for OpenSSL interop)? HOT 2
- Use of unstable library feature 'stdsimd HOT 6
- Use of unstable library feature 'stdsimd' HOT 3
- Incorrect use of cfg to import dependency HOT 1
- docs.rs homepage examples use `rand_core` crate option, but do not mention its existence HOT 2
- [docs request] how to serialize a public key in the format compatible with `~/.ssh/authorized_keys`? HOT 2
- AVX512-IFMA & AVX10 status
- curve25519: nightly CI seems borked w/ warn(unused_imports)
- Impl std::num_traits::{One, Zero} for Scalar types
- Zeroize `SecretKey` on drop HOT 5
- Potential optimization for the torsion check HOT 1
- 4.1.3 release? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from curve25519-dalek.