@@ -28,16 +28,17 @@ const MASP_MODELS = models.filter(m => m.name !== 'nanos')
28
28
const TEST_SIGN_DATA = {
29
29
name : 'transfer' ,
30
30
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
+ ] ,
41
42
}
42
43
43
44
describe ( 'Masp' , function ( ) {
@@ -141,24 +142,27 @@ describe('Masp', function () {
141
142
expect ( signature . rawPubkey ) . toEqual ( resp_addr . rawPubkey )
142
143
console . log ( signature )
143
144
// 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 )
145
146
const rawSig = ed25519 . verify ( signature . raw_signature . subarray ( 1 ) , unsignedRawSigHash , signature . rawPubkey . subarray ( 1 ) )
146
147
147
148
// Verify wrapper signature
148
149
const prefix = new Uint8Array ( [ 0x03 ] )
149
150
const rawHash : Buffer = hashSignatureSec (
150
151
[ signature . rawPubkey ] ,
151
152
signature . raw_salt ,
153
+ TEST_SIGN_DATA . sectionIndices ,
152
154
TEST_SIGN_DATA . sectionHashes ,
153
155
signature . raw_indices ,
154
156
signature . raw_signature ,
155
157
prefix ,
156
158
)
157
- const tmpHashes = { ...TEST_SIGN_DATA . sectionHashes }
159
+ const tmpIndices = [ ...TEST_SIGN_DATA . sectionIndices ]
160
+ const tmpHashes = [ ...TEST_SIGN_DATA . sectionHashes ]
158
161
159
- tmpHashes [ Object . keys ( tmpHashes ) . length - 1 ] = rawHash
162
+ tmpIndices . push ( tmpHashes . length - 1 )
163
+ tmpHashes . push ( rawHash . toString ( 'hex' ) )
160
164
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 )
162
166
const wrapperSig = ed25519 . verify ( signature . wrapper_signature . subarray ( 1 ) , unsignedWrapperSigHash , resp_addr . rawPubkey . subarray ( 1 ) )
163
167
164
168
expect ( wrapperSig && rawSig ) . toEqual ( true )
0 commit comments