Skip to content

Commit ae8c09c

Browse files
committed
Fixed #470
- Added s-part in transaction hash
1 parent fa035d8 commit ae8c09c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/model/transaction/Transaction.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ export abstract class Transaction {
138138
TransactionType.AGGREGATE_COMPLETE,
139139
].find((type: TransactionType) => entityType === type) !== undefined;
140140

141-
// 1) take "R" part of a signature (first 32 bytes)
142-
const signatureR: Uint8Array = transactionBytes.slice(8, 8 + 32);
141+
// 1) add full signature
142+
const signature: Uint8Array = transactionBytes.slice(8, 8 + 64);
143143

144144
// 2) add public key to match sign/verify behavior (32 bytes)
145-
const pubKeyIdx: number = signatureR.length;
145+
const pubKeyIdx: number = signature.length;
146146
const publicKey: Uint8Array = transactionBytes.slice(8 + 64, 8 + 64 + 32);
147147

148148
// 3) add generationHash (32 bytes)
@@ -162,12 +162,12 @@ export abstract class Transaction {
162162
// 5) concatenate binary hash parts
163163
// layout: `signature_R || signerPublicKey || generationHash || EntityDataBuffer`
164164
const entityHashBytes: Uint8Array = new Uint8Array(
165-
signatureR.length
165+
signature.length
166166
+ publicKey.length
167167
+ generationHash.length
168168
+ transactionBody.length,
169169
);
170-
entityHashBytes.set(signatureR, 0);
170+
entityHashBytes.set(signature, 0);
171171
entityHashBytes.set(publicKey, pubKeyIdx);
172172
entityHashBytes.set(generationHash, generationHashIdx);
173173
entityHashBytes.set(transactionBody, transactionBodyIdx);

test/model/transaction/Transaction.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ describe('Transaction', () => {
255255
);
256256

257257
// expected values
258-
const knownHash_sha3 = '709373248659274C5933BEA2920942D6C7B48B9C2DA4BAEE233510E71495931F';
258+
const knownHash_sha3 = 'F0F5A62A0863D45E832B50EFF4E2F68157268A5D1674EC1068D82EC5F88D950B';
259259
const generationHashBytes = Array.from(Convert.hexToUint8('988C4CDCE4D188013C13DE7914C7FD4D626169EF256722F61C52EFBE06BD5A2C'));
260260
const generationHashBytes_mt = Array.from(Convert.hexToUint8('17FA4747F5014B50413CCF968749604D728D7065DC504291EEE556899A534CBB'));
261261

0 commit comments

Comments
 (0)