2025-08-07 15:19:06 -03:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
2025-08-06 20:05:04 -03:00
|
|
|
use crate::signature::PublicKey;
|
|
|
|
|
|
2025-08-07 15:19:06 -03:00
|
|
|
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
|
|
pub struct Address {
|
2025-08-13 01:33:11 -03:00
|
|
|
value: [u8; 32],
|
2025-08-06 20:05:04 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Address {
|
2025-08-07 15:19:06 -03:00
|
|
|
pub fn new(value: [u8; 32]) -> Self {
|
2025-08-06 20:05:04 -03:00
|
|
|
Self { value }
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-09 06:36:13 -03:00
|
|
|
pub fn from_public_key(public_key: &PublicKey) -> Self {
|
2025-08-11 20:22:41 -03:00
|
|
|
// TODO: Check specs
|
2025-08-13 01:33:11 -03:00
|
|
|
Address::new(*public_key.value())
|
2025-08-06 20:05:04 -03:00
|
|
|
}
|
2025-08-09 06:36:13 -03:00
|
|
|
|
|
|
|
|
pub fn value(&self) -> &[u8; 32] {
|
|
|
|
|
&self.value
|
|
|
|
|
}
|
2025-08-06 20:05:04 -03:00
|
|
|
}
|