pub trait SecureShareContent{
// Provided methods
fn sign(
&self,
keypair: &KeyPair,
content_hash: &Hash,
sig_chain_id: Option<u64>,
) -> Result<Signature, ModelsError> { ... }
fn verify_signature(
&self,
public_key: &PublicKey,
content_hash: &Hash,
signature: &Signature,
sig_chain_id: Option<u64>,
) -> Result<(), ModelsError> { ... }
fn new_verifiable<Ser: Serializer<Self>, ID: Id>(
self,
content_serializer: Ser,
keypair: &KeyPair,
chain_id: u64,
sig_chain_id: Option<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,
_sig_chain_id: Option<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§
Sourcefn sign(
&self,
keypair: &KeyPair,
content_hash: &Hash,
sig_chain_id: Option<u64>,
) -> Result<Signature, ModelsError>
fn sign( &self, keypair: &KeyPair, content_hash: &Hash, sig_chain_id: Option<u64>, ) -> Result<Signature, ModelsError>
Sign the SecureShare given the content. sig_chain_id selects the
signed-hash layout: None for the legacy (chain-agnostic) layout,
Some(chain_id) to fold the chain id into the signed hash. Signing,
verification and denunciation reconstruction must use the same value
for a given message (see Self::compute_signed_hash).
Sourcefn verify_signature(
&self,
public_key: &PublicKey,
content_hash: &Hash,
signature: &Signature,
sig_chain_id: Option<u64>,
) -> Result<(), ModelsError>
fn verify_signature( &self, public_key: &PublicKey, content_hash: &Hash, signature: &Signature, sig_chain_id: Option<u64>, ) -> Result<(), ModelsError>
Verify a signature. sig_chain_id selects the signed-hash layout used
to reconstruct the signature hash (see Self::compute_signed_hash).
Sourcefn new_verifiable<Ser: Serializer<Self>, ID: Id>(
self,
content_serializer: Ser,
keypair: &KeyPair,
chain_id: u64,
sig_chain_id: Option<u64>,
) -> Result<SecureShare<Self, ID>, ModelsError>
fn new_verifiable<Ser: Serializer<Self>, ID: Id>( self, content_serializer: Ser, keypair: &KeyPair, chain_id: u64, sig_chain_id: Option<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 computes the content id (Self::compute_hash); sig_chain_id
selects the signed-hash layout (None = legacy / chain-agnostic,
Some(chain_id) = chain-scoped). The two must flip together at the
deterministic MIP-0002 activation slot so all nodes switch simultaneously.
Sourcefn compute_hash(
&self,
content_serialized: &[u8],
content_creator_pub_key: &PublicKey,
_chain_id: u64,
) -> Hash
fn compute_hash( &self, content_serialized: &[u8], content_creator_pub_key: &PublicKey, _chain_id: u64, ) -> Hash
Compute hash
Sourcefn compute_signed_hash(
&self,
_public_key: &PublicKey,
content_hash: &Hash,
_sig_chain_id: Option<u64>,
) -> Hash
fn compute_signed_hash( &self, _public_key: &PublicKey, content_hash: &Hash, _sig_chain_id: Option<u64>, ) -> Hash
Compute hash used for signature.
sig_chain_id selects the layout:
None-> legacy (chain-agnostic) layout, identical to the pre-fix one. Used for messages whose slot is governed by a network version predating the MIP-0002Executionv2 activation.Some(chain_id)-> chain-scoped layout, foldingchain_idinto the signed hash so two signatures produced on different chains for the same (slot, index) cannot be replayed as a denunciation on either chain (F90 / PDF #11).
The default ignores sig_chain_id and returns *content_hash (the
legacy layout), which is correct for components that never chain-scope
their signed hash (e.g. Operation, whose compute_hash already folds
in the chain id). Endorsement and BlockHeader override this to fold
in chain_id when Some.
Sourcefn serialize(
signature: &Signature,
creator_public_key: &PublicKey,
serialized_content: &[u8],
buffer: &mut Vec<u8>,
) -> Result<(), SerializeError>
fn serialize( signature: &Signature, creator_public_key: &PublicKey, serialized_content: &[u8], buffer: &mut Vec<u8>, ) -> Result<(), SerializeError>
Serialize the secured structure
Sourcefn 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>
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.