File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
yarn-project/simulator/src/public/avm/opcodes Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -132,13 +132,17 @@ export class Sha256Compression extends Instruction {
132132 const [ outputOffset , stateOffset , inputsOffset ] = addressing . resolve ( operands , memory ) ;
133133
134134 // Note: size of output is same as size of state
135- const inputs = Uint32Array . from ( memory . getSlice ( inputsOffset , INPUTS_SIZE ) . map ( word => word . toNumber ( ) ) ) ;
136- const state = Uint32Array . from ( memory . getSlice ( stateOffset , STATE_SIZE ) . map ( word => word . toNumber ( ) ) ) ;
135+ const inputs = memory . getSlice ( inputsOffset , INPUTS_SIZE ) . map ( word => word . toBigInt ( ) ) ;
136+ const state = memory . getSlice ( stateOffset , STATE_SIZE ) . map ( word => word . toBigInt ( ) ) ;
137137
138138 memory . checkTagsRange ( TypeTag . UINT32 , inputsOffset , INPUTS_SIZE ) ;
139139 memory . checkTagsRange ( TypeTag . UINT32 , stateOffset , STATE_SIZE ) ;
140140
141- const output = sha256Compression ( state , inputs ) ;
141+ // At this point both state and inputs are Uint32Array-compatible
142+ const inputsArray = new Uint32Array ( inputs . map ( i => Number ( i ) ) ) ;
143+ const stateArray = new Uint32Array ( state . map ( i => Number ( i ) ) ) ;
144+
145+ const output = sha256Compression ( stateArray , inputsArray ) ;
142146
143147 // Conversion required from Uint32Array to Uint32[] (can't map directly, need `...`)
144148 const res = [ ...output ] . map ( word => new Uint32 ( word ) ) ;
You can’t perform that action at this time.
0 commit comments