Remove FieldElement::from_square

The new `FieldElement::from_u256` is sufficient to load an unreduced value. The
caller can perform the square themselves, without us explicitly supporting this
special case.

Updates the monero-oxide version used to one which no longer uses
`FieldElement::from_square` (as their use is why it was added).
This commit is contained in:
Luke Parker
2025-08-22 18:42:43 -04:00
parent 758d422595
commit da3095ed15
6 changed files with 43 additions and 31 deletions

54
Cargo.lock generated
View File

@@ -1889,6 +1889,7 @@ checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76"
dependencies = [
"generic-array 0.14.7",
"rand_core",
"serdect",
"subtle",
"zeroize",
]
@@ -3493,7 +3494,7 @@ dependencies = [
"httpdate",
"itoa",
"pin-project-lite",
"socket2 0.5.7",
"socket2 0.4.10",
"tokio",
"tower-service",
"tracing",
@@ -4040,7 +4041,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
dependencies = [
"cfg-if",
"windows-targets 0.52.6",
"windows-targets 0.48.5",
]
[[package]]
@@ -4924,20 +4925,27 @@ dependencies = [
[[package]]
name = "monero-address"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=a74f41c2270707e340a9cb57fcd97a762d04975b#a74f41c2270707e340a9cb57fcd97a762d04975b"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"curve25519-dalek",
"monero-base58",
"monero-io",
"monero-primitives",
"std-shims",
"thiserror 2.0.14",
"zeroize",
]
[[package]]
name = "monero-base58"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"monero-primitives",
]
[[package]]
name = "monero-borromean"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=a74f41c2270707e340a9cb57fcd97a762d04975b#a74f41c2270707e340a9cb57fcd97a762d04975b"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"curve25519-dalek",
"monero-generators",
@@ -4950,7 +4958,7 @@ dependencies = [
[[package]]
name = "monero-bulletproofs"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=a74f41c2270707e340a9cb57fcd97a762d04975b#a74f41c2270707e340a9cb57fcd97a762d04975b"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"curve25519-dalek",
"monero-generators",
@@ -4965,7 +4973,7 @@ dependencies = [
[[package]]
name = "monero-clsag"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=a74f41c2270707e340a9cb57fcd97a762d04975b#a74f41c2270707e340a9cb57fcd97a762d04975b"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"curve25519-dalek",
"dalek-ff-group",
@@ -4986,8 +4994,9 @@ dependencies = [
[[package]]
name = "monero-generators"
version = "0.4.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=a74f41c2270707e340a9cb57fcd97a762d04975b#a74f41c2270707e340a9cb57fcd97a762d04975b"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"crypto-bigint",
"curve25519-dalek",
"dalek-ff-group",
"group",
@@ -5000,7 +5009,7 @@ dependencies = [
[[package]]
name = "monero-io"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=a74f41c2270707e340a9cb57fcd97a762d04975b#a74f41c2270707e340a9cb57fcd97a762d04975b"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"curve25519-dalek",
"std-shims",
@@ -5009,7 +5018,7 @@ dependencies = [
[[package]]
name = "monero-mlsag"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=a74f41c2270707e340a9cb57fcd97a762d04975b#a74f41c2270707e340a9cb57fcd97a762d04975b"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"curve25519-dalek",
"monero-generators",
@@ -5023,7 +5032,7 @@ dependencies = [
[[package]]
name = "monero-oxide"
version = "0.1.4-alpha"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=a74f41c2270707e340a9cb57fcd97a762d04975b#a74f41c2270707e340a9cb57fcd97a762d04975b"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"curve25519-dalek",
"hex-literal",
@@ -5041,7 +5050,7 @@ dependencies = [
[[package]]
name = "monero-primitives"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=a74f41c2270707e340a9cb57fcd97a762d04975b#a74f41c2270707e340a9cb57fcd97a762d04975b"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"curve25519-dalek",
"monero-generators",
@@ -5054,7 +5063,7 @@ dependencies = [
[[package]]
name = "monero-rpc"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=a74f41c2270707e340a9cb57fcd97a762d04975b#a74f41c2270707e340a9cb57fcd97a762d04975b"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"curve25519-dalek",
"hex",
@@ -5070,7 +5079,7 @@ dependencies = [
[[package]]
name = "monero-simple-request-rpc"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=a74f41c2270707e340a9cb57fcd97a762d04975b#a74f41c2270707e340a9cb57fcd97a762d04975b"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"digest_auth",
"hex",
@@ -5083,12 +5092,11 @@ dependencies = [
[[package]]
name = "monero-wallet"
version = "0.1.0"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=a74f41c2270707e340a9cb57fcd97a762d04975b#a74f41c2270707e340a9cb57fcd97a762d04975b"
source = "git+https://github.com/monero-oxide/monero-oxide?rev=32e6b5fe5ba9e1ea3e68da882550005122a11d22#32e6b5fe5ba9e1ea3e68da882550005122a11d22"
dependencies = [
"curve25519-dalek",
"dalek-ff-group",
"flexible-transcript",
"group",
"hex",
"modular-frost",
"monero-address",
@@ -8801,6 +8809,16 @@ dependencies = [
"time",
]
[[package]]
name = "serdect"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177"
dependencies = [
"base16ct",
"serde",
]
[[package]]
name = "sha-1"
version = "0.9.8"
@@ -11203,7 +11221,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.48.0",
]
[[package]]

View File

@@ -230,12 +230,6 @@ impl FieldElement {
FieldElement(reduce(U512::from_le_bytes(value)))
}
/// Interpret the value as a little-endian integer, square it, and reduce it into a FieldElement.
pub fn from_square(value: [u8; 32]) -> FieldElement {
let value = U256::from_le_bytes(value);
FieldElement(reduce(U512::from(value.mul_wide(&value))))
}
/// Perform an exponentiation.
pub fn pow(&self, other: FieldElement) -> FieldElement {
let mut table = [FieldElement::ONE; 16];

View File

@@ -55,8 +55,8 @@ ciphersuite-kp256 = { path = "../crypto/ciphersuite/kp256", default-features = f
ethereum-serai = { path = "../networks/ethereum", default-features = false, optional = true }
# Monero
monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "a74f41c2270707e340a9cb57fcd97a762d04975b", default-features = false, optional = true }
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "a74f41c2270707e340a9cb57fcd97a762d04975b", default-features = false, features = ["std", "multisig", "compile-time-generators"], optional = true }
monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "32e6b5fe5ba9e1ea3e68da882550005122a11d22", default-features = false, optional = true }
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "32e6b5fe5ba9e1ea3e68da882550005122a11d22", default-features = false, features = ["std", "multisig", "compile-time-generators"], optional = true }
# Application
log = { version = "0.4", default-features = false, features = ["std"] }

View File

@@ -40,7 +40,7 @@ bitcoin = { version = "0.32", optional = true }
dalek-ff-group = { path = "../../crypto/dalek-ff-group", optional = true }
ciphersuite = { path = "../../crypto/ciphersuite", version = "0.4", optional = true }
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "a74f41c2270707e340a9cb57fcd97a762d04975b", version = "0.1.0", default-features = false, features = ["std"], optional = true }
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "32e6b5fe5ba9e1ea3e68da882550005122a11d22", version = "0.1.0", default-features = false, features = ["std"], optional = true }
[dev-dependencies]
rand_core = "0.6"

View File

@@ -27,8 +27,8 @@ rand_core = { version = "0.6", default-features = false }
curve25519-dalek = { version = "4", features = ["rand_core"] }
bitcoin-serai = { path = "../../networks/bitcoin" }
monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "a74f41c2270707e340a9cb57fcd97a762d04975b" }
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "a74f41c2270707e340a9cb57fcd97a762d04975b" }
monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "32e6b5fe5ba9e1ea3e68da882550005122a11d22" }
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "32e6b5fe5ba9e1ea3e68da882550005122a11d22" }
scale = { package = "parity-scale-codec", version = "3" }
serde = "1"

View File

@@ -33,8 +33,8 @@ bitcoin-serai = { path = "../../networks/bitcoin" }
k256 = "0.13"
ethereum-serai = { path = "../../networks/ethereum" }
monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "a74f41c2270707e340a9cb57fcd97a762d04975b" }
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "a74f41c2270707e340a9cb57fcd97a762d04975b" }
monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "32e6b5fe5ba9e1ea3e68da882550005122a11d22" }
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "32e6b5fe5ba9e1ea3e68da882550005122a11d22" }
messages = { package = "serai-processor-messages", path = "../../processor/messages" }