val bn_get_ith_bit:
    #t:limb_t
  -> len:size_t
  -> b:lbignum t len
  -> i:size_t{v i / bits t < v len} ->
  Stack (limb t)
  (requires fun h -> live h b)
  (ensures  fun h0 r h1 -> h0 == h1 /\
    r == S.bn_get_ith_bit (as_seq h0 b) (v i))
let bn_get_ith_bit #t len input ind =
  [@inline_let]
  let pbits = size (bits t) in
  let i = ind /. pbits in
  assert (v i == v ind / bits t);
  let j = ind %. pbits in
  assert (v j == v ind % bits t);
  let tmp = input.(i) in
  (tmp >>. j) &. uint #t 1
val bn_get_ith_bit:
    #t:limb_t
  -> len:size_t
  -> b:lbignum t len
  -> i:size_t{v i / bits t < v len} ->
  Stack (limb t)
  (requires fun h -> live h b)
  (ensures  fun h0 r h1 -> h0 == h1 /\
    r == S.bn_get_ith_bit (as_seq h0 b) (v i))
let bn_get_ith_bit #t len input ind =
[@@ inline_let ]let pbits = size (bits t) in
let i = ind /. pbits in
assert (v i == v ind / bits t);
let j = ind %. pbits in
assert (v j == v ind % bits t);
let tmp = input.(i) in
(tmp >>. j) &. uint #t 1
Hacl.Bignum.Lib.fst.checked
prims.fst.checked Lib.Sequence.fsti.checked Lib.Loops.fsti.checked Lib.LoopCombinators.fsti.checked Lib.IntTypes.fsti.checked Lib.Buffer.fsti.checked Hacl.Spec.Bignum.Lib.fst.checked Hacl.Bignum.Definitions.fst.checked Hacl.Bignum.Base.fst.checked FStar.UInt32.fsti.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked FStar.Mul.fst.checked FStar.HyperStack.ST.fsti.checked FStar.HyperStack.fst.checked
Hacl.Bignum.Lib.fst
Hacl.Bignum.Definitions.limb_t Lib.IntTypes.size_t Hacl.Bignum.Definitions.lbignum Prims.b2t Prims.op_LessThan Prims.op_Division Lib.IntTypes.v Lib.IntTypes.U32 Lib.IntTypes.PUB Lib.IntTypes.bits Lib.IntTypes.op_Amp_Dot Lib.IntTypes.SEC Lib.IntTypes.op_Greater_Greater_Dot Lib.IntTypes.uint Hacl.Bignum.Definitions.limb Lib.Buffer.op_Array_Access Lib.Buffer.MUT Prims.unit Prims._assert Prims.eq2 Prims.int Prims.op_Modulus Lib.IntTypes.int_t Lib.IntTypes.op_Percent_Dot Lib.IntTypes.op_Slash_Dot Lib.IntTypes.size
module Hacl.Bignum.Lib

open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul

open Lib.IntTypes
open Lib.Buffer

open Hacl.Bignum.Base
open Hacl.Bignum.Definitions

module S = Hacl.Spec.Bignum.Lib
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence


#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"

///
///  Get and set i-th bit of a bignum
///

inline_for_extraction noextract
val bn_get_ith_bit:
    #t:limb_t
  -> len:size_t
  -> b:lbignum t len
  -> i:size_t{v i / bits t < v len} ->
  Stack (limb t)
  (requires fun h -> live h b)
  (ensures  fun h0 r h1 -> h0 == h1 /\
    r == S.bn_get_ith_bit (as_seq h0 b) (v i))
val bn_get_ith_bit:
    #t:limb_t
  -> len:size_t
  -> b:lbignum t len
  -> i:size_t{v i / bits t < v len} ->
  Stack (limb t)
  (requires fun h -> live h b)
  (ensures  fun h0 r h1 -> h0 == h1 /\
    r == S.bn_get_ith_bit (as_seq h0 b) (v i))

    len: Lib.IntTypes.size_t ->
    b: Hacl.Bignum.Definitions.lbignum t len ->
    i: Lib.IntTypes.size_t{Lib.IntTypes.v i / Lib.IntTypes.bits t < Lib.IntTypes.v len}
  -> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t)