Implement `Debug` trait for `Scalar` type.
This commit is contained in:
parent
65eb166c09
commit
8ed8cac2fe
|
@ -6,7 +6,7 @@
|
|||
//! provides the `Scalar` type and related.
|
||||
//!
|
||||
|
||||
use core::fmt;
|
||||
use core::{fmt, ops};
|
||||
|
||||
use crate::constants;
|
||||
|
||||
|
@ -23,6 +23,7 @@ use crate::constants;
|
|||
#[allow(missing_debug_implementations)]
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
|
||||
pub struct Scalar([u8; 32]);
|
||||
impl_pretty_debug!(Scalar);
|
||||
|
||||
const MAX_RAW: [u8; 32] = [
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
|
||||
|
@ -107,6 +108,16 @@ impl Scalar {
|
|||
}
|
||||
}
|
||||
|
||||
impl<I> ops::Index<I> for Scalar
|
||||
where
|
||||
[u8]: ops::Index<I>,
|
||||
{
|
||||
type Output = <[u8] as ops::Index<I>>::Output;
|
||||
|
||||
#[inline]
|
||||
fn index(&self, index: I) -> &Self::Output { &self.0[index] }
|
||||
}
|
||||
|
||||
impl From<crate::SecretKey> for Scalar {
|
||||
fn from(value: crate::SecretKey) -> Self { Scalar(value.secret_bytes()) }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue