@@ -10,7 +10,8 @@ import {
1010 WasmPastaFpPlonkIndex ,
1111 WasmPastaFqPlonkIndex ,
1212} from '../../bindings/compiled/node_bindings/plonk_wasm.cjs' ;
13- import { getRustConversion } from '../../bindings/crypto/bindings.js' ;
13+ // TODO: include conversion bundle to decide between wasm and napi conversion
14+ import { createNativeRustConversion , getRustConversion } from '../../bindings/crypto/bindings.js' ;
1415import { VerifierIndex } from '../../bindings/crypto/bindings/kimchi-types.js' ;
1516import { MlString } from '../ml/base.js' ;
1617import { CacheHeader , cacheHeaderVersion } from './cache.js' ;
@@ -95,21 +96,21 @@ function encodeProverKey(value: SnarkKey): Uint8Array {
9596 case KeyType . StepProvingKey : {
9697 let index = value [ 1 ] [ 1 ] ;
9798 let encoded = wasm . caml_pasta_fp_plonk_index_encode (
98- ( wasm as any ) . prover_index_fp_from_bytes ( index . serialize ( ) )
99+ ( wasm as any ) . prover_index_fp_deserialize ( ( wasm as any ) . prover_index_fp_serialize ( index ) )
99100 ) ;
100101 return encoded ;
101102 }
102103 case KeyType . StepVerificationKey : {
103104 let vkMl = value [ 1 ] ;
104- const rustConversion = getRustConversion ( wasm ) ;
105+ const rustConversion = createNativeRustConversion ( wasm ) ;
105106 let vkWasm = rustConversion . fp . verifierIndexToRust ( vkMl ) ;
106107 let string = wasm . caml_pasta_fp_plonk_verifier_index_serialize ( vkWasm ) ;
107108 return new TextEncoder ( ) . encode ( string ) ;
108109 }
109110 case KeyType . WrapProvingKey : {
110111 let index = value [ 1 ] [ 1 ] ;
111112 let encoded = wasm . caml_pasta_fq_plonk_index_encode (
112- ( wasm as any ) . prover_index_fq_from_bytes ( index . serialize ( ) )
113+ ( wasm as any ) . prover_index_fq_deserialize ( ( wasm as any ) . prover_index_fq_serialize ( index ) )
113114 ) ;
114115 return encoded ;
115116 }
@@ -139,7 +140,7 @@ function decodeProverKey(header: SnarkKeyHeader, bytes: Uint8Array): SnarkKey {
139140 let srs = Pickles . loadSrsFp ( ) ;
140141 let string = new TextDecoder ( ) . decode ( bytes ) ;
141142 let vkWasm = wasm . caml_pasta_fp_plonk_verifier_index_deserialize ( srs , string ) ;
142- const rustConversion = getRustConversion ( wasm ) ;
143+ const rustConversion = createNativeRustConversion ( wasm ) ;
143144 let vkMl = rustConversion . fp . verifierIndexFromRust ( vkWasm ) ;
144145 return [ KeyType . StepVerificationKey , vkMl ] ;
145146 }
0 commit comments