Squashed reset to unstable

This commit is contained in:
Daniel Knopik
2025-03-13 12:50:29 +01:00
committed by Daniel Knopik
parent b71b5f2231
commit f61f0b654c
416 changed files with 13195 additions and 38478 deletions

View File

@@ -66,15 +66,6 @@ where
&self.point
}
/// Instantiates `Self` from a `point`.
pub fn from_point(point: Sec) -> Self {
Self {
point,
_phantom_signature: PhantomData,
_phantom_public_key: PhantomData,
}
}
/// Serialize `self` as compressed bytes.
///
/// ## Note
@@ -103,3 +94,20 @@ where
}
}
}
impl<Sig, Pub, Sec> GenericSecretKey<Sig, Pub, Sec>
where
Sig: TSignature<Pub>,
Pub: TPublicKey,
Sec: TSecretKey<Sig, Pub> + Clone,
{
/// Instantiates `Self` from a `point`.
/// Takes a reference, as moves might accidentally leave behind key material
pub fn from_point(point: &Sec) -> Self {
Self {
point: point.clone(),
_phantom_signature: PhantomData,
_phantom_public_key: PhantomData,
}
}
}

View File

@@ -25,6 +25,16 @@ pub const INFINITY_SIGNATURE: [u8; SIGNATURE_BYTES_LEN] = [
0,
];
pub const INFINITY_SIGNATURE_UNCOMPRESSED: [u8; SIGNATURE_UNCOMPRESSED_BYTES_LEN] = [
0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
];
/// The compressed bytes used to represent `GenericSignature::empty()`.
pub const NONE_SIGNATURE: [u8; SIGNATURE_BYTES_LEN] = [0; SIGNATURE_BYTES_LEN];
@@ -148,9 +158,11 @@ where
/// Deserialize `self` from uncompressed bytes.
pub fn deserialize_uncompressed(bytes: &[u8]) -> Result<Self, Error> {
// The "none signature" is a beacon chain concept. As we never directly deal with
// uncompressed signatures on the beacon chain, it does not apply here.
Ok(Self {
point: Some(Sig::deserialize_uncompressed(bytes)?),
is_infinity: false, // todo
is_infinity: bytes == &INFINITY_SIGNATURE_UNCOMPRESSED[..],
_phantom: PhantomData,
})
}

View File

@@ -37,7 +37,10 @@ pub use generic_public_key::{
INFINITY_PUBLIC_KEY, PUBLIC_KEY_BYTES_LEN, PUBLIC_KEY_UNCOMPRESSED_BYTES_LEN,
};
pub use generic_secret_key::SECRET_KEY_BYTES_LEN;
pub use generic_signature::{INFINITY_SIGNATURE, SIGNATURE_BYTES_LEN};
pub use generic_signature::{
INFINITY_SIGNATURE, INFINITY_SIGNATURE_UNCOMPRESSED, SIGNATURE_BYTES_LEN,
SIGNATURE_UNCOMPRESSED_BYTES_LEN,
};
pub use get_withdrawal_credentials::get_withdrawal_credentials;
pub use zeroize_hash::ZeroizeHash;