@ -3183,7 +3183,6 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
if ( txfee = = 0 )
if ( txfee = = 0 )
txfee = DILITHIUM_TXFEE ;
txfee = DILITHIUM_TXFEE ;
mypk = pubkey2pk ( Mypubkey ( ) ) ;
mypk = pubkey2pk ( Mypubkey ( ) ) ;
fprintf ( stderr , " inside \n " ) ;
if ( params ! = 0 & & ( ( n = cJSON_GetArraySize ( params ) ) = = 2 | | n = = 3 ) )
if ( params ! = 0 & & ( ( n = cJSON_GetArraySize ( params ) ) = = 2 | | n = = 3 ) )
{
{
prevhash = juint256 ( jitem ( params , 0 ) ) ;
prevhash = juint256 ( jitem ( params , 0 ) ) ;
@ -3194,35 +3193,34 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
result . push_back ( Pair ( " warning " , " test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!! " ) ) ;
result . push_back ( Pair ( " warning " , " test mode using privkey for -pubkey, only for testing. there is no point using quantum secure signing if you are using a privkey with a known secp256k1 pubkey!! " ) ) ;
}
}
_dilithium_keypair ( pk , sk , seed ) ;
_dilithium_keypair ( pk , sk , seed ) ;
fprintf ( stderr , " after keypair \n " ) ;
if ( is_hexstr ( scriptstr , 0 ) ! = 0 )
if ( is_hexstr ( scriptstr , 0 ) ! = 0 )
{
{
fprintf ( stderr , " have script \n " ) ;
CScript scriptPubKey ;
CScript scriptPubKey ;
scriptPubKey . resize ( strlen ( scriptstr ) / 2 ) ;
scriptPubKey . resize ( strlen ( scriptstr ) / 2 ) ;
decode_hex ( & scriptPubKey [ 0 ] , strlen ( scriptstr ) / 2 , scriptstr ) ;
decode_hex ( & scriptPubKey [ 0 ] , strlen ( scriptstr ) / 2 , scriptstr ) ;
if ( myGetTransaction ( prevhash , vintx , hashBlock ) ! = 0 & & ( numvouts = vintx . vout . size ( ) ) > 1 )
if ( myGetTransaction ( prevhash , vintx , hashBlock ) ! = 0 & & ( numvouts = vintx . vout . size ( ) ) > 1 )
{
{
fprintf ( stderr , " got tx \n " ) ;
vout . nValue = vintx . vout [ 0 ] . nValue - txfee ;
vout . nValue = vintx . vout [ 0 ] . nValue - txfee ;
vout . scriptPubKey = scriptPubKey ;
vout . scriptPubKey = scriptPubKey ;
musig_prevoutmsg ( msg , prevhash , vout . scriptPubKey ) ;
musig_prevoutmsg ( msg , prevhash , vout . scriptPubKey ) ;
sig . resize ( 32 + CRYPTO_BYTES ) ;
sig . resize ( 32 + CRYPTO_BYTES ) ;
if ( dilithium_bigpubget ( handle , destpub33 , pk2 , destpubtxid ) < 0 )
if ( dilithium_sendopretdecode ( destpubtxid , tx . vout [ numvouts - 1 ] . scriptPubKey ) = = ' x ' )
return ( cclib_error ( result , " couldnt parse message to sign " ) ) ;
{
else if ( memcmp ( pk , pk2 , sizeof ( pk ) ) ! = 0 )
if ( dilithium_bigpubget ( handle , destpub33 , pk2 , destpubtxid ) < 0 )
return ( cclib_error ( result , " dilithium bigpub mismatch " ) ) ;
return ( cclib_error ( result , " couldnt parse message to sign " ) ) ;
else if ( destpub33 ! = mypk )
else if ( memcmp ( pk , pk2 , sizeof ( pk ) ) ! = 0 )
return ( cclib_error ( result , " destpub33 is not for this -pubkey " ) ) ;
return ( cclib_error ( result , " dilithium bigpub mismatch " ) ) ;
else if ( _dilithium_sign ( & sig [ 0 ] , & smlen , msg , 32 , sk ) < 0 )
else if ( destpub33 ! = mypk )
return ( cclib_error ( result , " dilithium signing error " ) ) ;
return ( cclib_error ( result , " destpub33 is not for this -pubkey " ) ) ;
else if ( smlen ! = 32 + CRYPTO_BYTES )
else if ( _dilithium_sign ( & sig [ 0 ] , & smlen , msg , 32 , sk ) < 0 )
return ( cclib_error ( result , " siglen error " ) ) ;
return ( cclib_error ( result , " dilithium signing error " ) ) ;
fprintf ( stderr , " prepare tx \n " ) ;
else if ( smlen ! = 32 + CRYPTO_BYTES )
mtx . vin . push_back ( CTxIn ( prevhash , 0 ) ) ;
return ( cclib_error ( result , " siglen error " ) ) ;
mtx . vout . push_back ( vout ) ;
mtx . vin . push_back ( CTxIn ( prevhash , 0 ) ) ;
rawtx = FinalizeCCTx ( 0 , cp , mtx , mypk , txfee , dilithium_spendopret ( destpubtxid , sig ) ) ;
mtx . vout . push_back ( vout ) ;
return ( dilithium_rawtxresult ( result , rawtx ) ) ;
rawtx = FinalizeCCTx ( 0 , cp , mtx , mypk , txfee , dilithium_spendopret ( destpubtxid , sig ) ) ;
return ( dilithium_rawtxresult ( result , rawtx ) ) ;
} else return ( cclib_error ( result , " couldnt decode send opret " ) ) ;
} else return ( cclib_error ( result , " couldnt find vin0 " ) ) ;
} else return ( cclib_error ( result , " couldnt find vin0 " ) ) ;
} else return ( cclib_error ( result , " script or bad destpubtxid is not hex " ) ) ;
} else return ( cclib_error ( result , " script or bad destpubtxid is not hex " ) ) ;
} else return ( cclib_error ( result , " need to have exactly 2 params sendtxid, scriptPubKey " ) ) ;
} else return ( cclib_error ( result , " need to have exactly 2 params sendtxid, scriptPubKey " ) ) ;