-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Denis
committed
Jul 26, 2021
1 parent
4a33058
commit 1357bd5
Showing
11 changed files
with
222 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::ops::Deref; | ||
|
||
use crate::elliptic::curves::{Curve, ECScalar, Scalar}; | ||
|
||
/// Encoded scalar | ||
pub struct EncodedScalar<E: Curve> { | ||
bytes: <E::Scalar as ECScalar>::ScalarBytes, | ||
} | ||
|
||
impl<E: Curve> Deref for EncodedScalar<E> { | ||
type Target = [u8]; | ||
fn deref(&self) -> &Self::Target { | ||
self.bytes.as_ref() | ||
} | ||
} | ||
|
||
impl<'s, E: Curve> From<&'s Scalar<E>> for EncodedScalar<E> { | ||
fn from(s: &'s Scalar<E>) -> Self { | ||
Self { | ||
bytes: s.as_raw().serialize(), | ||
} | ||
} | ||
} | ||
|
||
impl<E: Curve> From<Scalar<E>> for EncodedScalar<E> { | ||
fn from(s: Scalar<E>) -> Self { | ||
Self::from(&s) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mod arithmetic; | ||
mod encoded_point; | ||
mod encoded_scalar; | ||
pub mod error; | ||
mod format; | ||
mod generator; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters