-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rust/rbac-registration): extract type in CIP509 to its own file a…
…nd implement conversion (#97) * fix: extrat type to its own type and impl conversion Signed-off-by: bkioshn <[email protected]> * fix: make util public Signed-off-by: bkioshn <[email protected]> * fix: make cip19 utils public Signed-off-by: bkioshn <[email protected]> * fix: remove uuidv4 and ed25519pubkey type Signed-off-by: bkioshn <[email protected]> * chore: fix naming Signed-off-by: bkioshn <[email protected]> * fix: naming Signed-off-by: bkioshn <[email protected]> * fix: use ShelleyAddress instead of Shelley Payment part Signed-off-by: bkioshn <[email protected]> * fix: naming Signed-off-by: bkioshn <[email protected]> --------- Signed-off-by: bkioshn <[email protected]>
- Loading branch information
Showing
12 changed files
with
141 additions
and
146 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
37 changes: 37 additions & 0 deletions
37
rust/rbac-registration/src/cardano/cip509/types/cert_key_hash.rs
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,37 @@ | ||
//! Certificate key hash type | ||
/// Certificate key hash use in revocation list. | ||
#[derive(Debug, PartialEq, Clone, Default)] | ||
pub struct CertKeyHash([u8; 16]); | ||
|
||
impl From<[u8; 16]> for CertKeyHash { | ||
fn from(bytes: [u8; 16]) -> Self { | ||
CertKeyHash(bytes) | ||
} | ||
} | ||
|
||
impl TryFrom<Vec<u8>> for CertKeyHash { | ||
type Error = &'static str; | ||
|
||
fn try_from(vec: Vec<u8>) -> Result<Self, Self::Error> { | ||
if vec.len() == 16 { | ||
let mut array = [0u8; 16]; | ||
array.copy_from_slice(&vec); | ||
Ok(CertKeyHash(array)) | ||
} else { | ||
Err("Input Vec must be exactly 16 bytes") | ||
} | ||
} | ||
} | ||
|
||
impl From<CertKeyHash> for Vec<u8> { | ||
fn from(val: CertKeyHash) -> Self { | ||
val.0.to_vec() | ||
} | ||
} | ||
|
||
impl From<CertKeyHash> for [u8; 16] { | ||
fn from(val: CertKeyHash) -> Self { | ||
val.0 | ||
} | ||
} |
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,4 @@ | ||
//! Types use in CIP-509 | ||
pub mod cert_key_hash; | ||
pub mod tx_input_hash; |
37 changes: 37 additions & 0 deletions
37
rust/rbac-registration/src/cardano/cip509/types/tx_input_hash.rs
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,37 @@ | ||
//! Transaction input hash type | ||
/// Transaction input hash representing in 16 bytes. | ||
#[derive(Debug, PartialEq, Clone, Default)] | ||
pub struct TxInputHash([u8; 16]); | ||
|
||
impl From<[u8; 16]> for TxInputHash { | ||
fn from(bytes: [u8; 16]) -> Self { | ||
TxInputHash(bytes) | ||
} | ||
} | ||
|
||
impl TryFrom<Vec<u8>> for TxInputHash { | ||
type Error = &'static str; | ||
|
||
fn try_from(vec: Vec<u8>) -> Result<Self, Self::Error> { | ||
if vec.len() == 16 { | ||
let mut array = [0u8; 16]; | ||
array.copy_from_slice(&vec); | ||
Ok(TxInputHash(array)) | ||
} else { | ||
Err("Input Vec must be exactly 16 bytes") | ||
} | ||
} | ||
} | ||
|
||
impl From<TxInputHash> for Vec<u8> { | ||
fn from(val: TxInputHash) -> Self { | ||
val.0.to_vec() | ||
} | ||
} | ||
|
||
impl From<TxInputHash> for [u8; 16] { | ||
fn from(val: TxInputHash) -> Self { | ||
val.0 | ||
} | ||
} |
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,3 +1,3 @@ | ||
//! Utility functions for CIP-509 | ||
pub(crate) mod cip19; | ||
pub mod cip19; |
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.