Misc fixes so this compiles

This commit is contained in:
Luke Parker
2025-11-04 18:56:56 -05:00
parent 642848bd24
commit 1b499edfe1
7 changed files with 23 additions and 9 deletions

View File

@@ -1,5 +1,3 @@
#![expect(clippy::cast_possible_truncation)]
use core::fmt::Debug; use core::fmt::Debug;
use std::{ use std::{

View File

@@ -25,6 +25,7 @@ rand_core = { version = "0.6", default-features = false }
sha2 = { version = "0.11.0-rc.2", default-features = false, features = ["zeroize"] } sha2 = { version = "0.11.0-rc.2", default-features = false, features = ["zeroize"] }
blake2 = { version = "0.11.0-rc.2", default-features = false, features = ["zeroize"] } blake2 = { version = "0.11.0-rc.2", default-features = false, features = ["zeroize"] }
crypto-bigint = { version = "0.5", default-features = false }
prime-field = { path = "../prime-field", default-features = false } prime-field = { path = "../prime-field", default-features = false }
ciphersuite = { version = "0.4.2", path = "../ciphersuite", default-features = false } ciphersuite = { version = "0.4.2", path = "../ciphersuite", default-features = false }

View File

@@ -286,3 +286,21 @@ prime_field::odd_prime_field_with_specific_repr!(
false, false,
crate::ThirtyTwoArray crate::ThirtyTwoArray
); );
impl FieldElement {
/// This method is hidden as it's not part of our API commitment and has no guarantees made for
/// it. It MAY panic for an undefined class of inputs.
// TODO: `monero-oxide` requires this. PR `monero-oxide` to not require this.
#[doc(hidden)]
pub const fn from_u256(value: &crypto_bigint::U256) -> Self {
let mut bytes = [0; 32];
let mut i = 0;
while i < 256 {
bytes[i / 32] |= (value.bit_vartime(i) as u8) << (i % 8);
i += 1;
}
FieldElement::from_bytes(&bytes).unwrap()
}
}

View File

@@ -1,5 +1,3 @@
#![expect(clippy::cast_possible_truncation)]
use core::fmt; use core::fmt;
use std::collections::HashMap; use std::collections::HashMap;

View File

@@ -119,7 +119,7 @@ impl<D: Db, C: Coordinator> ContinuallyRan for CoordinatorTask<D, C> {
self self
.coordinator .coordinator
.publish_slash_report_signature(session, slash_report, Signature::from(signature)) .publish_slash_report_signature(session, slash_report, Signature(signature))
.await .await
.map_err(|e| { .map_err(|e| {
format!("couldn't send slash report signature to the coordinator: {e:?}") format!("couldn't send slash report signature to the coordinator: {e:?}")

View File

@@ -252,7 +252,7 @@ impl SlashReport {
#[test] #[test]
fn test_penalty() { fn test_penalty() {
for validators in [1, 50, 100, KeyShares::MAX_PER_SET_U32] { for validators in [1, 50, 100, KeyShares::MAX_PER_SET] {
let validators = NonZero::new(validators).unwrap(); let validators = NonZero::new(validators).unwrap();
// 12 hours of slash points should only decrease the rewards proportionately // 12 hours of slash points should only decrease the rewards proportionately
let twelve_hours_of_slash_points = let twelve_hours_of_slash_points =

View File

@@ -5,7 +5,7 @@ use rand_core::OsRng;
use ciphersuite::{group::GroupEncoding, WrappedGroup}; use ciphersuite::{group::GroupEncoding, WrappedGroup};
use dalek_ff_group::Ristretto; use dalek_ff_group::Ristretto;
use serai_primitives::{ExternalNetworkId, EXTERNAL_NETWORKS}; use serai_primitives::network_id::ExternalNetworkId;
use dockertest::{ use dockertest::{
PullPolicy, Image, LogAction, LogPolicy, LogSource, LogOptions, TestBodySpecification, PullPolicy, Image, LogAction, LogPolicy, LogSource, LogOptions, TestBodySpecification,
@@ -20,8 +20,7 @@ pub fn instance() -> (
serai_docker_tests::build("message-queue".to_string()); serai_docker_tests::build("message-queue".to_string());
let coord_key = <Ristretto as WrappedGroup>::F::random(&mut OsRng); let coord_key = <Ristretto as WrappedGroup>::F::random(&mut OsRng);
let priv_keys = EXTERNAL_NETWORKS let priv_keys = ExternalNetworkId::all()
.into_iter()
.map(|n| (n, <Ristretto as WrappedGroup>::F::random(&mut OsRng))) .map(|n| (n, <Ristretto as WrappedGroup>::F::random(&mut OsRng)))
.collect::<HashMap<_, _>>(); .collect::<HashMap<_, _>>();