@@ -245,6 +245,20 @@ namespace wavm_host_module {
245245 interface.top ()->eeiSelfDestruct (addressOffset);
246246 }
247247
248+ // the host module is called 'bignum'
249+ DEFINE_INTRINSIC_MODULE (bignum)
250+
251+ // host functions follow
252+ DEFINE_INTRINSIC_FUNCTION (bignum, " mul256" , void , mul256, U32 a, U32 b, U32 ret)
253+ {
254+ interface.top ()->mul256 (a, b, ret);
255+ }
256+
257+ DEFINE_INTRINSIC_FUNCTION (bignum, " umulmod256" , void , umulmod246, U32 a, U32 b, U32 mod, U32 ret)
258+ {
259+ interface.top ()->umulmod256 (a, b, mod, ret);
260+ }
261+
248262 // this is needed for resolving names of imported host functions
249263 struct HeraWavmResolver : Runtime::Resolver {
250264 HashMap<string, Runtime::ModuleInstance*> moduleNameToInstanceMap;
@@ -345,10 +359,14 @@ ExecutionResult WavmEngine::internalExecute(
345359 Runtime::GCPointer<Runtime::ModuleInstance> ethereumHostModule = Intrinsics::instantiateModule (compartment, wavm_host_module::INTRINSIC_MODULE_REF (ethereum), " ethereum" , {});
346360 heraAssert (ethereumHostModule, " Failed to create host module." );
347361
362+ Runtime::GCPointer<Runtime::ModuleInstance> bignumHostModule = Intrinsics::instantiateModule (compartment, wavm_host_module::INTRINSIC_MODULE_REF (bignum), " bignum" , {});
363+ heraAssert (bignumHostModule, " Failed to create host module." );
364+
348365 // prepare contract module to resolve links against host module
349366 wavm_host_module::HeraWavmResolver resolver;
350367 // TODO: move this into the constructor?
351368 resolver.moduleNameToInstanceMap .set (" ethereum" , ethereumHostModule);
369+ resolver.moduleNameToInstanceMap .set (" bignum" , bignumHostModule);
352370 Runtime::LinkResult linkResult = Runtime::linkModule (moduleIR, resolver);
353371 ensureCondition (linkResult.success , ContractValidationFailure, " Couldn't link contract against host module." );
354372
@@ -453,7 +471,7 @@ void WavmEngine::verifyContract(bytes_view code)
453471
454472 for (auto const & import : moduleIR.functions .imports ) {
455473#if HERA_DEBUGGING
456- if (import .moduleName == " debug" )
474+ if (import .moduleName == " debug" || import . moduleName == " bignum " )
457475 continue ;
458476#endif
459477
0 commit comments