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

Any chance of supporting 8-bit platforms? #182

Open
xphoniex opened this issue Feb 9, 2023 · 5 comments
Open

Any chance of supporting 8-bit platforms? #182

xphoniex opened this issue Feb 9, 2023 · 5 comments

Comments

@xphoniex
Copy link

xphoniex commented Feb 9, 2023

I'm trying to compile k256 for ATmega328, a popular 8-bit chip on arduino boards, but I'm getting:

error: this crate builds on 32-bit and 64-bit platforms only
  --> /.cargo/registry/src/github.com-1ecc6299db9ec823/crypto-bigint-0.4.9/src/limb.rs:31:1
   |
31 | compile_error!("this crate builds on 32-bit and 64-bit platforms only");

The other alternatives to k256, secp256k1 and libsecp256k1 both need alloc, which I have not been able to get working yet on that platform. Any thoughts?

@tarcieri
Copy link
Member

tarcieri commented Feb 9, 2023

With the forthcoming cpubits crate we may be able to select the 32-bit backend for 8-bit platforms, if that works: RustCrypto/utils#824

@xphoniex
Copy link
Author

sidenote: I tried compiling for 32-bit ARM and it still failed because of getrandom crate:

error[E0463]: can't find crate for `std`
 --> /home/usr/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.8/src/error_impls.rs:9:1
  |
9 | extern crate std;
  | ^^^^^^^^^^^^^^^^^ can't find crate
  |
  = note: the `thumbv6m-none-eabi` target may not support the standard library

error[E0463]: can't find crate for `std`
  |
  = note: the `thumbv6m-none-eabi` target may not support the standard library
  = note: `std` is required by `once_cell` because it does not declare `#![no_std]`

error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
   --> /home/usr/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.8/src/lib.rs:268:9
    |
268 | /         compile_error!("target is not supported, for more information see: \
269 | |                         https://docs.rs/getrandom/#unsupported-targets");
    | |________________________________________________________________________^

error[E0433]: failed to resolve: use of undeclared crate or module `imp`
   --> /home/usr/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.8/src/lib.rs:290:5
    |
290 |     imp::getrandom_inner(dest)
    |     ^^^ use of undeclared crate or module `imp`

so with the upcoming cpubits crate, k256 wouldn't still compile for an 8-bit platform like AVR, unless dependencies are changed.

@tarcieri
Copy link
Member

getrandom is only under dev-dependencies. Did you add default-features = false to disable the std feature?

We ensure all of the crates in this repo build on no_std targets that are unsupported by getrandom:

https://github.com/RustCrypto/elliptic-curves/blob/master/.github/workflows/k256.yml#L30

@xphoniex
Copy link
Author

xphoniex commented Feb 14, 2023

getrandom is only under dev-dependencies. Did you add default-features = false to disable the std feature?

We ensure all of the crates in this repo build on no_std targets that are unsupported by getrandom:

https://github.com/RustCrypto/elliptic-curves/blob/master/.github/workflows/k256.yml#L30

Oops, my bad, it works! I'd deleted default-features = false before while I was trying different combinations for AVR.

Btw, regarding cpubits: I checked and the crate (RustCrypto/utils@916240a) is simply empty for now. What are you blocked on atm? Might be able to help.

@tarcieri
Copy link
Member

I just need to finish and merge RustCrypto/utils#826, which I plan to do soon

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

No branches or pull requests

2 participants