@@ -19,7 +19,6 @@ import * as Comlink from 'comlink';
1919import { PresentationJSON as PresentationJSONa7 } from 'tlsn-js/build/types' ;
2020import { OffscreenActionTypes } from './types' ;
2121import { PresentationJSON } from '../../utils/types' ;
22- import { verify } from 'tlsn-js-v5' ;
2322import { waitForEvent } from '../utils' ;
2423import {
2524 setNotaryRequestError ,
@@ -37,7 +36,10 @@ export const initThreads = async () => {
3736 type : BackgroundActiontype . get_logging_level ,
3837 hardwareConcurrency : navigator . hardwareConcurrency ,
3938 } ) ;
40- await init ( { loggingLevel } ) ;
39+ await init ( {
40+ loggingLevel,
41+ hardwareConcurrency : navigator . hardwareConcurrency ,
42+ } ) ;
4143} ;
4244export const onNotarizationRequest = async ( request : any ) => {
4345 const { id } = request . data ;
@@ -536,36 +538,47 @@ async function verifyProof(proof: PresentationJSON): Promise<{
536538 } ;
537539
538540 switch ( proof . version ) {
539- case undefined : {
540- result = await verify ( proof ) ;
541- break ;
542- }
541+ case undefined :
543542 case '0.1.0-alpha.7' :
544543 case '0.1.0-alpha.8' :
545544 case '0.1.0-alpha.9' :
546- const presentation : TPresentation = await new Presentation ( proof . data ) ;
547- const verifierOutput = await presentation . verify ( ) ;
548- const transcript = new Transcript ( {
549- sent : verifierOutput . transcript . sent ,
550- recv : verifierOutput . transcript . recv ,
551- } ) ;
552- const vk = await presentation . verifyingKey ( ) ;
553- const verifyingKey = Buffer . from ( vk . data ) . toString ( 'hex' ) ;
554- const notaryUrl = proof . meta . notaryUrl
555- ? convertNotaryWsToHttp ( proof . meta . notaryUrl )
556- : '' ;
557- const publicKey = await new NotaryServer ( notaryUrl )
558- . publicKey ( )
559- . catch ( ( ) => '' ) ;
560545 result = {
561- sent : transcript . sent ( ) ,
562- recv : transcript . recv ( ) ,
563- verifierKey : verifyingKey ,
564- notaryKey : publicKey ,
546+ sent : 'version not supported' ,
547+ recv : 'version not supported' ,
565548 } ;
566549 break ;
550+ case '0.1.0-alpha.10' :
551+ result = await verify ( proof ) ;
552+ break ;
567553 }
568- return result ;
554+
555+ return result ! ;
556+ }
557+
558+ async function verify ( proof : PresentationJSON ) {
559+ if ( proof . version !== '0.1.0-alpha.10' ) {
560+ throw new Error ( 'wrong version' ) ;
561+ }
562+ const presentation : TPresentation = await new Presentation ( proof . data ) ;
563+ const verifierOutput = await presentation . verify ( ) ;
564+ const transcript = new Transcript ( {
565+ sent : verifierOutput . transcript . sent ,
566+ recv : verifierOutput . transcript . recv ,
567+ } ) ;
568+ const vk = await presentation . verifyingKey ( ) ;
569+ const verifyingKey = Buffer . from ( vk . data ) . toString ( 'hex' ) ;
570+ const notaryUrl = proof . meta . notaryUrl
571+ ? convertNotaryWsToHttp ( proof . meta . notaryUrl )
572+ : '' ;
573+ const publicKey = await new NotaryServer ( notaryUrl )
574+ . publicKey ( )
575+ . catch ( ( ) => '' ) ;
576+ return {
577+ sent : transcript . sent ( ) ,
578+ recv : transcript . recv ( ) ,
579+ verifierKey : verifyingKey ,
580+ notaryKey : publicKey ,
581+ } ;
569582}
570583
571584function updateRequestProgress (
0 commit comments