mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-13 06:29:25 +00:00
Remove non-small-order view key bound
Guaranteed addresses are in fact guaranteed even with this due to prefixing key images causing zeroing the ECDH to not zero the shared key.
This commit is contained in:
@@ -8,7 +8,7 @@ use std_shims::string::ToString;
|
||||
|
||||
use zeroize::Zeroize;
|
||||
|
||||
use curve25519_dalek::{traits::IsIdentity, EdwardsPoint};
|
||||
use curve25519_dalek::EdwardsPoint;
|
||||
|
||||
use monero_io::*;
|
||||
|
||||
@@ -341,15 +341,6 @@ pub const MONERO_BYTES: NetworkedAddressBytes = match NetworkedAddressBytes::new
|
||||
None => panic!("Monero network byte constants conflicted"),
|
||||
};
|
||||
|
||||
/// Errors when creating an address.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(thiserror::Error))]
|
||||
pub enum AddressCreationError {
|
||||
/// The view key was of small order despite being in a guaranteed address.
|
||||
#[cfg_attr(feature = "std", error("small-order view key in guaranteed address"))]
|
||||
SmallOrderView,
|
||||
}
|
||||
|
||||
/// A Monero address.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Zeroize)]
|
||||
pub struct Address<const ADDRESS_BYTES: u128> {
|
||||
@@ -404,16 +395,8 @@ impl<const ADDRESS_BYTES: u128> fmt::Display for Address<ADDRESS_BYTES> {
|
||||
|
||||
impl<const ADDRESS_BYTES: u128> Address<ADDRESS_BYTES> {
|
||||
/// Create a new address.
|
||||
pub fn new(
|
||||
network: Network,
|
||||
kind: AddressType,
|
||||
spend: EdwardsPoint,
|
||||
view: EdwardsPoint,
|
||||
) -> Result<Self, AddressCreationError> {
|
||||
if kind.is_guaranteed() && view.mul_by_cofactor().is_identity() {
|
||||
Err(AddressCreationError::SmallOrderView)?;
|
||||
}
|
||||
Ok(Address { network, kind, spend, view })
|
||||
pub fn new(network: Network, kind: AddressType, spend: EdwardsPoint, view: EdwardsPoint) -> Self {
|
||||
Address { network, kind, spend, view }
|
||||
}
|
||||
|
||||
/// Parse an address from a String, accepting any network it is.
|
||||
@@ -455,11 +438,6 @@ impl<const ADDRESS_BYTES: u128> Address<ADDRESS_BYTES> {
|
||||
Err(AddressError::InvalidLength)?;
|
||||
}
|
||||
|
||||
// If this is a guaranteed address, reject small-order view keys
|
||||
if kind.is_guaranteed() && view.mul_by_cofactor().is_identity() {
|
||||
Err(AddressError::SmallOrderView)?;
|
||||
}
|
||||
|
||||
Ok(Address { network, kind, spend, view })
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ fn featured() {
|
||||
let guaranteed = (features & GUARANTEED_FEATURE_BIT) == GUARANTEED_FEATURE_BIT;
|
||||
|
||||
let kind = AddressType::Featured { subaddress, payment_id, guaranteed };
|
||||
let addr = MoneroAddress::new(network, kind, spend, view).unwrap();
|
||||
let addr = MoneroAddress::new(network, kind, spend, view);
|
||||
|
||||
assert_eq!(addr.to_string().chars().next().unwrap(), first);
|
||||
assert_eq!(MoneroAddress::from_str(network, &addr.to_string()).unwrap(), addr);
|
||||
@@ -198,7 +198,6 @@ fn featured_vectors() {
|
||||
spend,
|
||||
view
|
||||
)
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
vector.address
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user