10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-12-22 12:23:31 +01:00

Accelerated Zkey

This commit is contained in:
Anthony Scemama 2018-01-23 23:52:57 +01:00
parent e0c0ec1353
commit fdf6b02043

View File

@ -137,49 +137,54 @@ let to_int_array ~kind a =
(** Transform the Zkey into an int tuple *) (** Transform the Zkey into an int tuple *)
let to_int_tuple ~kind a = let to_int_tuple ~kind a =
let open Int64 in
match kind with match kind with
| Kind_3 -> Three ( Z.to_int @@ Z.extract a 20 10 , | Kind_3 -> let x = Z.to_int64 a in
Z.to_int @@ Z.extract a 10 10 , Three ( to_int ( logand mask10 (shift_right x 20)),
Z.to_int @@ Z.extract a 0 10 ) to_int ( logand mask10 (shift_right x 10)),
to_int ( logand mask10 x) )
| Kind_6 -> Six ((Z.to_int @@ Z.extract a 50 10 , | Kind_6 -> let x = Z.to_int64 a in
Z.to_int @@ Z.extract a 40 10 , Six ( ( to_int ( logand mask10 (shift_right x 50)),
Z.to_int @@ Z.extract a 30 10), to_int ( logand mask10 (shift_right x 40)),
(Z.to_int @@ Z.extract a 20 10 , to_int ( logand mask10 (shift_right x 30))),
Z.to_int @@ Z.extract a 10 10 , ( to_int ( logand mask10 (shift_right x 20)),
Z.to_int @@ Z.extract a 0 10)) to_int ( logand mask10 (shift_right x 10)),
to_int ( logand mask10 x) ) )
| Kind_12 -> Twelve ((Z.to_int @@ Z.extract a 114 10 , | Kind_12 -> let x = Z.to_int64 @@ Z.extract a 0 60
Z.to_int @@ Z.extract a 104 10 , and y = Z.to_int64 @@ Z.extract a 64 60
Z.to_int @@ Z.extract a 94 10), in
(Z.to_int @@ Z.extract a 84 10 , Twelve ( ( to_int ( logand mask10 (shift_right y 114)),
Z.to_int @@ Z.extract a 74 10 , to_int ( logand mask10 (shift_right y 104)),
Z.to_int @@ Z.extract a 64 10), to_int ( logand mask10 (shift_right y 94))),
(Z.to_int @@ Z.extract a 50 10 , ( to_int ( logand mask10 (shift_right y 84)),
Z.to_int @@ Z.extract a 40 10 , to_int ( logand mask10 (shift_right y 74)),
Z.to_int @@ Z.extract a 30 10), to_int ( logand mask10 (shift_right y 64))),
(Z.to_int @@ Z.extract a 20 10 , ( to_int ( logand mask10 (shift_right x 50)),
Z.to_int @@ Z.extract a 10 10 , to_int ( logand mask10 (shift_right x 40)),
Z.to_int @@ Z.extract a 0 10)) to_int ( logand mask10 (shift_right x 30))),
( to_int ( logand mask10 (shift_right x 20)),
| Kind_9 -> Nine ((Z.to_int @@ Z.extract a 84 10 , to_int ( logand mask10 (shift_right x 10)),
Z.to_int @@ Z.extract a 74 10 , to_int ( logand mask10 x) ))
Z.to_int @@ Z.extract a 64 10), | Kind_9 -> let x = Z.to_int64 @@ Z.extract a 0 60
(Z.to_int @@ Z.extract a 50 10 , and y = Z.to_int64 @@ Z.extract a 64 60
Z.to_int @@ Z.extract a 40 10 , in
Z.to_int @@ Z.extract a 30 10), Nine ( ( to_int ( logand mask10 (shift_right y 84)),
(Z.to_int @@ Z.extract a 20 10 , to_int ( logand mask10 (shift_right y 74)),
Z.to_int @@ Z.extract a 10 10 , to_int ( logand mask10 (shift_right y 64))),
Z.to_int @@ Z.extract a 0 10)) ( to_int ( logand mask10 (shift_right x 50)),
to_int ( logand mask10 (shift_right x 40)),
| Kind_4 -> Four ((Z.to_int @@ Z.extract a 48 16 , to_int ( logand mask10 (shift_right x 30))),
Z.to_int @@ Z.extract a 32 16), ( to_int ( logand mask10 (shift_right x 20)),
(Z.to_int @@ Z.extract a 16 16 , to_int ( logand mask10 (shift_right x 10)),
Z.to_int @@ Z.extract a 0 16)) to_int ( logand mask10 x) ))
| Kind_4 -> let x = Z.to_int64 a in
| Kind_2 -> Two ( Z.to_int @@ Z.extract a 16 16, Four ( ( to_int ( logand mask16 (shift_right x 48)),
Z.to_int @@ Z.extract a 0 16 ) to_int ( logand mask16 (shift_right x 32))),
( to_int ( logand mask16 (shift_right x 16)),
to_int ( logand mask16 x) ))
| Kind_2 -> let x = Z.to_int64 a in
Two ( to_int ( logand mask16 (shift_right x 16)),
to_int ( logand mask16 x) )
| Kind_1 -> One ( Z.to_int a ) | Kind_1 -> One ( Z.to_int a )