-
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.
* Refactor da modules Include da core module in nomos-core * Include attestation trait * Added initial approach for Da protocol * Added empty certificate trait * Added certificate dispersal method * Rename validate method to validate attestation * Clippy happy * Add validate certificate method
- Loading branch information
1 parent
efabf66
commit 8da13f7
Showing
16 changed files
with
45 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use crate::da::blob::Blob; | ||
use bytes::Bytes; | ||
|
||
pub trait Attestation { | ||
type Blob: Blob; | ||
fn blob(&self) -> <Self::Blob as Blob>::Hash; | ||
fn as_bytes(&self) -> Bytes; | ||
} |
File renamed without changes.
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 @@ | ||
pub trait Certificate {} |
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,30 @@ | ||
// std | ||
use std::error::Error; | ||
// crates | ||
use bytes::Bytes; | ||
use futures::Stream; | ||
// internal | ||
use crate::da::attestation::Attestation; | ||
use crate::da::blob::Blob; | ||
use crate::da::certificate::Certificate; | ||
|
||
pub mod attestation; | ||
pub mod blob; | ||
pub mod certificate; | ||
|
||
pub trait DaProtocol { | ||
type Blob: Blob; | ||
type Attestation: Attestation; | ||
type Certificate: Certificate; | ||
|
||
fn encode<T: AsRef<[u8]>>(&self, data: T) -> Box<dyn Stream<Item = Self::Blob>>; | ||
fn decode<S: Stream<Item = Self::Blob>>(&self, s: S) -> Result<Bytes, Box<dyn Error>>; | ||
fn validate_attestation(&self, blob: &Self::Blob, attestation: &Self::Attestation) -> bool; | ||
|
||
fn certificate_dispersal<S: Stream<Item = Self::Attestation>>( | ||
&self, | ||
attestations: S, | ||
) -> Self::Certificate; | ||
|
||
fn validate_certificate(certificate: &Self::Certificate) -> bool; | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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