Skip to content

Feature: Initial no_std Support for Crypto#7

Open
sephynox wants to merge 4 commits intomainfrom
feat/no_std-support
Open

Feature: Initial no_std Support for Crypto#7
sephynox wants to merge 4 commits intomainfrom
feat/no_std-support

Conversation

@sephynox
Copy link
Collaborator

@sephynox sephynox commented Mar 5, 2026

Summary

  • Adds no_std support for the crypto crate
  • Adds no_std support for the utils crate

@sephynox sephynox requested review from Copilot and ezraripps March 5, 2026 23:11
@sephynox sephynox self-assigned this Mar 5, 2026
@sephynox sephynox added the enhancement New feature or request label Mar 5, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial no_std compatibility knobs to the keetanetwork-crypto and keetanetwork-utils crates by introducing std feature flags, switching to alloc types, and adjusting dependency feature sets to support no_std builds.

Changes:

  • Add #![no_std] under cfg_attr + alloc usage across keetanetwork-crypto modules.
  • Introduce std feature defaults for keetanetwork-utils and keetanetwork-crypto, and adjust dependencies to default-features = false where needed.
  • Update lockfile to reflect dependency feature/version resolution changes.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
keetanetwork-utils/src/lib.rs Adds no_std cfg gating at crate level.
keetanetwork-utils/Cargo.toml Adds std feature + changes defaults; modifies [lib] configuration.
keetanetwork-crypto/src/lib.rs Adds no_std gating and extern crate alloc for alloc-backed types/macros.
keetanetwork-crypto/src/utils.rs Switches String/Vec imports to alloc equivalents.
keetanetwork-crypto/src/operations/signature.rs Uses alloc::vec::Vec for no_std.
keetanetwork-crypto/src/operations/encryption.rs Uses alloc::vec::Vec for no_std.
keetanetwork-crypto/src/kdf.rs Uses alloc::vec::Vec for no_std.
keetanetwork-crypto/src/hash.rs Uses alloc::vec::Vec for no_std.
keetanetwork-crypto/src/error.rs Switches error strings to alloc::string::String.
keetanetwork-crypto/src/algorithms/mod.rs Uses alloc::vec::Vec and adjusts signature encoding import for no_std.
keetanetwork-crypto/src/algorithms/secp256r1.rs Uses alloc::vec::Vec for no_std.
keetanetwork-crypto/src/algorithms/secp256k1.rs Uses alloc::vec::Vec for no_std.
keetanetwork-crypto/src/algorithms/ed25519.rs Uses alloc::vec::Vec for no_std.
keetanetwork-crypto/src/algorithms/ecies.rs Uses alloc::vec::Vec for no_std.
keetanetwork-crypto/src/algorithms/aes_gcm.rs Uses alloc::vec::Vec for no_std.
keetanetwork-crypto/src/algorithms/aes_ctr.rs Uses alloc::vec::Vec for no_std.
keetanetwork-crypto/src/algorithms/aes_cbc.rs Uses alloc::vec::Vec for no_std.
keetanetwork-crypto/Cargo.toml Reworks dependency features for no_std and introduces std/alloc features.
Cargo.lock Updates resolved dependencies per feature/version changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


[dependencies.snafu]
workspace = true
version = "0.8.7"
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snafu is specified here with an explicit version even though the workspace already defines snafu under [workspace.dependencies] (Cargo.toml:70-73) and other crates depend on it via snafu.workspace = true. Consider switching back to workspace = true and overriding default-features/features locally (e.g., default-features = false and enabling snafu/std via this crate’s std feature) to keep dependency versions centralized and consistent across the workspace.

Suggested change
version = "0.8.7"
workspace = true

Copilot uses AI. Check for mistakes.

#![cfg_attr(not(feature = "std"), no_std)]

pub mod errors;
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keetanetwork-utils is now no_std when std feature is disabled, but it still unconditionally compiles and exports pub mod testing;. testing.rs uses Box, String, and format!/std::..., which will fail to compile for downstream crates building keetanetwork-utils with default-features = false (e.g., keetanetwork-crypto in no_std mode). Gate the testing module behind feature = "std" (or a dedicated testing feature), or refactor it to use alloc + alloc::format! so the crate actually builds in no_std.

Suggested change
pub mod errors;
pub mod errors;
#[cfg(feature = "std")]

Copilot uses AI. Check for mistakes.
Comment on lines 11 to 12
[lib]
crate-type = ["staticlib", "rlib"]
path = "src/lib.rs"
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR removes the [lib].crate-type = ["staticlib", "rlib"] configuration. That changes the produced artifacts (no staticlib by default) and isn’t mentioned in the PR description about no_std support. If staticlib outputs are still required (consistent with other workspace crates like keetanetwork-account, keetanetwork-error, etc.), re-add crate-type or document why it’s safe to drop.

Copilot uses AI. Check for mistakes.
Comment on lines 11 to 12
[lib]
crate-type = ["staticlib", "rlib"]
path = "src/lib.rs"
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR removes the [lib].crate-type = ["staticlib", "rlib"] configuration. That changes the produced artifacts (no staticlib by default) and isn’t mentioned in the PR description about no_std support. If staticlib outputs are still required/expected (most other workspace crates keep them), re-add crate-type or document why it’s safe to drop for keetanetwork-crypto.

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants