Implement FromUniformBytes<64> for dalek_ff_group::Scalar

This commit is contained in:
Luke Parker
2025-08-20 00:06:07 -04:00
parent 900a6612d7
commit 2bc2ca6906
4 changed files with 11 additions and 5 deletions

4
Cargo.lock generated
View File

@@ -1527,7 +1527,7 @@ dependencies = [
[[package]] [[package]]
name = "ciphersuite" name = "ciphersuite"
version = "0.4.1" version = "0.4.2"
dependencies = [ dependencies = [
"dalek-ff-group", "dalek-ff-group",
"digest 0.10.7", "digest 0.10.7",
@@ -1980,7 +1980,7 @@ dependencies = [
[[package]] [[package]]
name = "dalek-ff-group" name = "dalek-ff-group"
version = "0.4.2" version = "0.4.3"
dependencies = [ dependencies = [
"crypto-bigint", "crypto-bigint",
"curve25519-dalek", "curve25519-dalek",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "ciphersuite" name = "ciphersuite"
version = "0.4.1" version = "0.4.2"
description = "Ciphersuites built around ff/group" description = "Ciphersuites built around ff/group"
license = "MIT" license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/crypto/ciphersuite" repository = "https://github.com/serai-dex/serai/tree/develop/crypto/ciphersuite"

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "dalek-ff-group" name = "dalek-ff-group"
version = "0.4.2" version = "0.4.3"
description = "ff/group bindings around curve25519-dalek" description = "ff/group bindings around curve25519-dalek"
license = "MIT" license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dalek-ff-group" repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dalek-ff-group"

View File

@@ -30,7 +30,7 @@ use dalek::{
pub use constants::{ED25519_BASEPOINT_TABLE, RISTRETTO_BASEPOINT_TABLE}; pub use constants::{ED25519_BASEPOINT_TABLE, RISTRETTO_BASEPOINT_TABLE};
use group::{ use group::{
ff::{Field, PrimeField, FieldBits, PrimeFieldBits}, ff::{Field, PrimeField, FieldBits, PrimeFieldBits, FromUniformBytes},
Group, GroupEncoding, Group, GroupEncoding,
prime::PrimeGroup, prime::PrimeGroup,
}; };
@@ -322,6 +322,12 @@ impl PrimeFieldBits for Scalar {
} }
} }
impl FromUniformBytes<64> for Scalar {
fn from_uniform_bytes(bytes: &[u8; 64]) -> Self {
Self::from_bytes_mod_order_wide(bytes)
}
}
impl Sum<Scalar> for Scalar { impl Sum<Scalar> for Scalar {
fn sum<I: Iterator<Item = Scalar>>(iter: I) -> Scalar { fn sum<I: Iterator<Item = Scalar>>(iter: I) -> Scalar {
Self(DScalar::sum(iter)) Self(DScalar::sum(iter))