@@ -30,6 +30,7 @@ use rand::RngCore;
3030use vss_client:: client:: VssClient ;
3131use vss_client:: error:: VssError ;
3232use vss_client:: headers:: { FixedHeaders , LnurlAuthToJwtProvider , VssHeaderProvider } ;
33+ use vss_client:: sigs_auth:: SigsAuthProvider ;
3334use vss_client:: types:: {
3435 DeleteObjectRequest , GetObjectRequest , KeyValue , ListKeyVersionsRequest , PutObjectRequest ,
3536 Storable ,
@@ -69,6 +70,7 @@ impl_writeable_tlv_based_enum!(VssSchemaVersion,
6970
7071const VSS_HARDENED_CHILD_INDEX : u32 = 877 ;
7172const VSS_LNURL_AUTH_HARDENED_CHILD_INDEX : u32 = 138 ;
73+ const VSS_SIGS_AUTH_HARDENED_CHILD_INDEX : u32 = 139 ;
7274const VSS_SCHEMA_VERSION_KEY : & str = "vss_schema_version" ;
7375
7476// We set this to a small number of threads that would still allow to make some progress if one
@@ -856,6 +858,44 @@ impl VssStoreBuilder {
856858 Self { node_entropy, vss_url, store_id, network }
857859 }
858860
861+ /// Builds a [`VssStore`] with the simple signature-based authentication scheme.
862+ ///
863+ /// `fixed_headers` are included as it is in all the requests made to VSS and LNURL auth
864+ /// server.
865+ ///
866+ /// **Caution**: VSS support is in **alpha** and is considered experimental. Using VSS (or any
867+ /// remote persistence) may cause LDK to panic if persistence failures are unrecoverable, i.e.,
868+ /// if they remain unresolved after internal retries are exhausted.
869+ ///
870+ /// [VSS]: https://github.com/lightningdevkit/vss-server/blob/main/README.md
871+ /// [LNURL-auth]: https://github.com/lnurl/luds/blob/luds/04.md
872+ pub fn build_with_sigs_auth (
873+ & self , fixed_headers : HashMap < String , String > ,
874+ ) -> Result < VssStore , VssStoreBuildError > {
875+ let secp_ctx = Secp256k1 :: new ( ) ;
876+ let seed_bytes = self . node_entropy . to_seed_bytes ( ) ;
877+ let vss_xprv = Xpriv :: new_master ( self . network , & seed_bytes)
878+ . map_err ( |_| VssStoreBuildError :: KeyDerivationFailed )
879+ . and_then ( |master| {
880+ master
881+ . derive_priv (
882+ & secp_ctx,
883+ & [ ChildNumber :: Hardened { index : VSS_HARDENED_CHILD_INDEX } ] ,
884+ )
885+ . map_err ( |_| VssStoreBuildError :: KeyDerivationFailed )
886+ } ) ?;
887+
888+ let sigs_auth_xprv = vss_xprv
889+ . derive_priv (
890+ & secp_ctx,
891+ & [ ChildNumber :: Hardened { index : VSS_SIGS_AUTH_HARDENED_CHILD_INDEX } ] ,
892+ )
893+ . map_err ( |_| VssStoreBuildError :: KeyDerivationFailed ) ?;
894+
895+ let auth_provider = SigsAuthProvider :: new ( sigs_auth_xprv. private_key , fixed_headers) ;
896+ self . build_with_header_provider ( Arc :: new ( auth_provider) )
897+ }
898+
859899 /// Builds a [`VssStore`] with [LNURL-auth] based authentication scheme as default method for
860900 /// authentication/authorization.
861901 ///
@@ -872,7 +912,7 @@ impl VssStoreBuilder {
872912 ///
873913 /// [VSS]: https://github.com/lightningdevkit/vss-server/blob/main/README.md
874914 /// [LNURL-auth]: https://github.com/lnurl/luds/blob/luds/04.md
875- pub fn build (
915+ pub fn build_with_lnurl (
876916 & self , lnurl_auth_server_url : String , fixed_headers : HashMap < String , String > ,
877917 ) -> Result < VssStore , VssStoreBuildError > {
878918 let secp_ctx = Secp256k1 :: new ( ) ;
0 commit comments