@@ -85,6 +85,7 @@ static constexpr uint8_t PSBT_ELEMENTS_IN_VALUE_PROOF = 0x12;
8585static constexpr uint8_t PSBT_ELEMENTS_IN_EXPLICIT_ASSET = 0x13 ;
8686static constexpr uint8_t PSBT_ELEMENTS_IN_ASSET_PROOF = 0x14 ;
8787static constexpr uint8_t PSBT_ELEMENTS_IN_BLINDED_ISSUANCE = 0x15 ;
88+ static constexpr uint8_t PSBT_ELEMENTS_IN_ASSET_BLINDING_FACTOR = 0x16 ;
8889
8990// Output types
9091static constexpr uint8_t PSBT_OUT_REDEEMSCRIPT = 0x00 ;
@@ -104,6 +105,7 @@ static constexpr uint8_t PSBT_ELEMENTS_OUT_ECDH_PUBKEY = 0x07;
104105static constexpr uint8_t PSBT_ELEMENTS_OUT_BLINDER_INDEX = 0x08 ;
105106static constexpr uint8_t PSBT_ELEMENTS_OUT_BLIND_VALUE_PROOF = 0x09 ;
106107static constexpr uint8_t PSBT_ELEMENTS_OUT_BLIND_ASSET_PROOF = 0x0a ;
108+ static constexpr uint8_t PSBT_ELEMENTS_OUT_ASSET_BLINDING_FACTOR = 0x0b ;
107109
108110// Proprietary type identifier string
109111static const std::vector<unsigned char > PSBT_ELEMENTS_ID = {' p' , ' s' , ' e' , ' t' };
@@ -280,6 +282,7 @@ struct PSBTInput
280282 std::vector<unsigned char > m_value_proof;
281283 uint256 m_explicit_asset;
282284 std::vector<unsigned char > m_asset_proof;
285+ std::optional<uint256> m_asset_blinding_factor{std::nullopt };
283286
284287 bool IsNull () const ;
285288 void FillSignatureData (SignatureData& sigdata) const ;
@@ -543,6 +546,12 @@ struct PSBTInput
543546 SerializeToVector (s, CompactSizeWriter (PSBT_IN_PROPRIETARY), PSBT_ELEMENTS_ID, CompactSizeWriter (PSBT_ELEMENTS_IN_BLINDED_ISSUANCE));
544547 SerializeToVector (s, *m_blinded_issuance);
545548 }
549+
550+ // Asset blinding factor
551+ if (m_asset_blinding_factor.has_value ()) {
552+ SerializeToVector (s, CompactSizeWriter (PSBT_IN_PROPRIETARY), PSBT_ELEMENTS_ID, CompactSizeWriter (PSBT_ELEMENTS_IN_ASSET_BLINDING_FACTOR));
553+ SerializeToVector (s, m_asset_blinding_factor.value ());
554+ }
546555 }
547556
548557 // Write proprietary things
@@ -1096,6 +1105,18 @@ struct PSBTInput
10961105 m_blinded_issuance = b;
10971106 break ;
10981107 }
1108+ case PSBT_ELEMENTS_IN_ASSET_BLINDING_FACTOR:
1109+ {
1110+ if (m_asset_blinding_factor.has_value ()) {
1111+ throw std::ios_base::failure (" Duplicate Key, input asset blinding factor is already provided" );
1112+ } else if (subkey_len != 1 ) {
1113+ throw std::ios_base::failure (" Input asset blinding factor is more than one byte type" );
1114+ }
1115+ uint256 u;
1116+ UnserializeFromVector (s, u);
1117+ m_asset_blinding_factor = u;
1118+ break ;
1119+ }
10991120 default :
11001121 {
11011122 known = false ;
@@ -1185,6 +1206,7 @@ struct PSBTOutput
11851206 std::optional<uint32_t > m_blinder_index{std::nullopt };
11861207 std::vector<unsigned char > m_blind_value_proof;
11871208 std::vector<unsigned char > m_blind_asset_proof;
1209+ std::optional<uint256> m_asset_blinding_factor{std::nullopt };
11881210
11891211 bool IsNull () const ;
11901212 void FillSignatureData (SignatureData& sigdata) const ;
@@ -1282,6 +1304,12 @@ struct PSBTOutput
12821304 SerializeToVector (s, CompactSizeWriter (PSBT_OUT_PROPRIETARY), PSBT_ELEMENTS_ID, CompactSizeWriter (PSBT_ELEMENTS_OUT_BLIND_ASSET_PROOF));
12831305 s << m_blind_asset_proof;
12841306 }
1307+
1308+ // Asset blinding factor
1309+ if (m_asset_blinding_factor.has_value ()) {
1310+ SerializeToVector (s, CompactSizeWriter (PSBT_OUT_PROPRIETARY), PSBT_ELEMENTS_ID, CompactSizeWriter (PSBT_ELEMENTS_OUT_ASSET_BLINDING_FACTOR));
1311+ SerializeToVector (s, m_asset_blinding_factor.value ());
1312+ }
12851313 }
12861314
12871315 // Write proprietary things
@@ -1488,6 +1516,18 @@ struct PSBTOutput
14881516 s >> m_blind_asset_proof;
14891517 break ;
14901518 }
1519+ case PSBT_ELEMENTS_OUT_ASSET_BLINDING_FACTOR:
1520+ {
1521+ if (m_asset_blinding_factor.has_value ()) {
1522+ throw std::ios_base::failure (" Duplicate Key, output asset blinding factor is already provided" );
1523+ } else if (subkey_len != 1 ) {
1524+ throw std::ios_base::failure (" Output asset blinding factor is more than one byte type" );
1525+ }
1526+ uint256 u;
1527+ UnserializeFromVector (s, u);
1528+ m_asset_blinding_factor = u;
1529+ break ;
1530+ }
14911531 default :
14921532 {
14931533 known = false ;
0 commit comments