-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A0-4160: Make packing part of unit creation (#425)
* Make packing part of unit creation * Better variable name from review and doc update * Small review change
- Loading branch information
Showing
12 changed files
with
292 additions
and
478 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,31 @@ | ||
use crate::{ | ||
units::{FullUnit, PreUnit, SignedUnit}, | ||
Data, Hasher, MultiKeychain, SessionId, Signed, | ||
}; | ||
|
||
/// The component responsible for packing Data into PreUnits, | ||
/// and signing the outcome, thus creating SignedUnits that are sent back to Runway. | ||
pub struct Packer<MK: MultiKeychain> { | ||
keychain: MK, | ||
session_id: SessionId, | ||
} | ||
|
||
impl<MK: MultiKeychain> Packer<MK> { | ||
pub fn new(keychain: MK, session_id: SessionId) -> Self { | ||
Packer { | ||
keychain, | ||
session_id, | ||
} | ||
} | ||
|
||
pub fn pack<H: Hasher, D: Data>( | ||
&self, | ||
preunit: PreUnit<H>, | ||
data: Option<D>, | ||
) -> SignedUnit<H, D, MK> { | ||
Signed::sign( | ||
FullUnit::new(preunit, data, self.session_id), | ||
&self.keychain, | ||
) | ||
} | ||
} |
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
Oops, something went wrong.