SecureShareContent

Trait SecureShareContent 

Source
pub trait SecureShareContent
where Self: Sized + Display,
{ // Provided methods fn sign( &self, keypair: &KeyPair, content_hash: &Hash, chain_id: u64, ) -> Result<Signature, ModelsError> { ... } fn verify_signature( &self, public_key: &PublicKey, content_hash: &Hash, signature: &Signature, chain_id: u64, ) -> Result<(), ModelsError> { ... } fn new_verifiable<Ser: Serializer<Self>, ID: Id>( self, content_serializer: Ser, keypair: &KeyPair, chain_id: u64, ) -> Result<SecureShare<Self, ID>, ModelsError> { ... } fn compute_hash( &self, content_serialized: &[u8], content_creator_pub_key: &PublicKey, _chain_id: u64, ) -> Hash { ... } fn compute_signed_hash( &self, _public_key: &PublicKey, content_hash: &Hash, _chain_id: u64, ) -> Hash { ... } fn serialize( signature: &Signature, creator_public_key: &PublicKey, serialized_content: &[u8], buffer: &mut Vec<u8>, ) -> Result<(), SerializeError> { ... } fn deserialize<'a, E: ParseError<&'a [u8]> + ContextError<&'a [u8]>, Deser: Deserializer<Self>, ID: Id>( content_serializer: Option<&dyn Serializer<Self>>, signature_deserializer: &SignatureDeserializer, creator_public_key_deserializer: &PublicKeyDeserializer, content_deserializer: &Deser, buffer: &'a [u8], chain_id: u64, ) -> IResult<&'a [u8], SecureShare<Self, ID>, E> { ... } }
Expand description

Trait that define a structure that can be signed for secure sharing.

Provided Methods§

Source

fn sign( &self, keypair: &KeyPair, content_hash: &Hash, chain_id: u64, ) -> Result<Signature, ModelsError>

Sign the SecureShare given the content, on chain chain_id (see Self::compute_signed_hash).

Source

fn verify_signature( &self, public_key: &PublicKey, content_hash: &Hash, signature: &Signature, chain_id: u64, ) -> Result<(), ModelsError>

Verify a signature produced on chain chain_id (see Self::compute_signed_hash).

Source

fn new_verifiable<Ser: Serializer<Self>, ID: Id>( self, content_serializer: Ser, keypair: &KeyPair, chain_id: u64, ) -> Result<SecureShare<Self, ID>, ModelsError>

Using the provided key-pair, applies a cryptographic signature, and packages the data required to share and verify the data in a trust-free network of peers.

chain_id is used for both the content id (Self::compute_hash) and the signed hash (Self::compute_signed_hash).

Source

fn compute_hash( &self, content_serialized: &[u8], content_creator_pub_key: &PublicKey, _chain_id: u64, ) -> Hash

Compute hash

Source

fn compute_signed_hash( &self, _public_key: &PublicKey, content_hash: &Hash, _chain_id: u64, ) -> Hash

Compute hash used for signature.

The default returns *content_hash, which is correct for components whose compute_hash already folds in the chain id (e.g. Operation). Endorsement and BlockHeader override it to fold chain_id into the signed hash, so that the same message signed on two chains cannot be replayed as a denunciation on either (F90 / PDF #11).

Source

fn serialize( signature: &Signature, creator_public_key: &PublicKey, serialized_content: &[u8], buffer: &mut Vec<u8>, ) -> Result<(), SerializeError>

Serialize the secured structure

Source

fn deserialize<'a, E: ParseError<&'a [u8]> + ContextError<&'a [u8]>, Deser: Deserializer<Self>, ID: Id>( content_serializer: Option<&dyn Serializer<Self>>, signature_deserializer: &SignatureDeserializer, creator_public_key_deserializer: &PublicKeyDeserializer, content_deserializer: &Deser, buffer: &'a [u8], chain_id: u64, ) -> IResult<&'a [u8], SecureShare<Self, ID>, E>

Deserialize the secured structure

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl SecureShareContent for Block

Blocks are not signed at the block level: authentication lives in the nested SecuredHeader. The outer SecureShareBlock copies the header’s signature, creator key, and id for transport convenience, while serialized_data holds the full block bytes (header + operation ids).

Source§

impl SecureShareContent for BlockHeader

Source§

impl SecureShareContent for Endorsement

Source§

impl SecureShareContent for Operation