shorten transaction
This commit is contained in:
@@ -44,7 +44,6 @@ typedef struct {
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct {
|
||||
uint8_t txHash[32];
|
||||
uint8_t signature[64]; // Signature of the hash
|
||||
} transaction_sig_t;
|
||||
|
||||
|
||||
@@ -199,7 +199,9 @@ void Block_RemoveTransaction(block_t* block, uint8_t* txHash) {
|
||||
|
||||
for (size_t i = 0; i < DynArr_size(block->transactions); i++) {
|
||||
signed_transaction_t* currentTx = (signed_transaction_t*)DynArr_at(block->transactions, i);
|
||||
if (memcmp(currentTx->signature.txHash, txHash, 32) == 0) {
|
||||
uint8_t currentTxHash[32];
|
||||
Transaction_CalculateHash(currentTx, currentTxHash);
|
||||
if (memcmp(currentTxHash, txHash, 32) == 0) {
|
||||
DynArr_remove(block->transactions, i);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,10 @@ void Transaction_Sign(signed_transaction_t* tx, const uint8_t* privateKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
Transaction_CalculateHash(tx, tx->signature.txHash);
|
||||
uint8_t txHash[32];
|
||||
Transaction_CalculateHash(tx, txHash);
|
||||
Crypto_SignData(
|
||||
(const uint8_t*)&tx->transaction,
|
||||
txHash,
|
||||
sizeof(transaction_t),
|
||||
privateKey,
|
||||
tx->signature.signature
|
||||
@@ -81,13 +82,9 @@ bool Transaction_Verify(const signed_transaction_t* tx) {
|
||||
uint8_t txHash[32];
|
||||
Transaction_CalculateHash(tx, txHash);
|
||||
|
||||
if (memcmp(txHash, tx->signature.txHash, 32) != 0) {
|
||||
return false; // Hash does not match signature hash
|
||||
}
|
||||
|
||||
// If all checks pass, verify the signature
|
||||
return Crypto_VerifySignature(
|
||||
(const uint8_t*)&tx->transaction,
|
||||
txHash,
|
||||
sizeof(transaction_t),
|
||||
tx->signature.signature,
|
||||
tx->transaction.compressedPublicKey
|
||||
|
||||
Reference in New Issue
Block a user