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

@@ -25,6 +25,7 @@ rand_core = { version = "0.6", default-features = false }
sha2 = { 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 }
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,
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()
}
}