pub struct DealEnvelope {
pub id: Uuid,
pub buyer: AgentId,
pub seller: AgentId,
pub terms: Value,
pub signed_at: SystemTime,
pub prev_hash: [u8; 32],
pub hmac: [u8; 32],
}Expand description
One signed contract row. The hmac covers the canonical
concatenation id || buyer || seller || terms || signed_at || prev_hash so any tamper of a field invalidates the row.
Fields§
§id: Uuid§buyer: AgentId§seller: AgentId§terms: Value§signed_at: SystemTime§prev_hash: [u8; 32]§hmac: [u8; 32]Implementations§
Source§impl DealEnvelope
impl DealEnvelope
Sourcepub fn sign(
buyer: impl Into<String>,
seller: impl Into<String>,
terms: Value,
prev_hash: [u8; 32],
signed_at: SystemTime,
key: &[u8],
) -> Result<Self, EnvelopeError>
pub fn sign( buyer: impl Into<String>, seller: impl Into<String>, terms: Value, prev_hash: [u8; 32], signed_at: SystemTime, key: &[u8], ) -> Result<Self, EnvelopeError>
Build a fresh envelope chained off prev_hash. The signer
computes the HMAC; receivers verify with [verify_hmac].
Sourcepub fn verify_hmac(&self, key: &[u8]) -> Result<(), EnvelopeError>
pub fn verify_hmac(&self, key: &[u8]) -> Result<(), EnvelopeError>
Verify the envelope’s hmac against the supplied key.
Sourcepub fn next_prev_hash(&self) -> [u8; 32]
pub fn next_prev_hash(&self) -> [u8; 32]
Hash this envelope’s body to produce the prev_hash for the
next envelope in the chain. Pure fn — does not touch the
HMAC key.
Trait Implementations§
Source§impl Clone for DealEnvelope
impl Clone for DealEnvelope
Source§fn clone(&self) -> DealEnvelope
fn clone(&self) -> DealEnvelope
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DealEnvelope
impl Debug for DealEnvelope
Source§impl<'de> Deserialize<'de> for DealEnvelope
impl<'de> Deserialize<'de> for DealEnvelope
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for DealEnvelope
impl PartialEq for DealEnvelope
Source§impl Serialize for DealEnvelope
impl Serialize for DealEnvelope
impl StructuralPartialEq for DealEnvelope
Auto Trait Implementations§
impl Freeze for DealEnvelope
impl RefUnwindSafe for DealEnvelope
impl Send for DealEnvelope
impl Sync for DealEnvelope
impl Unpin for DealEnvelope
impl UnsafeUnpin for DealEnvelope
impl UnwindSafe for DealEnvelope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more