mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 04:09:23 +00:00
Differentiate no-std from alloc within tests/no-std
Fixes `no-std` builds for packages which intended to be `no-std` (without `alloc`). Updates a variety of MSRVs to 1.73 due to `flexible-transcript` no longer using `std-shims` to achieve 1.66 (as `std-shims` requires `alloc`). A future improvement would be for `std-shims` to have an `alloc` feature and only provide MSRV shims without it.
This commit is contained in:
4
.github/workflows/no-std.yml
vendored
4
.github/workflows/no-std.yml
vendored
@@ -32,4 +32,6 @@ jobs:
|
||||
run: sudo apt update && sudo apt install -y gcc-riscv64-unknown-elf gcc-multilib && rustup target add riscv32imac-unknown-none-elf
|
||||
|
||||
- name: Verify no-std builds
|
||||
run: CFLAGS=-I/usr/include cargo build --target riscv32imac-unknown-none-elf -p serai-no-std-tests
|
||||
run: |
|
||||
CFLAGS=-I/usr/include cargo +nightly build --target riscv32imac-unknown-none-elf -Z build-std=core -p serai-no-std-tests
|
||||
CFLAGS=-I/usr/include cargo +nightly build --target riscv32imac-unknown-none-elf -Z build-std=core,alloc -p serai-no-std-tests --features "alloc"
|
||||
|
||||
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3280,7 +3280,6 @@ dependencies = [
|
||||
"digest 0.10.7",
|
||||
"merlin",
|
||||
"sha2 0.10.9",
|
||||
"std-shims",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/ciphersuite
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = ["ciphersuite", "ff", "group"]
|
||||
edition = "2021"
|
||||
rust-version = "1.66"
|
||||
rust-version = "1.73"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
||||
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dalek-ff-gr
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = ["curve25519", "ed25519", "ristretto", "dalek", "group"]
|
||||
edition = "2021"
|
||||
rust-version = "1.66"
|
||||
rust-version = "1.73"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
@@ -33,7 +33,7 @@ ciphersuite = { path = "../ciphersuite", default-features = false }
|
||||
|
||||
crypto-bigint = { version = "0.5", default-features = false, features = ["zeroize"] }
|
||||
|
||||
curve25519-dalek = { version = ">= 4.0, < 4.2", default-features = false, features = ["alloc", "zeroize", "digest", "group", "precomputed-tables"] }
|
||||
curve25519-dalek = { version = ">= 4.0, < 4.2", default-features = false, features = ["zeroize", "digest", "group", "precomputed-tables"] }
|
||||
|
||||
[dev-dependencies]
|
||||
hex = "0.4"
|
||||
@@ -41,6 +41,6 @@ rand_core = { version = "0.6", default-features = false, features = ["std"] }
|
||||
ff-group-tests = { path = "../ff-group-tests" }
|
||||
|
||||
[features]
|
||||
alloc = ["zeroize/alloc", "ciphersuite/alloc"]
|
||||
alloc = ["zeroize/alloc", "ciphersuite/alloc", "curve25519-dalek/alloc"]
|
||||
std = ["alloc", "zeroize/std", "subtle/std", "rand_core/std", "digest/std", "sha2/std", "ciphersuite/std"]
|
||||
default = ["std"]
|
||||
|
||||
@@ -29,7 +29,10 @@ macro_rules! dalek_curve {
|
||||
}
|
||||
|
||||
fn hash_to_F(dst: &[u8], data: &[u8]) -> Self::F {
|
||||
Scalar::from_hash(Sha512::new_with_prefix(&[dst, data].concat()))
|
||||
let mut digest = Sha512::new();
|
||||
digest.update(dst);
|
||||
digest.update(data);
|
||||
Scalar::from_hash(digest)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dkg"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = ["dkg", "multisig", "threshold", "ff", "group"]
|
||||
edition = "2021"
|
||||
rust-version = "1.66"
|
||||
rust-version = "1.73"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
||||
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dkg/dealer"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = ["dkg", "multisig", "threshold", "ff", "group"]
|
||||
edition = "2021"
|
||||
rust-version = "1.66"
|
||||
rust-version = "1.73"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
||||
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dkg/recover
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = ["dkg", "multisig", "threshold", "ff", "group"]
|
||||
edition = "2021"
|
||||
rust-version = "1.66"
|
||||
rust-version = "1.73"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
||||
@@ -71,7 +71,11 @@ impl Ciphersuite for Ed448 {
|
||||
}
|
||||
|
||||
fn hash_to_F(dst: &[u8], data: &[u8]) -> Self::F {
|
||||
let digest = Self::H::digest([dst, data].concat());
|
||||
let mut digest = Self::H::new();
|
||||
Update::update(&mut digest, dst);
|
||||
Update::update(&mut digest, data);
|
||||
let digest = digest.finalize();
|
||||
|
||||
let mut wide_scalar = [0; 114];
|
||||
wide_scalar.copy_from_slice(digest.as_ref());
|
||||
Scalar::from_uniform_bytes(&wide_scalar)
|
||||
|
||||
@@ -94,9 +94,10 @@ impl ciphersuite::Ciphersuite for Embedwards25519 {
|
||||
/// substrings of each other.
|
||||
fn hash_to_F(dst: &[u8], data: &[u8]) -> Self::F {
|
||||
use blake2::Digest;
|
||||
<Scalar as FromUniformBytes<64>>::from_uniform_bytes(
|
||||
&Self::H::digest([dst, data].concat()).into(),
|
||||
)
|
||||
let mut digest = Self::H::new();
|
||||
digest.update(dst);
|
||||
digest.update(data);
|
||||
<Scalar as FromUniformBytes<64>>::from_uniform_bytes(&digest.finalize().into())
|
||||
}
|
||||
|
||||
// We override the provided impl, which compares against the reserialization, because
|
||||
|
||||
@@ -127,9 +127,10 @@ impl ciphersuite::Ciphersuite for Secq256k1 {
|
||||
/// substrings of each other.
|
||||
fn hash_to_F(dst: &[u8], data: &[u8]) -> Self::F {
|
||||
use blake2::Digest;
|
||||
<Scalar as FromUniformBytes<64>>::from_uniform_bytes(
|
||||
&Self::H::digest([dst, data].concat()).into(),
|
||||
)
|
||||
let mut digest = Self::H::new();
|
||||
digest.update(dst);
|
||||
digest.update(data);
|
||||
<Scalar as FromUniformBytes<64>>::from_uniform_bytes(&digest.finalize().into())
|
||||
}
|
||||
|
||||
// We override the provided impl, which compares against the reserialization, because
|
||||
|
||||
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/transcript"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = ["transcript"]
|
||||
edition = "2021"
|
||||
rust-version = "1.66"
|
||||
rust-version = "1.73"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
@@ -17,8 +17,6 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
std-shims = { path = "../../common/std-shims", version = "0.1.4", default-features = false }
|
||||
|
||||
zeroize = { version = "^1.5", default-features = false }
|
||||
|
||||
digest = { version = "0.10", default-features = false, features = ["core-api"] }
|
||||
@@ -31,7 +29,7 @@ sha2 = { version = "0.10", default-features = false }
|
||||
blake2 = { version = "0.10", default-features = false }
|
||||
|
||||
[features]
|
||||
std = ["std-shims/std", "zeroize/std", "digest/std", "blake2?/std", "merlin?/std"]
|
||||
std = ["zeroize/std", "digest/std", "blake2?/std", "merlin?/std"]
|
||||
recommended = ["blake2"]
|
||||
tests = []
|
||||
default = ["std"]
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
#![doc = include_str!("../README.md")]
|
||||
#![no_std]
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use std_shims::prelude::*;
|
||||
|
||||
use zeroize::Zeroize;
|
||||
|
||||
use digest::{
|
||||
|
||||
@@ -8,7 +8,6 @@ authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = []
|
||||
edition = "2021"
|
||||
publish = false
|
||||
rust-version = "1.56"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
||||
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/processor/view-key
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = []
|
||||
edition = "2021"
|
||||
rust-version = "1.66"
|
||||
rust-version = "1.73"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
||||
@@ -19,23 +19,45 @@ workspace = true
|
||||
[dependencies]
|
||||
flexible-transcript = { path = "../../crypto/transcript", default-features = false, features = ["recommended", "merlin"] }
|
||||
|
||||
multiexp = { path = "../../crypto/multiexp", default-features = false, features = ["batch"], optional = true }
|
||||
|
||||
dalek-ff-group = { path = "../../crypto/dalek-ff-group", default-features = false }
|
||||
minimal-ed448 = { path = "../../crypto/ed448", default-features = false }
|
||||
|
||||
ciphersuite = { path = "../../crypto/ciphersuite", default-features = false, features = ["alloc"] }
|
||||
ciphersuite = { path = "../../crypto/ciphersuite", default-features = false }
|
||||
|
||||
multiexp = { path = "../../crypto/multiexp", default-features = false, features = ["batch"] }
|
||||
schnorr-signatures = { path = "../../crypto/schnorr", default-features = false, optional = true }
|
||||
|
||||
schnorr-signatures = { path = "../../crypto/schnorr", default-features = false }
|
||||
|
||||
prime-field = { path = "../../crypto/prime-field", default-features = false, features = ["alloc"] }
|
||||
short-weierstrass = { path = "../../crypto/short-weierstrass", default-features = false, features = ["alloc"] }
|
||||
prime-field = { path = "../../crypto/prime-field", default-features = false }
|
||||
short-weierstrass = { path = "../../crypto/short-weierstrass", default-features = false }
|
||||
secq256k1 = { path = "../../crypto/secq256k1", default-features = false }
|
||||
embedwards25519 = { path = "../../crypto/embedwards25519", default-features = false }
|
||||
|
||||
dkg = { path = "../../crypto/dkg", default-features = false }
|
||||
dkg-evrf = { path = "../../crypto/dkg/evrf", default-features = false }
|
||||
dkg = { path = "../../crypto/dkg", default-features = false, optional = true }
|
||||
dkg-evrf = { path = "../../crypto/dkg/evrf", default-features = false, features = ["secp256k1", "ed25519", "ristretto"], optional = true }
|
||||
# modular-frost = { path = "../../crypto/frost", default-features = false }
|
||||
# frost-schnorrkel = { path = "../../crypto/schnorrkel", default-features = false }
|
||||
|
||||
bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, features = ["hazmat"] }
|
||||
bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, features = ["hazmat"], optional = true }
|
||||
|
||||
[features]
|
||||
alloc = [
|
||||
"multiexp",
|
||||
|
||||
"dalek-ff-group/alloc",
|
||||
"minimal-ed448/alloc",
|
||||
|
||||
"ciphersuite/alloc",
|
||||
|
||||
"schnorr-signatures",
|
||||
|
||||
"prime-field/alloc",
|
||||
"short-weierstrass/alloc",
|
||||
"secq256k1/alloc",
|
||||
"embedwards25519/alloc",
|
||||
|
||||
"dkg",
|
||||
"dkg-evrf",
|
||||
|
||||
"bitcoin-serai",
|
||||
]
|
||||
|
||||
@@ -7,20 +7,22 @@ pub use minimal_ed448;
|
||||
|
||||
pub use ciphersuite;
|
||||
|
||||
pub use multiexp;
|
||||
|
||||
pub use schnorr_signatures;
|
||||
|
||||
pub use prime_field;
|
||||
pub use short_weierstrass;
|
||||
pub use secq256k1;
|
||||
pub use embedwards25519;
|
||||
|
||||
pub use dkg;
|
||||
pub use dkg_evrf;
|
||||
/*
|
||||
pub use modular_frost;
|
||||
pub use frost_schnorrkel;
|
||||
*/
|
||||
|
||||
pub use bitcoin_serai;
|
||||
#[cfg(feature = "alloc")]
|
||||
pub mod alloc {
|
||||
pub use multiexp;
|
||||
pub use schnorr_signatures;
|
||||
|
||||
pub use dkg;
|
||||
pub use dkg_evrf;
|
||||
|
||||
pub use bitcoin_serai;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user