From 02a5f1553593a6e2d6810dcc5d70b2b50fcf864d Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sat, 6 Sep 2025 14:43:21 -0400 Subject: [PATCH 01/15] Make the MSRV lint more robust The prior version would fail if the last entry in the final array was not originally the last entry. --- .github/workflows/lint.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index de77c8c9..9b604577 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -144,14 +144,15 @@ jobs: function check_workspace { # Get the members array from the workspace's `Cargo.toml` cargo_toml_lines=$(cat ./Cargo.toml | wc -l) + # Keep all lines after the start of the array, then keep all lines before the next "]" members=$(cat Cargo.toml | grep "members\ \=\ \[" -m1 -A$cargo_toml_lines | grep "]" -m1 -B$cargo_toml_lines) - # Parse out any comments, including comments post-fixed on the same line as an entry - members=$(echo "$members" | grep -Ev "^[[:space:]]+#" | grep -Ev "^[[:space:]]?$" | awk -F',' '{print $1","}') # Prune `members = [` to `[` by replacing the first line with just `[` members=$(echo "$members" | sed "1s/.*/\[/") - # Remove the trailing comma by replacing the last line's "," with "" - members=$(echo "$members" | sed "$(($(echo "$members" | wc -l) - 1))s/\,//") - # Correct the last line, which was malleated to "]," when pruning comments + + # Parse out any comments, whitespace, including comments post-fixed on the same line as an entry + # We accomplish the latter by pruning all characters after the entry's "," + members=$(echo "$members" | grep -Ev "^[[:space:]]*(#|$)" | awk -F',' '{print $1","}') + # Correct the last line, which was malleated to "]," members=$(echo "$members" | sed "$(echo "$members" | wc -l)s/\]\,/\]/") # Don't check the patches @@ -174,6 +175,9 @@ jobs: members=$(echo "$members" | grep -v "mini\"") members=$(echo "$members" | grep -v "tests/") + # Remove the trailing comma by replacing the last line's "," with "" + members=$(echo "$members" | sed "$(($(echo "$members" | wc -l) - 1))s/\,//") + echo $members | jq -r ".[]" | while read -r member; do check_msrv $member correct=$? From 4db78b17871426edafece6f481b6b53e1a0d6067 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Thu, 11 Sep 2025 17:24:47 -0400 Subject: [PATCH 02/15] Add the ability to bound the response's size limit to simple-request --- common/request/Cargo.toml | 3 ++- common/request/src/lib.rs | 12 ++++++------ common/request/src/request.rs | 26 +++++++++++++++++++------- common/request/src/response.rs | 33 ++++++++++++++++++++++++++++----- 4 files changed, 55 insertions(+), 19 deletions(-) diff --git a/common/request/Cargo.toml b/common/request/Cargo.toml index d960e91b..467d967a 100644 --- a/common/request/Cargo.toml +++ b/common/request/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "simple-request" -version = "0.1.0" +version = "0.1.1" description = "A simple HTTP(S) request library" license = "MIT" repository = "https://github.com/serai-dex/serai/tree/develop/common/simple-request" @@ -21,6 +21,7 @@ tower-service = { version = "0.3", default-features = false } hyper = { version = "1", default-features = false, features = ["http1", "client"] } hyper-util = { version = "0.1", default-features = false, features = ["http1", "client-legacy", "tokio"] } http-body-util = { version = "0.1", default-features = false } +futures-util = { version = "0.3", default-features = false, features = ["std"] } tokio = { version = "1", default-features = false } hyper-rustls = { version = "0.27", default-features = false, features = ["http1", "ring", "rustls-native-certs", "native-tokio"], optional = true } diff --git a/common/request/src/lib.rs b/common/request/src/lib.rs index df9689e1..04b162aa 100644 --- a/common/request/src/lib.rs +++ b/common/request/src/lib.rs @@ -97,7 +97,7 @@ impl Client { pub async fn request>(&self, request: R) -> Result, Error> { let request: Request = request.into(); - let mut request = request.0; + let Request { mut request, response_size_limit } = request; if let Some(header_host) = request.headers().get(hyper::header::HOST) { match &self.connection { Connection::ConnectionPool(_) => {} @@ -153,11 +153,11 @@ impl Client { let mut err = connection.ready().await.err(); if err.is_none() { // Send the request - let res = connection.send_request(request).await; - if let Ok(res) = res { - return Ok(Response(res, self)); + let response = connection.send_request(request).await; + if let Ok(response) = response { + return Ok(Response { response, size_limit: response_size_limit, client: self }); } - err = res.err(); + err = response.err(); } // Since this connection has been put into an error state, drop it *connection_lock = None; @@ -165,6 +165,6 @@ impl Client { } }; - Ok(Response(response, self)) + Ok(Response { response, size_limit: response_size_limit, client: self }) } } diff --git a/common/request/src/request.rs b/common/request/src/request.rs index ced0d10b..64a10ea7 100644 --- a/common/request/src/request.rs +++ b/common/request/src/request.rs @@ -7,11 +7,15 @@ pub use http_body_util::Full; use crate::Error; #[derive(Debug)] -pub struct Request(pub(crate) hyper::Request>); +pub struct Request { + pub(crate) request: hyper::Request>, + pub(crate) response_size_limit: Option, +} + impl Request { #[cfg(feature = "basic-auth")] fn username_password_from_uri(&self) -> Result<(String, String), Error> { - if let Some(authority) = self.0.uri().authority() { + if let Some(authority) = self.request.uri().authority() { let authority = authority.as_str(); if authority.contains('@') { // Decode the username and password from the URI @@ -36,7 +40,7 @@ impl Request { let mut formatted = format!("{username}:{password}"); let mut encoded = Base64::encode_string(formatted.as_bytes()); formatted.zeroize(); - self.0.headers_mut().insert( + self.request.headers_mut().insert( hyper::header::AUTHORIZATION, HeaderValue::from_str(&format!("Basic {encoded}")).unwrap(), ); @@ -59,9 +63,17 @@ impl Request { pub fn with_basic_auth(&mut self) { let _ = self.basic_auth_from_uri(); } -} -impl From>> for Request { - fn from(request: hyper::Request>) -> Request { - Request(request) + + /// Set a size limit for the response. + /// + /// This may be exceeded by a single HTTP frame and accordingly isn't perfect. + pub fn set_response_size_limit(&mut self, response_size_limit: Option) { + self.response_size_limit = response_size_limit; + } +} + +impl From>> for Request { + fn from(request: hyper::Request>) -> Request { + Request { request, response_size_limit: None } } } diff --git a/common/request/src/response.rs b/common/request/src/response.rs index e4628f72..19e025cf 100644 --- a/common/request/src/response.rs +++ b/common/request/src/response.rs @@ -1,24 +1,47 @@ +use std::io; + use hyper::{ StatusCode, header::{HeaderValue, HeaderMap}, - body::{Buf, Incoming}, + body::Incoming, }; use http_body_util::BodyExt; +use futures_util::{Stream, StreamExt}; + use crate::{Client, Error}; // Borrows the client so its async task lives as long as this response exists. #[allow(dead_code)] #[derive(Debug)] -pub struct Response<'a>(pub(crate) hyper::Response, pub(crate) &'a Client); +pub struct Response<'a> { + pub(crate) response: hyper::Response, + pub(crate) size_limit: Option, + pub(crate) client: &'a Client, +} + impl Response<'_> { pub fn status(&self) -> StatusCode { - self.0.status() + self.response.status() } pub fn headers(&self) -> &HeaderMap { - self.0.headers() + self.response.headers() } pub async fn body(self) -> Result { - Ok(self.0.into_body().collect().await.map_err(Error::Hyper)?.aggregate().reader()) + let mut body = self.response.into_body().into_data_stream(); + let mut res: Vec = vec![]; + loop { + if let Some(size_limit) = self.size_limit { + let (lower, upper) = body.size_hint(); + if res.len().wrapping_add(upper.unwrap_or(lower)) > size_limit.min(usize::MAX - 1) { + Err(Error::ConnectionError("response exceeded size limit".into()))?; + } + } + + let Some(part) = body.next().await else { break }; + let part = part.map_err(Error::Hyper)?; + res.extend(part.as_ref()); + } + Ok(io::Cursor::new(res)) } } From 87b4dfc8f32cd815ac1e770fdbf336beda9958ce Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Fri, 12 Sep 2025 18:24:56 -0400 Subject: [PATCH 03/15] Expand `std_shims::prelude` to better match `std::prelude` --- common/std-shims/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/std-shims/src/lib.rs b/common/std-shims/src/lib.rs index 2c2e1090..b627c63d 100644 --- a/common/std-shims/src/lib.rs +++ b/common/std-shims/src/lib.rs @@ -13,6 +13,14 @@ pub use alloc::str; pub use alloc::string; pub mod prelude { + pub use alloc::{ + format, vec, + boxed::Box, + borrow::ToOwned, + vec::Vec, + string::{String, ToString}, + }; + #[rustversion::before(1.73)] #[doc(hidden)] pub trait StdShimsDivCeil { From 29093715e3449f86e9e6a15c63d79d771d2cd210 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Fri, 12 Sep 2025 18:25:10 -0400 Subject: [PATCH 04/15] Add `impl Read for &mut R` to `std_shims` Increases parity with `std::io`. --- Cargo.lock | 2 +- common/std-shims/Cargo.toml | 2 +- common/std-shims/src/io.rs | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5bb18250..6f35f3c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11861,7 +11861,7 @@ dependencies = [ [[package]] name = "std-shims" -version = "0.1.4" +version = "0.1.5" dependencies = [ "hashbrown 0.15.5", "rustversion", diff --git a/common/std-shims/Cargo.toml b/common/std-shims/Cargo.toml index cd6d0c31..d83a0a3d 100644 --- a/common/std-shims/Cargo.toml +++ b/common/std-shims/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "std-shims" -version = "0.1.4" +version = "0.1.5" description = "A series of std shims to make alloc more feasible" license = "MIT" repository = "https://github.com/serai-dex/serai/tree/develop/common/std-shims" diff --git a/common/std-shims/src/io.rs b/common/std-shims/src/io.rs index 3f049a46..6ab8436b 100644 --- a/common/std-shims/src/io.rs +++ b/common/std-shims/src/io.rs @@ -64,6 +64,12 @@ mod shims { } } + impl Read for &mut R { + fn read(&mut self, buf: &mut [u8]) -> Result { + R::read(*self, buf) + } + } + pub trait BufRead: Read { fn fill_buf(&mut self) -> Result<&[u8]>; fn consume(&mut self, amt: usize); From 3bd48974f37b03941d68f49e8fb0a33b0228c4ed Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sun, 14 Sep 2025 08:55:40 -0400 Subject: [PATCH 05/15] Add missing `alloc` feature to `multiexp`'s use of `zeroize` Fixes building `multiexp` without default features, without separately specifying `zeroize` and adding the `alloc` feature. --- crypto/multiexp/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/multiexp/Cargo.toml b/crypto/multiexp/Cargo.toml index fcf32f85..f9f46e65 100644 --- a/crypto/multiexp/Cargo.toml +++ b/crypto/multiexp/Cargo.toml @@ -21,7 +21,7 @@ rustversion = "1" std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false } -zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive"] } +zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive", "alloc"] } ff = { version = "0.13", default-features = false, features = ["bits"] } group = { version = "0.13", default-features = false } From 95909d83a4237faf14210260abec3826cbb46e46 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Mon, 15 Sep 2025 21:21:30 -0400 Subject: [PATCH 06/15] Expose `std_shims::io` on `core` The `io::Write` trait is somewhat worthless, being implemented for nothing, yet `Read` remains fully functional. This also allows using its polyfills _without_ requiring `alloc`. Opportunity taken to make `schnorr-signatures` not require `alloc`. This will require a version bump before being published due to newly requiring the `alloc` feature be specified to maintain pre-existing behavior. Enables resolving https://github.com/monero-oxide/monero-oxide/issues/48. --- Cargo.lock | 1 + common/std-shims/Cargo.toml | 7 ++-- common/std-shims/README.md | 33 +++++++++++---- common/std-shims/src/collections.rs | 10 ++--- common/std-shims/src/io.rs | 65 ++++++++++++++++++++++------- common/std-shims/src/lib.rs | 36 ++++++++++++---- common/std-shims/src/sync.rs | 21 ++++++---- crypto/ciphersuite/Cargo.toml | 4 +- crypto/ciphersuite/src/lib.rs | 5 --- crypto/embedwards25519/Cargo.toml | 4 +- crypto/embedwards25519/src/lib.rs | 1 - crypto/schnorr/Cargo.toml | 9 ++-- crypto/schnorr/src/lib.rs | 23 ++++++---- crypto/secq256k1/Cargo.toml | 4 +- crypto/secq256k1/src/lib.rs | 1 - tests/no-std/Cargo.toml | 8 +++- tests/no-std/src/lib.rs | 14 ++++--- 17 files changed, 168 insertions(+), 78 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f35f3c9..ef25987e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10246,6 +10246,7 @@ dependencies = [ "schnorr-signatures", "secq256k1", "short-weierstrass", + "std-shims", ] [[package]] diff --git a/common/std-shims/Cargo.toml b/common/std-shims/Cargo.toml index d83a0a3d..efaf1ab4 100644 --- a/common/std-shims/Cargo.toml +++ b/common/std-shims/Cargo.toml @@ -18,9 +18,10 @@ workspace = true [dependencies] rustversion = { version = "1", default-features = false } -spin = { version = "0.10", default-features = false, features = ["use_ticket_mutex", "once", "lazy"] } -hashbrown = { version = "0.15", default-features = false, features = ["default-hasher", "inline-more"] } +spin = { version = "0.10", default-features = false, features = ["use_ticket_mutex", "fair_mutex", "once", "lazy"] } +hashbrown = { version = "0.16", default-features = false, features = ["default-hasher", "inline-more"], optional = true } [features] -std = [] +alloc = ["hashbrown"] +std = ["alloc", "spin/std"] default = ["std"] diff --git a/common/std-shims/README.md b/common/std-shims/README.md index b5bc121d..cf552579 100644 --- a/common/std-shims/README.md +++ b/common/std-shims/README.md @@ -1,11 +1,28 @@ -# std shims +# `std` shims -A crate which passes through to std when the default `std` feature is enabled, -yet provides a series of shims when it isn't. +`std-shims` is a Rust crate with two purposes: +- Expand the functionality of `core` and `alloc` +- Polyfill functionality only available on newer version of Rust -No guarantee of one-to-one parity is provided. The shims provided aim to be sufficient for the -average case. +The goal is to make supporting no-`std` environments, and older versions of +Rust, as simple as possible. For most use cases, replacing `std::` with +`std_shims::` and adding `use std_shims::prelude::*` is sufficient to take full +advantage of `std-shims`. -`HashSet` and `HashMap` are provided via `hashbrown`. Synchronization primitives are provided via -`spin` (avoiding a requirement on `critical-section`). -types are not guaranteed to be +# API Surface + +`std-shims` only aims to have items _mutually available_ between `alloc` (with +extra dependencies) and `std` publicly exposed. Items exclusive to `std`, with +no shims available, will not be exported by `std-shims`. + +# Dependencies + +`HashSet` and `HashMap` are provided via `hashbrown`. Synchronization +primitives are provided via `spin` (avoiding a requirement on +`critical-section`). Sections of `std::io` are independently matched as +possible. `rustversion` is used to detect when to provide polyfills. + +# Disclaimer + +No guarantee of one-to-one parity is provided. The shims provided aim to be +sufficient for the average case. Pull requests are _welcome_. diff --git a/common/std-shims/src/collections.rs b/common/std-shims/src/collections.rs index d3c74bad..5d0f0a56 100644 --- a/common/std-shims/src/collections.rs +++ b/common/std-shims/src/collections.rs @@ -1,7 +1,7 @@ +#[cfg(all(feature = "alloc", not(feature = "std")))] +pub use extern_alloc::collections::*; +#[cfg(all(feature = "alloc", not(feature = "std")))] +pub use hashbrown::{HashSet, HashMap}; + #[cfg(feature = "std")] pub use std::collections::*; - -#[cfg(not(feature = "std"))] -pub use alloc::collections::*; -#[cfg(not(feature = "std"))] -pub use hashbrown::{HashSet, HashMap}; diff --git a/common/std-shims/src/io.rs b/common/std-shims/src/io.rs index 6ab8436b..6d3019fd 100644 --- a/common/std-shims/src/io.rs +++ b/common/std-shims/src/io.rs @@ -1,42 +1,74 @@ -#[cfg(feature = "std")] -pub use std::io::*; - #[cfg(not(feature = "std"))] mod shims { - use core::fmt::{Debug, Formatter}; - use alloc::{boxed::Box, vec::Vec}; + use core::fmt::{self, Debug, Display, Formatter}; + #[cfg(feature = "alloc")] + use extern_alloc::{boxed::Box, vec::Vec}; + use crate::error::Error as CoreError; + /// The kind of error. #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum ErrorKind { UnexpectedEof, Other, } + /// An error. + #[derive(Debug)] pub struct Error { kind: ErrorKind, - error: Box, + #[cfg(feature = "alloc")] + error: Box, } - impl Debug for Error { - fn fmt(&self, fmt: &mut Formatter<'_>) -> core::result::Result<(), core::fmt::Error> { - fmt.debug_struct("Error").field("kind", &self.kind).finish_non_exhaustive() + impl Display for Error { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + ::fmt(self, f) } } + impl CoreError for Error {} + + #[cfg(not(feature = "alloc"))] + pub trait IntoBoxSendSyncError {} + #[cfg(not(feature = "alloc"))] + impl IntoBoxSendSyncError for I {} + #[cfg(feature = "alloc")] + pub trait IntoBoxSendSyncError: Into> {} + #[cfg(feature = "alloc")] + impl>> IntoBoxSendSyncError for I {} impl Error { - pub fn new(kind: ErrorKind, error: E) -> Error { - Error { kind, error: Box::new(error) } + /// Create a new error. + /// + /// The error object itself is silently dropped when `alloc` is not enabled. + #[allow(unused)] + pub fn new(kind: ErrorKind, error: E) -> Error { + #[cfg(not(feature = "alloc"))] + let res = Error { kind }; + #[cfg(feature = "alloc")] + let res = Error { kind, error: error.into() }; + res } - pub fn other(error: E) -> Error { - Error { kind: ErrorKind::Other, error: Box::new(error) } + /// Create a new error with `io::ErrorKind::Other` as its kind. + /// + /// The error object itself is silently dropped when `alloc` is not enabled. + #[allow(unused)] + pub fn other(error: E) -> Error { + #[cfg(not(feature = "alloc"))] + let res = Error { kind: ErrorKind::Other }; + #[cfg(feature = "alloc")] + let res = Error { kind: ErrorKind::Other, error: error.into() }; + res } + /// The kind of error. pub fn kind(&self) -> ErrorKind { self.kind } - pub fn into_inner(self) -> Option> { + /// Retrieve the inner error. + #[cfg(feature = "alloc")] + pub fn into_inner(self) -> Option> { Some(self.error) } } @@ -94,6 +126,7 @@ mod shims { } } + #[cfg(feature = "alloc")] impl Write for Vec { fn write(&mut self, buf: &[u8]) -> Result { self.extend(buf); @@ -101,6 +134,8 @@ mod shims { } } } - #[cfg(not(feature = "std"))] pub use shims::*; + +#[cfg(feature = "std")] +pub use std::io::{ErrorKind, Error, Result, Read, BufRead, Write}; diff --git a/common/std-shims/src/lib.rs b/common/std-shims/src/lib.rs index b627c63d..0ea8da07 100644 --- a/common/std-shims/src/lib.rs +++ b/common/std-shims/src/lib.rs @@ -2,25 +2,44 @@ #![doc = include_str!("../README.md")] #![cfg_attr(not(feature = "std"), no_std)] -pub extern crate alloc; +#[cfg(not(feature = "alloc"))] +pub use core::*; +#[cfg(not(feature = "alloc"))] +pub use core::{alloc, borrow, ffi, fmt, slice, str, task}; + +#[cfg(not(feature = "std"))] +#[rustversion::before(1.81)] +pub mod error { + use core::fmt::Debug::Display; + pub trait Error: Debug + Display {} +} +#[cfg(not(feature = "std"))] +#[rustversion::since(1.81)] +pub use core::error; + +#[cfg(all(feature = "alloc", not(feature = "std")))] +pub extern crate alloc as extern_alloc; +#[cfg(all(feature = "alloc", not(feature = "std")))] +pub use extern_alloc::{alloc, borrow, boxed, ffi, fmt, rc, slice, str, string, task, vec, format}; +#[cfg(feature = "std")] +pub use std::{alloc, borrow, boxed, error, ffi, fmt, rc, slice, str, string, task, vec, format}; -pub mod sync; pub mod collections; pub mod io; - -pub use alloc::vec; -pub use alloc::str; -pub use alloc::string; +pub mod sync; pub mod prelude { - pub use alloc::{ + // Shim the `std` prelude + #[cfg(all(feature = "alloc", not(feature = "std")))] + pub use extern_alloc::{ format, vec, - boxed::Box, borrow::ToOwned, + boxed::Box, vec::Vec, string::{String, ToString}, }; + // Shim `div_ceil` #[rustversion::before(1.73)] #[doc(hidden)] pub trait StdShimsDivCeil { @@ -61,6 +80,7 @@ pub mod prelude { } } + // Shim `io::Error::other` #[cfg(feature = "std")] #[rustversion::before(1.74)] #[doc(hidden)] diff --git a/common/std-shims/src/sync.rs b/common/std-shims/src/sync.rs index b25bfc61..7857c50d 100644 --- a/common/std-shims/src/sync.rs +++ b/common/std-shims/src/sync.rs @@ -1,19 +1,26 @@ -pub use core::sync::*; -pub use alloc::sync::*; +pub use core::sync::atomic; +#[cfg(all(feature = "alloc", not(feature = "std")))] +pub use extern_alloc::sync::{Arc, Weak}; mod mutex_shim { - #[cfg(feature = "std")] - pub use std::sync::*; #[cfg(not(feature = "std"))] - pub use spin::*; + pub use spin::{Mutex, MutexGuard}; + #[cfg(feature = "std")] + pub use std::sync::{Mutex, MutexGuard}; + /// A shimmed `Mutex` with an API mutual to `spin` and `std`. #[derive(Default, Debug)] pub struct ShimMutex(Mutex); impl ShimMutex { + /// Construct a new `Mutex`. pub const fn new(value: T) -> Self { Self(Mutex::new(value)) } + /// Acquire a lock on the contents of the `Mutex`. + /// + /// On no-`std` environments, this may spin until the lock is acquired. On `std` environments, + /// this may panic if the `Mutex` was poisoned. pub fn lock(&self) -> MutexGuard<'_, T> { #[cfg(feature = "std")] let res = self.0.lock().unwrap(); @@ -25,10 +32,8 @@ mod mutex_shim { } pub use mutex_shim::{ShimMutex as Mutex, MutexGuard}; -#[cfg(not(feature = "std"))] -pub use spin::Lazy as LazyLock; #[rustversion::before(1.80)] -#[cfg(feature = "std")] +#[cfg(not(feature = "std"))] pub use spin::Lazy as LazyLock; #[rustversion::since(1.80)] #[cfg(feature = "std")] diff --git a/crypto/ciphersuite/Cargo.toml b/crypto/ciphersuite/Cargo.toml index d1911369..80f29e0e 100644 --- a/crypto/ciphersuite/Cargo.toml +++ b/crypto/ciphersuite/Cargo.toml @@ -17,7 +17,7 @@ rustdoc-args = ["--cfg", "docsrs"] workspace = true [dependencies] -std-shims = { path = "../../common/std-shims", version = "0.1.4", default-features = false, optional = true } +std-shims = { path = "../../common/std-shims", version = "0.1.4", default-features = false } zeroize = { version = "^1.5", default-features = false, features = ["derive"] } subtle = { version = "^2.4", default-features = false } @@ -33,7 +33,7 @@ hex = { version = "0.4", default-features = false, features = ["std"] } ff-group-tests = { version = "0.13", path = "../ff-group-tests" } [features] -alloc = ["std-shims", "zeroize/alloc", "digest/alloc", "ff/alloc"] +alloc = ["zeroize/alloc", "digest/alloc", "ff/alloc"] std = [ "alloc", diff --git a/crypto/ciphersuite/src/lib.rs b/crypto/ciphersuite/src/lib.rs index 4816565b..f09ad71a 100644 --- a/crypto/ciphersuite/src/lib.rs +++ b/crypto/ciphersuite/src/lib.rs @@ -3,10 +3,8 @@ #![cfg_attr(not(feature = "std"), no_std)] use core::fmt::Debug; -#[cfg(feature = "alloc")] #[allow(unused_imports)] use std_shims::prelude::*; -#[cfg(feature = "alloc")] use std_shims::io::{self, Read}; use subtle::{CtOption, ConstantTimeEq, ConditionallySelectable}; @@ -112,7 +110,6 @@ pub trait GroupCanonicalEncoding: WrappedGroup { } /// `std::io` extensions for `GroupCanonicalEncoding.` -#[cfg(feature = "alloc")] #[allow(non_snake_case)] pub trait GroupIo: GroupCanonicalEncoding { /// Read a canonical field element from something implementing `std::io::Read`. @@ -129,8 +126,6 @@ pub trait GroupIo: GroupCanonicalEncoding { } /// Read a canonical point from something implementing `std::io::Read`. - #[cfg(feature = "alloc")] - #[allow(non_snake_case)] fn read_G(reader: &mut R) -> io::Result { let mut bytes = ::Repr::default(); reader.read_exact(bytes.as_mut())?; diff --git a/crypto/embedwards25519/Cargo.toml b/crypto/embedwards25519/Cargo.toml index 6d2efed8..70696472 100644 --- a/crypto/embedwards25519/Cargo.toml +++ b/crypto/embedwards25519/Cargo.toml @@ -16,7 +16,7 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] hex-literal = { version = "1", default-features = false } -std-shims = { version = "0.1", path = "../../common/std-shims", default-features = false, optional = true } +std-shims = { version = "0.1", path = "../../common/std-shims", default-features = false } zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive"] } @@ -39,6 +39,6 @@ rand_core = { version = "0.6", features = ["std"] } ff-group-tests = { path = "../ff-group-tests" } [features] -alloc = ["std-shims", "zeroize/alloc", "prime-field/alloc", "short-weierstrass/alloc", "curve25519-dalek/alloc", "blake2/alloc", "ciphersuite/alloc", "generalized-bulletproofs-ec-gadgets"] +alloc = ["zeroize/alloc", "prime-field/alloc", "short-weierstrass/alloc", "curve25519-dalek/alloc", "blake2/alloc", "ciphersuite/alloc", "generalized-bulletproofs-ec-gadgets"] std = ["alloc", "std-shims/std", "zeroize/std", "prime-field/std", "short-weierstrass/std", "ciphersuite/std", "generalized-bulletproofs-ec-gadgets/std"] default = ["std"] diff --git a/crypto/embedwards25519/src/lib.rs b/crypto/embedwards25519/src/lib.rs index 71e13dc9..03305090 100644 --- a/crypto/embedwards25519/src/lib.rs +++ b/crypto/embedwards25519/src/lib.rs @@ -2,7 +2,6 @@ #![doc = include_str!("../README.md")] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(feature = "alloc")] #[allow(unused_imports)] use std_shims::prelude::*; diff --git a/crypto/schnorr/Cargo.toml b/crypto/schnorr/Cargo.toml index ef2e6103..006275a1 100644 --- a/crypto/schnorr/Cargo.toml +++ b/crypto/schnorr/Cargo.toml @@ -26,8 +26,8 @@ digest = { version = "0.11.0-rc.1", default-features = false, features = ["block transcript = { package = "flexible-transcript", path = "../transcript", version = "^0.3.2", default-features = false, optional = true } -ciphersuite = { path = "../ciphersuite", version = "^0.4.1", default-features = false, features = ["alloc"] } -multiexp = { path = "../multiexp", version = "0.4", default-features = false, features = ["batch"] } +ciphersuite = { path = "../ciphersuite", version = "^0.4.1", default-features = false } +multiexp = { path = "../multiexp", version = "0.4", default-features = false, features = ["batch"], optional = true } [dev-dependencies] hex = "0.4" @@ -40,6 +40,7 @@ dalek-ff-group = { path = "../dalek-ff-group" } ciphersuite = { path = "../ciphersuite" } [features] -aggregate = ["transcript"] -std = ["std-shims/std", "rand_core/std", "zeroize/std", "transcript?/std", "ciphersuite/std", "multiexp/std"] +alloc = ["zeroize/alloc", "digest/alloc", "ciphersuite/alloc", "multiexp"] +aggregate = ["alloc", "transcript"] +std = ["alloc", "std-shims/std", "rand_core/std", "zeroize/std", "transcript?/std", "ciphersuite/std", "multiexp/std"] default = ["std"] diff --git a/crypto/schnorr/src/lib.rs b/crypto/schnorr/src/lib.rs index 42aca4d1..071ef8e6 100644 --- a/crypto/schnorr/src/lib.rs +++ b/crypto/schnorr/src/lib.rs @@ -3,14 +3,15 @@ #![cfg_attr(not(feature = "std"), no_std)] use core::ops::Deref; -#[cfg(not(feature = "std"))] -#[macro_use] +#[cfg(all(feature = "alloc", not(feature = "std")))] extern crate alloc; -use std_shims::{ - vec::Vec, - io::{self, Read, Write}, -}; +#[cfg(all(feature = "alloc", not(feature = "std")))] +use alloc::vec::Vec; +#[allow(unused_imports)] +use std_shims::prelude::*; +use std_shims::io::{self, Read, Write}; +#[cfg(feature = "alloc")] use rand_core::{RngCore, CryptoRng}; use zeroize::{Zeroize, Zeroizing}; @@ -22,6 +23,7 @@ use ciphersuite::{ }, GroupIo, }; +#[cfg(feature = "alloc")] use multiexp::{multiexp_vartime, BatchVerifier}; /// Half-aggregation from . @@ -59,6 +61,7 @@ impl SchnorrSignature { } /// Serialize a SchnorrSignature, returning a `Vec`. + #[cfg(feature = "alloc")] pub fn serialize(&self) -> Vec { let mut buf = vec![]; self.write(&mut buf).unwrap(); @@ -106,7 +109,12 @@ impl SchnorrSignature { /// different keys/messages. #[must_use] pub fn verify(&self, public_key: C::G, challenge: C::F) -> bool { - multiexp_vartime(&self.batch_statements(public_key, challenge)).is_identity().into() + let statements = self.batch_statements(public_key, challenge); + #[cfg(feature = "alloc")] + let res = multiexp_vartime(&statements); + #[cfg(not(feature = "alloc"))] + let res = statements.into_iter().map(|(scalar, point)| point * scalar).sum::(); + res.is_identity().into() } /// Queue a signature for batch verification. @@ -114,6 +122,7 @@ impl SchnorrSignature { /// This challenge must be properly crafted, which means being binding to the public key, nonce, /// and any message. Failure to do so will let a malicious adversary to forge signatures for /// different keys/messages. + #[cfg(feature = "alloc")] pub fn batch_verify( &self, rng: &mut R, diff --git a/crypto/secq256k1/Cargo.toml b/crypto/secq256k1/Cargo.toml index e0c4f3f4..6d752545 100644 --- a/crypto/secq256k1/Cargo.toml +++ b/crypto/secq256k1/Cargo.toml @@ -16,7 +16,7 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] hex-literal = { version = "1", default-features = false } -std-shims = { version = "0.1", path = "../../common/std-shims", default-features = false, optional = true } +std-shims = { version = "0.1", path = "../../common/std-shims", default-features = false } sha2 = { version = "0.11.0-rc.0", default-features = false } k256 = { version = "0.13", default-features = false, features = ["arithmetic", "expose-field"] } @@ -34,6 +34,6 @@ rand_core = { version = "0.6", features = ["std"] } ff-group-tests = { path = "../ff-group-tests" } [features] -alloc = ["std-shims", "k256/alloc", "prime-field/alloc", "short-weierstrass/alloc", "sha2/alloc", "ciphersuite/alloc", "generalized-bulletproofs-ec-gadgets"] +alloc = ["k256/alloc", "prime-field/alloc", "short-weierstrass/alloc", "sha2/alloc", "ciphersuite/alloc", "generalized-bulletproofs-ec-gadgets"] std = ["alloc", "std-shims/std", "k256/std", "prime-field/std", "ciphersuite/std", "generalized-bulletproofs-ec-gadgets/std"] default = ["std"] diff --git a/crypto/secq256k1/src/lib.rs b/crypto/secq256k1/src/lib.rs index ed92dce1..a77760c7 100644 --- a/crypto/secq256k1/src/lib.rs +++ b/crypto/secq256k1/src/lib.rs @@ -2,7 +2,6 @@ #![doc = include_str!("../README.md")] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(feature = "alloc")] #[allow(unused_imports)] use std_shims::prelude::*; diff --git a/tests/no-std/Cargo.toml b/tests/no-std/Cargo.toml index 3777d8ec..a828fe9c 100644 --- a/tests/no-std/Cargo.toml +++ b/tests/no-std/Cargo.toml @@ -17,6 +17,8 @@ rustdoc-args = ["--cfg", "docsrs"] workspace = true [dependencies] +std-shims = { path = "../../common/std-shims", default-features = false } + flexible-transcript = { path = "../../crypto/transcript", default-features = false, features = ["recommended", "merlin"] } multiexp = { path = "../../crypto/multiexp", default-features = false, features = ["batch"], optional = true } @@ -26,7 +28,7 @@ minimal-ed448 = { path = "../../crypto/ed448", default-features = false } ciphersuite = { path = "../../crypto/ciphersuite", default-features = false } -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 } short-weierstrass = { path = "../../crypto/short-weierstrass", default-features = false } @@ -42,6 +44,8 @@ bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, fea [features] alloc = [ + "std-shims/alloc", + "multiexp", "dalek-ff-group/alloc", @@ -49,7 +53,7 @@ alloc = [ "ciphersuite/alloc", - "schnorr-signatures", + "schnorr-signatures/alloc", "prime-field/alloc", "short-weierstrass/alloc", diff --git a/tests/no-std/src/lib.rs b/tests/no-std/src/lib.rs index 805f52a4..57f41a0e 100644 --- a/tests/no-std/src/lib.rs +++ b/tests/no-std/src/lib.rs @@ -1,5 +1,7 @@ #![no_std] +pub use std_shims; + pub use flexible_transcript; pub use dalek_ff_group; @@ -11,18 +13,20 @@ pub use prime_field; pub use short_weierstrass; pub use secq256k1; pub use embedwards25519; -/* -pub use modular_frost; -pub use frost_schnorrkel; -*/ + +pub use schnorr_signatures; #[cfg(feature = "alloc")] pub mod alloc { pub use multiexp; - pub use schnorr_signatures; pub use dkg; pub use dkg_evrf; pub use bitcoin_serai; + + /* + pub use modular_frost; + pub use frost_schnorrkel; + */ } From d6d96fe8ffef59c77a735c93a648e9b137337d58 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Mon, 15 Sep 2025 21:59:58 -0400 Subject: [PATCH 07/15] Correct `std-shims` feature flagging --- common/std-shims/src/sync.rs | 2 ++ crypto/dkg/Cargo.toml | 2 +- crypto/dkg/dealer/Cargo.toml | 2 +- crypto/dkg/evrf/Cargo.toml | 2 +- crypto/dkg/musig/Cargo.toml | 2 +- crypto/multiexp/Cargo.toml | 2 +- networks/bitcoin/Cargo.toml | 2 +- 7 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common/std-shims/src/sync.rs b/common/std-shims/src/sync.rs index 7857c50d..6ef7f478 100644 --- a/common/std-shims/src/sync.rs +++ b/common/std-shims/src/sync.rs @@ -1,6 +1,8 @@ pub use core::sync::atomic; #[cfg(all(feature = "alloc", not(feature = "std")))] pub use extern_alloc::sync::{Arc, Weak}; +#[cfg(feature = "std")] +pub use std::sync::{Arc, Weak}; mod mutex_shim { #[cfg(not(feature = "std"))] diff --git a/crypto/dkg/Cargo.toml b/crypto/dkg/Cargo.toml index 602e3318..1c6e3073 100644 --- a/crypto/dkg/Cargo.toml +++ b/crypto/dkg/Cargo.toml @@ -21,7 +21,7 @@ zeroize = { version = "^1.5", default-features = false, features = ["zeroize_der thiserror = { version = "2", default-features = false } -std-shims = { version = "0.1", path = "../../common/std-shims", default-features = false } +std-shims = { version = "0.1", path = "../../common/std-shims", default-features = false, features = ["alloc"] } borsh = { version = "1", default-features = false, features = ["derive", "de_strict_order"], optional = true } diff --git a/crypto/dkg/dealer/Cargo.toml b/crypto/dkg/dealer/Cargo.toml index c945c55f..f12a07d0 100644 --- a/crypto/dkg/dealer/Cargo.toml +++ b/crypto/dkg/dealer/Cargo.toml @@ -20,7 +20,7 @@ workspace = true zeroize = { version = "^1.5", default-features = false } rand_core = { version = "0.6", default-features = false } -std-shims = { version = "0.1", path = "../../../common/std-shims", default-features = false } +std-shims = { version = "0.1", path = "../../../common/std-shims", default-features = false, features = ["alloc"] } ciphersuite = { path = "../../ciphersuite", version = "^0.4.1", default-features = false } dkg = { path = "../", version = "0.6", default-features = false } diff --git a/crypto/dkg/evrf/Cargo.toml b/crypto/dkg/evrf/Cargo.toml index 21c2e8de..1bf7d831 100644 --- a/crypto/dkg/evrf/Cargo.toml +++ b/crypto/dkg/evrf/Cargo.toml @@ -23,7 +23,7 @@ rand_core = { version = "0.6", default-features = false, features = ["alloc"] } zeroize = { version = "^1.5", default-features = false, features = ["alloc", "zeroize_derive"] } -std-shims = { version = "0.1", path = "../../../common/std-shims", default-features = false } +std-shims = { version = "0.1", path = "../../../common/std-shims", default-features = false, features = ["alloc"] } transcript = { package = "flexible-transcript", path = "../../transcript", version = "^0.3.2", default-features = false, features = ["recommended"] } diff --git a/crypto/dkg/musig/Cargo.toml b/crypto/dkg/musig/Cargo.toml index 3887368c..7f928685 100644 --- a/crypto/dkg/musig/Cargo.toml +++ b/crypto/dkg/musig/Cargo.toml @@ -23,7 +23,7 @@ rand_core = { version = "0.6", default-features = false } zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive"] } -std-shims = { version = "0.1", path = "../../../common/std-shims", default-features = false } +std-shims = { version = "0.1", path = "../../../common/std-shims", default-features = false, features = ["alloc"] } multiexp = { path = "../../multiexp", version = "0.4", default-features = false } ciphersuite = { path = "../../ciphersuite", version = "^0.4.1", default-features = false } diff --git a/crypto/multiexp/Cargo.toml b/crypto/multiexp/Cargo.toml index f9f46e65..18efef3f 100644 --- a/crypto/multiexp/Cargo.toml +++ b/crypto/multiexp/Cargo.toml @@ -19,7 +19,7 @@ workspace = true [dependencies] rustversion = "1" -std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false } +std-shims = { path = "../../common/std-shims", version = "0.1.1", default-features = false, features = ["alloc"] } zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive", "alloc"] } diff --git a/networks/bitcoin/Cargo.toml b/networks/bitcoin/Cargo.toml index 9147feee..4d220f1d 100644 --- a/networks/bitcoin/Cargo.toml +++ b/networks/bitcoin/Cargo.toml @@ -16,7 +16,7 @@ rustdoc-args = ["--cfg", "docsrs"] workspace = true [dependencies] -std-shims = { version = "0.1.1", path = "../../common/std-shims", default-features = false } +std-shims = { version = "0.1.1", path = "../../common/std-shims", default-features = false, features = ["alloc"] } thiserror = { version = "2", default-features = false } From be68e27551515adc7b5ace8cbda4df2aa81e5c01 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Mon, 15 Sep 2025 22:37:59 -0400 Subject: [PATCH 08/15] Tweak `multiexp` to compile on `core` On `core`, it'll use a serial implementation of no benefit other than the fact that when `alloc` _is_ enabled, it'll use the multi-scalar multiplication algorithms. `schnorr-signatures` was prior tweaked to include a shim for `SchnorrSignature::verify` which didn't use `multiexp_vartime` yet this same premise. Now, instead of callers writing these shims, it's within `multiexp`. --- Cargo.lock | 2 - crypto/multiexp/Cargo.toml | 11 +- crypto/multiexp/README.md | 5 +- crypto/multiexp/src/batch.rs | 2 +- crypto/multiexp/src/lib.rs | 307 ++++++++++++++----------------- crypto/multiexp/src/pippenger.rs | 2 + crypto/multiexp/src/straus.rs | 2 +- crypto/schnorr/Cargo.toml | 4 +- crypto/schnorr/src/lib.rs | 10 +- tests/no-std/Cargo.toml | 5 +- 10 files changed, 161 insertions(+), 189 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef25987e..a09e75d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6334,8 +6334,6 @@ dependencies = [ "group", "k256", "rand_core 0.6.4", - "rustversion", - "std-shims", "zeroize", ] diff --git a/crypto/multiexp/Cargo.toml b/crypto/multiexp/Cargo.toml index 18efef3f..8239c68b 100644 --- a/crypto/multiexp/Cargo.toml +++ b/crypto/multiexp/Cargo.toml @@ -17,11 +17,7 @@ rustdoc-args = ["--cfg", "docsrs"] workspace = true [dependencies] -rustversion = "1" - -std-shims = { path = "../../common/std-shims", version = "0.1.1", default-features = false, features = ["alloc"] } - -zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive", "alloc"] } +zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive"] } ff = { version = "0.13", default-features = false, features = ["bits"] } group = { version = "0.13", default-features = false } @@ -35,8 +31,9 @@ k256 = { version = "^0.13.1", default-features = false, features = ["arithmetic" dalek-ff-group = { path = "../dalek-ff-group" } [features] -std = ["std-shims/std", "zeroize/std", "ff/std", "rand_core?/std"] +alloc = ["zeroize/alloc"] +std = ["alloc", "zeroize/std", "ff/std", "rand_core?/std"] -batch = ["rand_core"] +batch = ["alloc", "rand_core"] default = ["std"] diff --git a/crypto/multiexp/README.md b/crypto/multiexp/README.md index 1366f7a6..547dfa06 100644 --- a/crypto/multiexp/README.md +++ b/crypto/multiexp/README.md @@ -12,5 +12,6 @@ culminating in commit [669d2dbffc1dafb82a09d9419ea182667115df06](https://github.com/serai-dex/serai/tree/669d2dbffc1dafb82a09d9419ea182667115df06). Any subsequent changes have not undergone auditing. -This library is usable under no_std, via alloc, when the default features are -disabled. +This library is usable under no-`std` and no-`alloc`. With the `alloc` feature, +the library is fully functional. Without the `alloc` feature, the `multiexp` +function is shimmed with a serial implementation. diff --git a/crypto/multiexp/src/batch.rs b/crypto/multiexp/src/batch.rs index ea8044dd..50f07fc8 100644 --- a/crypto/multiexp/src/batch.rs +++ b/crypto/multiexp/src/batch.rs @@ -1,4 +1,4 @@ -use std_shims::vec::Vec; +use alloc::vec::Vec; use rand_core::{RngCore, CryptoRng}; diff --git a/crypto/multiexp/src/lib.rs b/crypto/multiexp/src/lib.rs index 8b16aa91..9bc35e4e 100644 --- a/crypto/multiexp/src/lib.rs +++ b/crypto/multiexp/src/lib.rs @@ -2,200 +2,177 @@ #![doc = include_str!("../README.md")] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] -#[macro_use] +#[cfg(feature = "alloc")] extern crate alloc; -#[allow(unused_imports)] -use std_shims::prelude::*; -use std_shims::vec::Vec; use zeroize::Zeroize; use ff::PrimeFieldBits; use group::Group; +#[cfg(feature = "alloc")] mod straus; -use straus::*; - +#[cfg(feature = "alloc")] mod pippenger; -use pippenger::*; #[cfg(feature = "batch")] mod batch; -#[cfg(feature = "batch")] -pub use batch::BatchVerifier; -#[cfg(test)] +#[cfg(all(test, feature = "alloc"))] mod tests; -// Use black_box when possible -#[rustversion::since(1.66)] -use core::hint::black_box; -#[rustversion::before(1.66)] -fn black_box(val: T) -> T { - val -} +#[cfg(feature = "alloc")] +mod underlying { + use super::*; -fn u8_from_bool(bit_ref: &mut bool) -> u8 { - let bit_ref = black_box(bit_ref); + use core::hint::black_box; + use alloc::{vec, vec::Vec}; - let mut bit = black_box(*bit_ref); - #[allow(clippy::cast_lossless)] - let res = black_box(bit as u8); - bit.zeroize(); - debug_assert!((res | 1) == 1); + pub(crate) use straus::*; - bit_ref.zeroize(); - res -} + pub(crate) use pippenger::*; -// Convert scalars to `window`-sized bit groups, as needed to index a table -// This algorithm works for `window <= 8` -pub(crate) fn prep_bits>( - pairs: &[(G::Scalar, G)], - window: u8, -) -> Vec> { - let w_usize = usize::from(window); + #[cfg(feature = "batch")] + pub use batch::BatchVerifier; - let mut groupings = vec![]; - for pair in pairs { - let p = groupings.len(); - let mut bits = pair.0.to_le_bits(); - groupings.push(vec![0; bits.len().div_ceil(w_usize)]); + fn u8_from_bool(bit_ref: &mut bool) -> u8 { + let bit_ref = black_box(bit_ref); - for (i, mut bit) in bits.iter_mut().enumerate() { - let mut bit = u8_from_bool(&mut bit); - groupings[p][i / w_usize] |= bit << (i % w_usize); - bit.zeroize(); + let mut bit = black_box(*bit_ref); + #[allow(clippy::cast_lossless)] + let res = black_box(bit as u8); + bit.zeroize(); + debug_assert!((res | 1) == 1); + + bit_ref.zeroize(); + res + } + + // Convert scalars to `window`-sized bit groups, as needed to index a table + // This algorithm works for `window <= 8` + pub(crate) fn prep_bits>( + pairs: &[(G::Scalar, G)], + window: u8, + ) -> Vec> { + let w_usize = usize::from(window); + + let mut groupings = vec![]; + for pair in pairs { + let p = groupings.len(); + let mut bits = pair.0.to_le_bits(); + groupings.push(vec![0; bits.len().div_ceil(w_usize)]); + + for (i, mut bit) in bits.iter_mut().enumerate() { + let mut bit = u8_from_bool(&mut bit); + groupings[p][i / w_usize] |= bit << (i % w_usize); + bit.zeroize(); + } + } + + groupings + } + + #[derive(Clone, Copy, PartialEq, Eq, Debug)] + enum Algorithm { + Null, + Single, + Straus(u8), + Pippenger(u8), + } + + // These are 'rule of thumb's obtained via benchmarking `k256` and `curve25519-dalek` + fn algorithm(len: usize) -> Algorithm { + #[cfg(not(debug_assertions))] + if len == 0 { + Algorithm::Null + } else if len == 1 { + Algorithm::Single + } else if len < 10 { + // Straus 2 never showed a performance benefit, even with just 2 elements + Algorithm::Straus(3) + } else if len < 20 { + Algorithm::Straus(4) + } else if len < 50 { + Algorithm::Straus(5) + } else if len < 100 { + Algorithm::Pippenger(4) + } else if len < 125 { + Algorithm::Pippenger(5) + } else if len < 275 { + Algorithm::Pippenger(6) + } else if len < 400 { + Algorithm::Pippenger(7) + } else { + Algorithm::Pippenger(8) + } + + #[cfg(debug_assertions)] + if len == 0 { + Algorithm::Null + } else if len == 1 { + Algorithm::Single + } else if len < 10 { + Algorithm::Straus(3) + } else if len < 80 { + Algorithm::Straus(4) + } else if len < 100 { + Algorithm::Straus(5) + } else if len < 125 { + Algorithm::Pippenger(4) + } else if len < 275 { + Algorithm::Pippenger(5) + } else if len < 475 { + Algorithm::Pippenger(6) + } else if len < 750 { + Algorithm::Pippenger(7) + } else { + Algorithm::Pippenger(8) } } - groupings -} - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -enum Algorithm { - Null, - Single, - Straus(u8), - Pippenger(u8), -} - -/* -Release (with runs 20, so all of these are off by 20x): - -k256 -Straus 3 is more efficient at 5 with 678µs per -Straus 4 is more efficient at 10 with 530µs per -Straus 5 is more efficient at 35 with 467µs per - -Pippenger 5 is more efficient at 125 with 431µs per -Pippenger 6 is more efficient at 275 with 349µs per -Pippenger 7 is more efficient at 375 with 360µs per - -dalek -Straus 3 is more efficient at 5 with 519µs per -Straus 4 is more efficient at 10 with 376µs per -Straus 5 is more efficient at 170 with 330µs per - -Pippenger 5 is more efficient at 125 with 305µs per -Pippenger 6 is more efficient at 275 with 250µs per -Pippenger 7 is more efficient at 450 with 205µs per -Pippenger 8 is more efficient at 800 with 213µs per - -Debug (with runs 5, so...): - -k256 -Straus 3 is more efficient at 5 with 2532µs per -Straus 4 is more efficient at 10 with 1930µs per -Straus 5 is more efficient at 80 with 1632µs per - -Pippenger 5 is more efficient at 150 with 1441µs per -Pippenger 6 is more efficient at 300 with 1235µs per -Pippenger 7 is more efficient at 475 with 1182µs per -Pippenger 8 is more efficient at 625 with 1170µs per - -dalek: -Straus 3 is more efficient at 5 with 971µs per -Straus 4 is more efficient at 10 with 782µs per -Straus 5 is more efficient at 75 with 778µs per -Straus 6 is more efficient at 165 with 867µs per - -Pippenger 5 is more efficient at 125 with 677µs per -Pippenger 6 is more efficient at 250 with 655µs per -Pippenger 7 is more efficient at 475 with 500µs per -Pippenger 8 is more efficient at 875 with 499µs per -*/ -fn algorithm(len: usize) -> Algorithm { - #[cfg(not(debug_assertions))] - if len == 0 { - Algorithm::Null - } else if len == 1 { - Algorithm::Single - } else if len < 10 { - // Straus 2 never showed a performance benefit, even with just 2 elements - Algorithm::Straus(3) - } else if len < 20 { - Algorithm::Straus(4) - } else if len < 50 { - Algorithm::Straus(5) - } else if len < 100 { - Algorithm::Pippenger(4) - } else if len < 125 { - Algorithm::Pippenger(5) - } else if len < 275 { - Algorithm::Pippenger(6) - } else if len < 400 { - Algorithm::Pippenger(7) - } else { - Algorithm::Pippenger(8) + /// Performs a multiexponentiation, automatically selecting the optimal algorithm based on the + /// amount of pairs. + pub fn multiexp>( + pairs: &[(G::Scalar, G)], + ) -> G { + match algorithm(pairs.len()) { + Algorithm::Null => Group::identity(), + Algorithm::Single => pairs[0].1 * pairs[0].0, + // These functions panic if called without any pairs + Algorithm::Straus(window) => straus(pairs, window), + Algorithm::Pippenger(window) => pippenger(pairs, window), + } } - #[cfg(debug_assertions)] - if len == 0 { - Algorithm::Null - } else if len == 1 { - Algorithm::Single - } else if len < 10 { - Algorithm::Straus(3) - } else if len < 80 { - Algorithm::Straus(4) - } else if len < 100 { - Algorithm::Straus(5) - } else if len < 125 { - Algorithm::Pippenger(4) - } else if len < 275 { - Algorithm::Pippenger(5) - } else if len < 475 { - Algorithm::Pippenger(6) - } else if len < 750 { - Algorithm::Pippenger(7) - } else { - Algorithm::Pippenger(8) + /// Performs a multiexponentiation in variable time, automatically selecting the optimal algorithm + /// based on the amount of pairs. + pub fn multiexp_vartime>(pairs: &[(G::Scalar, G)]) -> G { + match algorithm(pairs.len()) { + Algorithm::Null => Group::identity(), + Algorithm::Single => pairs[0].1 * pairs[0].0, + Algorithm::Straus(window) => straus_vartime(pairs, window), + Algorithm::Pippenger(window) => pippenger_vartime(pairs, window), + } } } -/// Performs a multiexponentiation, automatically selecting the optimal algorithm based on the -/// amount of pairs. -pub fn multiexp>( - pairs: &[(G::Scalar, G)], -) -> G { - match algorithm(pairs.len()) { - Algorithm::Null => Group::identity(), - Algorithm::Single => pairs[0].1 * pairs[0].0, - // These functions panic if called without any pairs - Algorithm::Straus(window) => straus(pairs, window), - Algorithm::Pippenger(window) => pippenger(pairs, window), +#[cfg(not(feature = "alloc"))] +mod underlying { + use super::*; + + /// Performs a multiexponentiation, automatically selecting the optimal algorithm based on the + /// amount of pairs. + pub fn multiexp>( + pairs: &[(G::Scalar, G)], + ) -> G { + pairs.iter().map(|(scalar, point)| *point * scalar).sum() + } + + /// Performs a multiexponentiation in variable time, automatically selecting the optimal algorithm + /// based on the amount of pairs. + pub fn multiexp_vartime>(pairs: &[(G::Scalar, G)]) -> G { + pairs.iter().map(|(scalar, point)| *point * scalar).sum() } } -/// Performs a multiexponentiation in variable time, automatically selecting the optimal algorithm -/// based on the amount of pairs. -pub fn multiexp_vartime>(pairs: &[(G::Scalar, G)]) -> G { - match algorithm(pairs.len()) { - Algorithm::Null => Group::identity(), - Algorithm::Single => pairs[0].1 * pairs[0].0, - Algorithm::Straus(window) => straus_vartime(pairs, window), - Algorithm::Pippenger(window) => pippenger_vartime(pairs, window), - } -} +pub use underlying::*; diff --git a/crypto/multiexp/src/pippenger.rs b/crypto/multiexp/src/pippenger.rs index faf9edc2..42f91ab2 100644 --- a/crypto/multiexp/src/pippenger.rs +++ b/crypto/multiexp/src/pippenger.rs @@ -1,3 +1,5 @@ +use alloc::vec; + use zeroize::Zeroize; use ff::PrimeFieldBits; diff --git a/crypto/multiexp/src/straus.rs b/crypto/multiexp/src/straus.rs index 638b2827..c8994f1b 100644 --- a/crypto/multiexp/src/straus.rs +++ b/crypto/multiexp/src/straus.rs @@ -1,4 +1,4 @@ -use std_shims::vec::Vec; +use alloc::{vec, vec::Vec}; use zeroize::Zeroize; diff --git a/crypto/schnorr/Cargo.toml b/crypto/schnorr/Cargo.toml index 006275a1..0314223a 100644 --- a/crypto/schnorr/Cargo.toml +++ b/crypto/schnorr/Cargo.toml @@ -27,7 +27,7 @@ digest = { version = "0.11.0-rc.1", default-features = false, features = ["block transcript = { package = "flexible-transcript", path = "../transcript", version = "^0.3.2", default-features = false, optional = true } ciphersuite = { path = "../ciphersuite", version = "^0.4.1", default-features = false } -multiexp = { path = "../multiexp", version = "0.4", default-features = false, features = ["batch"], optional = true } +multiexp = { path = "../multiexp", version = "0.4", default-features = false } [dev-dependencies] hex = "0.4" @@ -40,7 +40,7 @@ dalek-ff-group = { path = "../dalek-ff-group" } ciphersuite = { path = "../ciphersuite" } [features] -alloc = ["zeroize/alloc", "digest/alloc", "ciphersuite/alloc", "multiexp"] +alloc = ["zeroize/alloc", "digest/alloc", "ciphersuite/alloc", "multiexp/alloc", "multiexp/batch"] aggregate = ["alloc", "transcript"] std = ["alloc", "std-shims/std", "rand_core/std", "zeroize/std", "transcript?/std", "ciphersuite/std", "multiexp/std"] default = ["std"] diff --git a/crypto/schnorr/src/lib.rs b/crypto/schnorr/src/lib.rs index 071ef8e6..23f64c79 100644 --- a/crypto/schnorr/src/lib.rs +++ b/crypto/schnorr/src/lib.rs @@ -23,8 +23,9 @@ use ciphersuite::{ }, GroupIo, }; +use multiexp::multiexp_vartime; #[cfg(feature = "alloc")] -use multiexp::{multiexp_vartime, BatchVerifier}; +use multiexp::BatchVerifier; /// Half-aggregation from . #[cfg(feature = "aggregate")] @@ -109,12 +110,7 @@ impl SchnorrSignature { /// different keys/messages. #[must_use] pub fn verify(&self, public_key: C::G, challenge: C::F) -> bool { - let statements = self.batch_statements(public_key, challenge); - #[cfg(feature = "alloc")] - let res = multiexp_vartime(&statements); - #[cfg(not(feature = "alloc"))] - let res = statements.into_iter().map(|(scalar, point)| point * scalar).sum::(); - res.is_identity().into() + multiexp_vartime(&self.batch_statements(public_key, challenge)).is_identity().into() } /// Queue a signature for batch verification. diff --git a/tests/no-std/Cargo.toml b/tests/no-std/Cargo.toml index a828fe9c..0b75f8ab 100644 --- a/tests/no-std/Cargo.toml +++ b/tests/no-std/Cargo.toml @@ -21,7 +21,7 @@ std-shims = { path = "../../common/std-shims", default-features = false } flexible-transcript = { path = "../../crypto/transcript", default-features = false, features = ["recommended", "merlin"] } -multiexp = { path = "../../crypto/multiexp", default-features = false, features = ["batch"], optional = true } +multiexp = { path = "../../crypto/multiexp", default-features = false } dalek-ff-group = { path = "../../crypto/dalek-ff-group", default-features = false } minimal-ed448 = { path = "../../crypto/ed448", default-features = false } @@ -46,7 +46,8 @@ bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, fea alloc = [ "std-shims/alloc", - "multiexp", + "multiexp/alloc", + "multiexp/batch", "dalek-ff-group/alloc", "minimal-ed448/alloc", From 19305aebc9b84f8704ddfda94ed3bc0415b22051 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Mon, 15 Sep 2025 23:16:11 -0400 Subject: [PATCH 09/15] Finally make `modular-frost` work with `alloc` alone Carries the update to `frost-schnorrkel` and `bitcoin-serai`. --- Cargo.lock | 8 +- crypto/frost/Cargo.toml | 68 ++++++-- crypto/frost/src/algorithm.rs | 4 +- crypto/frost/src/curve/mod.rs | 4 +- crypto/frost/src/lib.rs | 5 +- crypto/frost/src/nonce.rs | 4 +- crypto/frost/src/sign.rs | 4 +- crypto/frost/src/tests/mod.rs | 2 +- crypto/frost/src/tests/nonces.rs | 2 +- crypto/frost/src/tests/vectors.rs | 4 +- crypto/schnorrkel/Cargo.toml | 33 +++- crypto/schnorrkel/src/lib.rs | 5 +- crypto/schnorrkel/src/tests.rs | 2 +- networks/bitcoin/Cargo.toml | 4 +- networks/bitcoin/src/crypto.rs | 260 ++++++++++++++-------------- networks/bitcoin/src/lib.rs | 3 - networks/bitcoin/src/wallet/mod.rs | 47 +++-- networks/bitcoin/src/wallet/send.rs | 2 + tests/no-std/Cargo.toml | 14 +- tests/no-std/src/lib.rs | 9 +- 20 files changed, 280 insertions(+), 204 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a09e75d7..e2a4d6d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3546,11 +3546,11 @@ version = "0.2.0" dependencies = [ "ciphersuite 0.4.2", "flexible-transcript", - "group", "modular-frost", "rand_core 0.6.4", "schnorr-signatures", "schnorrkel", + "std-shims", "zeroize", ] @@ -6098,6 +6098,7 @@ dependencies = [ "schnorr-signatures", "serde_json", "sha2 0.10.9", + "std-shims", "subtle", "thiserror 2.0.16", "zeroize", @@ -10235,10 +10236,15 @@ dependencies = [ "ciphersuite 0.4.2", "dalek-ff-group 0.5.0", "dkg", + "dkg-dealer", "dkg-evrf", + "dkg-musig", + "dkg-recovery", "embedwards25519", "flexible-transcript", + "frost-schnorrkel", "minimal-ed448", + "modular-frost", "multiexp", "prime-field", "schnorr-signatures", diff --git a/crypto/frost/Cargo.toml b/crypto/frost/Cargo.toml index 790e4e3c..a7d56dd8 100644 --- a/crypto/frost/Cargo.toml +++ b/crypto/frost/Cargo.toml @@ -17,33 +17,35 @@ rustdoc-args = ["--cfg", "docsrs"] workspace = true [dependencies] -thiserror = { version = "2", default-features = false, features = ["std"] } +std-shims = { version = "0.1", path = "../../common/std-shims", default-features = false, features = ["alloc"] } -rand_core = { version = "0.6", default-features = false, features = ["std"] } -rand_chacha = { version = "0.3", default-features = false, features = ["std"] } +thiserror = { version = "2", default-features = false } -zeroize = { version = "^1.5", default-features = false, features = ["std", "zeroize_derive"] } -subtle = { version = "^2.4", default-features = false, features = ["std"] } +rand_core = { version = "0.6", default-features = false, features = ["alloc"] } +rand_chacha = { version = "0.3", default-features = false } -hex = { version = "0.4", default-features = false, features = ["std"], optional = true } +zeroize = { version = "^1.5", default-features = false, features = ["alloc", "zeroize_derive"] } +subtle = { version = "^2.4", default-features = false } -transcript = { package = "flexible-transcript", path = "../transcript", version = "^0.3.2", default-features = false, features = ["std", "recommended"] } +hex = { version = "0.4", default-features = false, features = ["alloc"], optional = true } -dalek-ff-group = { path = "../dalek-ff-group", version = "0.5", default-features = false, features = ["std"], optional = true } -minimal-ed448 = { path = "../ed448", version = "0.4", default-features = false, features = ["std"], optional = true } +transcript = { package = "flexible-transcript", path = "../transcript", version = "^0.3.2", default-features = false, features = ["recommended"] } -ciphersuite = { path = "../ciphersuite", version = "^0.4.1", default-features = false, features = ["std"] } +dalek-ff-group = { path = "../dalek-ff-group", version = "0.5", default-features = false, features = ["alloc"], optional = true } +minimal-ed448 = { path = "../ed448", version = "0.4", default-features = false, features = ["alloc"], optional = true } + +ciphersuite = { path = "../ciphersuite", version = "^0.4.1", default-features = false, features = ["alloc"] } sha2 = { version = "0.10.0", default-features = false, optional = true } elliptic-curve = { version = "0.13", default-features = false, features = ["hash2curve"], optional = true } -ciphersuite-kp256 = { path = "../ciphersuite/kp256", version = "0.4", default-features = false, features = ["std"], optional = true } +ciphersuite-kp256 = { path = "../ciphersuite/kp256", version = "0.4", default-features = false, features = ["alloc"], optional = true } -multiexp = { path = "../multiexp", version = "0.4", default-features = false, features = ["std", "batch"] } +multiexp = { path = "../multiexp", version = "0.4", default-features = false, features = ["alloc", "batch"] } -schnorr = { package = "schnorr-signatures", path = "../schnorr", version = "^0.5.1", default-features = false, features = ["std"] } +schnorr = { package = "schnorr-signatures", path = "../schnorr", version = "^0.5.1", default-features = false, features = ["alloc"] } -dkg = { path = "../dkg", version = "0.6.1", default-features = false, features = ["std"] } -dkg-recovery = { path = "../dkg/recovery", version = "0.6", default-features = false, features = ["std"], optional = true } -dkg-dealer = { path = "../dkg/dealer", version = "0.6", default-features = false, features = ["std"], optional = true } +dkg = { path = "../dkg", version = "0.6.1", default-features = false } +dkg-recovery = { path = "../dkg/recovery", version = "0.6", default-features = false, optional = true } +dkg-dealer = { path = "../dkg/dealer", version = "0.6", default-features = false, optional = true } [dev-dependencies] hex = "0.4" @@ -54,6 +56,38 @@ dkg-recovery = { path = "../dkg/recovery", default-features = false, features = dkg-dealer = { path = "../dkg/dealer", default-features = false, features = ["std"] } [features] +std = [ + "std-shims/std", + + "thiserror/std", + + "rand_core/std", + "rand_chacha/std", + + "zeroize/std", + "subtle/std", + + "hex?/std", + + "transcript/std", + + "dalek-ff-group?/std", + "minimal-ed448?/std", + + "ciphersuite/std", + "sha2?/std", + "elliptic-curve?/std", + "ciphersuite-kp256?/std", + + "multiexp/std", + + "schnorr/std", + + "dkg/std", + "dkg-recovery?/std", + "dkg-dealer?/std", +] + ed25519 = ["dalek-ff-group"] ristretto = ["dalek-ff-group"] @@ -63,3 +97,5 @@ p256 = ["sha2", "elliptic-curve", "ciphersuite-kp256"] ed448 = ["minimal-ed448"] tests = ["hex", "rand_core/getrandom", "dkg-dealer", "dkg-recovery"] + +default = ["std"] diff --git a/crypto/frost/src/algorithm.rs b/crypto/frost/src/algorithm.rs index 7c0dc37e..26847c43 100644 --- a/crypto/frost/src/algorithm.rs +++ b/crypto/frost/src/algorithm.rs @@ -1,5 +1,7 @@ use core::{marker::PhantomData, fmt::Debug}; -use std::io::{self, Read, Write}; +#[allow(unused_imports)] +use std_shims::prelude::*; +use std_shims::io::{self, Read, Write}; use zeroize::Zeroizing; use rand_core::{RngCore, CryptoRng}; diff --git a/crypto/frost/src/curve/mod.rs b/crypto/frost/src/curve/mod.rs index 0796c5ef..3b5db584 100644 --- a/crypto/frost/src/curve/mod.rs +++ b/crypto/frost/src/curve/mod.rs @@ -1,5 +1,7 @@ use core::{ops::Deref, convert::AsRef}; -use std::io::{self, Read}; +#[allow(unused_imports)] +use std_shims::prelude::*; +use std_shims::io::{self, Read}; use rand_core::{RngCore, CryptoRng}; diff --git a/crypto/frost/src/lib.rs b/crypto/frost/src/lib.rs index 6baf8872..24cdfd7f 100644 --- a/crypto/frost/src/lib.rs +++ b/crypto/frost/src/lib.rs @@ -1,8 +1,11 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc = include_str!("../README.md")] +#![cfg_attr(not(feature = "std"), no_std)] use core::fmt::Debug; -use std::collections::HashMap; +#[allow(unused_imports)] +use std_shims::prelude::*; +use std_shims::collections::HashMap; use thiserror::Error; diff --git a/crypto/frost/src/nonce.rs b/crypto/frost/src/nonce.rs index f76f9bc4..6351a36e 100644 --- a/crypto/frost/src/nonce.rs +++ b/crypto/frost/src/nonce.rs @@ -6,7 +6,9 @@ // Each nonce remains of the form (d, e) and made into a proper nonce with d + (e * b) use core::ops::Deref; -use std::{ +#[allow(unused_imports)] +use std_shims::prelude::*; +use std_shims::{ io::{self, Read, Write}, collections::HashMap, }; diff --git a/crypto/frost/src/sign.rs b/crypto/frost/src/sign.rs index 833c251c..25151d5a 100644 --- a/crypto/frost/src/sign.rs +++ b/crypto/frost/src/sign.rs @@ -1,5 +1,7 @@ use core::{ops::Deref, fmt::Debug}; -use std::{ +#[allow(unused_imports)] +use std_shims::prelude::*; +use std_shims::{ io::{self, Read, Write}, collections::HashMap, }; diff --git a/crypto/frost/src/tests/mod.rs b/crypto/frost/src/tests/mod.rs index f4f6330b..423aa483 100644 --- a/crypto/frost/src/tests/mod.rs +++ b/crypto/frost/src/tests/mod.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std_shims::collections::HashMap; use rand_core::{RngCore, CryptoRng}; diff --git a/crypto/frost/src/tests/nonces.rs b/crypto/frost/src/tests/nonces.rs index a28c7dea..2e6d275b 100644 --- a/crypto/frost/src/tests/nonces.rs +++ b/crypto/frost/src/tests/nonces.rs @@ -1,4 +1,4 @@ -use std::io::{self, Read}; +use std_shims::io::{self, Read}; use zeroize::Zeroizing; diff --git a/crypto/frost/src/tests/vectors.rs b/crypto/frost/src/tests/vectors.rs index d5cda345..c127d58a 100644 --- a/crypto/frost/src/tests/vectors.rs +++ b/crypto/frost/src/tests/vectors.rs @@ -1,8 +1,8 @@ use core::ops::Deref; -use std::collections::HashMap; +use std_shims::collections::HashMap; #[cfg(test)] -use std::str::FromStr; +use core::str::FromStr; use zeroize::Zeroizing; diff --git a/crypto/schnorrkel/Cargo.toml b/crypto/schnorrkel/Cargo.toml index 030c4c28..1fe90be3 100644 --- a/crypto/schnorrkel/Cargo.toml +++ b/crypto/schnorrkel/Cargo.toml @@ -17,18 +17,35 @@ rustdoc-args = ["--cfg", "docsrs"] workspace = true [dependencies] -rand_core = "0.6" -zeroize = "^1.5" +std-shims = { version = "0.1", default-features = false, features = ["alloc"] } -transcript = { package = "flexible-transcript", path = "../transcript", version = "^0.3.2", features = ["merlin"] } +rand_core = { version = "0.6", default-features = false } +zeroize = { version = "1.5", default-features = false, features = ["zeroize_derive", "alloc"] } -group = "0.13" +transcript = { package = "flexible-transcript", path = "../transcript", version = "0.3.2", default-features = false, features = ["merlin"] } -ciphersuite = { path = "../ciphersuite", version = "^0.4.1", features = ["std"] } -schnorr = { package = "schnorr-signatures", path = "../schnorr", version = "^0.5.1" } -frost = { path = "../frost", package = "modular-frost", version = "0.11.0", features = ["ristretto"] } +ciphersuite = { path = "../ciphersuite", version = "0.4.1", default-features = false, features = ["alloc"] } +schnorr = { package = "schnorr-signatures", path = "../schnorr", version = "0.5.1", default-features = false, features = ["alloc"] } +frost = { path = "../frost", package = "modular-frost", version = "0.11.0", default-features = false, features = ["ristretto"] } -schnorrkel = { version = "0.11" } +schnorrkel = { version = "0.11", default-features = false, features = ["alloc"] } [dev-dependencies] frost = { path = "../frost", package = "modular-frost", features = ["tests"] } + +[features] +std = [ + "std-shims/std", + + "rand_core/std", + "zeroize/std", + + "transcript/std", + + "ciphersuite/std", + "schnorr/std", + "frost/std", + + "schnorrkel/std", +] +default = ["std"] diff --git a/crypto/schnorrkel/src/lib.rs b/crypto/schnorrkel/src/lib.rs index 4eb3c853..41f42db2 100644 --- a/crypto/schnorrkel/src/lib.rs +++ b/crypto/schnorrkel/src/lib.rs @@ -1,7 +1,10 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc = include_str!("../README.md")] +#![cfg_attr(not(feature = "std"), no_std)] -use std::io::{self, Read}; +#[allow(unused_imports)] +use std_shims::prelude::*; +use std_shims::io::{self, Read}; use rand_core::{RngCore, CryptoRng}; diff --git a/crypto/schnorrkel/src/tests.rs b/crypto/schnorrkel/src/tests.rs index 2f3c758b..b0ae9138 100644 --- a/crypto/schnorrkel/src/tests.rs +++ b/crypto/schnorrkel/src/tests.rs @@ -1,6 +1,6 @@ use rand_core::OsRng; -use group::GroupEncoding; +use ciphersuite::group::GroupEncoding; use frost::{ Participant, tests::{key_gen, algorithm_machines, sign}, diff --git a/networks/bitcoin/Cargo.toml b/networks/bitcoin/Cargo.toml index 4d220f1d..40823f9d 100644 --- a/networks/bitcoin/Cargo.toml +++ b/networks/bitcoin/Cargo.toml @@ -27,7 +27,7 @@ rand_core = { version = "0.6", default-features = false } bitcoin = { version = "0.32", default-features = false } k256 = { version = "^0.13.1", default-features = false, features = ["arithmetic", "bits"] } -frost = { package = "modular-frost", path = "../../crypto/frost", version = "0.11", default-features = false, features = ["secp256k1"], optional = true } +frost = { package = "modular-frost", path = "../../crypto/frost", version = "0.11", default-features = false, features = ["secp256k1"] } hex = { version = "0.4", default-features = false, optional = true } serde = { version = "1", default-features = false, features = ["derive"], optional = true } @@ -55,7 +55,7 @@ std = [ "bitcoin/serde", "k256/std", - "frost", + "frost/std", "hex/std", "serde/std", diff --git a/networks/bitcoin/src/crypto.rs b/networks/bitcoin/src/crypto.rs index 51e0f852..c083625e 100644 --- a/networks/bitcoin/src/crypto.rs +++ b/networks/bitcoin/src/crypto.rs @@ -1,9 +1,27 @@ -#[cfg(feature = "std")] +use core::fmt::Debug; +#[allow(unused_imports)] +use std_shims::prelude::*; +use std_shims::io; + use subtle::{Choice, ConstantTimeEq, ConditionallySelectable}; +use zeroize::Zeroizing; +use rand_core::{RngCore, CryptoRng}; -use k256::{elliptic_curve::sec1::ToEncodedPoint, ProjectivePoint}; +use k256::{ + elliptic_curve::{ops::Reduce, sec1::ToEncodedPoint}, + U256, Scalar, ProjectivePoint, +}; -use bitcoin::key::XOnlyPublicKey; +use bitcoin::{ + hashes::{HashEngine, Hash, sha256::Hash as Sha256}, + key::XOnlyPublicKey, +}; + +use frost::{ + curve::{WrappedGroup, Secp256k1}, + Participant, ThresholdKeys, ThresholdView, FrostError, + algorithm::{Hram as HramTrait, Algorithm, IetfSchnorr as FrostSchnorr}, +}; /// Get the x coordinate of a non-infinity point. /// @@ -21,142 +39,118 @@ pub(crate) fn x_only(key: &ProjectivePoint) -> XOnlyPublicKey { } /// Return if a point must be negated to have an even Y coordinate and be eligible for use. -#[cfg(feature = "std")] pub(crate) fn needs_negation(key: &ProjectivePoint) -> Choice { use k256::elliptic_curve::sec1::Tag; u8::from(key.to_encoded_point(true).tag()).ct_eq(&u8::from(Tag::CompressedOddY)) } -#[cfg(feature = "std")] -mod frost_crypto { - use core::fmt::Debug; - use std_shims::{vec::Vec, io}; +/// A BIP-340 compatible HRAm for use with the modular-frost Schnorr Algorithm. +/// +/// If passed an odd nonce, the challenge will be negated. +/// +/// If either `R` or `A` is the point at infinity, this will panic. +#[derive(Clone, Copy, Debug)] +pub struct Hram; +#[allow(non_snake_case)] +impl HramTrait for Hram { + fn hram(R: &ProjectivePoint, A: &ProjectivePoint, m: &[u8]) -> Scalar { + const TAG_HASH: Sha256 = Sha256::const_hash(b"BIP0340/challenge"); - use zeroize::Zeroizing; - use rand_core::{RngCore, CryptoRng}; + let mut data = Sha256::engine(); + data.input(TAG_HASH.as_ref()); + data.input(TAG_HASH.as_ref()); + data.input(&x(R)); + data.input(&x(A)); + data.input(m); - use bitcoin::hashes::{HashEngine, Hash, sha256::Hash as Sha256}; - - use k256::{elliptic_curve::ops::Reduce, U256, Scalar}; - - use frost::{ - curve::{WrappedGroup, Secp256k1}, - Participant, ThresholdKeys, ThresholdView, FrostError, - algorithm::{Hram as HramTrait, Algorithm, IetfSchnorr as FrostSchnorr}, - }; - - use super::*; - - /// A BIP-340 compatible HRAm for use with the modular-frost Schnorr Algorithm. - /// - /// If passed an odd nonce, the challenge will be negated. - /// - /// If either `R` or `A` is the point at infinity, this will panic. - #[derive(Clone, Copy, Debug)] - pub struct Hram; - #[allow(non_snake_case)] - impl HramTrait for Hram { - fn hram(R: &ProjectivePoint, A: &ProjectivePoint, m: &[u8]) -> Scalar { - const TAG_HASH: Sha256 = Sha256::const_hash(b"BIP0340/challenge"); - - let mut data = Sha256::engine(); - data.input(TAG_HASH.as_ref()); - data.input(TAG_HASH.as_ref()); - data.input(&x(R)); - data.input(&x(A)); - data.input(m); - - let c = Scalar::reduce(U256::from_be_slice(Sha256::from_engine(data).as_ref())); - // If the nonce was odd, sign `r - cx` instead of `r + cx`, allowing us to negate `s` at the - // end to sign as `-r + cx` - <_>::conditional_select(&c, &-c, needs_negation(R)) - } - } - - /// BIP-340 Schnorr signature algorithm. - /// - /// This may panic if called with nonces/a group key which are the point at infinity (which have - /// a negligible probability for a well-reasoned caller, even with malicious participants - /// present). - /// - /// `verify`, `verify_share` MUST be called after `sign_share` is called. Otherwise, this library - /// MAY panic. - #[derive(Clone)] - pub struct Schnorr(FrostSchnorr); - impl Schnorr { - /// Construct a Schnorr algorithm continuing the specified transcript. - #[allow(clippy::new_without_default)] - pub fn new() -> Schnorr { - Schnorr(FrostSchnorr::ietf()) - } - } - - impl Algorithm for Schnorr { - type Transcript = as Algorithm>::Transcript; - type Addendum = (); - type Signature = [u8; 64]; - - fn transcript(&mut self) -> &mut Self::Transcript { - self.0.transcript() - } - - fn nonces(&self) -> Vec> { - self.0.nonces() - } - - fn preprocess_addendum( - &mut self, - rng: &mut R, - keys: &ThresholdKeys, - ) { - self.0.preprocess_addendum(rng, keys) - } - - fn read_addendum(&self, reader: &mut R) -> io::Result { - self.0.read_addendum(reader) - } - - fn process_addendum( - &mut self, - view: &ThresholdView, - i: Participant, - addendum: (), - ) -> Result<(), FrostError> { - self.0.process_addendum(view, i, addendum) - } - - fn sign_share( - &mut self, - params: &ThresholdView, - nonce_sums: &[Vec<::G>], - nonces: Vec::F>>, - msg: &[u8], - ) -> ::F { - self.0.sign_share(params, nonce_sums, nonces, msg) - } - - fn verify( - &self, - group_key: ProjectivePoint, - nonces: &[Vec], - sum: Scalar, - ) -> Option { - self.0.verify(group_key, nonces, sum).map(|mut sig| { - sig.s = <_>::conditional_select(&sum, &-sum, needs_negation(&sig.R)); - // Convert to a Bitcoin signature by dropping the byte for the point's sign bit - sig.serialize()[1 ..].try_into().unwrap() - }) - } - - fn verify_share( - &self, - verification_share: ProjectivePoint, - nonces: &[Vec], - share: Scalar, - ) -> Result, ()> { - self.0.verify_share(verification_share, nonces, share) - } + let c = Scalar::reduce(U256::from_be_slice(Sha256::from_engine(data).as_ref())); + // If the nonce was odd, sign `r - cx` instead of `r + cx`, allowing us to negate `s` at the + // end to sign as `-r + cx` + <_>::conditional_select(&c, &-c, needs_negation(R)) + } +} + +/// BIP-340 Schnorr signature algorithm. +/// +/// This may panic if called with nonces/a group key which are the point at infinity (which have +/// a negligible probability for a well-reasoned caller, even with malicious participants +/// present). +/// +/// `verify`, `verify_share` MUST be called after `sign_share` is called. Otherwise, this library +/// MAY panic. +#[derive(Clone)] +pub struct Schnorr(FrostSchnorr); +impl Schnorr { + /// Construct a Schnorr algorithm continuing the specified transcript. + #[allow(clippy::new_without_default)] + pub fn new() -> Schnorr { + Schnorr(FrostSchnorr::ietf()) + } +} + +impl Algorithm for Schnorr { + type Transcript = as Algorithm>::Transcript; + type Addendum = (); + type Signature = [u8; 64]; + + fn transcript(&mut self) -> &mut Self::Transcript { + self.0.transcript() + } + + fn nonces(&self) -> Vec> { + self.0.nonces() + } + + fn preprocess_addendum( + &mut self, + rng: &mut R, + keys: &ThresholdKeys, + ) { + self.0.preprocess_addendum(rng, keys) + } + + fn read_addendum(&self, reader: &mut R) -> io::Result { + self.0.read_addendum(reader) + } + + fn process_addendum( + &mut self, + view: &ThresholdView, + i: Participant, + addendum: (), + ) -> Result<(), FrostError> { + self.0.process_addendum(view, i, addendum) + } + + fn sign_share( + &mut self, + params: &ThresholdView, + nonce_sums: &[Vec<::G>], + nonces: Vec::F>>, + msg: &[u8], + ) -> ::F { + self.0.sign_share(params, nonce_sums, nonces, msg) + } + + fn verify( + &self, + group_key: ProjectivePoint, + nonces: &[Vec], + sum: Scalar, + ) -> Option { + self.0.verify(group_key, nonces, sum).map(|mut sig| { + sig.s = <_>::conditional_select(&sum, &-sum, needs_negation(&sig.R)); + // Convert to a Bitcoin signature by dropping the byte for the point's sign bit + sig.serialize()[1 ..].try_into().unwrap() + }) + } + + fn verify_share( + &self, + verification_share: ProjectivePoint, + nonces: &[Vec], + share: Scalar, + ) -> Result, ()> { + self.0.verify_share(verification_share, nonces, share) } } -#[cfg(feature = "std")] -pub use frost_crypto::*; diff --git a/networks/bitcoin/src/lib.rs b/networks/bitcoin/src/lib.rs index 0aa17709..05d60139 100644 --- a/networks/bitcoin/src/lib.rs +++ b/networks/bitcoin/src/lib.rs @@ -2,9 +2,6 @@ #![doc = include_str!("../README.md")] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] -extern crate alloc; - /// The bitcoin Rust library. pub use bitcoin; diff --git a/networks/bitcoin/src/wallet/mod.rs b/networks/bitcoin/src/wallet/mod.rs index 97319f5f..a14d33f1 100644 --- a/networks/bitcoin/src/wallet/mod.rs +++ b/networks/bitcoin/src/wallet/mod.rs @@ -1,36 +1,31 @@ +#[allow(unused_imports)] +use std_shims::prelude::*; use std_shims::{ - vec::Vec, collections::HashMap, - io::{self, Write}, + io::{self, Read, Write}, }; -#[cfg(feature = "std")] -use std::io::{Read, BufReader}; use k256::{ elliptic_curve::sec1::{Tag, ToEncodedPoint}, Scalar, ProjectivePoint, }; -#[cfg(feature = "std")] use frost::{ curve::{WrappedGroup, GroupIo, Secp256k1}, ThresholdKeys, }; use bitcoin::{ - consensus::encode::serialize, key::TweakedPublicKey, OutPoint, ScriptBuf, TxOut, Transaction, - Block, + hashes::Hash, + key::TweakedPublicKey, + TapTweakHash, + consensus::encode::{Decodable, serialize}, + OutPoint, ScriptBuf, TxOut, Transaction, Block, }; -#[cfg(feature = "std")] -use bitcoin::{hashes::Hash, consensus::encode::Decodable, TapTweakHash}; -use crate::crypto::x_only; -#[cfg(feature = "std")] -use crate::crypto::needs_negation; +use crate::crypto::{x_only, needs_negation}; -#[cfg(feature = "std")] mod send; -#[cfg(feature = "std")] pub use send::*; /// Tweak keys to ensure they're usable with Bitcoin's Taproot upgrade. @@ -42,7 +37,6 @@ pub use send::*; /// After adding an unspendable script path, the key is negated if odd. /// /// This has a neligible probability of returning keys whose group key is the point at infinity. -#[cfg(feature = "std")] pub fn tweak_keys(keys: ThresholdKeys) -> ThresholdKeys { // Adds the unspendable script path per // https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_note-23 @@ -118,18 +112,23 @@ impl ReceivedOutput { } /// Read a ReceivedOutput from a generic satisfying Read. - #[cfg(feature = "std")] pub fn read(r: &mut R) -> io::Result { let offset = Secp256k1::read_F(r)?; - let output; - let outpoint; - { - let mut buf_r = BufReader::with_capacity(0, r); - output = - TxOut::consensus_decode(&mut buf_r).map_err(|_| io::Error::other("invalid TxOut"))?; - outpoint = - OutPoint::consensus_decode(&mut buf_r).map_err(|_| io::Error::other("invalid OutPoint"))?; + + struct BitcoinRead(R); + impl bitcoin::io::Read for BitcoinRead { + fn read(&mut self, buf: &mut [u8]) -> bitcoin::io::Result { + self + .0 + .read(buf) + .map_err(|e| bitcoin::io::Error::new(bitcoin::io::ErrorKind::Other, e.to_string())) + } } + let mut r = BitcoinRead(r); + + let output = TxOut::consensus_decode(&mut r).map_err(|_| io::Error::other("invalid TxOut"))?; + let outpoint = + OutPoint::consensus_decode(&mut r).map_err(|_| io::Error::other("invalid OutPoint"))?; Ok(ReceivedOutput { offset, output, outpoint }) } diff --git a/networks/bitcoin/src/wallet/send.rs b/networks/bitcoin/src/wallet/send.rs index 52824280..ec959934 100644 --- a/networks/bitcoin/src/wallet/send.rs +++ b/networks/bitcoin/src/wallet/send.rs @@ -1,3 +1,5 @@ +#[allow(unused_imports)] +use std_shims::prelude::*; use std_shims::{ io::{self, Read}, collections::HashMap, diff --git a/tests/no-std/Cargo.toml b/tests/no-std/Cargo.toml index 0b75f8ab..2552d7aa 100644 --- a/tests/no-std/Cargo.toml +++ b/tests/no-std/Cargo.toml @@ -36,9 +36,13 @@ secq256k1 = { path = "../../crypto/secq256k1", default-features = false } embedwards25519 = { path = "../../crypto/embedwards25519", default-features = false } dkg = { path = "../../crypto/dkg", default-features = false, optional = true } +dkg-dealer = { path = "../../crypto/dkg/dealer", default-features = false, optional = true } +dkg-recovery = { path = "../../crypto/dkg/recovery", default-features = false, optional = true } +dkg-musig = { path = "../../crypto/dkg/musig", default-features = false, optional = true } dkg-evrf = { path = "../../crypto/dkg/evrf", default-features = false, features = ["secp256k1", "ed25519"], optional = true } -# modular-frost = { path = "../../crypto/frost", default-features = false } -# frost-schnorrkel = { path = "../../crypto/schnorrkel", default-features = false } + +modular-frost = { path = "../../crypto/frost", default-features = false, optional = true } +frost-schnorrkel = { path = "../../crypto/schnorrkel", default-features = false, optional = true } bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, features = ["hazmat"], optional = true } @@ -62,7 +66,13 @@ alloc = [ "embedwards25519/alloc", "dkg", + "dkg-dealer", + "dkg-recovery", + "dkg-musig", "dkg-evrf", + "modular-frost", + "frost-schnorrkel", + "bitcoin-serai", ] diff --git a/tests/no-std/src/lib.rs b/tests/no-std/src/lib.rs index 57f41a0e..320a3c87 100644 --- a/tests/no-std/src/lib.rs +++ b/tests/no-std/src/lib.rs @@ -21,12 +21,13 @@ pub mod alloc { pub use multiexp; pub use dkg; + pub use dkg_dealer; + pub use dkg_recovery; + pub use dkg_musig; pub use dkg_evrf; - pub use bitcoin_serai; - - /* pub use modular_frost; pub use frost_schnorrkel; - */ + + pub use bitcoin_serai; } From 10c126ad924c438bd8ce04b6099053c6e24d4a89 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Thu, 18 Sep 2025 16:05:30 -0400 Subject: [PATCH 10/15] Misc updates --- .github/actions/build-dependencies/action.yml | 2 +- .github/workflows/daily-deny.yml | 2 +- .github/workflows/lint.yml | 12 +- Cargo.lock | 113 +++++++++--------- Cargo.toml | 4 +- crypto/dkg/evrf/Cargo.toml | 10 +- crypto/embedwards25519/Cargo.toml | 2 +- crypto/secq256k1/Cargo.toml | 2 +- crypto/short-weierstrass/Cargo.toml | 2 +- deny.toml | 102 ++++++++-------- .../dev/networks/monero/hashes-v0.18.3.4.txt | 50 -------- .../dev/networks/monero/hashes-v0.18.4.2.txt | 50 ++++++++ orchestration/src/main.rs | 2 +- orchestration/src/networks/monero.rs | 2 +- .../networks/monero/hashes-v0.18.3.4.txt | 50 -------- .../networks/monero/hashes-v0.18.4.2.txt | 50 ++++++++ patches/dalek-ff-group/Cargo.toml | 29 ----- patches/dalek-ff-group/LICENSE | 21 ---- patches/dalek-ff-group/README.md | 4 - patches/dalek-ff-group/src/lib.rs | 44 ------- processor/monero/Cargo.toml | 4 +- rust-toolchain.toml | 2 +- substrate/client/Cargo.toml | 2 +- substrate/node/Cargo.toml | 2 +- 24 files changed, 234 insertions(+), 329 deletions(-) delete mode 100644 orchestration/dev/networks/monero/hashes-v0.18.3.4.txt create mode 100644 orchestration/dev/networks/monero/hashes-v0.18.4.2.txt delete mode 100644 orchestration/testnet/networks/monero/hashes-v0.18.3.4.txt create mode 100644 orchestration/testnet/networks/monero/hashes-v0.18.4.2.txt delete mode 100644 patches/dalek-ff-group/Cargo.toml delete mode 100644 patches/dalek-ff-group/LICENSE delete mode 100644 patches/dalek-ff-group/README.md delete mode 100644 patches/dalek-ff-group/src/lib.rs diff --git a/.github/actions/build-dependencies/action.yml b/.github/actions/build-dependencies/action.yml index bfc02a4c..4629329b 100644 --- a/.github/actions/build-dependencies/action.yml +++ b/.github/actions/build-dependencies/action.yml @@ -43,7 +43,7 @@ runs: - name: Install solc shell: bash run: | - cargo +1.89 install svm-rs --version =0.5.18 + cargo +1.90 install svm-rs --version =0.5.19 svm install 0.8.26 svm use 0.8.26 diff --git a/.github/workflows/daily-deny.yml b/.github/workflows/daily-deny.yml index b11cdaf9..5cd7427e 100644 --- a/.github/workflows/daily-deny.yml +++ b/.github/workflows/daily-deny.yml @@ -18,7 +18,7 @@ jobs: key: rust-advisory-db - name: Install cargo deny - run: cargo +1.89 install cargo-deny --version =0.18.3 + run: cargo +1.90 install cargo-deny --version =0.18.4 - name: Run cargo deny run: cargo deny -L error --all-features check --hide-inclusion-graph diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9b604577..f78005b7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -52,7 +52,7 @@ jobs: key: rust-advisory-db - name: Install cargo deny - run: cargo +1.89 install cargo-deny --version =0.18.3 + run: cargo +1.90 install cargo-deny --version =0.18.4 - name: Run cargo deny run: cargo deny -L error --all-features check --hide-inclusion-graph @@ -88,8 +88,8 @@ jobs: - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac - name: Verify all dependencies are in use run: | - cargo +1.89 install cargo-machete --version =0.8.0 - cargo +1.89 machete + cargo +1.90 install cargo-machete --version =0.9.1 + cargo +1.90 machete msrv: runs-on: ubuntu-latest @@ -98,7 +98,7 @@ jobs: - name: Verify claimed `rust-version` shell: bash run: | - cargo +1.89 install cargo-msrv --version =0.18.4 + cargo +1.90 install cargo-msrv --version =0.18.4 function check_msrv { # We `cd` into the directory passed as the first argument, but will return to the @@ -146,12 +146,12 @@ jobs: cargo_toml_lines=$(cat ./Cargo.toml | wc -l) # Keep all lines after the start of the array, then keep all lines before the next "]" members=$(cat Cargo.toml | grep "members\ \=\ \[" -m1 -A$cargo_toml_lines | grep "]" -m1 -B$cargo_toml_lines) - # Prune `members = [` to `[` by replacing the first line with just `[` - members=$(echo "$members" | sed "1s/.*/\[/") # Parse out any comments, whitespace, including comments post-fixed on the same line as an entry # We accomplish the latter by pruning all characters after the entry's "," members=$(echo "$members" | grep -Ev "^[[:space:]]*(#|$)" | awk -F',' '{print $1","}') + # Replace the first line, which was "members = [" and is now "members = [,", with "[" + members=$(echo "$members" | sed "1s/.*/\[/") # Correct the last line, which was malleated to "]," members=$(echo "$members" | sed "$(echo "$members" | wc -l)s/\]\,/\]/") diff --git a/Cargo.lock b/Cargo.lock index e2a4d6d1..fa6d95c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -341,7 +341,7 @@ dependencies = [ "cfg-if", "const-hex", "derive_more 2.0.1", - "foldhash", + "foldhash 0.1.5", "hashbrown 0.15.5", "indexmap 2.11.0", "itoa", @@ -1938,7 +1938,7 @@ name = "ciphersuite" version = "0.4.99" dependencies = [ "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "std-shims", "zeroize", ] @@ -2402,7 +2402,7 @@ dependencies = [ "cxxbridge-cmd", "cxxbridge-flags", "cxxbridge-macro", - "foldhash", + "foldhash 0.1.5", "link-cplusplus", ] @@ -2470,16 +2470,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "dalek-ff-group" -version = "0.5.99" -dependencies = [ - "crypto-bigint 0.5.5", - "crypto-bigint 0.6.1", - "dalek-ff-group 0.5.0", - "prime-field", -] - [[package]] name = "darling" version = "0.20.11" @@ -2806,7 +2796,7 @@ dependencies = [ "blake2 0.11.0-rc.2", "ciphersuite 0.4.2", "ciphersuite-kp256", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "dkg", "dkg-recovery", "ec-divisors", @@ -2831,7 +2821,7 @@ name = "dkg-musig" version = "0.6.0" dependencies = [ "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "dkg", "dkg-recovery", "multiexp", @@ -2922,9 +2912,9 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "ec-divisors" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7216a2e84c7671c167c3d81eafe0d2b1f418f102#7216a2e84c7671c167c3d81eafe0d2b1f418f102" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=dc1b3dbe436aae61ec363505052d4715d38ce1df#dc1b3dbe436aae61ec363505052d4715d38ce1df" dependencies = [ - "dalek-ff-group 0.5.99", + "dalek-ff-group", "ff", "group", "rand_core 0.6.4", @@ -3350,6 +3340,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + [[package]] name = "fork-tree" version = "3.0.0" @@ -3771,7 +3767,7 @@ dependencies = [ [[package]] name = "generalized-bulletproofs" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7216a2e84c7671c167c3d81eafe0d2b1f418f102#7216a2e84c7671c167c3d81eafe0d2b1f418f102" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=dc1b3dbe436aae61ec363505052d4715d38ce1df#dc1b3dbe436aae61ec363505052d4715d38ce1df" dependencies = [ "blake2 0.10.6", "ciphersuite 0.4.99", @@ -3786,7 +3782,7 @@ dependencies = [ [[package]] name = "generalized-bulletproofs-circuit-abstraction" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7216a2e84c7671c167c3d81eafe0d2b1f418f102#7216a2e84c7671c167c3d81eafe0d2b1f418f102" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=dc1b3dbe436aae61ec363505052d4715d38ce1df#dc1b3dbe436aae61ec363505052d4715d38ce1df" dependencies = [ "ciphersuite 0.4.99", "generalized-bulletproofs", @@ -3797,7 +3793,7 @@ dependencies = [ [[package]] name = "generalized-bulletproofs-ec-gadgets" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7216a2e84c7671c167c3d81eafe0d2b1f418f102#7216a2e84c7671c167c3d81eafe0d2b1f418f102" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=dc1b3dbe436aae61ec363505052d4715d38ce1df#dc1b3dbe436aae61ec363505052d4715d38ce1df" dependencies = [ "ciphersuite 0.4.99", "generalized-bulletproofs-circuit-abstraction", @@ -4008,10 +4004,19 @@ checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ "allocator-api2", "equivalent", - "foldhash", + "foldhash 0.1.5", "serde", ] +[[package]] +name = "hashbrown" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +dependencies = [ + "foldhash 0.2.0", +] + [[package]] name = "heck" version = "0.4.1" @@ -6084,7 +6089,7 @@ version = "0.11.0" dependencies = [ "ciphersuite 0.4.2", "ciphersuite-kp256", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "dkg", "dkg-dealer", "dkg-recovery", @@ -6107,7 +6112,7 @@ dependencies = [ [[package]] name = "monero-address" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "curve25519-dalek", "monero-base58", @@ -6119,7 +6124,7 @@ dependencies = [ [[package]] name = "monero-base58" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "monero-primitives", "std-shims", @@ -6128,7 +6133,7 @@ dependencies = [ [[package]] name = "monero-borromean" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "curve25519-dalek", "monero-generators", @@ -6141,7 +6146,7 @@ dependencies = [ [[package]] name = "monero-bulletproofs" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "curve25519-dalek", "monero-generators", @@ -6156,10 +6161,10 @@ dependencies = [ [[package]] name = "monero-clsag" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "curve25519-dalek", - "dalek-ff-group 0.5.99", + "dalek-ff-group", "flexible-transcript", "group", "modular-frost", @@ -6177,11 +6182,11 @@ dependencies = [ [[package]] name = "monero-generators" version = "0.4.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "crypto-bigint 0.5.5", "curve25519-dalek", - "dalek-ff-group 0.5.99", + "dalek-ff-group", "group", "monero-io", "sha3 0.10.8", @@ -6192,7 +6197,7 @@ dependencies = [ [[package]] name = "monero-io" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "curve25519-dalek", "std-shims", @@ -6202,7 +6207,7 @@ dependencies = [ [[package]] name = "monero-mlsag" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "curve25519-dalek", "monero-generators", @@ -6216,7 +6221,7 @@ dependencies = [ [[package]] name = "monero-oxide" version = "0.1.4-alpha" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "curve25519-dalek", "hex-literal", @@ -6234,7 +6239,7 @@ dependencies = [ [[package]] name = "monero-primitives" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "curve25519-dalek", "monero-generators", @@ -6247,7 +6252,7 @@ dependencies = [ [[package]] name = "monero-rpc" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "curve25519-dalek", "hex", @@ -6263,7 +6268,7 @@ dependencies = [ [[package]] name = "monero-simple-request-rpc" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "digest_auth", "hex", @@ -6276,10 +6281,9 @@ dependencies = [ [[package]] name = "monero-wallet" version = "0.1.0" -source = "git+https://github.com/monero-oxide/monero-oxide?rev=7f37cc8f770858aa1739e0f56dbe447db86f4ba6#7f37cc8f770858aa1739e0f56dbe447db86f4ba6" +source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "curve25519-dalek", - "dalek-ff-group 0.5.99", "flexible-transcript", "hex", "modular-frost", @@ -6330,7 +6334,7 @@ dependencies = [ name = "multiexp" version = "0.4.2" dependencies = [ - "dalek-ff-group 0.5.0", + "dalek-ff-group", "ff", "group", "k256", @@ -9466,7 +9470,7 @@ name = "schnorr-signatures" version = "0.5.2" dependencies = [ "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "digest 0.11.0-rc.1", "flexible-transcript", "hex", @@ -9752,7 +9756,7 @@ dependencies = [ "borsh", "ciphersuite 0.4.2", "ciphersuite-kp256", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "dkg-musig", "dockertest", "frame-system", @@ -9813,7 +9817,7 @@ dependencies = [ "blake2 0.11.0-rc.2", "borsh", "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "dkg-musig", "env_logger", "frost-schnorrkel", @@ -9902,7 +9906,7 @@ dependencies = [ "blake2 0.11.0-rc.2", "borsh", "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "dkg", "log", "parity-scale-codec", @@ -10166,7 +10170,7 @@ version = "0.1.0" dependencies = [ "borsh", "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "env_logger", "flexible-transcript", "hex", @@ -10187,7 +10191,7 @@ name = "serai-message-queue-tests" version = "0.1.0" dependencies = [ "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "dockertest", "hex", "rand_core 0.6.4", @@ -10204,7 +10208,7 @@ version = "0.1.0" dependencies = [ "borsh", "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "dkg-evrf", "log", "modular-frost", @@ -10234,7 +10238,7 @@ version = "0.1.0" dependencies = [ "bitcoin-serai", "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "dkg", "dkg-dealer", "dkg-evrf", @@ -10262,7 +10266,7 @@ dependencies = [ "ciphersuite-kp256", "clap", "curve25519-dalek", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "embedwards25519", "frame-benchmarking", "futures-util", @@ -10313,7 +10317,7 @@ name = "serai-orchestrator" version = "0.0.1" dependencies = [ "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "embedwards25519", "flexible-transcript", "hex", @@ -10730,7 +10734,7 @@ version = "0.1.0" dependencies = [ "bitvec", "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "dkg-musig", "frame-support", "frame-system", @@ -10765,7 +10769,7 @@ version = "0.1.0" dependencies = [ "borsh", "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "dkg-musig", "parity-scale-codec", "scale-info", @@ -11050,9 +11054,10 @@ dependencies = [ [[package]] name = "simple-request" -version = "0.1.0" +version = "0.1.1" dependencies = [ "base64ct", + "futures-util", "http-body-util", "hyper 1.4.1", "hyper-rustls", @@ -11868,7 +11873,7 @@ dependencies = [ name = "std-shims" version = "0.1.5" dependencies = [ - "hashbrown 0.15.5", + "hashbrown 0.16.0", "rustversion", "spin 0.10.0", ] @@ -12618,7 +12623,7 @@ version = "0.1.0" dependencies = [ "blake2 0.11.0-rc.2", "ciphersuite 0.4.2", - "dalek-ff-group 0.5.0", + "dalek-ff-group", "flexible-transcript", "futures-channel", "futures-util", diff --git a/Cargo.toml b/Cargo.toml index a5443344..3234fac9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,8 +18,6 @@ members = [ # This re-exports the in-tree `ciphersuite` _without_ changes breaking to monero-oxide # Not included in workspace to prevent having two crates with the same name (an error) # "patches/ciphersuite", - # Same for `dalek-ff-group` - # "patches/dalek-ff-group", "common/std-shims", "common/zalloc", @@ -198,7 +196,7 @@ simple-request = { path = "common/request" } multiexp = { path = "crypto/multiexp" } flexible-transcript = { path = "crypto/transcript" } ciphersuite = { path = "patches/ciphersuite" } -dalek-ff-group = { path = "patches/dalek-ff-group" } +dalek-ff-group = { path = "crypto/dalek-ff-group" } minimal-ed448 = { path = "crypto/ed448" } modular-frost = { path = "crypto/frost" } diff --git a/crypto/dkg/evrf/Cargo.toml b/crypto/dkg/evrf/Cargo.toml index 1bf7d831..e7c768c0 100644 --- a/crypto/dkg/evrf/Cargo.toml +++ b/crypto/dkg/evrf/Cargo.toml @@ -34,10 +34,10 @@ generic-array = { version = "1", default-features = false, features = ["alloc"] blake2 = { version = "0.11.0-rc.2", default-features = false } rand_chacha = { version = "0.3", default-features = false } -generalized-bulletproofs = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7216a2e84c7671c167c3d81eafe0d2b1f418f102", default-features = false } -ec-divisors = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7216a2e84c7671c167c3d81eafe0d2b1f418f102", default-features = false } -generalized-bulletproofs-circuit-abstraction = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7216a2e84c7671c167c3d81eafe0d2b1f418f102", default-features = false } -generalized-bulletproofs-ec-gadgets = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7216a2e84c7671c167c3d81eafe0d2b1f418f102", default-features = false } +generalized-bulletproofs = { git = "https://github.com/monero-oxide/monero-oxide", rev = "dc1b3dbe436aae61ec363505052d4715d38ce1df", default-features = false } +ec-divisors = { git = "https://github.com/monero-oxide/monero-oxide", rev = "dc1b3dbe436aae61ec363505052d4715d38ce1df", default-features = false } +generalized-bulletproofs-circuit-abstraction = { git = "https://github.com/monero-oxide/monero-oxide", rev = "dc1b3dbe436aae61ec363505052d4715d38ce1df", default-features = false } +generalized-bulletproofs-ec-gadgets = { git = "https://github.com/monero-oxide/monero-oxide", rev = "dc1b3dbe436aae61ec363505052d4715d38ce1df", default-features = false } dkg = { path = "..", default-features = false } @@ -52,7 +52,7 @@ rand = { version = "0.8", default-features = false, features = ["std"] } ciphersuite = { path = "../../ciphersuite", default-features = false, features = ["std"] } embedwards25519 = { path = "../../embedwards25519", default-features = false, features = ["std"] } dalek-ff-group = { path = "../../dalek-ff-group", default-features = false, features = ["std"] } -generalized-bulletproofs = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7216a2e84c7671c167c3d81eafe0d2b1f418f102", features = ["tests"] } +generalized-bulletproofs = { git = "https://github.com/monero-oxide/monero-oxide", rev = "dc1b3dbe436aae61ec363505052d4715d38ce1df", features = ["tests"] } dkg-recovery = { path = "../recovery" } [features] diff --git a/crypto/embedwards25519/Cargo.toml b/crypto/embedwards25519/Cargo.toml index 70696472..c3af1a71 100644 --- a/crypto/embedwards25519/Cargo.toml +++ b/crypto/embedwards25519/Cargo.toml @@ -29,7 +29,7 @@ curve25519-dalek = { version = "4", default-features = false, features = ["legac blake2 = { version = "0.11.0-rc.2", default-features = false } ciphersuite = { path = "../ciphersuite", version = "0.4", default-features = false } -generalized-bulletproofs-ec-gadgets = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7216a2e84c7671c167c3d81eafe0d2b1f418f102", default-features = false, optional = true } +generalized-bulletproofs-ec-gadgets = { git = "https://github.com/monero-oxide/monero-oxide", rev = "dc1b3dbe436aae61ec363505052d4715d38ce1df", default-features = false, optional = true } [dev-dependencies] hex = "0.4" diff --git a/crypto/secq256k1/Cargo.toml b/crypto/secq256k1/Cargo.toml index 6d752545..e73d37e8 100644 --- a/crypto/secq256k1/Cargo.toml +++ b/crypto/secq256k1/Cargo.toml @@ -24,7 +24,7 @@ prime-field = { path = "../prime-field", default-features = false } short-weierstrass = { path = "../short-weierstrass", default-features = false } ciphersuite = { path = "../ciphersuite", version = "0.4", default-features = false } -generalized-bulletproofs-ec-gadgets = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7216a2e84c7671c167c3d81eafe0d2b1f418f102", default-features = false, optional = true } +generalized-bulletproofs-ec-gadgets = { git = "https://github.com/monero-oxide/monero-oxide", rev = "dc1b3dbe436aae61ec363505052d4715d38ce1df", default-features = false, optional = true } [dev-dependencies] hex = "0.4" diff --git a/crypto/short-weierstrass/Cargo.toml b/crypto/short-weierstrass/Cargo.toml index 3ad36bf6..b58fbf6e 100644 --- a/crypto/short-weierstrass/Cargo.toml +++ b/crypto/short-weierstrass/Cargo.toml @@ -21,7 +21,7 @@ rand_core = { version = "0.6", default-features = false } ff = { version = "0.13", default-features = false, features = ["bits"] } group = { version = "0.13", default-features = false } -ec-divisors = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7216a2e84c7671c167c3d81eafe0d2b1f418f102", default-features = false, optional = true } +ec-divisors = { git = "https://github.com/monero-oxide/monero-oxide", rev = "dc1b3dbe436aae61ec363505052d4715d38ce1df", default-features = false, optional = true } [features] alloc = ["zeroize/alloc", "rand_core/alloc", "ff/alloc", "group/alloc", "ec-divisors"] diff --git a/deny.toml b/deny.toml index 25cd1b2f..48b45cf2 100644 --- a/deny.toml +++ b/deny.toml @@ -36,77 +36,77 @@ allow = [ "MPL-2.0", "Apache-2.0", "Apache-2.0 WITH LLVM-exception", - "GPL-3.0 WITH Classpath-exception-2.0", + "GPL-3.0-or-later WITH Classpath-exception-2.0", ] exceptions = [ - { allow = ["AGPL-3.0"], name = "serai-env" }, - { allow = ["AGPL-3.0"], name = "serai-task" }, + { allow = ["AGPL-3.0-only"], name = "serai-env" }, + { allow = ["AGPL-3.0-only"], name = "serai-task" }, - { allow = ["AGPL-3.0"], name = "ethereum-schnorr-contract" }, - { allow = ["AGPL-3.0"], name = "serai-ethereum-relayer" }, + { allow = ["AGPL-3.0-only"], name = "ethereum-schnorr-contract" }, + { allow = ["AGPL-3.0-only"], name = "serai-ethereum-relayer" }, - { allow = ["AGPL-3.0"], name = "serai-message-queue" }, + { allow = ["AGPL-3.0-only"], name = "serai-message-queue" }, - { allow = ["AGPL-3.0"], name = "serai-processor-messages" }, - { allow = ["AGPL-3.0"], name = "serai-processor-primitives" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-messages" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-primitives" }, - { allow = ["AGPL-3.0"], name = "serai-processor-key-gen" }, - { allow = ["AGPL-3.0"], name = "serai-processor-frost-attempt-manager" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-key-gen" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-frost-attempt-manager" }, - { allow = ["AGPL-3.0"], name = "serai-processor-scanner" }, - { allow = ["AGPL-3.0"], name = "serai-processor-scheduler-primitives" }, - { allow = ["AGPL-3.0"], name = "serai-processor-utxo-scheduler-primitives" }, - { allow = ["AGPL-3.0"], name = "serai-processor-utxo-scheduler" }, - { allow = ["AGPL-3.0"], name = "serai-processor-transaction-chaining-scheduler" }, - { allow = ["AGPL-3.0"], name = "serai-processor-smart-contract-scheduler" }, - { allow = ["AGPL-3.0"], name = "serai-processor-signers" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-scanner" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-scheduler-primitives" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-utxo-scheduler-primitives" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-utxo-scheduler" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-transaction-chaining-scheduler" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-smart-contract-scheduler" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-signers" }, - { allow = ["AGPL-3.0"], name = "serai-bitcoin-processor" }, - { allow = ["AGPL-3.0"], name = "serai-processor-bin" }, - { allow = ["AGPL-3.0"], name = "serai-processor-ethereum-primitives" }, - { allow = ["AGPL-3.0"], name = "serai-ethereum-test-primitives" }, - { allow = ["AGPL-3.0"], name = "serai-processor-ethereum-deployer" }, - { allow = ["AGPL-3.0"], name = "serai-processor-ethereum-router" }, - { allow = ["AGPL-3.0"], name = "serai-processor-ethereum-erc20" }, - { allow = ["AGPL-3.0"], name = "serai-ethereum-processor" }, - { allow = ["AGPL-3.0"], name = "serai-monero-processor" }, + { allow = ["AGPL-3.0-only"], name = "serai-bitcoin-processor" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-bin" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-ethereum-primitives" }, + { allow = ["AGPL-3.0-only"], name = "serai-ethereum-test-primitives" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-ethereum-deployer" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-ethereum-router" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-ethereum-erc20" }, + { allow = ["AGPL-3.0-only"], name = "serai-ethereum-processor" }, + { allow = ["AGPL-3.0-only"], name = "serai-monero-processor" }, - { allow = ["AGPL-3.0"], name = "tributary-sdk" }, - { allow = ["AGPL-3.0"], name = "serai-cosign" }, - { allow = ["AGPL-3.0"], name = "serai-coordinator-substrate" }, - { allow = ["AGPL-3.0"], name = "serai-coordinator-tributary" }, - { allow = ["AGPL-3.0"], name = "serai-coordinator-p2p" }, - { allow = ["AGPL-3.0"], name = "serai-coordinator-libp2p-p2p" }, - { allow = ["AGPL-3.0"], name = "serai-coordinator" }, + { allow = ["AGPL-3.0-only"], name = "tributary-sdk" }, + { allow = ["AGPL-3.0-only"], name = "serai-cosign" }, + { allow = ["AGPL-3.0-only"], name = "serai-coordinator-substrate" }, + { allow = ["AGPL-3.0-only"], name = "serai-coordinator-tributary" }, + { allow = ["AGPL-3.0-only"], name = "serai-coordinator-p2p" }, + { allow = ["AGPL-3.0-only"], name = "serai-coordinator-libp2p-p2p" }, + { allow = ["AGPL-3.0-only"], name = "serai-coordinator" }, - { allow = ["AGPL-3.0"], name = "serai-coins-pallet" }, - { allow = ["AGPL-3.0"], name = "serai-dex-pallet" }, + { allow = ["AGPL-3.0-only"], name = "serai-coins-pallet" }, + { allow = ["AGPL-3.0-only"], name = "serai-dex-pallet" }, - { allow = ["AGPL-3.0"], name = "serai-genesis-liquidity-pallet" }, - { allow = ["AGPL-3.0"], name = "serai-emissions-pallet" }, + { allow = ["AGPL-3.0-only"], name = "serai-genesis-liquidity-pallet" }, + { allow = ["AGPL-3.0-only"], name = "serai-emissions-pallet" }, - { allow = ["AGPL-3.0"], name = "serai-economic-security-pallet" }, + { allow = ["AGPL-3.0-only"], name = "serai-economic-security-pallet" }, - { allow = ["AGPL-3.0"], name = "serai-in-instructions-pallet" }, + { allow = ["AGPL-3.0-only"], name = "serai-in-instructions-pallet" }, - { allow = ["AGPL-3.0"], name = "serai-validator-sets-pallet" }, + { allow = ["AGPL-3.0-only"], name = "serai-validator-sets-pallet" }, - { allow = ["AGPL-3.0"], name = "serai-signals-pallet" }, + { allow = ["AGPL-3.0-only"], name = "serai-signals-pallet" }, - { allow = ["AGPL-3.0"], name = "serai-runtime" }, - { allow = ["AGPL-3.0"], name = "serai-node" }, + { allow = ["AGPL-3.0-only"], name = "serai-runtime" }, + { allow = ["AGPL-3.0-only"], name = "serai-node" }, - { allow = ["AGPL-3.0"], name = "serai-orchestrator" }, + { allow = ["AGPL-3.0-only"], name = "serai-orchestrator" }, - { allow = ["AGPL-3.0"], name = "mini-serai" }, + { allow = ["AGPL-3.0-only"], name = "mini-serai" }, - { allow = ["AGPL-3.0"], name = "serai-docker-tests" }, - { allow = ["AGPL-3.0"], name = "serai-message-queue-tests" }, - { allow = ["AGPL-3.0"], name = "serai-processor-tests" }, - { allow = ["AGPL-3.0"], name = "serai-coordinator-tests" }, - { allow = ["AGPL-3.0"], name = "serai-full-stack-tests" }, - { allow = ["AGPL-3.0"], name = "serai-reproducible-runtime-tests" }, + { allow = ["AGPL-3.0-only"], name = "serai-docker-tests" }, + { allow = ["AGPL-3.0-only"], name = "serai-message-queue-tests" }, + { allow = ["AGPL-3.0-only"], name = "serai-processor-tests" }, + { allow = ["AGPL-3.0-only"], name = "serai-coordinator-tests" }, + { allow = ["AGPL-3.0-only"], name = "serai-full-stack-tests" }, + { allow = ["AGPL-3.0-only"], name = "serai-reproducible-runtime-tests" }, ] [[licenses.clarify]] diff --git a/orchestration/dev/networks/monero/hashes-v0.18.3.4.txt b/orchestration/dev/networks/monero/hashes-v0.18.3.4.txt deleted file mode 100644 index d3dca617..00000000 --- a/orchestration/dev/networks/monero/hashes-v0.18.3.4.txt +++ /dev/null @@ -1,50 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA256 - -# This GPG-signed message exists to confirm the SHA256 sums of Monero binaries. -# -# Please verify the signature against the key for binaryFate in the -# source code repository (/utils/gpg_keys). -# -# -## CLI -15e4d7dfc2f9261a0a452b0f8fd157c33cdbc8a896e23d883ddd13e2480a3800 monero-android-armv7-v0.18.3.4.tar.bz2 -d9c9249d1408822ce36b346c6b9fb6b896cda16714d62117fb1c588a5201763c monero-android-armv8-v0.18.3.4.tar.bz2 -360a551388922c8991a9ba4abaa88676b0fc7ec1fa4d0f4b5c0500847e0b946c monero-freebsd-x64-v0.18.3.4.tar.bz2 -354603c56446fb0551cdd6933bce5a13590b7881e05979b7ec25d89e7e59a0e2 monero-linux-armv7-v0.18.3.4.tar.bz2 -33ca2f0055529d225b61314c56370e35606b40edad61c91c859f873ed67a1ea7 monero-linux-armv8-v0.18.3.4.tar.bz2 -88739a1521b9fda3154540268e416c7af016ed7857041c76ab8ed7d7674c71ca monero-linux-riscv64-v0.18.3.4.tar.bz2 -51ba03928d189c1c11b5379cab17dd9ae8d2230056dc05c872d0f8dba4a87f1d monero-linux-x64-v0.18.3.4.tar.bz2 -d7ca0878abff2919a0104d7ed29d9c35df9ca0ea1b6fb4ebf6c8f7607ffb9e41 monero-linux-x86-v0.18.3.4.tar.bz2 -44520cb3a05c2518ca9aeae1b2e3080fe2bba1e3596d014ceff1090dfcba8ab4 monero-mac-armv8-v0.18.3.4.tar.bz2 -32c449f562216d3d83154e708471236d07db7477d6b67f1936a0a85a5005f2b8 monero-mac-x64-v0.18.3.4.tar.bz2 -54a66db6c892b2a0999754841f4ca68511741b88ea3ab20c7cd504a027f465f5 monero-win-x64-v0.18.3.4.zip -1a9824742aa1587023c3bddea788c115940cfd49371c78a8dd62c40113132d01 monero-win-x86-v0.18.3.4.zip -7d4845ec0a3b52404d41785da348ec33509f0a5981e8a27c5fa55b18d696e139 monero-source-v0.18.3.4.tar.bz2 -# -## GUI -63349d5a7637cd0c5d1693a1a2e910a92cbb123903d57667077a36454845d7bf monero-gui-install-win-x64-v0.18.3.4.exe -2866f3a2be30e4c4113e6274cad1d6698f81c37ceebc6e8f084c57230a0f70a6 monero-gui-linux-x64-v0.18.3.4.tar.bz2 -eedbf827513607a3ef579077dacd573e65892b199102effef97dff9d73138ca6 monero-gui-mac-armv8-v0.18.3.4.dmg -54eb151d7511a9f26130864e2c02f258344803b2b68311c8be29850d7faef359 monero-gui-mac-x64-v0.18.3.4.dmg -b5d42dddd722e728e480337f89038c8ea606c6507bf0c88ddf2af25050c9b751 monero-gui-win-x64-v0.18.3.4.zip -2f1d643bb2cc08e5eb334a6bfd649b0aa95ceb6178ff2f90448d5ef8d2a752a6 monero-gui-source-v0.18.3.4.tar.bz2 -# -# -# ~binaryFate ------BEGIN PGP SIGNATURE----- - -iQIzBAEBCAAdFiEEgaxZH+nEtlxYBq/D8K9NRioL35IFAmbF8bAACgkQ8K9NRioL -35KQAQ/7BP9j0Tx+zlFs3zbVIFXzfoPbGo2/uerM4xUWX/NUoI7XDTGWV2lpcR1x -o6eqstbuHciY0Aj2MsICsdqD+1PYW0EBZlfNLMrk161c3nQMJcjCE65uIhbLkOSs -6SUakmpxkueQOE/Ug5Afaa/JBATVTxLTmqSCI7Ai9NplF+6KNauXQXNrlwO/gHcd -whYDmsqp2JyOtMpMlpOckzLgg7Oroj7B0LBf78Z13p1naUyPooBaIEXSdKm5g2HI -vPd+z1bOVIluqPBnYWUwL7EmXy08/broejHGliQ+2iY9IsmDDx6rnSe/oprNEDic -l+/w3KvPcTkBh8hJLVDyYieYdVYHqOktIPlR1dKV512CnuP1ljr/CXjJmkAkXHlg -bObMUCIM9UYqp1I+KDaArjYNbzkHK02Lu6sak49GXgEuq66m9t4isF2GdcHrbERs -cLGsnhkTO2LtnGcziOC2l9XSzL41swxe0GrkK0rdeiyDCGAlb7hllevFy7zlT90l -Jw670TyFVBs8fUFHk/tOtT0ivSDJJg8m9waBzi/46ksOvuid6p3P3a0agqu3uclj -rscSpk0JS3E/3+A/N0IaiTmUO5zSjbsCrSnxQjcfrRRtERL+6JVHFVlW+nJzYWWH -u0O7bNZSqEruR4aTEtsddLgs57I10thDR5SUONuAqbEq8EYN8OE= -=aLFR ------END PGP SIGNATURE----- diff --git a/orchestration/dev/networks/monero/hashes-v0.18.4.2.txt b/orchestration/dev/networks/monero/hashes-v0.18.4.2.txt new file mode 100644 index 00000000..3188ceca --- /dev/null +++ b/orchestration/dev/networks/monero/hashes-v0.18.4.2.txt @@ -0,0 +1,50 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA256 + +# This GPG-signed message exists to confirm the SHA256 sums of Monero binaries. +# +# Please verify the signature against the key for binaryFate in the +# source code repository (/utils/gpg_keys). +# +# +## CLI +6122f0bcaca12d5badd92002338847d16032f6d52d86155c203bcb67d4fe1518 monero-android-armv7-v0.18.4.2.tar.bz2 +3b248c3201f028205915403b4b2f173df0dd8bf47eeb268fd67a4661251469d3 monero-android-armv8-v0.18.4.2.tar.bz2 +b4e2b7de80107a1b4613b878d8e2114244b3fb16397821d69baa72d9b0f8c8d5 monero-freebsd-x64-v0.18.4.2.tar.bz2 +ecb2577499a3b0901d731e11d462d3fadcd70095f3ab0def0c27ee64dc56b061 monero-linux-armv7-v0.18.4.2.tar.bz2 +a39530054dac348b219f1048a24ca629da26990f72cf9c1f6b6853e3d8c39a79 monero-linux-armv8-v0.18.4.2.tar.bz2 +18492ace80bf8ef2f44aa9a99b4f20adf00fd59c675a6a496211a720088d5d1a monero-linux-riscv64-v0.18.4.2.tar.bz2 +41d023f2357244ea43ee0a74796f5705ce75ce7373a5865d4959fefa13ecab06 monero-linux-x64-v0.18.4.2.tar.bz2 +03e77a4836861a47430664fa703dd149a355b3b214bc400b04ed38eb064a3ef0 monero-linux-x86-v0.18.4.2.tar.bz2 +9b98da6911b4769abef229c20e21f29d919b11db156965d6f139d2e1ad6625c2 monero-mac-armv8-v0.18.4.2.tar.bz2 +b1b1b580320118d3b6eaa5575fdbd73cf4db90fcc025b7abf875c5e5b4e335c1 monero-mac-x64-v0.18.4.2.tar.bz2 +14dd5aa11308f106183dd7834aa200e74ce6f3497103973696b556e893a4fef2 monero-win-x64-v0.18.4.2.zip +934d9dbeb06ff5610d2c96ebe34fa480e74f78eaeb3fa3e47d89b7961c9bc5e0 monero-win-x86-v0.18.4.2.zip +e9ec2062b3547db58f00102e6905621116ab7f56a331e0bc9b9e892607b87d24 monero-source-v0.18.4.2.tar.bz2 +# +## GUI +9d6e87add7e3ac006ee34c13c4f629252595395f54421db768f72dc233e94ea8 monero-gui-install-win-x64-v0.18.4.2.exe +e4fcdea3f0ff27c3616a8a75545f42a4e4866ea374fa2eeaa9c87027573358ea monero-gui-linux-x64-v0.18.4.2.tar.bz2 +3dfee5c5d8e000c72eb3755bf0eb03ca7c5928b69c3a241e147ad22d144e00a7 monero-gui-mac-armv8-v0.18.4.2.dmg +16abadcbd608d4f7ba20d17a297f2aa2c9066d33f6f22bf3fcdca679ab603990 monero-gui-mac-x64-v0.18.4.2.dmg +4daff8850280173d46464ba9a9de7f712228ad1ef76a1c4954531e4fd2b86d86 monero-gui-win-x64-v0.18.4.2.zip +691085e61ece6c56738431f3cfd395536ca0675214e5991e0dbfab85025e82d7 monero-gui-source-v0.18.4.2.tar.bz2 +# +# +# ~binaryFate +-----BEGIN PGP SIGNATURE----- + +iQIzBAEBCAAdFiEEgaxZH+nEtlxYBq/D8K9NRioL35IFAmitx+kACgkQ8K9NRioL +35J6cQ/7ByvGstg/a5lIYbB+Lz5bNiPozCILD9/offvC7GgOvna9rkHuofuLS+pX +qhYEMrjFjmp03XMY+i68M83qkBEZ+yU5iNDbwRuHUNMMWaaGlhnhm3nyUVtDpjjr +4xwVsee+dzi0JZhVQG7HJFURiP2Ub5Ua6bSaATDoT/aUYdhmrOnQiH2+VxogiCv3 +JStDqXq6LpFjzw7UkAfxxu1PW+AQFNBzi3L0qWfzb5WWL7xuK63wXGmEkYBlvult +qt3LUhDUzMrfZ5GiiOYDEw44Y2atD4ibOYtBnllCX9CKNb0o2KKU6Qkj+CYqqtnE +uGNOt1oT09VPOtE7OUkBLVkALjef7ZXRibE7tN4wSnsrG39DP795/52L6CGJbl4n +UDnHzLCUbuvhnoAu5U+rUP5nUEDYS9ANNyj610ogNCo7YjfzLH641WSQ/UnuXKkA +RmK8xIiKoOnUeOanX99zqeXqV7gQdQMlfwLUr3pQzCI2YjdvxdRoedSEi5nX5KvO +Snf3BcCYMBemGYqVMdo95tc0Gmsw12/O8WwrBbTea+PeAXJuLaBxrLNn+RNZLfF/ +UJYq2VcEwxG6vXb3cJ5lDKmRDDRI8Fxu6Amdab+6ponhM8Zy3eAynVIO952pLA7N +dtl72RsimM+sgHXP4ERYL4c6WARSHE5sAiog43dr56l3PPmM8pE= +=SoHG +-----END PGP SIGNATURE----- diff --git a/orchestration/src/main.rs b/orchestration/src/main.rs index b1e7b1cb..00615d82 100644 --- a/orchestration/src/main.rs +++ b/orchestration/src/main.rs @@ -149,7 +149,7 @@ fn build_serai_service(prelude: &str, release: bool, features: &str, package: &s format!( r#" -FROM rust:1.89-slim-bookworm AS builder +FROM rust:1.90-slim-bookworm AS builder COPY --from=mimalloc-debian libmimalloc.so /usr/lib RUN echo "/usr/lib/libmimalloc.so" >> /etc/ld.so.preload diff --git a/orchestration/src/networks/monero.rs b/orchestration/src/networks/monero.rs index 8103ff24..d30cdc69 100644 --- a/orchestration/src/networks/monero.rs +++ b/orchestration/src/networks/monero.rs @@ -10,7 +10,7 @@ fn monero_internal( monero_binary: &str, ports: &str, ) { - const MONERO_VERSION: &str = "0.18.3.4"; + const MONERO_VERSION: &str = "0.18.4.2"; let arch = match std::env::consts::ARCH { // We probably would run this without issues yet it's not worth needing to provide support for diff --git a/orchestration/testnet/networks/monero/hashes-v0.18.3.4.txt b/orchestration/testnet/networks/monero/hashes-v0.18.3.4.txt deleted file mode 100644 index d3dca617..00000000 --- a/orchestration/testnet/networks/monero/hashes-v0.18.3.4.txt +++ /dev/null @@ -1,50 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA256 - -# This GPG-signed message exists to confirm the SHA256 sums of Monero binaries. -# -# Please verify the signature against the key for binaryFate in the -# source code repository (/utils/gpg_keys). -# -# -## CLI -15e4d7dfc2f9261a0a452b0f8fd157c33cdbc8a896e23d883ddd13e2480a3800 monero-android-armv7-v0.18.3.4.tar.bz2 -d9c9249d1408822ce36b346c6b9fb6b896cda16714d62117fb1c588a5201763c monero-android-armv8-v0.18.3.4.tar.bz2 -360a551388922c8991a9ba4abaa88676b0fc7ec1fa4d0f4b5c0500847e0b946c monero-freebsd-x64-v0.18.3.4.tar.bz2 -354603c56446fb0551cdd6933bce5a13590b7881e05979b7ec25d89e7e59a0e2 monero-linux-armv7-v0.18.3.4.tar.bz2 -33ca2f0055529d225b61314c56370e35606b40edad61c91c859f873ed67a1ea7 monero-linux-armv8-v0.18.3.4.tar.bz2 -88739a1521b9fda3154540268e416c7af016ed7857041c76ab8ed7d7674c71ca monero-linux-riscv64-v0.18.3.4.tar.bz2 -51ba03928d189c1c11b5379cab17dd9ae8d2230056dc05c872d0f8dba4a87f1d monero-linux-x64-v0.18.3.4.tar.bz2 -d7ca0878abff2919a0104d7ed29d9c35df9ca0ea1b6fb4ebf6c8f7607ffb9e41 monero-linux-x86-v0.18.3.4.tar.bz2 -44520cb3a05c2518ca9aeae1b2e3080fe2bba1e3596d014ceff1090dfcba8ab4 monero-mac-armv8-v0.18.3.4.tar.bz2 -32c449f562216d3d83154e708471236d07db7477d6b67f1936a0a85a5005f2b8 monero-mac-x64-v0.18.3.4.tar.bz2 -54a66db6c892b2a0999754841f4ca68511741b88ea3ab20c7cd504a027f465f5 monero-win-x64-v0.18.3.4.zip -1a9824742aa1587023c3bddea788c115940cfd49371c78a8dd62c40113132d01 monero-win-x86-v0.18.3.4.zip -7d4845ec0a3b52404d41785da348ec33509f0a5981e8a27c5fa55b18d696e139 monero-source-v0.18.3.4.tar.bz2 -# -## GUI -63349d5a7637cd0c5d1693a1a2e910a92cbb123903d57667077a36454845d7bf monero-gui-install-win-x64-v0.18.3.4.exe -2866f3a2be30e4c4113e6274cad1d6698f81c37ceebc6e8f084c57230a0f70a6 monero-gui-linux-x64-v0.18.3.4.tar.bz2 -eedbf827513607a3ef579077dacd573e65892b199102effef97dff9d73138ca6 monero-gui-mac-armv8-v0.18.3.4.dmg -54eb151d7511a9f26130864e2c02f258344803b2b68311c8be29850d7faef359 monero-gui-mac-x64-v0.18.3.4.dmg -b5d42dddd722e728e480337f89038c8ea606c6507bf0c88ddf2af25050c9b751 monero-gui-win-x64-v0.18.3.4.zip -2f1d643bb2cc08e5eb334a6bfd649b0aa95ceb6178ff2f90448d5ef8d2a752a6 monero-gui-source-v0.18.3.4.tar.bz2 -# -# -# ~binaryFate ------BEGIN PGP SIGNATURE----- - -iQIzBAEBCAAdFiEEgaxZH+nEtlxYBq/D8K9NRioL35IFAmbF8bAACgkQ8K9NRioL -35KQAQ/7BP9j0Tx+zlFs3zbVIFXzfoPbGo2/uerM4xUWX/NUoI7XDTGWV2lpcR1x -o6eqstbuHciY0Aj2MsICsdqD+1PYW0EBZlfNLMrk161c3nQMJcjCE65uIhbLkOSs -6SUakmpxkueQOE/Ug5Afaa/JBATVTxLTmqSCI7Ai9NplF+6KNauXQXNrlwO/gHcd -whYDmsqp2JyOtMpMlpOckzLgg7Oroj7B0LBf78Z13p1naUyPooBaIEXSdKm5g2HI -vPd+z1bOVIluqPBnYWUwL7EmXy08/broejHGliQ+2iY9IsmDDx6rnSe/oprNEDic -l+/w3KvPcTkBh8hJLVDyYieYdVYHqOktIPlR1dKV512CnuP1ljr/CXjJmkAkXHlg -bObMUCIM9UYqp1I+KDaArjYNbzkHK02Lu6sak49GXgEuq66m9t4isF2GdcHrbERs -cLGsnhkTO2LtnGcziOC2l9XSzL41swxe0GrkK0rdeiyDCGAlb7hllevFy7zlT90l -Jw670TyFVBs8fUFHk/tOtT0ivSDJJg8m9waBzi/46ksOvuid6p3P3a0agqu3uclj -rscSpk0JS3E/3+A/N0IaiTmUO5zSjbsCrSnxQjcfrRRtERL+6JVHFVlW+nJzYWWH -u0O7bNZSqEruR4aTEtsddLgs57I10thDR5SUONuAqbEq8EYN8OE= -=aLFR ------END PGP SIGNATURE----- diff --git a/orchestration/testnet/networks/monero/hashes-v0.18.4.2.txt b/orchestration/testnet/networks/monero/hashes-v0.18.4.2.txt new file mode 100644 index 00000000..3188ceca --- /dev/null +++ b/orchestration/testnet/networks/monero/hashes-v0.18.4.2.txt @@ -0,0 +1,50 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA256 + +# This GPG-signed message exists to confirm the SHA256 sums of Monero binaries. +# +# Please verify the signature against the key for binaryFate in the +# source code repository (/utils/gpg_keys). +# +# +## CLI +6122f0bcaca12d5badd92002338847d16032f6d52d86155c203bcb67d4fe1518 monero-android-armv7-v0.18.4.2.tar.bz2 +3b248c3201f028205915403b4b2f173df0dd8bf47eeb268fd67a4661251469d3 monero-android-armv8-v0.18.4.2.tar.bz2 +b4e2b7de80107a1b4613b878d8e2114244b3fb16397821d69baa72d9b0f8c8d5 monero-freebsd-x64-v0.18.4.2.tar.bz2 +ecb2577499a3b0901d731e11d462d3fadcd70095f3ab0def0c27ee64dc56b061 monero-linux-armv7-v0.18.4.2.tar.bz2 +a39530054dac348b219f1048a24ca629da26990f72cf9c1f6b6853e3d8c39a79 monero-linux-armv8-v0.18.4.2.tar.bz2 +18492ace80bf8ef2f44aa9a99b4f20adf00fd59c675a6a496211a720088d5d1a monero-linux-riscv64-v0.18.4.2.tar.bz2 +41d023f2357244ea43ee0a74796f5705ce75ce7373a5865d4959fefa13ecab06 monero-linux-x64-v0.18.4.2.tar.bz2 +03e77a4836861a47430664fa703dd149a355b3b214bc400b04ed38eb064a3ef0 monero-linux-x86-v0.18.4.2.tar.bz2 +9b98da6911b4769abef229c20e21f29d919b11db156965d6f139d2e1ad6625c2 monero-mac-armv8-v0.18.4.2.tar.bz2 +b1b1b580320118d3b6eaa5575fdbd73cf4db90fcc025b7abf875c5e5b4e335c1 monero-mac-x64-v0.18.4.2.tar.bz2 +14dd5aa11308f106183dd7834aa200e74ce6f3497103973696b556e893a4fef2 monero-win-x64-v0.18.4.2.zip +934d9dbeb06ff5610d2c96ebe34fa480e74f78eaeb3fa3e47d89b7961c9bc5e0 monero-win-x86-v0.18.4.2.zip +e9ec2062b3547db58f00102e6905621116ab7f56a331e0bc9b9e892607b87d24 monero-source-v0.18.4.2.tar.bz2 +# +## GUI +9d6e87add7e3ac006ee34c13c4f629252595395f54421db768f72dc233e94ea8 monero-gui-install-win-x64-v0.18.4.2.exe +e4fcdea3f0ff27c3616a8a75545f42a4e4866ea374fa2eeaa9c87027573358ea monero-gui-linux-x64-v0.18.4.2.tar.bz2 +3dfee5c5d8e000c72eb3755bf0eb03ca7c5928b69c3a241e147ad22d144e00a7 monero-gui-mac-armv8-v0.18.4.2.dmg +16abadcbd608d4f7ba20d17a297f2aa2c9066d33f6f22bf3fcdca679ab603990 monero-gui-mac-x64-v0.18.4.2.dmg +4daff8850280173d46464ba9a9de7f712228ad1ef76a1c4954531e4fd2b86d86 monero-gui-win-x64-v0.18.4.2.zip +691085e61ece6c56738431f3cfd395536ca0675214e5991e0dbfab85025e82d7 monero-gui-source-v0.18.4.2.tar.bz2 +# +# +# ~binaryFate +-----BEGIN PGP SIGNATURE----- + +iQIzBAEBCAAdFiEEgaxZH+nEtlxYBq/D8K9NRioL35IFAmitx+kACgkQ8K9NRioL +35J6cQ/7ByvGstg/a5lIYbB+Lz5bNiPozCILD9/offvC7GgOvna9rkHuofuLS+pX +qhYEMrjFjmp03XMY+i68M83qkBEZ+yU5iNDbwRuHUNMMWaaGlhnhm3nyUVtDpjjr +4xwVsee+dzi0JZhVQG7HJFURiP2Ub5Ua6bSaATDoT/aUYdhmrOnQiH2+VxogiCv3 +JStDqXq6LpFjzw7UkAfxxu1PW+AQFNBzi3L0qWfzb5WWL7xuK63wXGmEkYBlvult +qt3LUhDUzMrfZ5GiiOYDEw44Y2atD4ibOYtBnllCX9CKNb0o2KKU6Qkj+CYqqtnE +uGNOt1oT09VPOtE7OUkBLVkALjef7ZXRibE7tN4wSnsrG39DP795/52L6CGJbl4n +UDnHzLCUbuvhnoAu5U+rUP5nUEDYS9ANNyj610ogNCo7YjfzLH641WSQ/UnuXKkA +RmK8xIiKoOnUeOanX99zqeXqV7gQdQMlfwLUr3pQzCI2YjdvxdRoedSEi5nX5KvO +Snf3BcCYMBemGYqVMdo95tc0Gmsw12/O8WwrBbTea+PeAXJuLaBxrLNn+RNZLfF/ +UJYq2VcEwxG6vXb3cJ5lDKmRDDRI8Fxu6Amdab+6ponhM8Zy3eAynVIO952pLA7N +dtl72RsimM+sgHXP4ERYL4c6WARSHE5sAiog43dr56l3PPmM8pE= +=SoHG +-----END PGP SIGNATURE----- diff --git a/patches/dalek-ff-group/Cargo.toml b/patches/dalek-ff-group/Cargo.toml deleted file mode 100644 index 0cac3c94..00000000 --- a/patches/dalek-ff-group/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "dalek-ff-group" -version = "0.5.99" -description = "ff/group bindings around curve25519-dalek" -license = "MIT" -repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dalek-ff-group" -authors = ["Luke Parker "] -keywords = ["curve25519", "ed25519", "ristretto", "dalek", "group"] -edition = "2021" -rust-version = "1.85" - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] - -[lints] -workspace = true - -[dependencies] -dalek-ff-group = { path = "../../crypto/dalek-ff-group", default-features = false } - -crypto-bigint-05 = { package = "crypto-bigint", version = "0.5", default-features = false, features = ["zeroize"] } -crypto-bigint = { version = "0.6", default-features = false, features = ["zeroize"] } -prime-field = { path = "../../crypto/prime-field", default-features = false } - -[features] -alloc = ["dalek-ff-group/alloc", "crypto-bigint-05/alloc", "crypto-bigint/alloc", "prime-field/alloc"] -std = ["alloc", "dalek-ff-group/std", "prime-field/std"] -default = ["std"] diff --git a/patches/dalek-ff-group/LICENSE b/patches/dalek-ff-group/LICENSE deleted file mode 100644 index 32ff304a..00000000 --- a/patches/dalek-ff-group/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022-2025 Luke Parker - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/patches/dalek-ff-group/README.md b/patches/dalek-ff-group/README.md deleted file mode 100644 index 5a25d05b..00000000 --- a/patches/dalek-ff-group/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Dalek FF/Group - -Patch for the `crates.io` `dalek-ff-group` to use the in-tree `dalek-ff-group`, -resolving relevant breaking changes made since. diff --git a/patches/dalek-ff-group/src/lib.rs b/patches/dalek-ff-group/src/lib.rs deleted file mode 100644 index 848f2a8f..00000000 --- a/patches/dalek-ff-group/src/lib.rs +++ /dev/null @@ -1,44 +0,0 @@ -#![allow(deprecated)] -#![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![no_std] // Prevents writing new code, in what should be a simple wrapper, which requires std -#![doc = include_str!("../README.md")] -#![allow(clippy::redundant_closure_call)] - -pub use dalek_ff_group::{Scalar, EdwardsPoint, RistrettoPoint, Ed25519, Ristretto}; - -type ThirtyTwoArray = [u8; 32]; -prime_field::odd_prime_field_with_specific_repr!( - FieldElement, - "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed", - "02", - false, - crate::ThirtyTwoArray -); - -impl FieldElement { - /// Create a FieldElement from a `crypto_bigint::U256`. - /// - /// This will reduce the `U256` by the modulus, into a member of the field. - #[deprecated] - pub const fn from_u256(u256: &crypto_bigint_05::U256) -> Self { - const MODULUS: crypto_bigint::U256 = crypto_bigint::U256::from_be_hex( - "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed", - ); - let mut u256 = crypto_bigint::U256::from_words(*u256.as_words()); - loop { - let result = FieldElement::from_bytes(&u256.to_le_bytes()); - if let Some(result) = result { - return result; - } - u256 = u256.wrapping_sub(&MODULUS); - } - } - - /// Create a `FieldElement` from the reduction of a 512-bit number. - /// - /// The bytes are interpreted in little-endian format. - #[deprecated] - pub fn wide_reduce(value: [u8; 64]) -> Self { - >::from_uniform_bytes(&value) - } -} diff --git a/processor/monero/Cargo.toml b/processor/monero/Cargo.toml index 8ceef0f9..d4949dd9 100644 --- a/processor/monero/Cargo.toml +++ b/processor/monero/Cargo.toml @@ -29,8 +29,8 @@ dalek-ff-group = { path = "../../crypto/dalek-ff-group", default-features = fals dkg = { package = "dkg-evrf", path = "../../crypto/dkg/evrf", default-features = false, features = ["std", "ed25519"] } frost = { package = "modular-frost", path = "../../crypto/frost", default-features = false } -monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7f37cc8f770858aa1739e0f56dbe447db86f4ba6", default-features = false, features = ["std", "multisig"] } -monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7f37cc8f770858aa1739e0f56dbe447db86f4ba6", default-features = false } +monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "2c847f71079a105456376f9957cee86c4b6a9eb8", default-features = false, features = ["std", "multisig"] } +monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "2c847f71079a105456376f9957cee86c4b6a9eb8", default-features = false } serai-client = { path = "../../substrate/client", default-features = false, features = ["monero"] } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index cdd2b730..41d13f48 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.89" +channel = "1.90" targets = ["wasm32v1-none"] profile = "minimal" components = ["rust-src", "rustfmt", "clippy"] diff --git a/substrate/client/Cargo.toml b/substrate/client/Cargo.toml index 0df6540b..dbf3a56a 100644 --- a/substrate/client/Cargo.toml +++ b/substrate/client/Cargo.toml @@ -43,7 +43,7 @@ bitcoin = { version = "0.32", optional = true } ciphersuite = { path = "../../crypto/ciphersuite", optional = true } dalek-ff-group = { path = "../../crypto/dalek-ff-group", optional = true } -monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7f37cc8f770858aa1739e0f56dbe447db86f4ba6", version = "0.1.0", default-features = false, features = ["std"], optional = true } +monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "2c847f71079a105456376f9957cee86c4b6a9eb8", version = "0.1.0", default-features = false, features = ["std"], optional = true } [dev-dependencies] rand_core = "0.6" diff --git a/substrate/node/Cargo.toml b/substrate/node/Cargo.toml index 25cb6d57..758ba34e 100644 --- a/substrate/node/Cargo.toml +++ b/substrate/node/Cargo.toml @@ -82,7 +82,7 @@ serai-env = { path = "../../common/env" } curve25519-dalek = { version = "4", default-features = false, features = ["alloc", "zeroize"] } bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, features = ["std", "hazmat"] } -monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7f37cc8f770858aa1739e0f56dbe447db86f4ba6", default-features = false, features = ["std"] } +monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "2c847f71079a105456376f9957cee86c4b6a9eb8", default-features = false, features = ["std"] } [build-dependencies] substrate-build-script-utils = { git = "https://github.com/serai-dex/substrate" } From 18a9cf2535c061d87bc0ab4258f6643179361ca3 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Thu, 18 Sep 2025 17:03:16 -0400 Subject: [PATCH 11/15] Have `simple-request` return an error upon failing to find the system's root certificates --- common/request/src/lib.rs | 24 +++++++++++-------- common/request/src/request.rs | 3 ++- networks/bitcoin/src/rpc.rs | 3 ++- .../alloy-simple-request-transport/src/lib.rs | 6 ++--- networks/ethereum/schnorr/src/tests/mod.rs | 2 +- processor/ethereum/deployer/src/tests.rs | 2 +- processor/ethereum/router/src/tests/mod.rs | 2 +- processor/ethereum/src/main.rs | 2 +- substrate/client/src/serai/mod.rs | 2 +- tests/processor/src/lib.rs | 12 +++++----- tests/processor/src/networks.rs | 4 ++-- 11 files changed, 34 insertions(+), 28 deletions(-) diff --git a/common/request/src/lib.rs b/common/request/src/lib.rs index 04b162aa..4feffd7d 100644 --- a/common/request/src/lib.rs +++ b/common/request/src/lib.rs @@ -52,7 +52,7 @@ pub struct Client { } impl Client { - fn connector() -> Connector { + fn connector() -> Result { let mut res = HttpConnector::new(); res.set_keepalive(Some(core::time::Duration::from_secs(60))); res.set_nodelay(true); @@ -62,27 +62,31 @@ impl Client { #[cfg(feature = "tls")] let res = HttpsConnectorBuilder::new() .with_native_roots() - .expect("couldn't fetch system's SSL roots") + .map_err(|e| { + Error::ConnectionError( + format!("couldn't load system's SSL root certificates: {e:?}").into(), + ) + })? .https_or_http() .enable_http1() .wrap_connector(res); - res + Ok(res) } - pub fn with_connection_pool() -> Client { - Client { + pub fn with_connection_pool() -> Result { + Ok(Client { connection: Connection::ConnectionPool( HyperClient::builder(TokioExecutor::new()) .pool_idle_timeout(core::time::Duration::from_secs(60)) - .build(Self::connector()), + .build(Self::connector()?), ), - } + }) } pub fn without_connection_pool(host: &str) -> Result { Ok(Client { connection: Connection::Connection { - connector: Self::connector(), + connector: Self::connector()?, host: { let uri: Uri = host.parse().map_err(|_| Error::InvalidUri)?; if uri.host().is_none() { @@ -149,7 +153,7 @@ impl Client { *connection_lock = Some(requester); } - let connection = connection_lock.as_mut().unwrap(); + let connection = connection_lock.as_mut().expect("lock over the connection was poisoned"); let mut err = connection.ready().await.err(); if err.is_none() { // Send the request @@ -161,7 +165,7 @@ impl Client { } // Since this connection has been put into an error state, drop it *connection_lock = None; - Err(Error::Hyper(err.unwrap()))? + Err(Error::Hyper(err.expect("only here if `err` is some yet no error")))? } }; diff --git a/common/request/src/request.rs b/common/request/src/request.rs index 64a10ea7..6898f350 100644 --- a/common/request/src/request.rs +++ b/common/request/src/request.rs @@ -42,7 +42,8 @@ impl Request { formatted.zeroize(); self.request.headers_mut().insert( hyper::header::AUTHORIZATION, - HeaderValue::from_str(&format!("Basic {encoded}")).unwrap(), + HeaderValue::from_str(&format!("Basic {encoded}")) + .expect("couldn't form header from base64-encoded string"), ); encoded.zeroize(); } diff --git a/networks/bitcoin/src/rpc.rs b/networks/bitcoin/src/rpc.rs index fb1c35d6..6d50a951 100644 --- a/networks/bitcoin/src/rpc.rs +++ b/networks/bitcoin/src/rpc.rs @@ -62,7 +62,8 @@ impl Rpc { /// provided to this library, if the RPC has an incompatible argument layout. That is not checked /// at time of RPC creation. pub async fn new(url: String) -> Result { - let rpc = Rpc { client: Client::with_connection_pool(), url }; + let rpc = + Rpc { client: Client::with_connection_pool().map_err(|_| RpcError::ConnectionError)?, url }; // Make an RPC request to verify the node is reachable and sane let res: String = rpc.rpc_call("help", json!([])).await?; diff --git a/networks/ethereum/alloy-simple-request-transport/src/lib.rs b/networks/ethereum/alloy-simple-request-transport/src/lib.rs index 93b35bc1..bae98add 100644 --- a/networks/ethereum/alloy-simple-request-transport/src/lib.rs +++ b/networks/ethereum/alloy-simple-request-transport/src/lib.rs @@ -7,7 +7,7 @@ use std::io; use alloy_json_rpc::{RequestPacket, ResponsePacket}; use alloy_transport::{TransportError, TransportErrorKind, TransportFut}; -use simple_request::{hyper, Request, Client}; +use simple_request::{hyper, Error, Request, Client}; use tower::Service; @@ -18,8 +18,8 @@ pub struct SimpleRequest { } impl SimpleRequest { - pub fn new(url: String) -> Self { - Self { client: Client::with_connection_pool(), url } + pub fn new(url: String) -> Result { + Ok(Self { client: Client::with_connection_pool()?, url }) } } diff --git a/networks/ethereum/schnorr/src/tests/mod.rs b/networks/ethereum/schnorr/src/tests/mod.rs index f606a59e..8abdab79 100644 --- a/networks/ethereum/schnorr/src/tests/mod.rs +++ b/networks/ethereum/schnorr/src/tests/mod.rs @@ -36,7 +36,7 @@ async fn setup_test() -> (AnvilInstance, Arc, Address) { let anvil = Anvil::new().spawn(); let provider = Arc::new(RootProvider::new( - ClientBuilder::default().transport(SimpleRequest::new(anvil.endpoint()), true), + ClientBuilder::default().transport(SimpleRequest::new(anvil.endpoint()).unwrap(), true), )); let mut address = [0; 20]; diff --git a/processor/ethereum/deployer/src/tests.rs b/processor/ethereum/deployer/src/tests.rs index 12969016..25974057 100644 --- a/processor/ethereum/deployer/src/tests.rs +++ b/processor/ethereum/deployer/src/tests.rs @@ -21,7 +21,7 @@ async fn test_deployer() { let anvil = Anvil::new().arg("--hardfork").arg(network).spawn(); let provider = Arc::new(RootProvider::new( - ClientBuilder::default().transport(SimpleRequest::new(anvil.endpoint()), true), + ClientBuilder::default().transport(SimpleRequest::new(anvil.endpoint()).unwrap(), true), )); // Deploy the Deployer diff --git a/processor/ethereum/router/src/tests/mod.rs b/processor/ethereum/router/src/tests/mod.rs index 6c6614fe..0ab366e7 100644 --- a/processor/ethereum/router/src/tests/mod.rs +++ b/processor/ethereum/router/src/tests/mod.rs @@ -129,7 +129,7 @@ impl Test { .spawn(); let provider = Arc::new(RootProvider::new( - ClientBuilder::default().transport(SimpleRequest::new(anvil.endpoint()), true), + ClientBuilder::default().transport(SimpleRequest::new(anvil.endpoint()).unwrap(), true), )); let chain_id = U256::from(provider.get_chain_id().await.unwrap()); diff --git a/processor/ethereum/src/main.rs b/processor/ethereum/src/main.rs index 792a216e..f90974aa 100644 --- a/processor/ethereum/src/main.rs +++ b/processor/ethereum/src/main.rs @@ -61,7 +61,7 @@ async fn main() { let db = bin::init(); let provider = Arc::new(RootProvider::new( - ClientBuilder::default().transport(SimpleRequest::new(bin::url()), true), + ClientBuilder::default().transport(SimpleRequest::new(bin::url()).unwrap(), true), )); let chain_id = { diff --git a/substrate/client/src/serai/mod.rs b/substrate/client/src/serai/mod.rs index 61bde40b..2cccf0f1 100644 --- a/substrate/client/src/serai/mod.rs +++ b/substrate/client/src/serai/mod.rs @@ -158,7 +158,7 @@ impl Serai { } pub async fn new(url: String) -> Result { - let client = Client::with_connection_pool(); + let client = Client::with_connection_pool().map_err(|_| SeraiError::ConnectionError)?; let mut res = Serai { url, client, genesis: [0xfe; 32] }; res.genesis = res.block_hash(0).await?.ok_or_else(|| { SeraiError::InvalidNode("node didn't have the first block's hash".to_string()) diff --git a/tests/processor/src/lib.rs b/tests/processor/src/lib.rs index 9309e227..a369a1a7 100644 --- a/tests/processor/src/lib.rs +++ b/tests/processor/src/lib.rs @@ -277,7 +277,7 @@ impl Coordinator { }; let provider = Arc::new(RootProvider::<_, Ethereum>::new( - ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()), true), + ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()).unwrap(), true), )); if handle @@ -417,7 +417,7 @@ impl Coordinator { }; let provider = RootProvider::<_, Ethereum>::new( - ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()), true), + ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()).unwrap(), true), ); let start = provider .get_block(BlockNumberOrTag::Latest.into(), BlockTransactionsKind::Hashes) @@ -509,7 +509,7 @@ impl Coordinator { let (expected_number, state) = { let provider = RootProvider::<_, Ethereum>::new( - ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()), true), + ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()).unwrap(), true), ); let expected_number = provider @@ -528,7 +528,7 @@ impl Coordinator { for coordinator in others { let rpc_url = network_rpc(coordinator.network, ops, &coordinator.network_handle); let provider = RootProvider::<_, Ethereum>::new( - ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()), true), + ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()).unwrap(), true), ); assert!(provider .raw_request::<_, bool>("anvil_loadState".into(), &[&state]) @@ -605,7 +605,7 @@ impl Coordinator { }; let provider = RootProvider::<_, Ethereum>::new( - ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()), true), + ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()).unwrap(), true), ); let _ = provider.send_raw_transaction(tx).await.unwrap(); } @@ -662,7 +662,7 @@ impl Coordinator { ExternalNetworkId::Ethereum => { /* let provider = RootProvider::<_, Ethereum>::new( - ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()), true), + ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()).unwrap(), true), ); let mut hash = [0; 32]; hash.copy_from_slice(tx); diff --git a/tests/processor/src/networks.rs b/tests/processor/src/networks.rs index edc04715..55d17369 100644 --- a/tests/processor/src/networks.rs +++ b/tests/processor/src/networks.rs @@ -165,7 +165,7 @@ impl Wallet { ethereum_serai::crypto::address(&(::generator() * key)); let provider = RootProvider::<_, Ethereum>::new( - ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()), true), + ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()).unwrap(), true), ); provider @@ -319,7 +319,7 @@ impl Wallet { let one_eth = eighteen_decimals; let provider = Arc::new(RootProvider::<_, Ethereum>::new( - ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()), true), + ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()).unwrap(), true), )); let to_as_key = PublicKey::new( From ca8afb83a1557edde73d9fce20acbf0abf92f7b2 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Thu, 18 Sep 2025 17:12:46 -0400 Subject: [PATCH 12/15] `simple-request 0.2.0` --- common/request/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/request/Cargo.toml b/common/request/Cargo.toml index 467d967a..7ed74def 100644 --- a/common/request/Cargo.toml +++ b/common/request/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "simple-request" -version = "0.1.1" +version = "0.2.0" description = "A simple HTTP(S) request library" license = "MIT" -repository = "https://github.com/serai-dex/serai/tree/develop/common/simple-request" +repository = "https://github.com/serai-dex/serai/tree/develop/common/request" authors = ["Luke Parker "] keywords = ["http", "https", "async", "request", "ssl"] edition = "2021" From df9fda29711eeeeaaa57472d7a6d4e0eac7b1fcf Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Thu, 18 Sep 2025 17:26:02 -0400 Subject: [PATCH 13/15] Fixes from errors in cherry-picked commits --- Cargo.lock | 136 ++++++++++-------- Cargo.toml | 11 +- common/std-shims/src/lib.rs | 6 +- crypto/schnorrkel/Cargo.toml | 2 +- networks/bitcoin/Cargo.toml | 2 +- .../alloy-simple-request-transport/Cargo.toml | 2 +- patches/dalek-ff-group/Cargo.toml | 29 ++++ patches/dalek-ff-group/LICENSE | 21 +++ patches/dalek-ff-group/README.md | 4 + patches/dalek-ff-group/src/lib.rs | 44 ++++++ patches/simple-request/Cargo.toml | 23 +++ patches/simple-request/src/lib.rs | 18 +++ patches/std-shims/Cargo.toml | 23 +++ patches/std-shims/src/lib.rs | 5 + substrate/client/Cargo.toml | 2 +- 15 files changed, 257 insertions(+), 71 deletions(-) create mode 100644 patches/dalek-ff-group/Cargo.toml create mode 100644 patches/dalek-ff-group/LICENSE create mode 100644 patches/dalek-ff-group/README.md create mode 100644 patches/dalek-ff-group/src/lib.rs create mode 100644 patches/simple-request/Cargo.toml create mode 100644 patches/simple-request/src/lib.rs create mode 100644 patches/std-shims/Cargo.toml create mode 100644 patches/std-shims/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index fa6d95c2..7ca9d2cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -544,7 +544,7 @@ dependencies = [ "alloy-json-rpc", "alloy-transport", "serde_json", - "simple-request", + "simple-request 0.2.0", "tower 0.5.2", ] @@ -1461,8 +1461,8 @@ dependencies = [ "secp256k1 0.29.1", "serde", "serde_json", - "simple-request", - "std-shims", + "simple-request 0.2.0", + "std-shims 0.1.5", "subtle", "thiserror 2.0.16", "tokio", @@ -1928,7 +1928,7 @@ dependencies = [ "ff-group-tests", "group", "hex", - "std-shims", + "std-shims 0.1.5", "subtle", "zeroize", ] @@ -1938,8 +1938,8 @@ name = "ciphersuite" version = "0.4.99" dependencies = [ "ciphersuite 0.4.2", - "dalek-ff-group", - "std-shims", + "dalek-ff-group 0.5.0", + "std-shims 0.1.5", "zeroize", ] @@ -2470,6 +2470,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "dalek-ff-group" +version = "0.5.99" +dependencies = [ + "crypto-bigint 0.5.5", + "crypto-bigint 0.6.1", + "dalek-ff-group 0.5.0", + "prime-field", +] + [[package]] name = "darling" version = "0.20.11" @@ -2542,7 +2552,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d162beedaa69905488a8da94f5ac3edb4dd4788b732fadb7bd120b2625c1976" dependencies = [ "data-encoding", - "syn 2.0.106", + "syn 1.0.109", ] [[package]] @@ -2773,7 +2783,7 @@ version = "0.6.1" dependencies = [ "borsh", "ciphersuite 0.4.2", - "std-shims", + "std-shims 0.1.5", "thiserror 2.0.16", "zeroize", ] @@ -2785,7 +2795,7 @@ dependencies = [ "ciphersuite 0.4.2", "dkg", "rand_core 0.6.4", - "std-shims", + "std-shims 0.1.5", "zeroize", ] @@ -2796,7 +2806,7 @@ dependencies = [ "blake2 0.11.0-rc.2", "ciphersuite 0.4.2", "ciphersuite-kp256", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "dkg", "dkg-recovery", "ec-divisors", @@ -2811,7 +2821,7 @@ dependencies = [ "rand_chacha 0.3.1", "rand_core 0.6.4", "secq256k1", - "std-shims", + "std-shims 0.1.5", "thiserror 2.0.16", "zeroize", ] @@ -2821,12 +2831,12 @@ name = "dkg-musig" version = "0.6.0" dependencies = [ "ciphersuite 0.4.2", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "dkg", "dkg-recovery", "multiexp", "rand_core 0.6.4", - "std-shims", + "std-shims 0.1.5", "thiserror 2.0.16", "zeroize", ] @@ -2914,11 +2924,11 @@ name = "ec-divisors" version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide?rev=dc1b3dbe436aae61ec363505052d4715d38ce1df#dc1b3dbe436aae61ec363505052d4715d38ce1df" dependencies = [ - "dalek-ff-group", + "dalek-ff-group 0.5.99", "ff", "group", "rand_core 0.6.4", - "std-shims", + "std-shims 0.1.99", "subtle", "zeroize", ] @@ -3033,7 +3043,7 @@ dependencies = [ "prime-field", "rand_core 0.6.4", "short-weierstrass", - "std-shims", + "std-shims 0.1.5", "typenum", "zeroize", ] @@ -3546,7 +3556,7 @@ dependencies = [ "rand_core 0.6.4", "schnorr-signatures", "schnorrkel", - "std-shims", + "std-shims 0.1.5", "zeroize", ] @@ -3775,7 +3785,7 @@ dependencies = [ "flexible-transcript", "multiexp", "rand_core 0.6.4", - "std-shims", + "std-shims 0.1.99", "zeroize", ] @@ -3786,7 +3796,7 @@ source = "git+https://github.com/monero-oxide/monero-oxide?rev=dc1b3dbe436aae61e dependencies = [ "ciphersuite 0.4.99", "generalized-bulletproofs", - "std-shims", + "std-shims 0.1.99", "zeroize", ] @@ -3798,7 +3808,7 @@ dependencies = [ "ciphersuite 0.4.99", "generalized-bulletproofs-circuit-abstraction", "generic-array 1.2.0", - "std-shims", + "std-shims 0.1.99", ] [[package]] @@ -4250,7 +4260,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.8", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -6089,7 +6099,7 @@ version = "0.11.0" dependencies = [ "ciphersuite 0.4.2", "ciphersuite-kp256", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "dkg", "dkg-dealer", "dkg-recovery", @@ -6103,7 +6113,7 @@ dependencies = [ "schnorr-signatures", "serde_json", "sha2 0.10.9", - "std-shims", + "std-shims 0.1.5", "subtle", "thiserror 2.0.16", "zeroize", @@ -6127,7 +6137,7 @@ version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "monero-primitives", - "std-shims", + "std-shims 0.1.99", ] [[package]] @@ -6139,7 +6149,7 @@ dependencies = [ "monero-generators", "monero-io", "monero-primitives", - "std-shims", + "std-shims 0.1.99", "zeroize", ] @@ -6153,7 +6163,7 @@ dependencies = [ "monero-io", "monero-primitives", "rand_core 0.6.4", - "std-shims", + "std-shims 0.1.99", "thiserror 2.0.16", "zeroize", ] @@ -6164,7 +6174,7 @@ version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "curve25519-dalek", - "dalek-ff-group", + "dalek-ff-group 0.5.99", "flexible-transcript", "group", "modular-frost", @@ -6173,7 +6183,7 @@ dependencies = [ "monero-primitives", "rand_chacha 0.3.1", "rand_core 0.6.4", - "std-shims", + "std-shims 0.1.99", "subtle", "thiserror 2.0.16", "zeroize", @@ -6186,11 +6196,11 @@ source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a10545 dependencies = [ "crypto-bigint 0.5.5", "curve25519-dalek", - "dalek-ff-group", + "dalek-ff-group 0.5.99", "group", "monero-io", "sha3 0.10.8", - "std-shims", + "std-shims 0.1.99", "subtle", ] @@ -6200,7 +6210,7 @@ version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide?rev=2c847f71079a105456376f9957cee86c4b6a9eb8#2c847f71079a105456376f9957cee86c4b6a9eb8" dependencies = [ "curve25519-dalek", - "std-shims", + "std-shims 0.1.99", "zeroize", ] @@ -6213,7 +6223,7 @@ dependencies = [ "monero-generators", "monero-io", "monero-primitives", - "std-shims", + "std-shims 0.1.99", "thiserror 2.0.16", "zeroize", ] @@ -6232,7 +6242,7 @@ dependencies = [ "monero-io", "monero-mlsag", "monero-primitives", - "std-shims", + "std-shims 0.1.99", "zeroize", ] @@ -6245,7 +6255,7 @@ dependencies = [ "monero-generators", "monero-io", "sha3 0.10.8", - "std-shims", + "std-shims 0.1.99", "zeroize", ] @@ -6260,7 +6270,7 @@ dependencies = [ "monero-oxide", "serde", "serde_json", - "std-shims", + "std-shims 0.1.99", "thiserror 2.0.16", "zeroize", ] @@ -6273,7 +6283,7 @@ dependencies = [ "digest_auth", "hex", "monero-rpc", - "simple-request", + "simple-request 0.1.99", "tokio", "zeroize", ] @@ -6295,7 +6305,7 @@ dependencies = [ "rand_chacha 0.3.1", "rand_core 0.6.4", "rand_distr", - "std-shims", + "std-shims 0.1.99", "thiserror 2.0.16", "zeroize", ] @@ -6334,7 +6344,7 @@ dependencies = [ name = "multiexp" version = "0.4.2" dependencies = [ - "dalek-ff-group", + "dalek-ff-group 0.5.0", "ff", "group", "k256", @@ -9470,14 +9480,14 @@ name = "schnorr-signatures" version = "0.5.2" dependencies = [ "ciphersuite 0.4.2", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "digest 0.11.0-rc.1", "flexible-transcript", "hex", "multiexp", "rand_core 0.6.4", "sha2 0.10.9", - "std-shims", + "std-shims 0.1.5", "zeroize", ] @@ -9610,7 +9620,7 @@ dependencies = [ "rand_core 0.6.4", "sha2 0.11.0-rc.2", "short-weierstrass", - "std-shims", + "std-shims 0.1.5", ] [[package]] @@ -9756,7 +9766,7 @@ dependencies = [ "borsh", "ciphersuite 0.4.2", "ciphersuite-kp256", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "dkg-musig", "dockertest", "frame-system", @@ -9771,7 +9781,7 @@ dependencies = [ "serai-docker-tests", "serde", "serde_json", - "simple-request", + "simple-request 0.2.0", "sp-core", "sp-runtime", "thiserror 2.0.16", @@ -9817,7 +9827,7 @@ dependencies = [ "blake2 0.11.0-rc.2", "borsh", "ciphersuite 0.4.2", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "dkg-musig", "env_logger", "frost-schnorrkel", @@ -9906,7 +9916,7 @@ dependencies = [ "blake2 0.11.0-rc.2", "borsh", "ciphersuite 0.4.2", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "dkg", "log", "parity-scale-codec", @@ -10170,7 +10180,7 @@ version = "0.1.0" dependencies = [ "borsh", "ciphersuite 0.4.2", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "env_logger", "flexible-transcript", "hex", @@ -10191,7 +10201,7 @@ name = "serai-message-queue-tests" version = "0.1.0" dependencies = [ "ciphersuite 0.4.2", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "dockertest", "hex", "rand_core 0.6.4", @@ -10208,7 +10218,7 @@ version = "0.1.0" dependencies = [ "borsh", "ciphersuite 0.4.2", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "dkg-evrf", "log", "modular-frost", @@ -10238,7 +10248,7 @@ version = "0.1.0" dependencies = [ "bitcoin-serai", "ciphersuite 0.4.2", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "dkg", "dkg-dealer", "dkg-evrf", @@ -10254,7 +10264,7 @@ dependencies = [ "schnorr-signatures", "secq256k1", "short-weierstrass", - "std-shims", + "std-shims 0.1.5", ] [[package]] @@ -10266,7 +10276,7 @@ dependencies = [ "ciphersuite-kp256", "clap", "curve25519-dalek", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "embedwards25519", "frame-benchmarking", "futures-util", @@ -10317,7 +10327,7 @@ name = "serai-orchestrator" version = "0.0.1" dependencies = [ "ciphersuite 0.4.2", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "embedwards25519", "flexible-transcript", "hex", @@ -10734,7 +10744,7 @@ version = "0.1.0" dependencies = [ "bitvec", "ciphersuite 0.4.2", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "dkg-musig", "frame-support", "frame-system", @@ -10769,7 +10779,7 @@ version = "0.1.0" dependencies = [ "borsh", "ciphersuite 0.4.2", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "dkg-musig", "parity-scale-codec", "scale-info", @@ -11054,7 +11064,14 @@ dependencies = [ [[package]] name = "simple-request" -version = "0.1.1" +version = "0.1.99" +dependencies = [ + "simple-request 0.2.0", +] + +[[package]] +name = "simple-request" +version = "0.2.0" dependencies = [ "base64ct", "futures-util", @@ -11878,6 +11895,13 @@ dependencies = [ "spin 0.10.0", ] +[[package]] +name = "std-shims" +version = "0.1.99" +dependencies = [ + "std-shims 0.1.5", +] + [[package]] name = "strobe-rs" version = "0.8.1" @@ -12623,7 +12647,7 @@ version = "0.1.0" dependencies = [ "blake2 0.11.0-rc.2", "ciphersuite 0.4.2", - "dalek-ff-group", + "dalek-ff-group 0.5.0", "flexible-transcript", "futures-channel", "futures-util", diff --git a/Cargo.toml b/Cargo.toml index 3234fac9..3285abd1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,11 +14,6 @@ members = [ "patches/option-ext", "patches/directories-next", - # monero-oxide expects `ciphersuite`, yet the `ciphersuite` in-tree here has breaking changes - # This re-exports the in-tree `ciphersuite` _without_ changes breaking to monero-oxide - # Not included in workspace to prevent having two crates with the same name (an error) - # "patches/ciphersuite", - "common/std-shims", "common/zalloc", "common/patchable-async-sleep", @@ -191,12 +186,12 @@ overflow-checks = true [patch.crates-io] # Dependencies from monero-oxide which originate from within our own tree -std-shims = { path = "common/std-shims" } -simple-request = { path = "common/request" } +std-shims = { path = "patches/std-shims" } +simple-request = { path = "patches/simple-request" } multiexp = { path = "crypto/multiexp" } flexible-transcript = { path = "crypto/transcript" } ciphersuite = { path = "patches/ciphersuite" } -dalek-ff-group = { path = "crypto/dalek-ff-group" } +dalek-ff-group = { path = "patches/dalek-ff-group" } minimal-ed448 = { path = "crypto/ed448" } modular-frost = { path = "crypto/frost" } diff --git a/common/std-shims/src/lib.rs b/common/std-shims/src/lib.rs index 0ea8da07..ed40db40 100644 --- a/common/std-shims/src/lib.rs +++ b/common/std-shims/src/lib.rs @@ -17,8 +17,8 @@ pub mod error { #[rustversion::since(1.81)] pub use core::error; -#[cfg(all(feature = "alloc", not(feature = "std")))] -pub extern crate alloc as extern_alloc; +#[cfg(feature = "alloc")] +extern crate alloc as extern_alloc; #[cfg(all(feature = "alloc", not(feature = "std")))] pub use extern_alloc::{alloc, borrow, boxed, ffi, fmt, rc, slice, str, string, task, vec, format}; #[cfg(feature = "std")] @@ -30,7 +30,7 @@ pub mod sync; pub mod prelude { // Shim the `std` prelude - #[cfg(all(feature = "alloc", not(feature = "std")))] + #[cfg(feature = "alloc")] pub use extern_alloc::{ format, vec, borrow::ToOwned, diff --git a/crypto/schnorrkel/Cargo.toml b/crypto/schnorrkel/Cargo.toml index 1fe90be3..24e4e24d 100644 --- a/crypto/schnorrkel/Cargo.toml +++ b/crypto/schnorrkel/Cargo.toml @@ -17,7 +17,7 @@ rustdoc-args = ["--cfg", "docsrs"] workspace = true [dependencies] -std-shims = { version = "0.1", default-features = false, features = ["alloc"] } +std-shims = { version = "0.1", path = "../../common/std-shims", default-features = false, features = ["alloc"] } rand_core = { version = "0.6", default-features = false } zeroize = { version = "1.5", default-features = false, features = ["zeroize_derive", "alloc"] } diff --git a/networks/bitcoin/Cargo.toml b/networks/bitcoin/Cargo.toml index 40823f9d..66c24a67 100644 --- a/networks/bitcoin/Cargo.toml +++ b/networks/bitcoin/Cargo.toml @@ -32,7 +32,7 @@ frost = { package = "modular-frost", path = "../../crypto/frost", version = "0.1 hex = { version = "0.4", default-features = false, optional = true } serde = { version = "1", default-features = false, features = ["derive"], optional = true } serde_json = { version = "1", default-features = false, optional = true } -simple-request = { path = "../../common/request", version = "0.1", default-features = false, features = ["tls", "basic-auth"], optional = true } +simple-request = { path = "../../common/request", version = "0.2", default-features = false, features = ["tls", "basic-auth"], optional = true } [dev-dependencies] secp256k1 = { version = "0.29", default-features = false, features = ["std"] } diff --git a/networks/ethereum/alloy-simple-request-transport/Cargo.toml b/networks/ethereum/alloy-simple-request-transport/Cargo.toml index 69dc25b4..bff76492 100644 --- a/networks/ethereum/alloy-simple-request-transport/Cargo.toml +++ b/networks/ethereum/alloy-simple-request-transport/Cargo.toml @@ -19,7 +19,7 @@ workspace = true tower = "0.5" serde_json = { version = "1", default-features = false } -simple-request = { path = "../../../common/request", version = "0.1", default-features = false } +simple-request = { path = "../../../common/request", version = "0.2", default-features = false } alloy-json-rpc = { version = "1", default-features = false } alloy-transport = { version = "1", default-features = false } diff --git a/patches/dalek-ff-group/Cargo.toml b/patches/dalek-ff-group/Cargo.toml new file mode 100644 index 00000000..0cac3c94 --- /dev/null +++ b/patches/dalek-ff-group/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "dalek-ff-group" +version = "0.5.99" +description = "ff/group bindings around curve25519-dalek" +license = "MIT" +repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dalek-ff-group" +authors = ["Luke Parker "] +keywords = ["curve25519", "ed25519", "ristretto", "dalek", "group"] +edition = "2021" +rust-version = "1.85" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true + +[dependencies] +dalek-ff-group = { path = "../../crypto/dalek-ff-group", default-features = false } + +crypto-bigint-05 = { package = "crypto-bigint", version = "0.5", default-features = false, features = ["zeroize"] } +crypto-bigint = { version = "0.6", default-features = false, features = ["zeroize"] } +prime-field = { path = "../../crypto/prime-field", default-features = false } + +[features] +alloc = ["dalek-ff-group/alloc", "crypto-bigint-05/alloc", "crypto-bigint/alloc", "prime-field/alloc"] +std = ["alloc", "dalek-ff-group/std", "prime-field/std"] +default = ["std"] diff --git a/patches/dalek-ff-group/LICENSE b/patches/dalek-ff-group/LICENSE new file mode 100644 index 00000000..32ff304a --- /dev/null +++ b/patches/dalek-ff-group/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022-2025 Luke Parker + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/patches/dalek-ff-group/README.md b/patches/dalek-ff-group/README.md new file mode 100644 index 00000000..5a25d05b --- /dev/null +++ b/patches/dalek-ff-group/README.md @@ -0,0 +1,4 @@ +# Dalek FF/Group + +Patch for the `crates.io` `dalek-ff-group` to use the in-tree `dalek-ff-group`, +resolving relevant breaking changes made since. diff --git a/patches/dalek-ff-group/src/lib.rs b/patches/dalek-ff-group/src/lib.rs new file mode 100644 index 00000000..848f2a8f --- /dev/null +++ b/patches/dalek-ff-group/src/lib.rs @@ -0,0 +1,44 @@ +#![allow(deprecated)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![no_std] // Prevents writing new code, in what should be a simple wrapper, which requires std +#![doc = include_str!("../README.md")] +#![allow(clippy::redundant_closure_call)] + +pub use dalek_ff_group::{Scalar, EdwardsPoint, RistrettoPoint, Ed25519, Ristretto}; + +type ThirtyTwoArray = [u8; 32]; +prime_field::odd_prime_field_with_specific_repr!( + FieldElement, + "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed", + "02", + false, + crate::ThirtyTwoArray +); + +impl FieldElement { + /// Create a FieldElement from a `crypto_bigint::U256`. + /// + /// This will reduce the `U256` by the modulus, into a member of the field. + #[deprecated] + pub const fn from_u256(u256: &crypto_bigint_05::U256) -> Self { + const MODULUS: crypto_bigint::U256 = crypto_bigint::U256::from_be_hex( + "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed", + ); + let mut u256 = crypto_bigint::U256::from_words(*u256.as_words()); + loop { + let result = FieldElement::from_bytes(&u256.to_le_bytes()); + if let Some(result) = result { + return result; + } + u256 = u256.wrapping_sub(&MODULUS); + } + } + + /// Create a `FieldElement` from the reduction of a 512-bit number. + /// + /// The bytes are interpreted in little-endian format. + #[deprecated] + pub fn wide_reduce(value: [u8; 64]) -> Self { + >::from_uniform_bytes(&value) + } +} diff --git a/patches/simple-request/Cargo.toml b/patches/simple-request/Cargo.toml new file mode 100644 index 00000000..80ff44ec --- /dev/null +++ b/patches/simple-request/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "simple-request" +version = "0.1.99" +description = "simple-request which patches to the latest update" +license = "MIT" +repository = "https://github.com/serai-dex/serai/tree/develop/patches/simple-request" +authors = ["Luke Parker "] +keywords = ["nostd", "no_std", "alloc", "io"] +edition = "2021" +rust-version = "1.65" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true + +[dependencies] +simple-request = { path = "../../common/request" } + +[features] +tls = ["simple-request/tls"] diff --git a/patches/simple-request/src/lib.rs b/patches/simple-request/src/lib.rs new file mode 100644 index 00000000..c4ddd3e6 --- /dev/null +++ b/patches/simple-request/src/lib.rs @@ -0,0 +1,18 @@ +pub use simple_request::{hyper, Error, Request, Response}; + +#[derive(Clone, Debug)] +pub struct Client(simple_request::Client); + +impl Client { + pub fn with_connection_pool() -> Client { + Self(simple_request::Client::with_connection_pool().unwrap()) + } + + pub fn without_connection_pool(host: &str) -> Result { + simple_request::Client::without_connection_pool(host).map(Self) + } + + pub async fn request>(&self, request: R) -> Result, Error> { + self.0.request(request).await + } +} diff --git a/patches/std-shims/Cargo.toml b/patches/std-shims/Cargo.toml new file mode 100644 index 00000000..537c8286 --- /dev/null +++ b/patches/std-shims/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "std-shims" +version = "0.1.99" +description = "std-shims which patches to the latest update" +license = "MIT" +repository = "https://github.com/serai-dex/serai/tree/develop/patches/std-shims" +authors = ["Luke Parker "] +keywords = ["nostd", "no_std", "alloc", "io"] +edition = "2021" +rust-version = "1.65" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true + +[dependencies] +std-shims = { path = "../../common/std-shims", default-features = false, features = ["alloc"] } + +[features] +std = ["std-shims/std"] diff --git a/patches/std-shims/src/lib.rs b/patches/std-shims/src/lib.rs new file mode 100644 index 00000000..673132ea --- /dev/null +++ b/patches/std-shims/src/lib.rs @@ -0,0 +1,5 @@ +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![cfg_attr(not(feature = "std"), no_std)] + +pub extern crate alloc; +pub use std_shims::{str, vec, string, collections, io, sync, prelude}; diff --git a/substrate/client/Cargo.toml b/substrate/client/Cargo.toml index dbf3a56a..641ccbc9 100644 --- a/substrate/client/Cargo.toml +++ b/substrate/client/Cargo.toml @@ -37,7 +37,7 @@ frame-system = { git = "https://github.com/serai-dex/substrate", optional = true async-lock = "3" -simple-request = { path = "../../common/request", version = "0.1", optional = true } +simple-request = { path = "../../common/request", version = "0.2", optional = true } bitcoin = { version = "0.32", optional = true } From 80009ab67f5b17dd2d03f7579c4d73a8a71855c4 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Thu, 18 Sep 2025 17:40:55 -0400 Subject: [PATCH 14/15] Tidy unused import --- coordinator/tributary-sdk/src/tests/transaction/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coordinator/tributary-sdk/src/tests/transaction/mod.rs b/coordinator/tributary-sdk/src/tests/transaction/mod.rs index deaf2e56..52e7c1d4 100644 --- a/coordinator/tributary-sdk/src/tests/transaction/mod.rs +++ b/coordinator/tributary-sdk/src/tests/transaction/mod.rs @@ -7,7 +7,7 @@ use rand::{RngCore, CryptoRng, rngs::OsRng}; use blake2::{Digest, Blake2s256}; use dalek_ff_group::Ristretto; -use ciphersuite::{group::Group, *}; +use ciphersuite::*; use schnorr::SchnorrSignature; use scale::Encode; From a9b1e5293c0e9c8bf92899e03e4da622684e4b0e Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Thu, 18 Sep 2025 18:15:24 -0400 Subject: [PATCH 15/15] Support `webpki-roots` as a fallback in `simple-request` --- Cargo.lock | 12 +++++++++++- common/request/Cargo.toml | 1 + common/request/src/lib.rs | 26 ++++++++++++++++---------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7ca9d2cb..3c7e4985 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4317,6 +4317,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", + "webpki-roots 1.0.2", ] [[package]] @@ -5622,7 +5623,7 @@ dependencies = [ "soketto 0.8.1", "thiserror 1.0.69", "url", - "webpki-roots", + "webpki-roots 0.25.4", ] [[package]] @@ -13396,6 +13397,15 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +[[package]] +name = "webpki-roots" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8983c3ab33d6fb807cfcdad2491c4ea8cbc8ed839181c7dfd9c67c83e261b2" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "which" version = "4.4.2" diff --git a/common/request/Cargo.toml b/common/request/Cargo.toml index 7ed74def..75c7d67a 100644 --- a/common/request/Cargo.toml +++ b/common/request/Cargo.toml @@ -31,5 +31,6 @@ base64ct = { version = "1", features = ["alloc"], optional = true } [features] tls = ["hyper-rustls"] +webpki-roots = ["tls", "hyper-rustls/webpki-roots"] basic-auth = ["zeroize", "base64ct"] default = ["tls"] diff --git a/common/request/src/lib.rs b/common/request/src/lib.rs index 4feffd7d..63350a1c 100644 --- a/common/request/src/lib.rs +++ b/common/request/src/lib.rs @@ -52,24 +52,30 @@ pub struct Client { } impl Client { + #[allow(clippy::unnecessary_wraps)] fn connector() -> Result { let mut res = HttpConnector::new(); res.set_keepalive(Some(core::time::Duration::from_secs(60))); res.set_nodelay(true); res.set_reuse_address(true); + #[cfg(feature = "tls")] res.enforce_http(false); #[cfg(feature = "tls")] - let res = HttpsConnectorBuilder::new() - .with_native_roots() - .map_err(|e| { - Error::ConnectionError( - format!("couldn't load system's SSL root certificates: {e:?}").into(), - ) - })? - .https_or_http() - .enable_http1() - .wrap_connector(res); + let https = HttpsConnectorBuilder::new().with_native_roots(); + #[cfg(all(feature = "tls", not(feature = "webpki-roots")))] + let https = https.map_err(|e| { + Error::ConnectionError( + format!("couldn't load system's SSL root certificates and webpki-roots unavilable: {e:?}") + .into(), + ) + })?; + // Fallback to `webpki-roots` if present + #[cfg(all(feature = "tls", feature = "webpki-roots"))] + let https = https.unwrap_or(HttpsConnectorBuilder::new().with_webpki_roots()); + #[cfg(feature = "tls")] + let res = https.https_or_http().enable_http1().wrap_connector(res); + Ok(res) }