@@ -21,6 +21,7 @@ import { Types, TypesBigint } from '../../../bindings/mina-transaction/v1/types.
2121import type { NetworkId } from '../../../mina-signer/src/types.js' ;
2222import type { Account } from './account.js' ;
2323import type { NetworkValue } from './precondition.js' ;
24+ import { VerificationKey } from '../../proof-system/verification-key.js' ;
2425
2526export {
2627 reportGetAccountError ,
@@ -242,8 +243,13 @@ async function verifyAccountUpdate(
242243 publicOutput : [ ] ,
243244 } ;
244245
245- let verificationKey = account . zkapp ?. verificationKey ?. data ;
246- assert ( verificationKey !== undefined , 'Account does not have a verification key' ) ;
246+ let verificationKeyRaw = account . zkapp ?. verificationKey ;
247+ assert ( verificationKeyRaw !== undefined , 'Account does not have a verification key' ) ;
248+ let verificationKey = verificationKeyRaw . data ;
249+
250+ const isVkValid = await VerificationKey . checkValidity ( verificationKeyRaw ) ;
251+ if ( ! isVkValid )
252+ throw Error ( `The verification key hash is not consistent with the provided data` ) ;
247253
248254 isValidProof = await verify ( proof , verificationKey ) ;
249255 if ( ! isValidProof ) {
@@ -305,6 +311,13 @@ async function verifyAccountUpdate(
305311 }
306312 } ) ;
307313
314+ if ( accountUpdate . update . verificationKey . isSome . toBoolean ( ) ) {
315+ const isVkValid = await VerificationKey . checkValidity (
316+ accountUpdate . update . verificationKey . value
317+ ) ;
318+ if ( ! isVkValid )
319+ throw Error ( `The verification key hash is not consistent with the provided data` ) ;
320+ }
308321 // checks the sequence events (which result in an updated sequence state)
309322 if ( accountUpdate . body . actions . data . length > 0 ) {
310323 let p = permissionForUpdate ( 'actions' ) ;
0 commit comments