123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899(*****************************************************************************)(* *)(* MIT License *)(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)moduletypeVdf_sig=sigmoduleGroup:S.GROUP(** [prove_vdf discriminant form difficulty] *)valprove:Group.t->Unsigned.UInt64.t->Group.t*Group.t(** [verify_vdf discriminant form difficulty form form] *)valverify:Group.t->Unsigned.UInt64.t->Group.t->Group.t->boolendmoduleStubs=structexternalprove:Bytes.t->Unsigned.Size_t.t->Bytes.t->Unsigned.UInt64.t->Bytes.t->Bytes.t->int="caml_prove_bytecode_stubs""caml_prove_stubs"externalverify:Bytes.t->Unsigned.Size_t.t->Bytes.t->Bytes.t->Bytes.t->Unsigned.UInt64.t->int="caml_verify_bytecode_stubs""caml_verify_stubs"endmoduleMake(CG:Class_group.Class_group_sig):Vdf_sig=structmoduleGroup=CGletdiscriminant_bytes=Utils.Integer.to_bytesCG.discriminantletprovechallengedifficulty=letchallenge_bytes=CG.to_byteschallengeinletresult_bytes=Bytes.createCG.size_in_bytesinletproof_bytes=Bytes.createCG.size_in_bytesinletstatus=Stubs.provediscriminant_bytesCG.discriminant_sizechallenge_bytesdifficultyresult_bytesproof_bytesinletresult=CG.of_bytes_exnresult_bytesinletproof=CG.of_bytes_exnproof_bytesinmatchstatuswith|xwhenx=0->(result,proof)|xwhenx=2->raiseUtils.invalid_group_element|_->raiseUtils.unknown_errorletverifychallengedifficultyresultproof=letchallenge_bytes=CG.to_byteschallengeinletresult_bytes=CG.to_bytesresultinletproof_bytes=CG.to_bytesproofinletstatus=Stubs.verifydiscriminant_bytesCG.discriminant_sizechallenge_bytesresult_bytesproof_bytesdifficultyinmatchstatuswith|xwhenx=0->false|xwhenx=1->true|xwhenx=2->raiseUtils.invalid_group_element|_->raiseUtils.unknown_errorend