pub struct SignatureScope {
pub document_id: DocumentId,
pub layouts: Option<HashMap<String, DocumentId>>,
}Available on crate feature
signatures only.Expand description
Signature scope for scoped signatures.
Scoped signatures allow attesting to specific layout renditions in addition to the semantic content. The scope is serialized using JSON Canonicalization Scheme (JCS, RFC 8785) before signing.
§Example
use cdx_core::security::SignatureScope;
use cdx_core::{HashAlgorithm, Hasher};
use std::collections::HashMap;
let doc_id = Hasher::hash(HashAlgorithm::Sha256, b"content");
let layout_hash = Hasher::hash(HashAlgorithm::Sha256, b"layout");
let mut layouts = HashMap::new();
layouts.insert("presentation/print.json".to_string(), layout_hash);
let scope = SignatureScope::new(doc_id).with_layouts(layouts);Fields§
§document_id: DocumentIdDocument ID that must match the top-level document ID.
layouts: Option<HashMap<String, DocumentId>>Layout paths and their content hashes for layout attestation.
Keys are presentation file paths (e.g., “presentation/print.json”), values are the content hashes of those files.
Implementations§
Source§impl SignatureScope
impl SignatureScope
Sourcepub fn new(document_id: DocumentId) -> Self
pub fn new(document_id: DocumentId) -> Self
Create a new signature scope for a document.
Sourcepub fn with_layouts(self, layouts: HashMap<String, DocumentId>) -> Self
pub fn with_layouts(self, layouts: HashMap<String, DocumentId>) -> Self
Add layout attestations.
Sourcepub fn with_layout(self, path: impl Into<String>, hash: DocumentId) -> Self
pub fn with_layout(self, path: impl Into<String>, hash: DocumentId) -> Self
Add a single layout attestation.
Sourcepub fn has_layouts(&self) -> bool
pub fn has_layouts(&self) -> bool
Check if this scope attests to any layouts.
Trait Implementations§
Source§impl Clone for SignatureScope
impl Clone for SignatureScope
Source§fn clone(&self) -> SignatureScope
fn clone(&self) -> SignatureScope
Returns a duplicate of the value. Read more
1.0.0 · 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 SignatureScope
impl Debug for SignatureScope
Source§impl<'de> Deserialize<'de> for SignatureScope
impl<'de> Deserialize<'de> for SignatureScope
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 SignatureScope
impl PartialEq for SignatureScope
Source§impl Serialize for SignatureScope
impl Serialize for SignatureScope
impl Eq for SignatureScope
impl StructuralPartialEq for SignatureScope
Auto Trait Implementations§
impl Freeze for SignatureScope
impl RefUnwindSafe for SignatureScope
impl Send for SignatureScope
impl Sync for SignatureScope
impl Unpin for SignatureScope
impl UnsafeUnpin for SignatureScope
impl UnwindSafe for SignatureScope
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.