text stringlengths 0 601k |
|---|
module Make ( A : T0 ) T0 ( A_value : T0 ) T0 = struct module I = Inductive_rule . T ( A ) A ( A_value ) A_value let prev ( type xs ys ws hs ) hs ~ self ( ~ choices : ( xs , ys , ws , hs ) hs H4 . T ( TI ) TI . t ) t = let module M_inner = H4 . Map ( Tag ) Tag ( E04 ( Domains ) Domains ) Domains ( struct let f : type a... |
let wrap ident exn_args global_idx = let open JavaAST in let name = Ident . name ident in Output . verbose ( Printf . sprintf " wrapping exception % S . . . " name ) name ; let exn_args = List . mapi ( fun i arg -> let info = TypeMap . find false arg in let name = Printf . sprintf " p % d " i in info , name ) name exn_... |
let wrap modname name res params eqs module_types approx approx_idx = let fname = Ident . name name in Output . verbose ( Printf . sprintf " wrapping functor % S . . . " fname ) fname ; let open JavaAST in let links = ref [ ] in let meth_parameters = List . mapi ( fun i ( mn , mt ) mt -> let id = Printf . sprintf " p %... |
let pad_domains ( type prev_varss prev_valuess branches max_proofs_verified ) max_proofs_verified ( module Max_proofs_verified : Nat . Intf with type n = max_proofs_verified ) max_proofs_verified ( pi_branches : ( prev_varss , branches ) branches Length . t ) t ( prev_wrap_domains : ( prev_varss , prev_valuess , _ , _ ... |
module Old_bulletproof_chals = struct type t = | T : ' max_local_max_proofs_verified Nat . t * ' max_local_max_proofs_verified Challenges_vector . t -> t end |
let pack_statement max_proofs_verified t = with_label __LOC__ ( fun ( ) -> Spec . pack ( module Impl ) Impl ( Types . Step . Statement . spec max_proofs_verified Backend . Tock . Rounds . n ) n ( Types . Step . Statement . to_data t ) t ) |
let shifts ~ log2_size = Common . tock_shifts ~ log2_size |> Plonk_types . Shifts . map ~ f : Impl . Field . constant |
let domain_generator ~ log2_size = Backend . Tock . Field . domain_generator ~ log2_size |> Impl . Field . constant |
let split_field_typ : ( Field . t * Boolean . var , Field . Constant . t ) t Typ . t = Typ . transport Typ ( . field * Boolean . typ ) typ ~ there ( : fun ( x : Field . Constant . t ) t -> let n = Bigint . of_field x in let is_odd = Bigint . test_bit n 0 in let y = Field . Constant ( ( . if is_odd then x - one else x )... |
let split_field ( x : Field . t ) t : Field . t * Boolean . var = let ( ( y , is_odd ) is_odd as res ) res = exists Typ ( . field * Boolean . typ ) typ ~ compute ( : fun ( ) -> let x = As_prover . read_var x in let n = Bigint . of_field x in let is_odd = Bigint . test_bit n 0 in let y = Field . Constant ( ( . if is_odd... |
let wrap_main ( type max_proofs_verified branches prev_varss prev_valuess env max_local_max_proofs_verifieds ) ( full_signature : ( max_proofs_verified , branches , max_local_max_proofs_verifieds ) Full_signature . t ) ( pi_branches : ( prev_varss , branches ) branches Hlist . Length . t ) t ( step_keys : ( Wrap_main_i... |
let sponge_params_constant = Sponge . Params ( . map pasta_q_kimchi ~ f : Impl . Field . Constant . of_string ) of_string |
let field_random_oracle ( ? length = Me . Field . size_in_bits - 1 ) 1 s = Me . Field . of_bits ( bits_random_oracle ~ length s ) s |
let unrelated_g = let group_map = unstage ( group_map ( module Me . Field ) Field ~ a : Me . Inner_curve . Params . a ~ b : Me . Inner_curve . Params . b ) and str = Fn . compose bits_to_bytes Me . Field . to_bits in fun ( x , y ) y -> group_map ( field_random_oracle ( str x ^ str y ) y ) y |
module Other_field = struct type t = Impls . Step . Field . Constant . t [ @@ deriving sexp ] sexp include ( Tick . Field : module type of Tick . Field with type t := t ) t let size = Impls . Step . Bigint . to_bignum_bigint size end |
let sponge_params = Sponge . Params ( . map sponge_params_constant ~ f : Impl . Field . constant ) constant |
module Unsafe = struct let unpack_unboolean ( ? length = Field . size_in_bits ) size_in_bits x = let res = exists ( Typ . list Boolean . typ_unchecked ~ length ) length ~ compute : As_prover ( . fun ( ) -> List . take ( Field . Constant . unpack ( read_var x ) x ) x length ) length in Field . Assert . equal x ( Field .... |
module Sponge = struct module Permutation = Sponge_inputs . Make ( Impl ) Impl ( struct include Tock_field_sponge . Inputs let params = Tock_field_sponge . params end ) end module S = Sponge . Make_sponge ( Permutation ) Permutation include S let squeeze_field = squeeze let squeeze = squeeze end let module T = Make_spo... |
module Input_domain = struct let lagrange_commitments domain : Me . Inner_curve . Affine . t array = let domain_size = Domain . size domain in time " lagrange " ( fun ( ) -> Array . init domain_size ~ f ( : fun i -> ( Kimchi_bindings . Protocol . SRS . Fp . lagrange_commitment ( Tick . Keypair . load_urs ( ) ) domain_s... |
module Inner_curve = struct module C = Kimchi_pasta . Pasta . Vesta module Inputs = struct module Impl = Impl module Params = struct include C . Params let one = C . to_affine_exn C . one let group_size_in_bits = Field . size_in_bits end module F = struct include struct open Impl . Field type nonrec t = t let ( * ) , (... |
module Generators = struct let h = lazy ( Kimchi_bindings . Protocol . SRS . Fp . urs_h ( Backend . Tick . Keypair . load_urs ( ) ) |> Common . finite_exn ) end |
let elements_of_signature signature = let open Types in let types , functions , _ = List . fold_left ( fun ( acc_types , acc_functions , idx ) idx elem -> match elem with | Sig_type ( id , { type_params = [ ] ; type_arity = 0 ; type_kind = Type_abstract ; type_manifest = None ; _ } , _ ) _ -> ( Ident . name id , List .... |
let rec patch_function types type_expr = let open Types in let desc = match type_expr . desc with | Tarrow ( x , te1 , te2 , c ) c -> let te1 = patch_function types te1 in let te2 = patch_function types te2 in Tarrow ( x , te1 , te2 , c ) c | Ttuple l -> Ttuple ( patch_function_list types l ) l | Tconstr ( path , _ , _... |
let wrap name signature = let class_name = Ident . name name in Output . verbose ( Printf . sprintf " wrapping module type % S . . . " class_name ) class_name ; TypeMap . add_local name true ; let open JavaAST in let type_parameters , functions = elements_of_signature signature in let wrapper_fields , get_wrapper_meth ... |
type dlog_opening = ( Tock . Curve . Affine . t , Tock . Field . t ) t Types . Step . Bulletproof . t |
module Constant = struct type t = { messages : Tock . Curve . Affine . t Plonk_types . Messages . t ; opening : dlog_opening } [ @@ deriving hlist ] hlist end |
module Checked = struct type t = { messages : Inner_curve . t Plonk_types . Messages . t ; opening : ( Inner_curve . t , Impls . Step . Other_field . t Shifted_value . Type2 . t ) Types . Step . Bulletproof . t } [ @@ deriving hlist ] hlist end |
let typ : ( Checked . t , Constant . t ) t Typ . t = let shift = Shifted_value . Type2 . Shift . create ( module Tock . Field ) Field in Typ . of_hlistable ~ var_to_hlist : Checked . to_hlist ~ var_of_hlist : Checked . of_hlist ~ value_to_hlist : Constant . to_hlist ~ value_of_hlist : Constant . of_hlist [ Plonk_types ... |
let wrap name fields record_repr type_parameters = let open JavaAST in let open Types in TypeMap . add_local name false ; let generics = TypeParametersTable . make type_parameters in let infos = List . mapi ( fun i ( _ , _ , type_expr ) type_expr -> i , TypeMap . find ~ generics false type_expr ) type_expr fields in le... |
let make_try_catch body = let open JavaAST in let handlers = [ " OCamlException " , " oe " , [ Throw ( Call ( Identifier " oe " , " getFailException " , [ ] ) ) ] ; ] in let body = [ Try_catch ( body , handlers ) handlers ] handlers in body |
let make_body meth_return_type call = let open JavaAST in match meth_return_type with | Some ( t , conv , _gen ) _gen -> let ret = return ( cast_if_needed t ( conv ( Identifier " res ) ) ) " in [ Variable_declaration ( t , " res " , call ) call ; ret ] | None -> [ Expression call ; return ( Identifier " Value . UNIT ) ... |
let rec split3 = function | ( x , y , z ) z :: tl -> let x ' , y ' , z ' = split3 tl in x :: x ' , y :: y ' , z :: z ' | [ ] -> [ ] , [ ] , [ ] |
let make_methods is_object methods = let open JavaAST in let name_hash = List . map ( fun ( name , _ , _ ) _ -> Btype . hash_variant name , name ) name methods in let name_hash = List . sort Pervasives . compare name_hash in let name_hash = List . mapi ( fun i ( _ , x ) x -> x , i ) i name_hash in let all_methods = Lis... |
type variant_kind = | Simple_variant | Polymorphic_variant |
let get_element variant_kind x fields idx = if variant_kind = Simple_variant then get x idx else if ( List . length fields ) fields = 1 then get x 1 else get ( get x 1 ) 1 idx |
let wrap ident constructors variant_kind type_parameters = let open JavaAST in let name = Ident . name ident in TypeMap . add_local ident ( variant_kind = Polymorphic_variant ) Polymorphic_variant ; let generics = TypeParametersTable . make type_parameters in let wrapper_fields , get_wrapper_meth , get_wrapper_idx_meth... |
module type Inputs = Intf . Wrap_main_inputs . S |
let challenge_polynomial ~ one ~ add ~ mul chals = let ( + ) = add and ( * ) = mul in stage ( fun pt -> let k = Array . length chals in let pow_two_pows = let res = Array . init k ~ f ( : fun _ -> pt ) pt in for i = 1 to k - 1 do let y = res ( . i - 1 ) 1 in res ( . i ) i <- y * y done ; res in let prod f = let r = ref... |
module Make ( Inputs : Inputs with type Impl . field = Tock . Field . t and type Impl . Bigint . t = Tock . Bigint . R . t and type Inner_curve . Constant . Scalar . t = Tick . Field . t ) t = struct open Inputs open Impl module Other_field = struct module Packed = struct module Constant = Other_field type t = Impls . ... |
let merge ( { dv = dv1 } as def1 , s1 ) ( { dv = dv2 } as def2 , s2 ) = Total . union def1 def2 , S . union dv1 ( S . union dv2 ( S . union s1 s2 ) ) |
let union ( { dv = dv1 } as def1 , s1 ) ( { dv = dv2 } as def2 , s2 ) = Total . union def1 def2 , S . union ( S . inter dv1 dv2 ) ( S . union s1 s2 ) |
let filter_env shared_set b_env = let filter n ( { t_sort = sort } as entry ) ( bounded , env ) = let entry = match sort with S . add n bounded , Env . add n entry env in Env . fold filter b_env ( S . empty , Env . empty ) |
let rec equation ( { eq_desc = desc } as eq ) = let eq , defnames , shared_set = match desc with | EQeq ( pat , e ) -> { eq with eq_desc = EQeq ( pat , expression e ) } , { Deftypes . empty with dv = Vars . fv_pat S . empty S . empty pat } , S . empty | EQpluseq ( n , e ) -> { eq with eq_desc = EQpluseq ( n , expressio... |
let implementation impl = match impl . desc with | Econstdecl ( n , is_static , e ) -> { impl with desc = Econstdecl ( n , is_static , expression e ) } | Efundecl ( n , ( { f_body = e } as body ) ) -> { impl with desc = Efundecl ( n , { body with f_body = expression e } ) } | _ -> impl |
let implementation_list impl_list = Zmisc . iter implementation impl_list |
module Core_over_monad ( Monad : Preface_specs . MONAD ) ( Tape : Preface_specs . MONOID ) = struct type tape = Tape . t type ' a monad = ' a Monad . t type ' a t = ( ' a * tape ) monad let upper m = Monad . bind ( fun a -> Monad . return ( a , Tape . neutral ) ) m let writer ( x , t ) = Monad . return ( x , t ) let ru... |
module Functor ( F : Preface_specs . FUNCTOR ) ( Tape : Preface_specs . MONOID ) = type ' a t = ( ' a * Tape . t ) F . t let map f x = F . map ( fun ( y , t ) -> ( f y , t ) ) x end ) |
module Applicative ( A : Preface_specs . APPLICATIVE ) ( Tape : Preface_specs . MONOID ) = type ' a t = ( ' a * Tape . t ) A . t let pure x = A . pure ( x , Tape . neutral ) let apply f v = let g ( x , t ) ( y , u ) = ( x y , Tape . combine t u ) in A . lift2 g f v ; ; end ) |
module Alternative ( A : Preface_specs . ALTERNATIVE ) ( Tape : Preface_specs . MONOID ) = Alternative . Over_applicative ( Applicative ( A ) ( Tape ) ) ( struct type ' a t = ( ' a * Tape . t ) A . t let neutral = A . neutral let combine writer_l writer_r = A . combine writer_l writer_r end ) |
module Monad ( M : Preface_specs . MONAD ) ( Tape : Preface_specs . MONOID ) = type ' a t = ( ' a * Tape . t ) M . t let return x = M . return ( x , Tape . neutral ) let bind f m = M . ( m >>= fun ( x , t ) -> f x >|= fun ( y , u ) -> ( y , Tape . combine t u ) ) ; ; end ) |
module Monad_plus ( M : Preface_specs . MONAD_PLUS ) ( Tape : Preface_specs . MONOID ) = Monad_plus . Over_monad ( Monad ( M ) ( Tape ) ) ( struct type ' a t = ( ' a * Tape . t ) M . t let neutral = M . neutral let combine writer_l writer_r = M . combine writer_l writer_r end ) |
module Over_monad ( M : Preface_specs . MONAD ) ( Tape : Preface_specs . MONOID ) = struct include Core_over_monad ( M ) ( Tape ) module Monad = Monad ( M ) ( Tape ) include Monad end |
module Id = Unique_id . Int63 ( ) |
let io_stats = Io_stats . create ( ) |
module Time_ns_suppress_sexp_in_test = struct type t = Time_ns . t let sexp_of_t t = if am_running_inline_test then Sexp . List [ ] else Time_ns . sexp_of_t t end |
module Flush_result = struct type t = | Error | Consumer_left | Flushed of Time_ns_suppress_sexp_in_test . t [ @@ deriving sexp_of ] end |
module Line_ending = struct type t = | Dos | Unix [ @@ deriving sexp_of ] end |
module Check_buffer_age ' = struct type ' a t = { writer : ' a ; maximum_age : Time_ns . Span . t ; mutable bytes_received_at_now_minus_maximum_age : Int63 . t ; bytes_received_queue : Int63 . t Queue . t ; times_received_queue : Time_ns . t Queue . t ; mutable bytes_seen : Int63 . t ; mutable too_old : unit Ivar . t ;... |
type open_flags = ( Open_flags . t , exn ) Result . t [ @@ deriving sexp_of ] |
module Destroy_or_keep = struct type t = | Destroy | Keep [ @@ deriving sexp_of ] end |
module Scheduled = struct type t = ( Bigstring . t IOVec . t * Destroy_or_keep . t ) Deque . t let length ( t : t ) = Deque . fold t ~ init : 0 ~ f ( : fun n ( iovec , _ ) -> n + iovec . len ) end |
module Stop_reason = struct type t = | Error | Consumer_left [ @@ deriving sexp_of ] end |
type t = { id : Id . t ; mutable fd : Fd . t ; monitor : Monitor . t ; inner_monitor : Monitor . t ; mutable background_writer_state : [ ` Running | ` Not_running | ` Stopped_permanently of Stop_reason . t ] ; background_writer_stopped : unit Ivar . t ; syscall : [ ` Per_cycle | ` Periodic of Time . Span . t ] ; mutabl... |
let sexp_of_t t = [ % sexp ( t . fd : Fd . t_hum ) ] |
let sexp_of_t_internals { id ; fd ; monitor ; inner_monitor ; background_writer_state ; background_writer_stopped ; syscall ; bytes_received ; bytes_written ; scheduled = _ ; scheduled_bytes ; buf = _ ; scheduled_back ; back ; time_source ; flushes = _ ; close_state ; close_finished ; close_started ; producers_to_flush... |
type writer = t [ @@ deriving sexp_of ] |
let set_raise_when_consumer_leaves t bool = t . raise_when_consumer_leaves <- bool |
let bytes_to_write t = t . scheduled_bytes + t . back - t . scheduled_back |
let is_stopped_permanently t = match t . background_writer_state with | ` Stopped_permanently _ -> true | ` Running | ` Not_running -> false ; ; |
let invariant t : unit = try let check f field = f ( Field . get field t ) in Fields . iter ~ id : ignore ~ fd : ignore ~ monitor : ignore ~ inner_monitor : ignore ~ buf : ignore ~ background_writer_state : ( check ( function | ` Stopped_permanently _ -> assert ( bytes_to_write t = 0 ) ; assert ( Ivar . is_full t . bac... |
module Check_buffer_age : sig type t = writer Check_buffer_age ' . t Bag . Elt . t option val dummy : t val create : writer -> maximum_age [ : ` At_most of Time . Span . t | ` Unlimited ] -> t val destroy : t -> unit val too_old : t -> unit Deferred . t module Internal_for_unit_test : sig val check_now : check_invarian... |
let flushed_or_failed_with_result t = match t . backing_out_channel with | Some backing_out_channel -> Backing_out_channel . flush backing_out_channel ; return ( Flush_result . Flushed ( Time_source . now t . time_source ) ) | None -> if Int63 . O . ( t . bytes_written = t . bytes_received ) then return ( Flush_result ... |
let eager_map t ~ f = if Deferred . is_determined t then return ( f ( Deferred . value_exn t ) ) else Deferred . map t ~ f ; ; |
let eager_bind t ~ f = if Deferred . is_determined t then f ( Deferred . value_exn t ) else Deferred . bind t ~ f ; ; |
let flushed_or_failed_unit t = eager_map ( flushed_or_failed_with_result t ) ~ f : ignore |
let flushed_time_ns t = eager_bind ( flushed_or_failed_with_result t ) ~ f ( : function | Flushed t -> Deferred . return t | Error | Consumer_left -> Deferred . never ( ) ) ; ; |
let flushed_time t = eager_map ( flushed_time_ns t ) ~ f : Time_ns . to_time_float_round_nearest |
let flushed t = eager_map ( flushed_time_ns t ) ~ f ( : ignore : Time_ns . t -> unit ) ; ; |
let set_backing_out_channel t backing_out_channel = t . backing_out_channel <- Some backing_out_channel ; ; |
let set_synchronous_backing_out_channel t backing_out_channel = let rec wait_until_no_bytes_to_write ( ) = if bytes_to_write t = 0 then ( set_backing_out_channel t backing_out_channel ; return ( ) ) else ( let % bind ( ) = flushed t in wait_until_no_bytes_to_write ( ) ) in wait_until_no_bytes_to_write ( ) ; ; |
let set_synchronous_out_channel t out_channel = set_synchronous_backing_out_channel t ( Backing_out_channel . of_out_channel out_channel ) ; ; |
let using_synchronous_backing_out_channel t = Option . is_some t . backing_out_channel |
let clear_synchronous_out_channel t = if is_some t . backing_out_channel then ( assert ( bytes_to_write t = 0 ) ; t . backing_out_channel <- None ) ; ; |
let with_synchronous_backing_out_channel t backing_out_channel ~ f = let saved_backing_out_channel = t . backing_out_channel in Monitor . protect ( fun ( ) -> let % bind ( ) = set_synchronous_backing_out_channel t backing_out_channel in f ( ) ) ~ finally ( : fun ( ) -> t . backing_out_channel <- saved_backing_out_chann... |
let with_synchronous_out_channel t out_channel ~ f = with_synchronous_backing_out_channel t ~ f ( Backing_out_channel . of_out_channel out_channel ) ; ; |
let set_fd t fd = let % map ( ) = flushed t in t . fd <- fd ; ; |
let consumer_left t = Ivar . read t . consumer_left |
let close_finished t = Ivar . read t . close_finished |
let close_started t = Ivar . read t . close_started |
let is_closed t = match t . close_state with | ` Open -> false | ` Closed | ` Closed_and_flushing -> true ; ; |
let is_open t = not ( is_closed t ) |
let writers_to_flush_at_shutdown : t Bag . t = Bag . create ( ) |
let final_flush ? force t = let producers_flushed = Deferred . List . iter ~ how ` : Parallel ~ f ( : fun f -> f ( ) ) ( Bag . to_list t . producers_to_flush_at_close ) in let force = match force with | Some fc -> fc | None -> ( match Fd . kind t . fd with | File -> Deferred . never ( ) | Char | Fifo | Socket _ -> Time... |
let close ? force_close t = if debug then Debug . log " Writer . close " t [ % sexp_of : t ] ; ( match t . close_state with | ` Closed_and_flushing | ` Closed -> ( ) | ` Open -> t . close_state <- ` Closed_and_flushing ; Ivar . fill t . close_started ( ) ; final_flush t ? force : force_close >>> fun ( ) -> t . close_st... |
let ( ) = Shutdown . at_shutdown ( fun ( ) -> if debug then Debug . log_string " Writer . at_shutdown " ; Deferred . List . iter ~ how ` : Parallel ( Bag . to_list writers_to_flush_at_shutdown ) ~ f ( : fun t -> Deferred . any_unit [ final_flush t ; close_finished t ] ) ) ; ; |
let fill_flushes { bytes_written ; flushes ; time_source ; _ } = if not ( Queue . is_empty flushes ) then ( let now = Time_source . now time_source in let rec loop ( ) = match Queue . peek flushes with | None -> ( ) | Some ( ivar , z ) -> if Int63 . ( z <= bytes_written ) then ( Ivar . fill ivar ( Flush_result . Flushe... |
let stop_permanently t ( outcome : Stop_reason . t ) = t . background_writer_state <- ` Stopped_permanently outcome ; Deque . clear t . scheduled ; t . scheduled_bytes <- 0 ; t . buf <- Bigstring . create 0 ; t . scheduled_back <- 0 ; t . back <- 0 ; Ivar . fill_if_empty t . background_writer_stopped ( ) ; Queue . iter... |
let stopped_permanently t = Ivar . read t . background_writer_stopped |
let die t sexp = stop_permanently t Error ; raise_s sexp ; ; |
type buffer_age_limit = [ ` At_most of Time . Span . t | ` Unlimited ] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.