-
Notifications
You must be signed in to change notification settings - Fork 156
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
feat: nostd, core+alloc support #22
Conversation
Cargo.toml
Outdated
@@ -50,7 +51,8 @@ name = "key" | |||
# debug = true | |||
|
|||
[features] | |||
default = [] | |||
default = ["std"] | |||
std = [] |
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.
shouldn’t this enable the std features on the crates that got it disabled above?
I wonder if we can write a custom library for stack allocated bigints bounded by a prime constant. it would be also useful for the SRP implementation. Do you know any prior art libraries which have done it? |
doesnt smallvec already do this, given it is the backing structure of the bigints?
…On 18. Aug 2019, 20:49 +0200, Artyom Pavlov ***@***.***>, wrote:
I wonder if we can write a custom library for stack allocating bigints bounded by a prime constant. it would be also useful for SRP implementation. Do you know any prior art libraries which have done it?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
That's exactly what smallvec does. A |
I meant bigints without the heap fallback. Since most operations are done modulo some value with a known length, it should be doable? Plus this hypothetical crate can be significantly smaller, since we don't need general purpose bigints. |
Well for statically allocated vecs, arrayvec exists and is pretty good. But it would require changing the bigint library to be generic over the storage backend somehow, since otherwise we'd have to copy paste a fairly significant portion of the bigint algorithms over. |
@roblabla I have updated |
I'll try to squeeze some time during the week to get this up and running. |
b9fb1fe
to
49505e8
Compare
I did some fixes here and there, but I'm stuck against a wall again. A PR was merged in August allowing nostd usage of base64, but there hasn't been a new release of base64 since. So we're waiting for upstream to release a new version. |
@roblabla you can use |
The new base64 dependency breaks Rust 1.31 builds 😭. Subtle-encoding also has an MSRV of 1.36. May I bump the MSRV @dignifiedquire ? |
there is always sth :D feel free to bump the version |
src/algorithms.rs
Outdated
@@ -2,6 +2,7 @@ use num_bigint::traits::ModInverse; | |||
use num_bigint::{BigUint, RandPrime}; | |||
use num_traits::{FromPrimitive, One, Zero}; | |||
use rand::Rng; | |||
use libm::F64Ext; |
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.
Could you update to libm@0.2, I did that in num-bigint-dig, unfortunately that doesn't have the extension anymore, so you need to do some manual wrapping of things.
.travis.yml
Outdated
@@ -2,14 +2,16 @@ language: rust | |||
|
|||
matrix: | |||
include: | |||
- rust: 1.31.0 | |||
- rust: 1.34.0 |
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 bumped the msr to 1.36, because of smallvec@1.0 in #33
@roblabla merged everything else on master, any chance you want to pick this up again and bring it over the finishline? |
I'll take a look! |
Some quick thoughts:
|
You can also use |
I ended up using cargo expand and copy pasting the output of thiserror lol. I'll look into displaydoc. I pushed a first draft of the no-std support. It's WIP and untested, but at least it builds. Things to do:
Things that will happen in a follow-up PR:
|
+1 to Also +1 to ditching You might check out https://github.com/oliver-giersch/conquer-once
|
Ooh, I hadn't heard of conquer-once. And it does seem to provide lazy init on no_std: https://docs.rs/conquer-once/0.2.0/conquer_once/spin/type.Lazy.html is available in no-std, and is exactly what we want. We should be able to swap between this and the top-level I'll try it out in a follow-up PR. |
Is this ready to merge? Looks good to me at first glance |
6b45d82
to
9b935e5
Compare
@roblabla almost there one more rebase please and can you check out those clippy warnings please? Sorry for the long turnaround times |
Should be good to go I hope! |
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.
awesome, thanks for getting this through!
Blocked on dignifiedquire/num-bigint#12
Missing: docs, tests and a way to avoid having base64 break our builds to rust-lang/cargo#4866.