2323//!
2424//! * **Encrypt** — [`PendingStackCipherText::plan`] walks the value into
2525//! vitaminc's pending tree and does no I/O. A single
26- //! [`PendingStackCipherText::seal`] (or the [`KeysetCipher::encrypt `]
26+ //! [`PendingStackCipherText::seal`] (or the [`KeysetCipher::encrypt_node `]
2727//! convenience) then batches **one** `generate_keys` call for the whole
2828//! tree, under the handle's keyset, and seals every leaf through
2929//! `MintedKeys`, the sealing half of this crate's [`Cipher`], one key per
@@ -667,7 +667,7 @@ impl<K: IndexKeySource> StackCipher<K> {
667667 /// .init()
668668 /// .await?;
669669 /// let tenant = cipher.keyset(IdentifiedBy::Name("acme".to_string().into())).await?;
670- /// let sealed = tenant.encrypt ("hello".to_string(), nonempty!("greeting")).await?;
670+ /// let sealed = tenant.encrypt_node ("hello".to_string(), nonempty!("greeting")).await?;
671671 /// # Ok(())
672672 /// # }
673673 /// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(example()).unwrap();
@@ -1010,10 +1010,13 @@ fn hmac_prf_from_index_key(index_key: &stack_kms::IndexKey) -> vitaminc_hmac::Hm
10101010}
10111011
10121012impl < K : DataKeySource + IndexKeySource > KeysetCipher < ' _ , K > {
1013+ /// Low-level structural encryption. For one opaque scalar use
1014+ /// [`Self::encrypt`] or [`Self::encrypt_with_context`].
1015+ ///
10131016 /// Encrypt a value, binding `aad`, and seal it against fresh ZeroKMS data
10141017 /// keys in a single batched `generate_keys` call under this keyset.
10151018 /// Every key is requested under the [`Descriptor`] of `aad`.
1016- pub async fn encrypt < ' a , T , A > ( & self , value : T , aad : A ) -> Result < StackCipherText , Error >
1019+ pub async fn encrypt_node < ' a , T , A > ( & self , value : T , aad : A ) -> Result < StackCipherText , Error >
10171020 where
10181021 T : Encrypt ,
10191022 A : IntoContext < ' a > ,
@@ -1026,7 +1029,11 @@ impl<K: DataKeySource + IndexKeySource> KeysetCipher<'_, K> {
10261029 /// [`StackCipher::decrypt`], constrained to this keyset: a leaf sealed
10271030 /// under any other is [`Error::ForeignKeyset`], refused before any key
10281031 /// is retrieved.
1029- pub async fn decrypt < ' a , T , A > ( & self , ciphertext : StackCipherText , aad : A ) -> Result < T , Error >
1032+ pub async fn decrypt_node < ' a , T , A > (
1033+ & self ,
1034+ ciphertext : StackCipherText ,
1035+ aad : A ,
1036+ ) -> Result < T , Error >
10301037 where
10311038 T : Decrypt ,
10321039 A : IntoContext < ' a > ,
@@ -1784,13 +1791,16 @@ mod tests {
17841791 . await
17851792 . unwrap ( ) ;
17861793 let keyset = cipher. default_keyset ( ) ;
1787- let leaf = keyset. encrypt ( 7u32 , "users/age" ) . await . unwrap ( ) ;
1794+ let leaf = keyset. encrypt_node ( 7u32 , "users/age" ) . await . unwrap ( ) ;
17881795 let opened: Result < String , _ > = cipher. decrypt ( leaf, "users/age" ) . await ;
17891796 assert ! (
17901797 matches!( opened, Err ( Error :: OpenedType { .. } ) ) ,
17911798 "{opened:?}"
17921799 ) ;
1793- let seq = keyset. encrypt ( vec ! [ 7u32 , 8 ] , "users/age" ) . await . unwrap ( ) ;
1800+ let seq = keyset
1801+ . encrypt_node ( vec ! [ 7u32 , 8 ] , "users/age" )
1802+ . await
1803+ . unwrap ( ) ;
17941804 let opened: Result < u32 , _ > = cipher. decrypt ( seq, "users/age" ) . await ;
17951805 assert ! (
17961806 matches!( opened, Err ( Error :: OpenedType { .. } ) ) ,
0 commit comments