Skip to content

Commit 67a062f

Browse files
committed
Move test data into separate file.
1 parent a86995d commit 67a062f

File tree

5 files changed

+111
-112
lines changed

5 files changed

+111
-112
lines changed

tests_zemu/tests/masp.test.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ const MASP_MODELS = models.filter(m => m.name !== 'nanos')
2828
const TEST_SIGN_DATA = {
2929
name: 'transfer',
3030
blob: Buffer.from(MASP_TRANSFER_SIGNING_TX, 'hex'),
31-
sectionHashes: {
32-
0: Buffer.from('af859437564c2c660a42903d9dca0686f1229cf4039894cf2b4cc4529decde6f', 'hex'),
33-
1: Buffer.from('1f07d555db2430f5dbf51e1f70ce0852affeb8d5791a6957a9895b40ce79e726', 'hex'),
34-
2: Buffer.from('20b9054f4e22fdaeda9d89999fee8c91493873ccaa268df016e0fe86e55de363', 'hex'),
35-
3: Buffer.from('a4fa85bd4b2205d4fd51e438bf65c95edf3503236ec0ffbe3a471524af2efa24', 'hex'),
36-
4: Buffer.from('0cadb91730d8d5904469534807019c50300e492afd8aa118d91482c5c8f7d657', 'hex'),
37-
5: Buffer.from('229f900de2dd6d43affc2822cceac915bdfba7e9b001f435f42a677c69708aaa', 'hex'),
38-
6: Buffer.from('21085924ad08eb3b0934a9f558c9a34d89180defbb4bb583747e519073f2399e', 'hex'),
39-
0xff: Buffer.from('95d70ed16980f4cab39179b420fe39b5d0209eae016778307bf3bc43d4b9999a', 'hex'),
40-
} as { [index: number]: Buffer },
31+
sectionIndices: [0, 1, 2, 3, 4, 5, 6, 0xff],
32+
sectionHashes: [
33+
"af859437564c2c660a42903d9dca0686f1229cf4039894cf2b4cc4529decde6f",
34+
"1f07d555db2430f5dbf51e1f70ce0852affeb8d5791a6957a9895b40ce79e726",
35+
"20b9054f4e22fdaeda9d89999fee8c91493873ccaa268df016e0fe86e55de363",
36+
"a4fa85bd4b2205d4fd51e438bf65c95edf3503236ec0ffbe3a471524af2efa24",
37+
"0cadb91730d8d5904469534807019c50300e492afd8aa118d91482c5c8f7d657",
38+
"229f900de2dd6d43affc2822cceac915bdfba7e9b001f435f42a677c69708aaa",
39+
"21085924ad08eb3b0934a9f558c9a34d89180defbb4bb583747e519073f2399e",
40+
"95d70ed16980f4cab39179b420fe39b5d0209eae016778307bf3bc43d4b9999a",
41+
],
4142
}
4243

4344
describe('Masp', function () {
@@ -141,24 +142,27 @@ describe('Masp', function () {
141142
expect(signature.rawPubkey).toEqual(resp_addr.rawPubkey)
142143
console.log(signature)
143144
// Verify raw signature
144-
const unsignedRawSigHash = hashSignatureSec([], signature.raw_salt, TEST_SIGN_DATA.sectionHashes, signature.raw_indices, null, null)
145+
const unsignedRawSigHash = hashSignatureSec([], signature.raw_salt, TEST_SIGN_DATA.sectionIndices, TEST_SIGN_DATA.sectionHashes, signature.raw_indices, null, null)
145146
const rawSig = ed25519.verify(signature.raw_signature.subarray(1), unsignedRawSigHash, signature.rawPubkey.subarray(1))
146147

147148
// Verify wrapper signature
148149
const prefix = new Uint8Array([0x03])
149150
const rawHash: Buffer = hashSignatureSec(
150151
[signature.rawPubkey],
151152
signature.raw_salt,
153+
TEST_SIGN_DATA.sectionIndices,
152154
TEST_SIGN_DATA.sectionHashes,
153155
signature.raw_indices,
154156
signature.raw_signature,
155157
prefix,
156158
)
157-
const tmpHashes = { ...TEST_SIGN_DATA.sectionHashes }
159+
const tmpIndices = [ ...TEST_SIGN_DATA.sectionIndices ]
160+
const tmpHashes = [ ...TEST_SIGN_DATA.sectionHashes ]
158161

159-
tmpHashes[Object.keys(tmpHashes).length - 1] = rawHash
162+
tmpIndices.push(tmpHashes.length - 1)
163+
tmpHashes.push(rawHash.toString('hex'))
160164

161-
const unsignedWrapperSigHash = hashSignatureSec([], signature.wrapper_salt, tmpHashes, signature.wrapper_indices, null, null)
165+
const unsignedWrapperSigHash = hashSignatureSec([], signature.wrapper_salt, tmpIndices, tmpHashes, signature.wrapper_indices, null, null)
162166
const wrapperSig = ed25519.verify(signature.wrapper_signature.subarray(1), unsignedWrapperSigHash, resp_addr.rawPubkey.subarray(1))
163167

164168
expect(wrapperSig && rawSig).toEqual(true)

0 commit comments

Comments
 (0)