### Complete Workflow Example Source: https://github.com/brycx/pasetors/blob/master/_autodocs/api-reference/paserk.md An end-to-end example demonstrating key generation, serialization to PASERK, and deserialization. ```APIDOC ## Complete Workflow Example ```rust use pasetors::keys::{Generate, AsymmetricKeyPair}; use pasetors::paserk::{FormatAsPaserk, Id}; use pasetors::version4::V4; use core::convert::TryFrom; // Generate a keypair let kp = AsymmetricKeyPair::::generate()?; // Serialize secret key to PASERK let mut secret_paserk = String::new(); kp.secret.fmt(&mut secret_paserk)?; println!("Secret: {}", secret_paserk); // Serialize public key to PASERK let mut public_paserk = String::new(); kp.public.fmt(&mut public_paserk)?; println!("Public: {}", public_paserk); // Create key ID let id = Id::from(&kp.public); let mut id_paserk = String::new(); id.fmt(&mut id_paserk)?; println!("Key ID: {}", id_paserk); // Later, deserialize from PASERK let restored_secret = pasetors::keys::AsymmetricSecretKey::::try_from(secret_paserk.as_str())?; let restored_public = pasetors::keys::AsymmetricPublicKey::::try_from(public_paserk.as_str())?; // Verify they're the same assert_eq!(restored_secret, kp.secret); assert_eq!(restored_public, kp.public); # Ok::<(), Box>(()) ``` ``` -------------------------------- ### Public PASETO Token Example Source: https://github.com/brycx/pasetors/blob/master/_autodocs/api-reference/token.md Example of a public PASETO token, which includes a footer. ```text v4.public.eyJ...ew.eyJr...g ``` -------------------------------- ### Example Rust Code Block in Documentation Source: https://github.com/brycx/pasetors/blob/master/_autodocs/INDEX.md This shows the standard format for Rust code examples within the pasetors documentation. The line starting with '#' is for testing and is not rendered. ```rust use pasetors::example::{Type, function}; // Example code here # Ok::<(), pasetors::errors::Error>(()) ``` -------------------------------- ### Local PASETO Token Example Source: https://github.com/brycx/pasetors/blob/master/_autodocs/api-reference/token.md Example of a local PASETO token, which does not include a footer. ```text v4.local.AAAA...bbbb ``` -------------------------------- ### Footer::new Source: https://github.com/brycx/pasetors/blob/master/_autodocs/api-reference/footer.md Creates a new `Footer` instance with default limits. This is the starting point for building a footer. ```APIDOC ## Footer::new ### Description Creates a new `Footer` instance with default limits. ### Method `new()` ### Returns `Footer` - New footer instance ### Example ```rust use pasetors::footer::Footer; let footer = Footer::new(); # Ok::<(), pasetors::errors::Error>(()) ``` ``` -------------------------------- ### Usage Example: Footer with Token Signing Source: https://github.com/brycx/pasetors/blob/master/_autodocs/api-reference/footer.md Demonstrates how to create and populate a footer with additional claims, and then use it when signing a token with public key cryptography. ```rust use pasetors::footer::Footer; use pasetors::claims::Claims; use pasetors::public; use pasetors::keys::{Generate, AsymmetricKeyPair}; use pasetors::version4::V4; // Create and populate a footer let mut footer = Footer::new(); footer.add_additional("request_id", "req123")?; footer.add_additional("user_context", "admin")?; // Use with public token signing let kp = AsymmetricKeyPair::::generate()?; let mut claims = Claims::new()?; claims.add_additional("user", "alice")?; let token = public::sign(&kp.secret, &claims, Some(&footer), None)?; # Ok::<(), pasetors::errors::Error>(()) ``` -------------------------------- ### PASETO Token Format Example Source: https://github.com/brycx/pasetors/blob/master/_autodocs/api-reference/token.md Illustrates the standard PASETO token format, which includes version, purpose, payload, and an optional footer. ```text ..[.