@@ -29,6 +29,7 @@ use prost::Message;
2929use rand:: RngCore ;
3030use vss_client:: client:: VssClient ;
3131use vss_client:: error:: VssError ;
32+ use vss_client:: headers:: sigs_auth:: SigsAuthProvider ;
3233use vss_client:: headers:: { FixedHeaders , LnurlAuthToJwtProvider , VssHeaderProvider } ;
3334use vss_client:: types:: {
3435 DeleteObjectRequest , GetObjectRequest , KeyValue , ListKeyVersionsRequest , PutObjectRequest ,
@@ -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
@@ -853,6 +855,44 @@ impl VssStoreBuilder {
853855 Self { node_entropy, vss_url, store_id, network }
854856 }
855857
858+ /// Builds a [`VssStore`] with the simple signature-based authentication scheme.
859+ ///
860+ /// `fixed_headers` are included as it is in all the requests made to VSS and LNURL auth
861+ /// server.
862+ ///
863+ /// **Caution**: VSS support is in **alpha** and is considered experimental. Using VSS (or any
864+ /// remote persistence) may cause LDK to panic if persistence failures are unrecoverable, i.e.,
865+ /// if they remain unresolved after internal retries are exhausted.
866+ ///
867+ /// [VSS]: https://github.com/lightningdevkit/vss-server/blob/main/README.md
868+ /// [LNURL-auth]: https://github.com/lnurl/luds/blob/luds/04.md
869+ pub fn build_with_sigs_auth (
870+ & self , fixed_headers : HashMap < String , String > ,
871+ ) -> Result < VssStore , VssStoreBuildError > {
872+ let secp_ctx = Secp256k1 :: new ( ) ;
873+ let seed_bytes = self . node_entropy . to_seed_bytes ( ) ;
874+ let vss_xprv = Xpriv :: new_master ( self . network , & seed_bytes)
875+ . map_err ( |_| VssStoreBuildError :: KeyDerivationFailed )
876+ . and_then ( |master| {
877+ master
878+ . derive_priv (
879+ & secp_ctx,
880+ & [ ChildNumber :: Hardened { index : VSS_HARDENED_CHILD_INDEX } ] ,
881+ )
882+ . map_err ( |_| VssStoreBuildError :: KeyDerivationFailed )
883+ } ) ?;
884+
885+ let sigs_auth_xprv = vss_xprv
886+ . derive_priv (
887+ & secp_ctx,
888+ & [ ChildNumber :: Hardened { index : VSS_SIGS_AUTH_HARDENED_CHILD_INDEX } ] ,
889+ )
890+ . map_err ( |_| VssStoreBuildError :: KeyDerivationFailed ) ?;
891+
892+ let auth_provider = SigsAuthProvider :: new ( sigs_auth_xprv. private_key , fixed_headers) ;
893+ self . build_with_header_provider ( Arc :: new ( auth_provider) )
894+ }
895+
856896 /// Builds a [`VssStore`] with [LNURL-auth] based authentication scheme as default method for
857897 /// authentication/authorization.
858898 ///
@@ -869,7 +909,7 @@ impl VssStoreBuilder {
869909 ///
870910 /// [VSS]: https://github.com/lightningdevkit/vss-server/blob/main/README.md
871911 /// [LNURL-auth]: https://github.com/lnurl/luds/blob/luds/04.md
872- pub fn build (
912+ pub fn build_with_lnurl (
873913 & self , lnurl_auth_server_url : String , fixed_headers : HashMap < String , String > ,
874914 ) -> Result < VssStore , VssStoreBuildError > {
875915 let secp_ctx = Secp256k1 :: new ( ) ;
0 commit comments