Skip to main content

protect

Attribute Macro protect 

Source
#[protect]
Expand description

Attribute macro that makes a struct protectable by a TEE.

Generates:

  • fn protect(ctx, fields...) -> Result<Protected<Self>> constructor
  • Zeroize on Drop (if zeroize = true, the default)
  • Derives Serialize, Deserialize on the struct

§Example

#[hyde::protect]
struct DocumentKey {
    key_material: [u8; 32],
}

// Generated API:
let protected = DocumentKey::protect(&mut ctx, key_material)?;
let doc_key: DocumentKey = protected.unprotect(&mut ctx)?;

§Attributes

  • zeroize = false — disable Zeroize on Drop (default: true)