Add project files.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
dep.graph
|
||||
*.fst
|
||||
*.fsti
|
||||
*.json
|
||||
.depend
|
||||
@@ -0,0 +1,253 @@
|
||||
# This is a generically useful Makefile for F* that is self-contained
|
||||
#
|
||||
# We expect:
|
||||
# 1. `fstar.exe` to be in PATH (alternatively, you can also set
|
||||
# $FSTAR_HOME to be set to your F* repo/install directory)
|
||||
#
|
||||
# 2. `cargo`, `rustup`, `hax` and `jq` to be installed and in PATH.
|
||||
#
|
||||
# 3. the extracted Cargo crate to have "hax-lib" as a dependency:
|
||||
# `hax-lib = { version = "0.1.0-pre.1", git = "https://github.com/hacspec/hax"}`
|
||||
#
|
||||
# Optionally, you can set `HACL_HOME`.
|
||||
#
|
||||
# ROOTS contains all the top-level F* files you wish to verify
|
||||
# The default target `verify` verified ROOTS and its dependencies
|
||||
# To lax-check instead, set `OTHERFLAGS="--lax"` on the command-line
|
||||
#
|
||||
# To make F* emacs mode use the settings in this file, you need to
|
||||
# add the following lines to your .emacs
|
||||
#
|
||||
# (setq-default fstar-executable "<YOUR_FSTAR_HOME>/bin/fstar.exe")
|
||||
# (setq-default fstar-smt-executable "<YOUR_Z3_HOME>/bin/z3")
|
||||
#
|
||||
# (defun my-fstar-compute-prover-args-using-make ()
|
||||
# "Construct arguments to pass to F* by calling make."
|
||||
# (with-demoted-errors "Error when constructing arg string: %S"
|
||||
# (let* ((fname (file-name-nondirectory buffer-file-name))
|
||||
# (target (concat fname "-in"))
|
||||
# (argstr (car (process-lines "make" "--quiet" target))))
|
||||
# (split-string argstr))))
|
||||
# (setq fstar-subp-prover-args #'my-fstar-compute-prover-args-using-make)
|
||||
#
|
||||
|
||||
PATH_TO_CHILD_MAKEFILE := "$(abspath $(firstword $(MAKEFILE_LIST)))"
|
||||
PATH_TO_TEMPLATE_MAKEFILE := "$(abspath $(lastword $(MAKEFILE_LIST)))"
|
||||
|
||||
HACL_HOME ?= $(HOME)/.hax/hacl_home
|
||||
# Expand variable FSTAR_BIN_DETECT now, so that we don't run this over and over
|
||||
|
||||
FSTAR_BIN_DETECT := $(if $(shell command -v fstar.exe), fstar.exe, $(FSTAR_HOME)/bin/fstar.exe)
|
||||
FSTAR_BIN ?= $(FSTAR_BIN_DETECT)
|
||||
|
||||
GIT_ROOT_DIR := $(shell git rev-parse --show-toplevel)/
|
||||
CACHE_DIR ?= ${GIT_ROOT_DIR}.fstar-cache/checked
|
||||
HINT_DIR ?= ${GIT_ROOT_DIR}.fstar-cache/hints
|
||||
|
||||
# Makes command quiet by default
|
||||
Q ?= @
|
||||
|
||||
# Verify the required executable are in PATH
|
||||
EXECUTABLES = cargo cargo-hax jq
|
||||
K := $(foreach exec,$(EXECUTABLES),\
|
||||
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
|
||||
|
||||
export ANSI_COLOR_BLUE=\033[34m
|
||||
export ANSI_COLOR_RED=\033[31m
|
||||
export ANSI_COLOR_BBLUE=\033[1;34m
|
||||
export ANSI_COLOR_GRAY=\033[90m
|
||||
export ANSI_COLOR_TONE=\033[35m
|
||||
export ANSI_COLOR_RESET=\033[0m
|
||||
|
||||
ifdef NO_COLOR
|
||||
export ANSI_COLOR_BLUE=
|
||||
export ANSI_COLOR_RED=
|
||||
export ANSI_COLOR_BBLUE=
|
||||
export ANSI_COLOR_GRAY=
|
||||
export ANSI_COLOR_TONE=
|
||||
export ANSI_COLOR_RESET=
|
||||
endif
|
||||
|
||||
# The following is a bash script that discovers F* libraries.
|
||||
# Due to incompatibilities with make 4.3, I had to make a "oneliner" bash script...
|
||||
FINDLIBS_OUTPUT := $(shell \
|
||||
MANIFEST=$$(cargo metadata --format-version 1 | jq -r '.resolve.root as $$root | .packages as $$pkgs | .resolve.nodes[] | select(.id == $$root) | .dependencies[] as $$dep | select($$dep | contains("hax-lib")) | $$pkgs[] | select(.id == $$dep) | .manifest_path' 2>/dev/null); \
|
||||
if [ -n "$$MANIFEST" ] && [ "$$MANIFEST" != "null" ]; then \
|
||||
DIR=$$(dirname "$$MANIFEST"); \
|
||||
[ -d "$$DIR/proofs/fstar/extraction" ] && echo "$$DIR/proofs/fstar/extraction"; \
|
||||
for p in "$$DIR/proof-libs/fstar" "$$DIR/../proof-libs/fstar"; do \
|
||||
if [ -d "$$p" ]; then \
|
||||
echo "$$p/core"; \
|
||||
echo "$$p/rust_primitives"; \
|
||||
break; \
|
||||
fi; \
|
||||
done; \
|
||||
fi | sort -u)
|
||||
|
||||
|
||||
FSTAR_INCLUDE_DIRS_EXTRA ?=
|
||||
FSTAR_INCLUDE_DIRS = $(HACL_HOME)/lib $(FSTAR_INCLUDE_DIRS_EXTRA) $(FINDLIBS_OUTPUT) ../models
|
||||
|
||||
# Make sure FSTAR_INCLUDE_DIRS has the `proof-libs`, print hints and
|
||||
# an error message otherwise
|
||||
ifneq (,$(findstring proof-libs/fstar,$(FSTAR_INCLUDE_DIRS)))
|
||||
else
|
||||
K += $(info )
|
||||
ERROR := $(shell printf '${ANSI_COLOR_RED}Error: could not detect `proof-libs`!${ANSI_COLOR_RESET}')
|
||||
K += $(info ${ERROR})
|
||||
ERROR := $(shell printf ' > Do you have `${ANSI_COLOR_BLUE}hax-lib${ANSI_COLOR_RESET}` in your `${ANSI_COLOR_BLUE}Cargo.toml${ANSI_COLOR_RESET}` as a ${ANSI_COLOR_BLUE}git${ANSI_COLOR_RESET} or ${ANSI_COLOR_BLUE}path${ANSI_COLOR_RESET} dependency?')
|
||||
K += $(info ${ERROR})
|
||||
ERROR := $(shell printf ' ${ANSI_COLOR_BLUE}> Tip: you may want to run `cargo add --git https://github.com/hacspec/hax hax-lib`${ANSI_COLOR_RESET}')
|
||||
K += $(info ${ERROR})
|
||||
K += $(info )
|
||||
K += $(error Fatal error: `proof-libs` is required.)
|
||||
endif
|
||||
|
||||
.PHONY: all verify clean
|
||||
|
||||
all:
|
||||
$(Q)rm -f .depend
|
||||
$(Q)$(MAKE) -f $(PATH_TO_CHILD_MAKEFILE) .depend hax.fst.config.json verify
|
||||
|
||||
all-keep-going:
|
||||
$(Q)rm -f .depend
|
||||
$(Q)$(MAKE) -f $(PATH_TO_CHILD_MAKEFILE) --keep-going .depend hax.fst.config.json verify
|
||||
|
||||
# If $HACL_HOME doesn't exist, clone it
|
||||
${HACL_HOME}:
|
||||
$(Q)mkdir -p "${HACL_HOME}"
|
||||
$(info Cloning Hacl* in ${HACL_HOME}...)
|
||||
git clone --depth 1 https://github.com/hacl-star/hacl-star.git "${HACL_HOME}"
|
||||
$(info Cloning Hacl* in ${HACL_HOME}... done!)
|
||||
|
||||
# If no any F* file is detected, we run hax
|
||||
ifeq "$(wildcard *.fst *fsti)" ""
|
||||
$(shell cargo hax into fstar)
|
||||
endif
|
||||
|
||||
# By default, we process all the files in the current directory
|
||||
ROOTS ?= $(wildcard *.fst *fsti)
|
||||
ADMIT_MODULES ?=
|
||||
|
||||
ADMIT_MODULE_FLAGS ?= --admit_smt_queries true
|
||||
|
||||
# Can be useful for debugging purposes
|
||||
FINDLIBS.sh:
|
||||
$(Q)echo '${FINDLIBS}' > FINDLIBS.sh
|
||||
include-dirs:
|
||||
$(Q)bash -c '${FINDLIBS}'
|
||||
|
||||
FSTAR_FLAGS = \
|
||||
--warn_error -321-331-241-274-239-271 \
|
||||
--ext context_pruning --z3version 4.13.3 --query_stats \
|
||||
--cache_checked_modules --cache_dir $(CACHE_DIR) \
|
||||
--already_cached "+Prims+FStar+LowStar+C+Spec.Loops+TestLib" \
|
||||
$(addprefix --include ,$(FSTAR_INCLUDE_DIRS))
|
||||
|
||||
FSTAR := $(FSTAR_BIN) $(FSTAR_FLAGS)
|
||||
|
||||
.depend: $(HINT_DIR) $(CACHE_DIR) $(ROOTS) $(HACL_HOME)
|
||||
@$(FSTAR) --dep full $(ROOTS) --extract '* -Prims -LowStar -FStar' > $@
|
||||
|
||||
include .depend
|
||||
|
||||
$(HINT_DIR) $(CACHE_DIR):
|
||||
$(Q)mkdir -p $@
|
||||
|
||||
define HELPMESSAGE
|
||||
echo "hax' default Makefile for F*"
|
||||
echo ""
|
||||
echo "The available targets are:"
|
||||
echo ""
|
||||
function target() {
|
||||
printf ' ${ANSI_COLOR_BLUE}%-20b${ANSI_COLOR_RESET} %s\n' "$$1" "$$2"
|
||||
}
|
||||
target "all" "Verify every F* files (stops whenever an F* fails first)"
|
||||
target "all-keep-going" "Verify every F* files (tries as many F* module as possible)"
|
||||
target "" ""
|
||||
target "run/${ANSI_COLOR_TONE}<MyModule.fst> " 'Runs F* on `MyModule.fst` only'
|
||||
target "" ""
|
||||
target "vscode" 'Generates a `hax.fst.config.json` file'
|
||||
target "${ANSI_COLOR_TONE}<MyModule.fst>${ANSI_COLOR_BLUE}-in " 'Useful for Emacs, outputs the F* prefix command to be used'
|
||||
target "" ""
|
||||
target "clean" 'Cleanup the target'
|
||||
target "include-dirs" 'List the F* include directories'
|
||||
target "" ""
|
||||
target "describe" 'List the F* root modules, and describe the environment.'
|
||||
echo ""
|
||||
echo "Variables:"
|
||||
target "NO_COLOR" "Set to anything to disable colors"
|
||||
target "ADMIT_MODULES" "List of modules where F* will assume every SMT query"
|
||||
target "FSTAR_INCLUDE_DIRS_EXTRA" "List of extra include F* dirs"
|
||||
endef
|
||||
export HELPMESSAGE
|
||||
|
||||
describe:
|
||||
@printf '${ANSI_COLOR_BBLUE}F* roots:${ANSI_COLOR_RESET}\n'
|
||||
@for root in ${ROOTS}; do \
|
||||
filename=$$(basename -- "$$root") ;\
|
||||
ext="$${filename##*.}" ;\
|
||||
noext="$${filename%.*}" ;\
|
||||
printf "${ANSI_COLOR_GRAY}$$(dirname -- "$$root")/${ANSI_COLOR_RESET}%s${ANSI_COLOR_GRAY}.${ANSI_COLOR_TONE}%s${ANSI_COLOR_RESET}%b\n" "$$noext" "$$ext" $$([[ "${ADMIT_MODULES}" =~ (^| )$$root($$| ) ]] && echo '${ANSI_COLOR_RED}\t[ADMITTED]${ANSI_COLOR_RESET}'); \
|
||||
done
|
||||
@printf '\n${ANSI_COLOR_BBLUE}Environment:${ANSI_COLOR_RESET}\n'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}HACL_HOME${ANSI_COLOR_RESET} = %s\n' '${HACL_HOME}'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}FSTAR_BIN${ANSI_COLOR_RESET} = %s\n' '${FSTAR_BIN}'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}GIT_ROOT_DIR${ANSI_COLOR_RESET} = %s\n' '${GIT_ROOT_DIR}'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}CACHE_DIR${ANSI_COLOR_RESET} = %s\n' '${CACHE_DIR}'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}HINT_DIR${ANSI_COLOR_RESET} = %s\n' '${HINT_DIR}'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}ADMIT_MODULE_FLAGS${ANSI_COLOR_RESET} = %s\n' '${ADMIT_MODULE_FLAGS}'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}FSTAR_INCLUDE_DIRS_EXTRA${ANSI_COLOR_RESET} = %s\n' '${FSTAR_INCLUDE_DIRS_EXTRA}'
|
||||
|
||||
help: ;@bash -c "$$HELPMESSAGE"
|
||||
h: ;@bash -c "$$HELPMESSAGE"
|
||||
|
||||
HEADER = $(Q)printf '${ANSI_COLOR_BBLUE}[CHECK] %s ${ANSI_COLOR_RESET}\n' "$(basename $(notdir $@))"
|
||||
|
||||
run/%: | .depend $(HINT_DIR) $(CACHE_DIR) $(HACL_HOME)
|
||||
${HEADER}
|
||||
$(Q)$(FSTAR) $(OTHERFLAGS) $(@:run/%=%)
|
||||
|
||||
VERIFIED_CHECKED = $(addsuffix .checked, $(addprefix $(CACHE_DIR)/,$(ROOTS)))
|
||||
ADMIT_CHECKED = $(addsuffix .checked, $(addprefix $(CACHE_DIR)/,$(ADMIT_MODULES)))
|
||||
|
||||
$(ADMIT_CHECKED):
|
||||
$(Q)printf '${ANSI_COLOR_BBLUE}[${ANSI_COLOR_TONE}ADMIT${ANSI_COLOR_BBLUE}] %s ${ANSI_COLOR_RESET}\n' "$(basename $(notdir $@))"
|
||||
$(Q)$(FSTAR) $(OTHERFLAGS) $(ADMIT_MODULE_FLAGS) $< $(ENABLE_HINTS) --hint_file $(HINT_DIR)/$(notdir $*).hints || { \
|
||||
echo "" ; \
|
||||
exit 1 ; \
|
||||
}
|
||||
$(Q)printf "\n\n"
|
||||
|
||||
$(CACHE_DIR)/%.checked: | .depend $(HINT_DIR) $(CACHE_DIR) $(HACL_HOME)
|
||||
${HEADER}
|
||||
$(Q)$(FSTAR) $(OTHERFLAGS) $< $(ENABLE_HINTS) --hint_file $(HINT_DIR)/$(notdir $*).hints || { \
|
||||
echo "" ; \
|
||||
exit 1 ; \
|
||||
}
|
||||
touch $@
|
||||
$(Q)printf "\n\n"
|
||||
|
||||
verify: $(VERIFIED_CHECKED) $(ADMIT_CHECKED)
|
||||
|
||||
# Targets for Emacs
|
||||
%.fst-in:
|
||||
$(info $(FSTAR_FLAGS) \
|
||||
$(ENABLE_HINTS) --hint_file $(HINT_DIR)/$(basename $@).fst.hints)
|
||||
%.fsti-in:
|
||||
$(info $(FSTAR_FLAGS) \
|
||||
$(ENABLE_HINTS) --hint_file $(HINT_DIR)/$(basename $@).fsti.hints)
|
||||
|
||||
# Targets for VSCode
|
||||
hax.fst.config.json: .depend
|
||||
$(Q)echo "$(FSTAR_INCLUDE_DIRS)" | jq --arg fstar "$(FSTAR_BIN)" -R 'split(" ") | {fstar_exe: $$fstar | gsub("^\\s+|\\s+$$";""), include_dirs: .}' > $@
|
||||
vscode:
|
||||
$(Q)rm -f .depend
|
||||
$(Q)$(MAKE) -f $(PATH_TO_CHILD_MAKEFILE) hax.fst.config.json
|
||||
|
||||
SHELL=bash
|
||||
|
||||
# Clean target
|
||||
clean:
|
||||
rm -rf $(CACHE_DIR)/*
|
||||
rm *.fst
|
||||
@@ -0,0 +1,293 @@
|
||||
module BitVecEq
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 100"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
open MkSeq
|
||||
open FStar.FunctionalExtensionality
|
||||
|
||||
val bit_vec_equal (#n: nat) (bv1 bv2: bit_vec n): Type0
|
||||
val bit_vec_equal_intro (#n: nat) (bv1 bv2: bit_vec n)
|
||||
: Lemma (requires forall i. bv1 i == bv2 i)
|
||||
(ensures bit_vec_equal bv1 bv2)
|
||||
val bit_vec_equal_elim (#n: nat) (bv1 bv2: bit_vec n)
|
||||
: Lemma (requires bit_vec_equal #n bv1 bv2)
|
||||
(ensures bv1 == bv2)
|
||||
[SMTPat (bit_vec_equal #n bv1 bv2)]
|
||||
|
||||
let bit_vec_equal_intro_principle ()
|
||||
: Lemma (forall n (bv1 bv2: bit_vec n). (forall i. bv1 i == bv2 i) ==> bit_vec_equal #n bv1 bv2)
|
||||
= introduce forall n (bv1 bv2: bit_vec n). _
|
||||
with introduce (forall i. bv1 i == bv2 i) ==> bit_vec_equal #n bv1 bv2
|
||||
with _. bit_vec_equal_intro #n bv1 bv2
|
||||
|
||||
let bit_vec_equal_elim_principle ()
|
||||
: Lemma (forall n (bv1 bv2: bit_vec n). bit_vec_equal #n bv1 bv2 ==> (forall i. bv1 i == bv2 i))
|
||||
= introduce forall n (bv1 bv2: bit_vec n). _
|
||||
with introduce bit_vec_equal #n bv1 bv2 ==> (forall i. bv1 i == bv2 i)
|
||||
with _. bit_vec_equal_elim #n bv1 bv2
|
||||
|
||||
let bit_vec_equal_trivial (bv1 bv2: bit_vec 0): Lemma (bv1 == bv2)
|
||||
[SMTPat (eq2 #(bit_vec 0) bv1 bv2)]
|
||||
= bit_vec_equal_intro bv1 bv2
|
||||
|
||||
let bit_vec_sub #n (bv: bit_vec n) (start: nat) (len: nat {start + len <= n})
|
||||
: bit_vec len
|
||||
= on (i: nat {i < len})
|
||||
(fun i -> bv (start + i))
|
||||
|
||||
let bit_vec_equal_trivial_sub_smtpat (bv1: bit_vec 'n)
|
||||
: Lemma (forall (bv2: bit_vec 0). bit_vec_sub bv1 0 0 == bv2)
|
||||
[SMTPat (bit_vec_sub bv1 0 0)]
|
||||
= introduce forall (bv2: bit_vec 0). bit_vec_sub bv1 0 0 == bv2
|
||||
with bit_vec_equal_trivial (bit_vec_sub bv1 0 0) bv2
|
||||
|
||||
unfold let retype #a #b (#_:unit{a == b})
|
||||
(x: a): b
|
||||
= x
|
||||
|
||||
let bit_vec_sub_all_lemma #n (bv: bit_vec n)
|
||||
: Lemma (bit_vec_sub bv 0 n == bv)
|
||||
[SMTPat (bit_vec_sub bv 0 n)]
|
||||
= bit_vec_equal_intro (bit_vec_sub bv 0 n) bv
|
||||
|
||||
let int_t_array_bitwise_eq'
|
||||
#t1 #t2 #n1 #n2
|
||||
(arr1: t_Array (int_t t1) n1) (d1: num_bits t1)
|
||||
(arr2: t_Array (int_t t2) n2) (d2: num_bits t2 {v n1 * d1 == v n2 * d2})
|
||||
= bit_vec_equal (bit_vec_of_int_t_array arr1 d1)
|
||||
(retype (bit_vec_of_int_t_array arr2 d2))
|
||||
|
||||
let int_t_array_bitwise_eq
|
||||
#t1 #t2 #n1 #n2
|
||||
(arr1: t_Array (int_t t1) n1) (d1: num_bits t1)
|
||||
(arr2: t_Array (int_t t2) n2) (d2: num_bits t2 {v n1 * d1 == v n2 * d2})
|
||||
= bit_vec_of_int_t_array arr1 d1 == bit_vec_of_int_t_array arr2 d2
|
||||
|
||||
// let get_bit_intro ()
|
||||
// : Lemma (forall (#n: inttype) (x: int_t n) (nth: usize {v nth < bits n}).
|
||||
// get_bit #n x nth == ( if v x >= 0 then get_bit_nat (v x) (v nth)
|
||||
// else get_bit_nat (pow2 (bits n) + v x) (v nth)))
|
||||
// = introduce forall (n: inttype) (x: int_t n) (nth: usize {v nth < bits n}).
|
||||
// get_bit #n x nth == ( if v x >= 0 then get_bit_nat (v x) (v nth)
|
||||
// else get_bit_nat (pow2 (bits n) + v x) (v nth))
|
||||
// with get_bit_intro #n x nth
|
||||
|
||||
#push-options "--fuel 0 --ifuel 0 --z3rlimit 150"
|
||||
/// Rewrite a `bit_vec_of_int_t_array (Seq.slice arr ...)` into a `bit_vec_sub ...`
|
||||
let int_t_seq_slice_to_bv_sub_lemma #t #n
|
||||
(arr: t_Array (int_t t) n)
|
||||
(start: nat) (len: usize {start + v len <= v n})
|
||||
(d: num_bits t)
|
||||
: Lemma ( bit_vec_of_int_t_array (Seq.slice arr start (start + v len) <: t_Array _ len) d
|
||||
`bit_vec_equal` bit_vec_sub (bit_vec_of_int_t_array arr d) (start * d) (v len * d))
|
||||
[SMTPat (bit_vec_sub (bit_vec_of_int_t_array arr d) (start * d) (v len * d))]
|
||||
= let bv1 = bit_vec_of_int_t_array #_ #len (Seq.slice arr start (start + v len)) d in
|
||||
let bv2 = bit_vec_sub (bit_vec_of_int_t_array arr d) (start * d) (v len * d) in
|
||||
introduce forall i. bv1 i == bv2 i
|
||||
with ( Seq.lemma_index_slice arr start (start + v len) (i / d);
|
||||
Math.Lemmas.lemma_div_plus i start d;
|
||||
Math.Lemmas.lemma_mod_plus i start d);
|
||||
bit_vec_equal_intro bv1 bv2
|
||||
|
||||
#push-options "--split_queries always"
|
||||
let int_t_eq_seq_slice_bv_sub_lemma #t #n1 #n2
|
||||
(arr1: t_Array (int_t t) n1) (arr2: t_Array (int_t t) n2) (d: num_bits t)
|
||||
(start1 start2: nat) (len: nat {start1 + len <= v n1 /\ start2 + len <= v n2})
|
||||
: Lemma (requires Seq.slice arr1 start1 (start1 + len) == Seq.slice arr2 start2 (start2 + len))
|
||||
(ensures bit_vec_equal
|
||||
(bit_vec_sub (bit_vec_of_int_t_array arr1 d) (start1 * d) (len * d))
|
||||
(bit_vec_sub (bit_vec_of_int_t_array arr2 d) (start2 * d) (len * d)))
|
||||
[SMTPat ((bit_vec_sub (bit_vec_of_int_t_array arr1 d) (start1 * d) (len * d)) ==
|
||||
(bit_vec_sub (bit_vec_of_int_t_array arr2 d) (start2 * d) (len * d)))]
|
||||
= let len = sz len in
|
||||
int_t_seq_slice_to_bv_sub_lemma arr1 start1 len d;
|
||||
int_t_seq_slice_to_bv_sub_lemma arr2 start2 len d;
|
||||
// bit_vec_equal_elim_principle ();
|
||||
bit_vec_equal_intro_principle ()
|
||||
#pop-options
|
||||
|
||||
let bit_vec_equal_extend #n1 #n2
|
||||
(bv1: bit_vec n1) (bv2: bit_vec n2) (start1 start2: nat)
|
||||
(len1: nat)
|
||||
(len2: nat { start1 + len1 + len2 <= n1 /\ start2 + len1 + len2 <= n2})
|
||||
: Lemma
|
||||
(requires
|
||||
bit_vec_sub bv1 start1 len1 == bit_vec_sub bv2 start2 len1
|
||||
/\ bit_vec_sub bv1 (start1 + len1) len2 == bit_vec_sub bv2 (start2 + len1) len2)
|
||||
(ensures bit_vec_sub bv1 start1 (len1+len2) == bit_vec_sub bv2 start2 (len1+len2))
|
||||
// [SMTPat (bit_vec_sub bv1 start1 len1 == bit_vec_sub bv2 start2 len1);
|
||||
// SMTPat ()
|
||||
// ]
|
||||
// SMTPat (bit_vec_sub bv1 (start1 + len1) len2 == bit_vec_sub bv2 (start2 + len1) len2)]
|
||||
= let left1 = bit_vec_sub bv1 start1 len1 in
|
||||
let left2 = bit_vec_sub bv2 start2 len1 in
|
||||
let right1 = bit_vec_sub bv1 (start1 + len1) len2 in
|
||||
let right2 = bit_vec_sub bv2 (start2 + len1) len2 in
|
||||
// ()
|
||||
// bit_vec_equal_elim left1 left2 ;
|
||||
// bit_vec_equal_elim right1 right2;
|
||||
let entire1 = bit_vec_sub bv1 start1 (len1 + len2) in
|
||||
let entire2 = bit_vec_sub bv2 start2 (len1 + len2) in
|
||||
assert (forall (i:nat). i < len1 ==> left1 i == left2 i);
|
||||
assert (forall (i:nat). i < len2 ==> right1 i == right2 i);
|
||||
introduce forall (i:nat). i < len1 + len2 ==> entire1 i == entire2 i
|
||||
with introduce i < len1 + len2 ==> entire1 i == entire2 i
|
||||
with _. if i < len1 then assert (left1 i == left2 i)
|
||||
else assert (entire1 i == right1 (i - len1));
|
||||
bit_vec_equal_intro entire1 entire2
|
||||
#pop-options
|
||||
|
||||
// let bit_vec_equal_trans (#n: nat) (bv1 bv2 bv3: bit_vec n)
|
||||
// : Lemma (requires bv1 `bit_vec_equal` bv2 /\ bv2 `bit_vec_equal` bv3)
|
||||
// (ensures bv1 `bit_vec_equal` bv3)
|
||||
// = bit_vec_equal_elim_principle ();
|
||||
// bit_vec_equal_intro_principle ()
|
||||
|
||||
(*
|
||||
let int_arr_bitwise_eq_range
|
||||
#t1 #t2 #n1 #n2
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement1: int_t t1 -> Type0)
|
||||
(arr1: t_Array (x: int_t t1 {refinement1 x}) n1)
|
||||
(d1: num_bits t1)
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement2: int_t t2 -> Type0)
|
||||
(arr2: t_Array (x: int_t t2 {refinement2 x}) n2)
|
||||
(d2: num_bits t2)
|
||||
(offset1 offset2: nat)
|
||||
(bits: nat {
|
||||
offset1 + bits <= v n1 * d1
|
||||
/\ offset2 + bits <= v n2 * d2
|
||||
})
|
||||
= bit_vec_equal #bits (fun i -> bit_vec_of_int_t_array arr1 d1 (i + offset1))
|
||||
= forall (k: nat). k < bits ==>
|
||||
bit_vec_of_int_t_array arr1 d1 (offset1 + k)
|
||||
== bit_vec_of_int_t_array arr2 d2 (offset2 + k)
|
||||
|
||||
let int_arr_bitwise_eq_range_comm
|
||||
#t1 #t2 #n1 #n2
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement1: int_t t1 -> Type0)
|
||||
(arr1: t_Array (x: int_t t1 {refinement1 x}) n1)
|
||||
(d1: num_bits t1)
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement2: int_t t2 -> Type0)
|
||||
(arr2: t_Array (x: int_t t2 {refinement2 x}) n2)
|
||||
(d2: num_bits t2)
|
||||
(offset1 offset2: nat)
|
||||
(bits: nat {
|
||||
offset1 + bits <= v n1 * d1
|
||||
/\ offset2 + bits <= v n2 * d2
|
||||
})
|
||||
: Lemma (requires int_arr_bitwise_eq_range arr1 d1 arr2 d2 offset1 offset2 bits)
|
||||
(ensures int_arr_bitwise_eq_range arr2 d2 arr1 d1 offset2 offset1 bits)
|
||||
= ()
|
||||
|
||||
// kill that function in favor of range
|
||||
let int_arr_bitwise_eq_up_to
|
||||
#t1 #t2 #n1 #n2
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement1: int_t t1 -> Type0)
|
||||
(arr1: t_Array (x: int_t t1 {refinement1 x}) n1)
|
||||
(d1: num_bits t1)
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement: int_t t2 -> Type0)
|
||||
(arr2: t_Array (x: int_t t2 {refinement x}) n2)
|
||||
(d2: num_bits t2 {v n1 * d1 == v n2 * d2})
|
||||
(max: nat {max <= v n1 * d1})
|
||||
|
||||
= forall i. i < max
|
||||
==> bit_vec_of_int_t_array arr1 d1 i == bit_vec_of_int_t_array arr2 d2 i
|
||||
|
||||
let int_arr_bitwise_eq_
|
||||
#t1 #t2 #n1 #n2
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement1: int_t t1 -> Type0)
|
||||
(arr1: t_Array (x: int_t t1 {refinement1 x}) n1)
|
||||
(d1: num_bits t1)
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement: int_t t2 -> Type0)
|
||||
(arr2: t_Array (x: int_t t2 {refinement x}) n2)
|
||||
(d2: num_bits t2 {v n1 * d1 == v n2 * d2})
|
||||
= int_arr_bitwise_eq_up_to arr1 d1 arr2 d2 (v n1 * d1)
|
||||
|
||||
// move to fsti
|
||||
let bit_vec_equal #n (bv1 bv2: bit_vec n)
|
||||
= forall i. i < n ==> bv1 i == bv2 i
|
||||
|
||||
let int_arr_bitwise_eq
|
||||
#t1 #t2 #n1 #n2
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement1: int_t t1 -> Type0)
|
||||
(arr1: t_Array (x: int_t t1 {refinement1 x}) n1)
|
||||
(d1: num_bits t1)
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement: int_t t2 -> Type0)
|
||||
(arr2: t_Array (x: int_t t2 {refinement x}) n2)
|
||||
(d2: num_bits t2 {v n1 * d1 == v n2 * d2})
|
||||
= forall i. i < v n1 * d1
|
||||
==> bit_vec_of_int_t_array arr1 d1 i == bit_vec_of_int_t_array arr2 d2 i
|
||||
|
||||
let int_arr_bitwise_eq_range_transitivity
|
||||
#t1 #t2 #t3 #n1 #n2 #n3
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement1: int_t t1 -> Type0)
|
||||
(arr1: t_Array (x: int_t t1 {refinement1 x}) n1)
|
||||
(d1: num_bits t1)
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement2: int_t t2 -> Type0)
|
||||
(arr2: t_Array (x: int_t t2 {refinement2 x}) n2)
|
||||
(d2: num_bits t2)
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement3: int_t t3 -> Type0)
|
||||
(arr3: t_Array (x: int_t t3 {refinement3 x}) n3)
|
||||
(d3: num_bits t3)
|
||||
(offset1 offset2 offset3: nat)
|
||||
(bits: nat {
|
||||
offset1 + bits <= v n1 * d1
|
||||
/\ offset2 + bits <= v n2 * d2
|
||||
/\ offset3 + bits <= v n3 * d3
|
||||
})
|
||||
: Lemma
|
||||
(requires int_arr_bitwise_eq_range #t1 #t2 #n1 #n2 arr1 d1 arr2 d2 offset1 offset2 bits
|
||||
/\ int_arr_bitwise_eq_range #t2 #t3 #n2 #n3 arr2 d2 arr3 d3 offset2 offset3 bits)
|
||||
(ensures int_arr_bitwise_eq_range #t1 #t3 #n1 #n3 arr1 d1 arr3 d3 offset1 offset3 bits)
|
||||
= ()
|
||||
|
||||
|
||||
let int_arr_bitwise_eq_range_intro
|
||||
#t1 #t2 #n1 #n2
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement1: int_t t1 -> Type0)
|
||||
(arr1: t_Array (x: int_t t1 {refinement1 x}) n1)
|
||||
(d1: num_bits t1)
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement: int_t t2 -> Type0)
|
||||
(arr2: t_Array (x: int_t t2 {refinement x}) n2)
|
||||
(d2: num_bits t2 {v n1 * d1 == v n2 * d2})
|
||||
: Lemma
|
||||
(requires int_arr_bitwise_eq arr1 d1 arr2 d2)
|
||||
(ensures int_arr_bitwise_eq_range arr1 d1 arr2 d2 0 0 (v n1 * d1))
|
||||
= admit ()
|
||||
|
||||
let int_arr_bitwise_eq_range_intro_eq_slice
|
||||
#t #n1 #n2
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement: int_t t -> Type0)
|
||||
(arr1: t_Array (x: int_t t {refinement x}) n1)
|
||||
(arr2: t_Array (x: int_t t {refinement x}) n2)
|
||||
(d: num_bits t)
|
||||
(offset1 offset2: nat)
|
||||
(n: nat {offset1 + n < v n1 /\ offset2 + n < v n2})
|
||||
(bits: nat {
|
||||
offset1 + bits <= v n1 * d
|
||||
/\ offset2 + bits <= v n2 * d
|
||||
/\ bits <= n * d
|
||||
})
|
||||
: Lemma (requires Seq.slice arr1 offset1 (offset1 + n) == Seq.slice arr2 offset2 (offset2 + n))
|
||||
(ensures int_arr_bitwise_eq_range arr1 d arr2 d offset1 offset2 bits)
|
||||
= admit ()
|
||||
|
||||
let int_arr_bitwise_eq_range_intro_eq
|
||||
#t #n1 #n2
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement1: int_t t -> Type0)
|
||||
(arr1: t_Array (x: int_t t {refinement1 x}) n1)
|
||||
(#[FStar.Tactics.exact (`(fun _ -> True))]refinement2: int_t t -> Type0)
|
||||
(arr2: t_Array (x: int_t t {refinement2 x}) n2)
|
||||
(d: num_bits t)
|
||||
(n_offset1 n_offset2: nat)
|
||||
(n: nat {n_offset1 + n <= v n1 /\ n_offset2 + n <= v n2})
|
||||
// (offset1 offset2: nat)
|
||||
(bits: nat {
|
||||
n_offset1 * d + bits <= v n1 * d
|
||||
/\ n_offset2 * d + bits <= v n2 * d
|
||||
/\ bits <= n * d
|
||||
})
|
||||
: Lemma (requires forall (i: nat). i < n ==> Seq.index arr1 (i + n_offset1) == Seq.index arr2 (i + n_offset2))
|
||||
(ensures int_arr_bitwise_eq_range arr1 d arr2 d (n_offset1 * d) (n_offset2 * d) bits)
|
||||
= admit ()
|
||||
*)
|
||||
@@ -0,0 +1,258 @@
|
||||
module Bytes.Buf.Buf_impl
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
val sign_extend (v_val: u64) (nbytes: usize) : Prims.Pure i64 Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
(* item error backend: (AndMutDefsite) The support in hax of function with one or more inputs of type `&mut _` is limited. Onlu trivial patterns are allowed there: `fn f(x: &mut (T, U)) ...` is allowed while `f((x, y): &mut (T, U))` is rejected.
|
||||
Last available AST for this item:
|
||||
|
||||
/** Read bytes from a buffer.*//***//** A buffer stores bytes in memory such that read operations are infallible.*//** The underlying storage may or may not be in contiguous memory. A `Buf` value*//** is a cursor into the buffer. Reading from `Buf` advances the cursor*//** position. It can be thought of as an efficient `Iterator` for collections of*//** bytes.*//***//** The simplest `Buf` is a `&[u8]`.*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"hello world"[..];*//***//** assert_eq!(b'h', buf.get_u8());*//** assert_eq!(b'e', buf.get_u8());*//** assert_eq!(b'l', buf.get_u8());*//***//** let mut rest = [0; 8];*//** buf.copy_to_slice(&mut rest);*//***//** assert_eq!(&rest[..], &b"lo world"[..]);*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]trait t_Buf<Self_>{/** Returns the number of bytes between the current position and the end of*//** the buffer.*//***//** This value is greater than or equal to the length of the slice returned*//** by `chunk()`.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"hello world"[..];*//***//** assert_eq!(buf.remaining(), 11);*//***//** buf.get_u8();*//***//** assert_eq!(buf.remaining(), 10);*//** ```*//***//** # Implementer notes*//***//** Implementations of `remaining` should ensure that the return value does*//** not change unless a call is made to `advance` or any other function that*//** is documented to change the `Buf`'s current position.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_remaining<Anonymous: 'unk>(_: &Self) -> int;
|
||||
/** Returns a slice starting at the current position and of length between 0*//** and `Buf::remaining()`. Note that this *can* return a shorter slice (this*//** allows non-continuous internal representation).*//***//** This is a lower level function. Most operations are done with other*//** functions.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"hello world"[..];*//***//** assert_eq!(buf.chunk(), &b"hello world"[..]);*//***//** buf.advance(6);*//***//** assert_eq!(buf.chunk(), &b"world"[..]);*//** ```*//***//** # Implementer notes*//***//** This function should never panic. `chunk()` should return an empty*//** slice **if and only if** `remaining()` returns 0. In other words,*//** `chunk()` returning an empty slice implies that `remaining()` will*//** return 0 and `remaining()` returning 0 implies that `chunk()` will*//** return an empty slice.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_chunk<Anonymous: 'unk>(_: &Self) -> &[int];
|
||||
/** Fills `dst` with potentially multiple slices starting at `self`'s*//** current position.*//***//** If the `Buf` is backed by disjoint slices of bytes, `chunk_vectored` enables*//** fetching more than one slice at once. `dst` is a slice of `IoSlice`*//** references, enabling the slice to be directly used with [`writev`]*//** without any further conversion. The sum of the lengths of all the*//** buffers written to `dst` will be less than or equal to `Buf::remaining()`.*//***//** The entries in `dst` will be overwritten, but the data **contained** by*//** the slices **will not** be modified. The return value is the number of*//** slices written to `dst`. If `Buf::remaining()` is non-zero, then this*//** writes at least one non-empty slice to `dst`.*//***//** This is a lower level function. Most operations are done with other*//** functions.*//***//** # Implementer notes*//***//** This function should never panic. Once the end of the buffer is reached,*//** i.e., `Buf::remaining` returns 0, calls to `chunk_vectored` must return 0*//** without mutating `dst`.*//***//** Implementations should also take care to properly handle being called*//** with `dst` being a zero length slice.*//***//** [`writev`]: http://man7.org/linux/man-pages/man2/readv.2.html*/#[cfg(feature = "std")]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_chunks_vectored<'a: 'unk, Anonymous: 'unk>((self: &Self,dst: &mut [std::io::t_IoSlice<lifetime!(something)>])) -> int{{let _: tuple0 = {(if core::slice::impl__is_empty::<std::io::t_IoSlice<lifetime!(something)>>(&(deref(dst))){rust_primitives::hax::never_to_any({(return 0)})})};{(if bytes::buf::buf_impl::f_has_remaining(&(deref(self))){{let _: tuple0 = {(deref(dst)[0] = std::io::impl_10__new::<lifetime!(something)>(&(deref(bytes::buf::buf_impl::f_chunk(&(deref(self)))))))};{1}}} else {{0}})}}}
|
||||
/** Advance the internal cursor of the Buf*//***//** The next call to `chunk()` will return a slice starting `cnt` bytes*//** further into the underlying buffer.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"hello world"[..];*//***//** assert_eq!(buf.chunk(), &b"hello world"[..]);*//***//** buf.advance(6);*//***//** assert_eq!(buf.chunk(), &b"world"[..]);*//** ```*//***//** # Panics*//***//** This function **may** panic if `cnt > self.remaining()`.*//***//** # Implementer notes*//***//** It is recommended for implementations of `advance` to panic if `cnt >*//** self.remaining()`. If the implementation does not panic, the call must*//** behave as if `cnt == self.remaining()`.*//***//** A call with `cnt == 0` should never panic and be a no-op.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_advance<Anonymous: 'unk>(_: &mut Self,_: int) -> tuple0;
|
||||
/** Returns true if there are any more bytes to consume*//***//** This is equivalent to `self.remaining() != 0`.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"a"[..];*//***//** assert!(buf.has_remaining());*//***//** buf.get_u8();*//***//** assert!(!buf.has_remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_has_remaining<Anonymous: 'unk>((self: &Self)) -> bool{{core::cmp::PartialOrd::gt(bytes::buf::buf_impl::f_remaining(&(deref(self))),0)}}
|
||||
/** Copies bytes from `self` into `dst`.*//***//** The cursor is advanced by the number of bytes copied. `self` must have*//** enough remaining bytes to fill `dst`.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"hello world"[..];*//** let mut dst = [0; 5];*//***//** buf.copy_to_slice(&mut dst);*//** assert_eq!(&b"hello"[..], &dst);*//** assert_eq!(6, buf.remaining());*//** ```*//***//** # Panics*//***//** This function panics if `self.remaining() < dst.len()`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_copy_to_slice<Anonymous: 'unk, Anonymous: 'unk>((self: &mut Self,dst: &mut [int])) -> tuple0{{let _: tuple0 = {core::result::impl__unwrap_or_else::<tuple0,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> tuple0)>(bytes::buf::buf_impl::f_try_copy_to_slice(&mut (deref(self)),&mut (deref(dst))),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))}))};Tuple0}}
|
||||
/** Gets an unsigned 8 bit integer from `self`.*//***//** The current position is advanced by 1.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08 hello"[..];*//** assert_eq!(8, buf.get_u8());*//** ```*//***//** # Panics*//***//** This function panics if there is no more remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u8<Anonymous: 'unk>((self: &mut Self)) -> int{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),1){{rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(bytes::TryGetError{f_requested:1,f_available:0,})))))}})};{let ret: int = {core::ops::index::Index::index(deref(bytes::buf::buf_impl::f_chunk(&(self))),0)};{let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),1)};{ret}}}}}
|
||||
/** Gets a signed 8 bit integer from `self`.*//***//** The current position is advanced by 1.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08 hello"[..];*//** assert_eq!(8, buf.get_i8());*//** ```*//***//** # Panics*//***//** This function panics if there is no more remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i8<Anonymous: 'unk>((self: &mut Self)) -> int{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),1){rust_primitives::hax::never_to_any({bytes::panic_advance(&(deref(&(bytes::TryGetError{f_requested:1,f_available:0,}))))})})};{let ret: int = {cast(core::ops::index::Index::index(deref(bytes::buf::buf_impl::f_chunk(&(self))),0))};{let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),1)};{ret}}}}}
|
||||
/** Gets an unsigned 16 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 2.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08\x09 hello"[..];*//** assert_eq!(0x0809, buf.get_u16());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u16<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_u16::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_u16::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_u16::v_SIZE,}),(|src| {unsafe {core::num::impl__u16__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_u16::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;2] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,2))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u16__from_be_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned 16 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 2.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x09\x08 hello"[..];*//** assert_eq!(0x0809, buf.get_u16_le());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u16_le<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_u16_le::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_u16_le::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_u16_le::v_SIZE,}),(|src| {unsafe {core::num::impl__u16__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_u16_le::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;2] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,2))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u16__from_le_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned 16 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 2.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x08\x09 hello",*//** false => b"\x09\x08 hello",*//** };*//** assert_eq!(0x0809, buf.get_u16_ne());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u16_ne<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_u16_ne::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_u16_ne::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_u16_ne::v_SIZE,}),(|src| {unsafe {core::num::impl__u16__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_u16_ne::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;2] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,2))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u16__from_ne_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets a signed 16 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 2.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08\x09 hello"[..];*//** assert_eq!(0x0809, buf.get_i16());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i16<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_i16::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_i16::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_i16::v_SIZE,}),(|src| {unsafe {core::num::impl__i16__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_i16::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;2] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,2))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i16__from_be_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets a signed 16 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 2.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x09\x08 hello"[..];*//** assert_eq!(0x0809, buf.get_i16_le());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i16_le<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_i16_le::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_i16_le::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_i16_le::v_SIZE,}),(|src| {unsafe {core::num::impl__i16__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_i16_le::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;2] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,2))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i16__from_le_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets a signed 16 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 2.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x08\x09 hello",*//** false => b"\x09\x08 hello",*//** };*//** assert_eq!(0x0809, buf.get_i16_ne());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i16_ne<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_i16_ne::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_i16_ne::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_i16_ne::v_SIZE,}),(|src| {unsafe {core::num::impl__i16__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_i16_ne::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;2] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,2))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i16__from_ne_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned 32 bit integer from `self` in the big-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08\x09\xA0\xA1 hello"[..];*//** assert_eq!(0x0809A0A1, buf.get_u32());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u32<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_u32::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_u32::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_u32::v_SIZE,}),(|src| {unsafe {core::num::impl__u32__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_u32::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;4] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,4))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u32__from_be_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned 32 bit integer from `self` in the little-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\xA1\xA0\x09\x08 hello"[..];*//** assert_eq!(0x0809A0A1, buf.get_u32_le());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u32_le<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_u32_le::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_u32_le::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_u32_le::v_SIZE,}),(|src| {unsafe {core::num::impl__u32__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_u32_le::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;4] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,4))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u32__from_le_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned 32 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x08\x09\xA0\xA1 hello",*//** false => b"\xA1\xA0\x09\x08 hello",*//** };*//** assert_eq!(0x0809A0A1, buf.get_u32_ne());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u32_ne<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_u32_ne::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_u32_ne::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_u32_ne::v_SIZE,}),(|src| {unsafe {core::num::impl__u32__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_u32_ne::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;4] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,4))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u32__from_ne_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets a signed 32 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08\x09\xA0\xA1 hello"[..];*//** assert_eq!(0x0809A0A1, buf.get_i32());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i32<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_i32::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_i32::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_i32::v_SIZE,}),(|src| {unsafe {core::num::impl__i32__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_i32::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;4] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,4))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i32__from_be_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets a signed 32 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\xA1\xA0\x09\x08 hello"[..];*//** assert_eq!(0x0809A0A1, buf.get_i32_le());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i32_le<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_i32_le::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_i32_le::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_i32_le::v_SIZE,}),(|src| {unsafe {core::num::impl__i32__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_i32_le::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;4] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,4))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i32__from_le_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets a signed 32 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x08\x09\xA0\xA1 hello",*//** false => b"\xA1\xA0\x09\x08 hello",*//** };*//** assert_eq!(0x0809A0A1, buf.get_i32_ne());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i32_ne<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_i32_ne::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_i32_ne::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_i32_ne::v_SIZE,}),(|src| {unsafe {core::num::impl__i32__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_i32_ne::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;4] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,4))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i32__from_ne_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned 64 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08 hello"[..];*//** assert_eq!(0x0102030405060708, buf.get_u64());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u64<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_u64::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_u64::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_u64::v_SIZE,}),(|src| {unsafe {core::num::impl__u64__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_u64::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u64__from_be_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned 64 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];*//** assert_eq!(0x0102030405060708, buf.get_u64_le());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u64_le<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_u64_le::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_u64_le::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_u64_le::v_SIZE,}),(|src| {unsafe {core::num::impl__u64__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_u64_le::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u64__from_le_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned 64 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03\x04\x05\x06\x07\x08 hello",*//** false => b"\x08\x07\x06\x05\x04\x03\x02\x01 hello",*//** };*//** assert_eq!(0x0102030405060708, buf.get_u64_ne());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u64_ne<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_u64_ne::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_u64_ne::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_u64_ne::v_SIZE,}),(|src| {unsafe {core::num::impl__u64__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_u64_ne::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u64__from_ne_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets a signed 64 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08 hello"[..];*//** assert_eq!(0x0102030405060708, buf.get_i64());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i64<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_i64::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_i64::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_i64::v_SIZE,}),(|src| {unsafe {core::num::impl__i64__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_i64::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i64__from_be_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets a signed 64 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];*//** assert_eq!(0x0102030405060708, buf.get_i64_le());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i64_le<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_i64_le::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_i64_le::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_i64_le::v_SIZE,}),(|src| {unsafe {core::num::impl__i64__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_i64_le::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i64__from_le_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets a signed 64 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03\x04\x05\x06\x07\x08 hello",*//** false => b"\x08\x07\x06\x05\x04\x03\x02\x01 hello",*//** };*//** assert_eq!(0x0102030405060708, buf.get_i64_ne());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i64_ne<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_i64_ne::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_i64_ne::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_i64_ne::v_SIZE,}),(|src| {unsafe {core::num::impl__i64__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_i64_ne::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i64__from_ne_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned 128 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 16.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello"[..];*//** assert_eq!(0x01020304050607080910111213141516, buf.get_u128());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u128<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_u128::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_u128::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_u128::v_SIZE,}),(|src| {unsafe {core::num::impl__u128__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_u128::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;16] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,16))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u128__from_be_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned 128 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 16.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];*//** assert_eq!(0x01020304050607080910111213141516, buf.get_u128_le());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u128_le<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_u128_le::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_u128_le::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_u128_le::v_SIZE,}),(|src| {unsafe {core::num::impl__u128__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_u128_le::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;16] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,16))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u128__from_le_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned 128 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 16.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello",*//** false => b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello",*//** };*//** assert_eq!(0x01020304050607080910111213141516, buf.get_u128_ne());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_u128_ne<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_u128_ne::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_u128_ne::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_u128_ne::v_SIZE,}),(|src| {unsafe {core::num::impl__u128__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_u128_ne::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;16] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,16))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u128__from_ne_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets a signed 128 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 16.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello"[..];*//** assert_eq!(0x01020304050607080910111213141516, buf.get_i128());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i128<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_i128::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_i128::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_i128::v_SIZE,}),(|src| {unsafe {core::num::impl__i128__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_i128::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;16] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,16))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i128__from_be_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets a signed 128 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 16.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];*//** assert_eq!(0x01020304050607080910111213141516, buf.get_i128_le());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i128_le<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_i128_le::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_i128_le::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_i128_le::v_SIZE,}),(|src| {unsafe {core::num::impl__i128__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_i128_le::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;16] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,16))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i128__from_le_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets a signed 128 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 16.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello",*//** false => b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello",*//** };*//** assert_eq!(0x01020304050607080910111213141516, buf.get_i128_ne());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_i128_ne<Anonymous: 'unk>((self: &mut Self)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::get_i128_ne::v_SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::get_i128_ne::v_SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::get_i128_ne::v_SIZE,}),(|src| {unsafe {core::num::impl__i128__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::get_i128_ne::v_SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;16] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,16))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i128__from_ne_bytes(buf)))}}})}})}}}})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned n-byte integer from `self` in big-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x01\x02\x03 hello"[..];*//** assert_eq!(0x010203, buf.get_uint(3));*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`, or*//** if `nbytes` is greater than 8.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_uint<Anonymous: 'unk>((self: &mut Self,nbytes: int)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {rust_primitives::hax::never_to_any({let slice_at: int = {(match (core::num::impl__usize__checked_sub(bytes::buf::buf_impl::Buf::get_uint::v_SIZE,nbytes)) {core::option::Option_Some(slice_at) => {slice_at},core::option::Option_None => {rust_primitives::hax::never_to_any(bytes::panic_does_not_fit(bytes::buf::buf_impl::Buf::get_uint::v_SIZE,nbytes))}})};{let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {(match (bytes::buf::buf_impl::f_try_copy_to_slice(&mut (deref(self)),&mut (deref(&mut (deref(core::ops::index::f_index_mut(&mut (buf),core::ops::range::RangeFrom{f_start:slice_at,}))))))) {core::result::Result_Ok(ok) => {ok},core::result::Result_Err(err) => {(return core::result::Result_Err(err))}})};{(return core::result::Result_Ok(core::num::impl__u64__from_be_bytes(buf)))}}}})})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned n-byte integer from `self` in little-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x03\x02\x01 hello"[..];*//** assert_eq!(0x010203, buf.get_uint_le(3));*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`, or*//** if `nbytes` is greater than 8.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_uint_le<Anonymous: 'unk>((self: &mut Self,nbytes: int)) -> int{rust_primitives::hax::never_to_any({{(return core::result::impl__unwrap_or_else::<int,bytes::t_TryGetError,arrow!(bytes::t_TryGetError -> int)>(core::ops::function::f_call_mut(&mut ((|_| {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let subslice: &mut [int] = {(match (core::slice::impl__get_mut::<int,core::ops::range::t_RangeTo<int>>(rust_primitives::unsize(&mut (buf)),core::ops::range::RangeTo{f_end:nbytes,})) {core::option::Option_Some(subslice) => {subslice},core::option::Option_None => {rust_primitives::hax::never_to_any(bytes::panic_does_not_fit(bytes::buf::buf_impl::Buf::get_uint_le::v_SIZE,nbytes))}})};{let _: tuple0 = {(match (bytes::buf::buf_impl::f_try_copy_to_slice(&mut (deref(self)),&mut (deref(subslice)))) {core::result::Result_Ok(ok) => {ok},core::result::Result_Err(err) => {(return core::result::Result_Err(err))}})};{(return core::result::Result_Ok(core::num::impl__u64__from_le_bytes(buf)))}}}})})),Tuple0()),(|error| {rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(error)))))})))}})}
|
||||
/** Gets an unsigned n-byte integer from `self` in native-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03 hello",*//** false => b"\x03\x02\x01 hello",*//** };*//** assert_eq!(0x010203, buf.get_uint_ne(3));*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`, or*//** if `nbytes` is greater than 8.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_uint_ne<Anonymous: 'unk>((self: &mut Self,nbytes: int)) -> int{{(if false{{bytes::buf::buf_impl::f_get_uint(&mut (deref(self)),nbytes)}} else {{bytes::buf::buf_impl::f_get_uint_le(&mut (deref(self)),nbytes)}})}}
|
||||
/** Gets a signed n-byte integer from `self` in big-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x01\x02\x03 hello"[..];*//** assert_eq!(0x010203, buf.get_int(3));*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`, or*//** if `nbytes` is greater than 8.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_int<Anonymous: 'unk>((self: &mut Self,nbytes: int)) -> int{{bytes::buf::buf_impl::sign_extend(bytes::buf::buf_impl::f_get_uint(&mut (deref(self)),nbytes),nbytes)}}
|
||||
/** Gets a signed n-byte integer from `self` in little-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x03\x02\x01 hello"[..];*//** assert_eq!(0x010203, buf.get_int_le(3));*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`, or*//** if `nbytes` is greater than 8.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_int_le<Anonymous: 'unk>((self: &mut Self,nbytes: int)) -> int{{bytes::buf::buf_impl::sign_extend(bytes::buf::buf_impl::f_get_uint_le(&mut (deref(self)),nbytes),nbytes)}}
|
||||
/** Gets a signed n-byte integer from `self` in native-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03 hello",*//** false => b"\x03\x02\x01 hello",*//** };*//** assert_eq!(0x010203, buf.get_int_ne(3));*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`, or*//** if `nbytes` is greater than 8.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_int_ne<Anonymous: 'unk>((self: &mut Self,nbytes: int)) -> int{{(if false{{bytes::buf::buf_impl::f_get_int(&mut (deref(self)),nbytes)}} else {{bytes::buf::buf_impl::f_get_int_le(&mut (deref(self)),nbytes)}})}}
|
||||
/** Gets an IEEE754 single-precision (4 bytes) floating point number from*//** `self` in big-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x3F\x99\x99\x9A hello"[..];*//** assert_eq!(1.2f32, buf.get_f32());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_f32<Anonymous: 'unk>((self: &mut Self)) -> float{{core::f32::impl__f32__from_bits(bytes::buf::buf_impl::f_get_u32(&mut (deref(self))))}}
|
||||
/** Gets an IEEE754 single-precision (4 bytes) floating point number from*//** `self` in little-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x9A\x99\x99\x3F hello"[..];*//** assert_eq!(1.2f32, buf.get_f32_le());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_f32_le<Anonymous: 'unk>((self: &mut Self)) -> float{{core::f32::impl__f32__from_bits(bytes::buf::buf_impl::f_get_u32_le(&mut (deref(self))))}}
|
||||
/** Gets an IEEE754 single-precision (4 bytes) floating point number from*//** `self` in native-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x3F\x99\x99\x9A hello",*//** false => b"\x9A\x99\x99\x3F hello",*//** };*//** assert_eq!(1.2f32, buf.get_f32_ne());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_f32_ne<Anonymous: 'unk>((self: &mut Self)) -> float{{core::f32::impl__f32__from_bits(bytes::buf::buf_impl::f_get_u32_ne(&mut (deref(self))))}}
|
||||
/** Gets an IEEE754 double-precision (8 bytes) floating point number from*//** `self` in big-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x3F\xF3\x33\x33\x33\x33\x33\x33 hello"[..];*//** assert_eq!(1.2f64, buf.get_f64());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_f64<Anonymous: 'unk>((self: &mut Self)) -> float{{core::f64::impl__f64__from_bits(bytes::buf::buf_impl::f_get_u64(&mut (deref(self))))}}
|
||||
/** Gets an IEEE754 double-precision (8 bytes) floating point number from*//** `self` in little-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x33\x33\x33\x33\x33\x33\xF3\x3F hello"[..];*//** assert_eq!(1.2f64, buf.get_f64_le());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_f64_le<Anonymous: 'unk>((self: &mut Self)) -> float{{core::f64::impl__f64__from_bits(bytes::buf::buf_impl::f_get_u64_le(&mut (deref(self))))}}
|
||||
/** Gets an IEEE754 double-precision (8 bytes) floating point number from*//** `self` in native-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x3F\xF3\x33\x33\x33\x33\x33\x33 hello",*//** false => b"\x33\x33\x33\x33\x33\x33\xF3\x3F hello",*//** };*//** assert_eq!(1.2f64, buf.get_f64_ne());*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining data in `self`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_get_f64_ne<Anonymous: 'unk>((self: &mut Self)) -> float{{core::f64::impl__f64__from_bits(bytes::buf::buf_impl::f_get_u64_ne(&mut (deref(self))))}}
|
||||
/** Copies bytes from `self` into `dst`.*//***//** The cursor is advanced by the number of bytes copied. `self` must have*//** enough remaining bytes to fill `dst`.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"hello world"[..];*//** let mut dst = [0; 5];*//***//** assert_eq!(Ok(()), buf.try_copy_to_slice(&mut dst));*//** assert_eq!(&b"hello"[..], &dst);*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"hello world"[..];*//** let mut dst = [0; 12];*//***//** assert_eq!(Err(TryGetError{requested: 12, available: 11}), buf.try_copy_to_slice(&mut dst));*//** assert_eq!(11, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_copy_to_slice<Anonymous: 'unk, Anonymous: 'unk>((self: &mut Self,mut dst: &mut [int])) -> core::result::t_Result<tuple0, bytes::t_TryGetError>{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),core::slice::impl__len::<int>(&(deref(dst)))){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:core::slice::impl__len::<int>(&(deref(dst))),f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let _: tuple0 = {{loop { {(if core::ops::bit::Not::not(core::slice::impl__is_empty::<int>(&(deref(dst)))){{let src: &[int] = {bytes::buf::buf_impl::f_chunk(&(self))};{let cnt: int = {core::cmp::f_min(core::slice::impl__len::<int>(&(deref(src))),core::slice::impl__len::<int>(&(deref(dst))))};{let _: tuple0 = {core::slice::impl__copy_from_slice::<int>(&mut (deref(core::ops::index::f_index_mut(&mut (deref(dst)),core::ops::range::RangeTo{f_end:cnt,}))),&(deref(&(deref(core::ops::index::f_index(&(deref(src)),core::ops::range::RangeTo{f_end:cnt,}))))))};{let _: tuple0 = {(dst = &mut (deref(&mut (deref(core::ops::index::f_index_mut(&mut (deref(dst)),core::ops::range::RangeFrom{f_start:cnt,}))))))};{let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),cnt)};Tuple0}}}}}} else {rust_primitives::hax::never_to_any({rust_primitives::hax::never_to_any((break (Tuple0)))})})} }}};{core::result::Result_Ok(Tuple0())}}}}
|
||||
/** Gets an unsigned 8 bit integer from `self`.*//***//** The current position is advanced by 1.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08 hello"[..];*//** assert_eq!(Ok(0x08_u8), buf.try_get_u8());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b""[..];*//** assert_eq!(Err(TryGetError{requested: 1, available: 0}), buf.try_get_u8());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u8<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),1){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:1,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: int = {core::ops::index::Index::index(deref(bytes::buf::buf_impl::f_chunk(&(self))),0)};{let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),1)};{core::result::Result_Ok(ret)}}}}}
|
||||
/** Gets a signed 8 bit integer from `self`.*//***//** The current position is advanced by 1.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08 hello"[..];*//** assert_eq!(Ok(0x08_i8), buf.try_get_i8());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b""[..];*//** assert_eq!(Err(TryGetError{requested: 1, available: 0}), buf.try_get_i8());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i8<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),1){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:1,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: int = {cast(core::ops::index::Index::index(deref(bytes::buf::buf_impl::f_chunk(&(self))),0))};{let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),1)};{core::result::Result_Ok(ret)}}}}}
|
||||
/** Gets an unsigned 16 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 2.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08\x09 hello"[..];*//** assert_eq!(Ok(0x0809_u16), buf.try_get_u16());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x08"[..];*//** assert_eq!(Err(TryGetError{requested: 2, available: 1}), buf.try_get_u16());*//** assert_eq!(1, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u16<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_u16__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_u16__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_u16__SIZE,}),(|src| {unsafe {core::num::impl__u16__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_u16__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;2] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,2))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u16__from_be_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an unsigned 16 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 2.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x09\x08 hello"[..];*//** assert_eq!(Ok(0x0809_u16), buf.try_get_u16_le());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x08"[..];*//** assert_eq!(Err(TryGetError{requested: 2, available: 1}), buf.try_get_u16_le());*//** assert_eq!(1, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u16_le<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_u16_le__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_u16_le__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_u16_le__SIZE,}),(|src| {unsafe {core::num::impl__u16__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_u16_le__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;2] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,2))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u16__from_le_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an unsigned 16 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 2.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x08\x09 hello",*//** false => b"\x09\x08 hello",*//** };*//** assert_eq!(Ok(0x0809_u16), buf.try_get_u16_ne());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x08"[..];*//** assert_eq!(Err(TryGetError{requested: 2, available: 1}), buf.try_get_u16_ne());*//** assert_eq!(1, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u16_ne<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_u16_ne__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_u16_ne__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_u16_ne__SIZE,}),(|src| {unsafe {core::num::impl__u16__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_u16_ne__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;2] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,2))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u16__from_ne_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets a signed 16 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 2.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08\x09 hello"[..];*//** assert_eq!(Ok(0x0809_i16), buf.try_get_i16());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x08"[..];*//** assert_eq!(Err(TryGetError{requested: 2, available: 1}), buf.try_get_i16());*//** assert_eq!(1, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i16<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_i16__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_i16__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_i16__SIZE,}),(|src| {unsafe {core::num::impl__i16__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_i16__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;2] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,2))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i16__from_be_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an signed 16 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 2.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x09\x08 hello"[..];*//** assert_eq!(Ok(0x0809_i16), buf.try_get_i16_le());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x08"[..];*//** assert_eq!(Err(TryGetError{requested: 2, available: 1}), buf.try_get_i16_le());*//** assert_eq!(1, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i16_le<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_i16_le__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_i16_le__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_i16_le__SIZE,}),(|src| {unsafe {core::num::impl__i16__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_i16_le__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;2] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,2))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i16__from_le_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets a signed 16 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 2.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x08\x09 hello",*//** false => b"\x09\x08 hello",*//** };*//** assert_eq!(Ok(0x0809_i16), buf.try_get_i16_ne());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x08"[..];*//** assert_eq!(Err(TryGetError{requested: 2, available: 1}), buf.try_get_i16_ne());*//** assert_eq!(1, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i16_ne<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_i16_ne__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_i16_ne__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_i16_ne__SIZE,}),(|src| {unsafe {core::num::impl__i16__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_i16_ne__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;2] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,2))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i16__from_ne_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an unsigned 32 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 4.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08\x09\xA0\xA1 hello"[..];*//** assert_eq!(Ok(0x0809A0A1), buf.try_get_u32());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_u32());*//** assert_eq!(3, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u32<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_u32__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_u32__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_u32__SIZE,}),(|src| {unsafe {core::num::impl__u32__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_u32__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;4] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,4))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u32__from_be_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an unsigned 32 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 4.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\xA1\xA0\x09\x08 hello"[..];*//** assert_eq!(Ok(0x0809A0A1_u32), buf.try_get_u32_le());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x08\x09\xA0"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_u32_le());*//** assert_eq!(3, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u32_le<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_u32_le__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_u32_le__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_u32_le__SIZE,}),(|src| {unsafe {core::num::impl__u32__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_u32_le__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;4] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,4))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u32__from_le_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an unsigned 32 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 4.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x08\x09\xA0\xA1 hello",*//** false => b"\xA1\xA0\x09\x08 hello",*//** };*//** assert_eq!(Ok(0x0809A0A1_u32), buf.try_get_u32_ne());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x08\x09\xA0"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_u32_ne());*//** assert_eq!(3, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u32_ne<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_u32_ne__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_u32_ne__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_u32_ne__SIZE,}),(|src| {unsafe {core::num::impl__u32__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_u32_ne__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;4] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,4))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u32__from_ne_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets a signed 32 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 4.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08\x09\xA0\xA1 hello"[..];*//** assert_eq!(Ok(0x0809A0A1_i32), buf.try_get_i32());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_i32());*//** assert_eq!(3, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i32<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_i32__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_i32__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_i32__SIZE,}),(|src| {unsafe {core::num::impl__i32__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_i32__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;4] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,4))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i32__from_be_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets a signed 32 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 4.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\xA1\xA0\x09\x08 hello"[..];*//** assert_eq!(Ok(0x0809A0A1_i32), buf.try_get_i32_le());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x08\x09\xA0"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_i32_le());*//** assert_eq!(3, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i32_le<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_i32_le__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_i32_le__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_i32_le__SIZE,}),(|src| {unsafe {core::num::impl__i32__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_i32_le__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;4] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,4))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i32__from_le_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets a signed 32 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 4.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x08\x09\xA0\xA1 hello",*//** false => b"\xA1\xA0\x09\x08 hello",*//** };*//** assert_eq!(Ok(0x0809A0A1_i32), buf.try_get_i32_ne());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x08\x09\xA0"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_i32_ne());*//** assert_eq!(3, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i32_ne<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_i32_ne__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_i32_ne__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_i32_ne__SIZE,}),(|src| {unsafe {core::num::impl__i32__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_i32_ne__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;4] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,4))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i32__from_ne_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an unsigned 64 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 8.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08 hello"[..];*//** assert_eq!(Ok(0x0102030405060708_u64), buf.try_get_u64());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07"[..];*//** assert_eq!(Err(TryGetError{requested: 8, available: 7}), buf.try_get_u64());*//** assert_eq!(7, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u64<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_u64__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_u64__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_u64__SIZE,}),(|src| {unsafe {core::num::impl__u64__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_u64__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u64__from_be_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an unsigned 64 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 8.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];*//** assert_eq!(Ok(0x0102030405060708_u64), buf.try_get_u64_le());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x08\x07\x06\x05\x04\x03\x02"[..];*//** assert_eq!(Err(TryGetError{requested: 8, available: 7}), buf.try_get_u64_le());*//** assert_eq!(7, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u64_le<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_u64_le__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_u64_le__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_u64_le__SIZE,}),(|src| {unsafe {core::num::impl__u64__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_u64_le__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u64__from_le_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an unsigned 64 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 8.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03\x04\x05\x06\x07\x08 hello",*//** false => b"\x08\x07\x06\x05\x04\x03\x02\x01 hello",*//** };*//** assert_eq!(Ok(0x0102030405060708_u64), buf.try_get_u64_ne());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07"[..];*//** assert_eq!(Err(TryGetError{requested: 8, available: 7}), buf.try_get_u64_ne());*//** assert_eq!(7, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u64_ne<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_u64_ne__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_u64_ne__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_u64_ne__SIZE,}),(|src| {unsafe {core::num::impl__u64__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_u64_ne__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u64__from_ne_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets a signed 64 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 8.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08 hello"[..];*//** assert_eq!(Ok(0x0102030405060708_i64), buf.try_get_i64());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07"[..];*//** assert_eq!(Err(TryGetError{requested: 8, available: 7}), buf.try_get_i64());*//** assert_eq!(7, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i64<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_i64__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_i64__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_i64__SIZE,}),(|src| {unsafe {core::num::impl__i64__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_i64__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i64__from_be_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets a signed 64 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 8.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];*//** assert_eq!(Ok(0x0102030405060708_i64), buf.try_get_i64_le());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x08\x07\x06\x05\x04\x03\x02"[..];*//** assert_eq!(Err(TryGetError{requested: 8, available: 7}), buf.try_get_i64_le());*//** assert_eq!(7, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i64_le<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_i64_le__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_i64_le__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_i64_le__SIZE,}),(|src| {unsafe {core::num::impl__i64__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_i64_le__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i64__from_le_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets a signed 64 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 8.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03\x04\x05\x06\x07\x08 hello",*//** false => b"\x08\x07\x06\x05\x04\x03\x02\x01 hello",*//** };*//** assert_eq!(Ok(0x0102030405060708_i64), buf.try_get_i64_ne());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07"[..];*//** assert_eq!(Err(TryGetError{requested: 8, available: 7}), buf.try_get_i64_ne());*//** assert_eq!(7, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i64_ne<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_i64_ne__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_i64_ne__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_i64_ne__SIZE,}),(|src| {unsafe {core::num::impl__i64__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_i64_ne__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i64__from_ne_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an unsigned 128 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 16.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello"[..];*//** assert_eq!(Ok(0x01020304050607080910111213141516_u128), buf.try_get_u128());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15"[..];*//** assert_eq!(Err(TryGetError{requested: 16, available: 15}), buf.try_get_u128());*//** assert_eq!(15, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u128<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_u128__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_u128__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_u128__SIZE,}),(|src| {unsafe {core::num::impl__u128__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_u128__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;16] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,16))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u128__from_be_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an unsigned 128 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 16.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];*//** assert_eq!(Ok(0x01020304050607080910111213141516_u128), buf.try_get_u128_le());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02"[..];*//** assert_eq!(Err(TryGetError{requested: 16, available: 15}), buf.try_get_u128_le());*//** assert_eq!(15, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u128_le<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_u128_le__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_u128_le__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_u128_le__SIZE,}),(|src| {unsafe {core::num::impl__u128__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_u128_le__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;16] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,16))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u128__from_le_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an unsigned 128 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 16.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello",*//** false => b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello",*//** };*//** assert_eq!(Ok(0x01020304050607080910111213141516_u128), buf.try_get_u128_ne());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15"[..];*//** assert_eq!(Err(TryGetError{requested: 16, available: 15}), buf.try_get_u128_ne());*//** assert_eq!(15, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_u128_ne<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_u128_ne__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_u128_ne__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_u128_ne__SIZE,}),(|src| {unsafe {core::num::impl__u128__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_u128_ne__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;16] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,16))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__u128__from_ne_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets a signed 128 bit integer from `self` in big-endian byte order.*//***//** The current position is advanced by 16.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello"[..];*//** assert_eq!(Ok(0x01020304050607080910111213141516_i128), buf.try_get_i128());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15"[..];*//** assert_eq!(Err(TryGetError{requested: 16, available: 15}), buf.try_get_i128());*//** assert_eq!(15, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i128<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_i128__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_i128__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_i128__SIZE,}),(|src| {unsafe {core::num::impl__i128__from_be_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_i128__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;16] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,16))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i128__from_be_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets a signed 128 bit integer from `self` in little-endian byte order.*//***//** The current position is advanced by 16.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];*//** assert_eq!(Ok(0x01020304050607080910111213141516_i128), buf.try_get_i128_le());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02"[..];*//** assert_eq!(Err(TryGetError{requested: 16, available: 15}), buf.try_get_i128_le());*//** assert_eq!(15, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i128_le<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_i128_le__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_i128_le__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_i128_le__SIZE,}),(|src| {unsafe {core::num::impl__i128__from_le_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_i128_le__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;16] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,16))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i128__from_le_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets a signed 128 bit integer from `self` in native-endian byte order.*//***//** The current position is advanced by 16.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello",*//** false => b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello",*//** };*//** assert_eq!(Ok(0x01020304050607080910111213141516_i128), buf.try_get_i128_ne());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15"[..];*//** assert_eq!(Err(TryGetError{requested: 16, available: 15}), buf.try_get_i128_ne());*//** assert_eq!(15, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_i128_ne<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<int, bytes::t_TryGetError>{{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),bytes::buf::buf_impl::Buf::try_get_i128_ne__SIZE){rust_primitives::hax::never_to_any({(return core::result::Result_Err(bytes::TryGetError{f_requested:bytes::buf::buf_impl::Buf::try_get_i128_ne__SIZE,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))})})};{let ret: core::option::t_Option<int> = {core::option::impl__map::<&[int],int,arrow!(&[int] -> int)>(core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(&(deref(bytes::buf::buf_impl::f_chunk(&(self)))),core::ops::range::RangeTo{f_end:bytes::buf::buf_impl::Buf::try_get_i128_ne__SIZE,}),(|src| {unsafe {core::num::impl__i128__from_ne_bytes(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","deref")(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","cast(address_of)")))}}))};{(match (ret) {core::option::Option_Some(ret) => {rust_primitives::hax::never_to_any({let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (deref(self)),bytes::buf::buf_impl::Buf::try_get_i128_ne__SIZE)};{(return core::result::Result_Ok(ret))}})},_ => {rust_primitives::hax::never_to_any({let mut buf: [int;16] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,16))};{let _: tuple0 = {bytes::buf::buf_impl::f_copy_to_slice(&mut (deref(self)),rust_primitives::unsize(&mut (deref(&mut (buf)))))};{(return core::result::Result_Ok(core::num::impl__i128__from_ne_bytes(buf)))}}})}})}}}}}
|
||||
/** Gets an unsigned n-byte integer from `self` in big-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x01\x02\x03 hello"[..];*//** assert_eq!(Ok(0x010203_u64), buf.try_get_uint(3));*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_uint(4));*//** assert_eq!(3, buf.remaining());*//** ```*//***//** # Panics*//***//** This function panics if `nbytes` > 8.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_uint<Anonymous: 'unk>((self: &mut Self,nbytes: int)) -> core::result::t_Result<int, bytes::t_TryGetError>{rust_primitives::hax::never_to_any({{let slice_at: int = {(match (core::num::impl__usize__checked_sub(bytes::buf::buf_impl::Buf::try_get_uint__SIZE,nbytes)) {core::option::Option_Some(slice_at) => {slice_at},core::option::Option_None => {rust_primitives::hax::never_to_any(bytes::panic_does_not_fit(bytes::buf::buf_impl::Buf::try_get_uint__SIZE,nbytes))}})};{let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {(match (bytes::buf::buf_impl::f_try_copy_to_slice(&mut (deref(self)),&mut (deref(&mut (deref(core::ops::index::f_index_mut(&mut (buf),core::ops::range::RangeFrom{f_start:slice_at,}))))))) {core::result::Result_Ok(ok) => {ok},core::result::Result_Err(err) => {(return core::result::Result_Err(err))}})};{(return core::result::Result_Ok(core::num::impl__u64__from_be_bytes(buf)))}}}}})}
|
||||
/** Gets an unsigned n-byte integer from `self` in little-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x03\x02\x01 hello"[..];*//** assert_eq!(Ok(0x010203_u64), buf.try_get_uint_le(3));*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_uint_le(4));*//** assert_eq!(3, buf.remaining());*//** ```*//***//** # Panics*//***//** This function panics if `nbytes` > 8.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_uint_le<Anonymous: 'unk>((self: &mut Self,nbytes: int)) -> core::result::t_Result<int, bytes::t_TryGetError>{rust_primitives::hax::never_to_any({{let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let subslice: &mut [int] = {(match (core::slice::impl__get_mut::<int,core::ops::range::t_RangeTo<int>>(rust_primitives::unsize(&mut (buf)),core::ops::range::RangeTo{f_end:nbytes,})) {core::option::Option_Some(subslice) => {subslice},core::option::Option_None => {rust_primitives::hax::never_to_any(bytes::panic_does_not_fit(bytes::buf::buf_impl::Buf::try_get_uint_le__SIZE,nbytes))}})};{let _: tuple0 = {(match (bytes::buf::buf_impl::f_try_copy_to_slice(&mut (deref(self)),&mut (deref(subslice)))) {core::result::Result_Ok(ok) => {ok},core::result::Result_Err(err) => {(return core::result::Result_Err(err))}})};{(return core::result::Result_Ok(core::num::impl__u64__from_le_bytes(buf)))}}}}})}
|
||||
/** Gets an unsigned n-byte integer from `self` in native-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03 hello",*//** false => b"\x03\x02\x01 hello",*//** };*//** assert_eq!(Ok(0x010203_u64), buf.try_get_uint_ne(3));*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03",*//** false => b"\x03\x02\x01",*//** };*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_uint_ne(4));*//** assert_eq!(3, buf.remaining());*//** ```*//***//** # Panics*//***//** This function panics if `nbytes` is greater than 8.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_uint_ne<Anonymous: 'unk>((self: &mut Self,nbytes: int)) -> core::result::t_Result<int, bytes::t_TryGetError>{{(if false{{bytes::buf::buf_impl::f_try_get_uint(&mut (deref(self)),nbytes)}} else {{bytes::buf::buf_impl::f_try_get_uint_le(&mut (deref(self)),nbytes)}})}}
|
||||
/** Gets a signed n-byte integer from `self` in big-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x01\x02\x03 hello"[..];*//** assert_eq!(Ok(0x010203_i64), buf.try_get_int(3));*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_int(4));*//** assert_eq!(3, buf.remaining());*//** ```*//***//** # Panics*//***//** This function panics if `nbytes` is greater than 8.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_int<Anonymous: 'unk>((self: &mut Self,nbytes: int)) -> core::result::t_Result<int, bytes::t_TryGetError>{rust_primitives::hax::never_to_any({{let slice_at: int = {(match (core::num::impl__usize__checked_sub(bytes::buf::buf_impl::Buf::try_get_int__SIZE,nbytes)) {core::option::Option_Some(slice_at) => {slice_at},core::option::Option_None => {rust_primitives::hax::never_to_any(bytes::panic_does_not_fit(bytes::buf::buf_impl::Buf::try_get_int__SIZE,nbytes))}})};{let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let _: tuple0 = {(match (bytes::buf::buf_impl::f_try_copy_to_slice(&mut (deref(self)),&mut (deref(&mut (deref(core::ops::index::f_index_mut(&mut (buf),core::ops::range::RangeFrom{f_start:slice_at,}))))))) {core::result::Result_Ok(ok) => {ok},core::result::Result_Err(err) => {(return core::result::Result_Err(err))}})};{(return core::result::Result_Ok(core::num::impl__i64__from_be_bytes(buf)))}}}}})}
|
||||
/** Gets a signed n-byte integer from `self` in little-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x03\x02\x01 hello"[..];*//** assert_eq!(Ok(0x010203_i64), buf.try_get_int_le(3));*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x01\x02\x03"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_int_le(4));*//** assert_eq!(3, buf.remaining());*//** ```*//***//** # Panics*//***//** This function panics if `nbytes` is greater than 8.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_int_le<Anonymous: 'unk>((self: &mut Self,nbytes: int)) -> core::result::t_Result<int, bytes::t_TryGetError>{rust_primitives::hax::never_to_any({{let mut buf: [int;8] = {alloc::boxed::impl__new(rust_primitives::hax::repeat(0,8))};{let subslice: &mut [int] = {(match (core::slice::impl__get_mut::<int,core::ops::range::t_RangeTo<int>>(rust_primitives::unsize(&mut (buf)),core::ops::range::RangeTo{f_end:nbytes,})) {core::option::Option_Some(subslice) => {subslice},core::option::Option_None => {rust_primitives::hax::never_to_any(bytes::panic_does_not_fit(bytes::buf::buf_impl::Buf::try_get_int_le__SIZE,nbytes))}})};{let _: tuple0 = {(match (bytes::buf::buf_impl::f_try_copy_to_slice(&mut (deref(self)),&mut (deref(subslice)))) {core::result::Result_Ok(ok) => {ok},core::result::Result_Err(err) => {(return core::result::Result_Err(err))}})};{(return core::result::Result_Ok(core::num::impl__i64__from_le_bytes(buf)))}}}}})}
|
||||
/** Gets a signed n-byte integer from `self` in native-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03 hello",*//** false => b"\x03\x02\x01 hello",*//** };*//** assert_eq!(Ok(0x010203_i64), buf.try_get_int_ne(3));*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x01\x02\x03",*//** false => b"\x03\x02\x01",*//** };*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_int_ne(4));*//** assert_eq!(3, buf.remaining());*//** ```*//***//** # Panics*//***//** This function panics if `nbytes` is greater than 8.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_int_ne<Anonymous: 'unk>((self: &mut Self,nbytes: int)) -> core::result::t_Result<int, bytes::t_TryGetError>{{(if false{{bytes::buf::buf_impl::f_try_get_int(&mut (deref(self)),nbytes)}} else {{bytes::buf::buf_impl::f_try_get_int_le(&mut (deref(self)),nbytes)}})}}
|
||||
/** Gets an IEEE754 single-precision (4 bytes) floating point number from*//** `self` in big-endian byte order.*//***//** The current position is advanced by 4.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x3F\x99\x99\x9A hello"[..];*//** assert_eq!(1.2f32, buf.get_f32());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x3F\x99\x99"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_f32());*//** assert_eq!(3, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_f32<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<float, bytes::t_TryGetError>{{core::result::Result_Ok(core::f32::impl__f32__from_bits((match (bytes::buf::buf_impl::f_try_get_u32(&mut (deref(self)))) {core::result::Result_Ok(ok) => {ok},core::result::Result_Err(err) => {(return core::result::Result_Err(err))}})))}}
|
||||
/** Gets an IEEE754 single-precision (4 bytes) floating point number from*//** `self` in little-endian byte order.*//***//** The current position is advanced by 4.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x9A\x99\x99\x3F hello"[..];*//** assert_eq!(1.2f32, buf.get_f32_le());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x3F\x99\x99"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_f32_le());*//** assert_eq!(3, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_f32_le<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<float, bytes::t_TryGetError>{{core::result::Result_Ok(core::f32::impl__f32__from_bits((match (bytes::buf::buf_impl::f_try_get_u32_le(&mut (deref(self)))) {core::result::Result_Ok(ok) => {ok},core::result::Result_Err(err) => {(return core::result::Result_Err(err))}})))}}
|
||||
/** Gets an IEEE754 single-precision (4 bytes) floating point number from*//** `self` in native-endian byte order.*//***//** The current position is advanced by 4.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x3F\x99\x99\x9A hello",*//** false => b"\x9A\x99\x99\x3F hello",*//** };*//** assert_eq!(1.2f32, buf.get_f32_ne());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x3F\x99\x99"[..];*//** assert_eq!(Err(TryGetError{requested: 4, available: 3}), buf.try_get_f32_ne());*//** assert_eq!(3, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_f32_ne<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<float, bytes::t_TryGetError>{{core::result::Result_Ok(core::f32::impl__f32__from_bits((match (bytes::buf::buf_impl::f_try_get_u32_ne(&mut (deref(self)))) {core::result::Result_Ok(ok) => {ok},core::result::Result_Err(err) => {(return core::result::Result_Err(err))}})))}}
|
||||
/** Gets an IEEE754 double-precision (8 bytes) floating point number from*//** `self` in big-endian byte order.*//***//** The current position is advanced by 8.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x3F\xF3\x33\x33\x33\x33\x33\x33 hello"[..];*//** assert_eq!(1.2f64, buf.get_f64());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x3F\xF3\x33\x33\x33\x33\x33"[..];*//** assert_eq!(Err(TryGetError{requested: 8, available: 7}), buf.try_get_f64());*//** assert_eq!(7, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_f64<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<float, bytes::t_TryGetError>{{core::result::Result_Ok(core::f64::impl__f64__from_bits((match (bytes::buf::buf_impl::f_try_get_u64(&mut (deref(self)))) {core::result::Result_Ok(ok) => {ok},core::result::Result_Err(err) => {(return core::result::Result_Err(err))}})))}}
|
||||
/** Gets an IEEE754 double-precision (8 bytes) floating point number from*//** `self` in little-endian byte order.*//***//** The current position is advanced by 8.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf = &b"\x33\x33\x33\x33\x33\x33\xF3\x3F hello"[..];*//** assert_eq!(1.2f64, buf.get_f64_le());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x3F\xF3\x33\x33\x33\x33\x33"[..];*//** assert_eq!(Err(TryGetError{requested: 8, available: 7}), buf.try_get_f64_le());*//** assert_eq!(7, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_f64_le<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<float, bytes::t_TryGetError>{{core::result::Result_Ok(core::f64::impl__f64__from_bits((match (bytes::buf::buf_impl::f_try_get_u64_le(&mut (deref(self)))) {core::result::Result_Ok(ok) => {ok},core::result::Result_Err(err) => {(return core::result::Result_Err(err))}})))}}
|
||||
/** Gets an IEEE754 double-precision (8 bytes) floating point number from*//** `self` in native-endian byte order.*//***//** The current position is advanced by 8.*//***//** Returns `Err(TryGetError)` when there are not enough*//** remaining bytes to read the value.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut buf: &[u8] = match cfg!(target_endian = "big") {*//** true => b"\x3F\xF3\x33\x33\x33\x33\x33\x33 hello",*//** false => b"\x33\x33\x33\x33\x33\x33\xF3\x3F hello",*//** };*//** assert_eq!(1.2f64, buf.get_f64_ne());*//** assert_eq!(6, buf.remaining());*//** ```*//***//** ```*//** use bytes::{Buf, TryGetError};*//***//** let mut buf = &b"\x3F\xF3\x33\x33\x33\x33\x33"[..];*//** assert_eq!(Err(TryGetError{requested: 8, available: 7}), buf.try_get_f64_ne());*//** assert_eq!(7, buf.remaining());*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_try_get_f64_ne<Anonymous: 'unk>((self: &mut Self)) -> core::result::t_Result<float, bytes::t_TryGetError>{{core::result::Result_Ok(core::f64::impl__f64__from_bits((match (bytes::buf::buf_impl::f_try_get_u64_ne(&mut (deref(self)))) {core::result::Result_Ok(ok) => {ok},core::result::Result_Err(err) => {(return core::result::Result_Err(err))}})))}}
|
||||
/** Consumes `len` bytes inside self and returns new instance of `Bytes`*//** with this data.*//***//** This function may be optimized by the underlying type to avoid actual*//** copies. For example, `Bytes` implementation will do a shallow copy*//** (ref-count increment).*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let bytes = (&b"hello world"[..]).copy_to_bytes(5);*//** assert_eq!(&bytes[..], &b"hello"[..]);*//** ```*//***//** # Panics*//***//** This function panics if `len > self.remaining()`.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_copy_to_bytes<Anonymous: 'unk>((self: &mut Self,len: int)) -> bytes::bytes::t_Bytes{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_impl::f_remaining(&(self)),len){rust_primitives::hax::never_to_any({bytes::panic_advance(&(deref(&(bytes::TryGetError{f_requested:len,f_available:bytes::buf::buf_impl::f_remaining(&(self)),}))))})})};{let mut ret: bytes::bytes_mut::t_BytesMut = {bytes::bytes_mut::impl__BytesMut__with_capacity(len)};{let _: tuple0 = {bytes::buf::buf_mut::f_put::<bytes::buf::take::t_Take<&mut Self>>(&mut (ret),bytes::buf::buf_impl::f_take(&mut (deref(self)),len))};{bytes::bytes_mut::impl__BytesMut__freeze(ret)}}}}}
|
||||
/** Creates an adaptor which will read at most `limit` bytes from `self`.*//***//** This function returns a new instance of `Buf` which will read at most*//** `limit` bytes.*//***//** # Examples*//***//** ```*//** use bytes::{Buf, BufMut};*//***//** let mut buf = b"hello world"[..].take(5);*//** let mut dst = vec![];*//***//** dst.put(&mut buf);*//** assert_eq!(dst, b"hello");*//***//** let mut buf = buf.into_inner();*//** dst.clear();*//** dst.put(&mut buf);*//** assert_eq!(dst, b" world");*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_take((self: Self,limit: int)) -> bytes::buf::take::t_Take<Self>{{bytes::buf::take::new::<Self>(self,limit)}}
|
||||
/** Creates an adaptor which will chain this buffer with another.*//***//** The returned `Buf` instance will first consume all bytes from `self`.*//** Afterwards the output is equivalent to the output of next.*//***//** # Examples*//***//** ```*//** use bytes::Buf;*//***//** let mut chain = b"hello "[..].chain(&b"world"[..]);*//***//** let full = chain.copy_to_bytes(11);*//** assert_eq!(full.chunk(), b"hello world");*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_chain<U>((self: Self,next: U)) -> bytes::buf::chain::t_Chain<Self, U> where _: bytes::buf::buf_impl::t_Buf<U>{{bytes::buf::chain::impl__new::<Self,U>(self,next)}}
|
||||
/** Creates an adaptor which implements the `Read` trait for `self`.*//***//** This function returns a new value which implements `Read` by adapting*//** the `Read` trait functions to the `Buf` trait functions. Given that*//** `Buf` operations are infallible, none of the `Read` functions will*//** return with `Err`.*//***//** # Examples*//***//** ```*//** use bytes::{Bytes, Buf};*//** use std::io::Read;*//***//** let buf = Bytes::from("hello world");*//***//** let mut reader = buf.reader();*//** let mut dst = [0; 1024];*//***//** let num = reader.read(&mut dst).unwrap();*//***//** assert_eq!(11, num);*//** assert_eq!(&dst[..11], &b"hello world"[..]);*//** ```*/#[cfg(feature = "std")]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_reader((self: Self)) -> bytes::buf::reader::t_Reader<Self>{{bytes::buf::reader::new::<Self>(self)}}}
|
||||
|
||||
Last AST:
|
||||
/** print_rust: pitem: not implemented (item: { Concrete_ident.T.def_id =
|
||||
{ Concrete_ident.Imported.krate = "bytes";
|
||||
path =
|
||||
[{ Concrete_ident.Imported.data = (Concrete_ident.Imported.TypeNs "buf");
|
||||
disambiguator = 0 };
|
||||
{ Concrete_ident.Imported.data =
|
||||
(Concrete_ident.Imported.TypeNs "buf_impl"); disambiguator = 0 };
|
||||
{ Concrete_ident.Imported.data = (Concrete_ident.Imported.TypeNs "Buf");
|
||||
disambiguator = 0 }
|
||||
]
|
||||
};
|
||||
kind = Concrete_ident.Kind.Value }) */
|
||||
const _: () = ();
|
||||
*)
|
||||
|
||||
(* item error backend: (DirectAndMut) The mutation of this [1m&mut[0m is not allowed here.
|
||||
Last available AST for this item:
|
||||
|
||||
#[_hax::json("\"Erased\"")]
|
||||
#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
|
||||
#[doc(
|
||||
test(
|
||||
no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||
)
|
||||
)]
|
||||
#[no_std()]
|
||||
#[feature(register_tool)]
|
||||
#[register_tool(_hax)]
|
||||
impl<T, Anonymous: 'unk> bytes::buf::buf_impl::t_Buf<&mut T> for &mut T
|
||||
where
|
||||
_: bytes::buf::buf_impl::t_Buf<T>,
|
||||
{
|
||||
fn dropped_body(_: tuple0) -> tuple0 {
|
||||
Tuple0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Last AST:
|
||||
/** print_rust: pitem: not implemented (item: { Concrete_ident.T.def_id =
|
||||
{ Concrete_ident.Imported.krate = "bytes";
|
||||
path =
|
||||
[{ Concrete_ident.Imported.data = (Concrete_ident.Imported.TypeNs "buf");
|
||||
disambiguator = 0 };
|
||||
{ Concrete_ident.Imported.data =
|
||||
(Concrete_ident.Imported.TypeNs "buf_impl"); disambiguator = 0 };
|
||||
{ Concrete_ident.Imported.data = Concrete_ident.Imported.Impl;
|
||||
disambiguator = 0 }
|
||||
]
|
||||
};
|
||||
kind = Concrete_ident.Kind.Value }) */
|
||||
const _: () = ();
|
||||
*)
|
||||
|
||||
class t_Buf (v_T: Type0) = {
|
||||
dummy_field: Type0
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_1 (#v_T: Type0) {| i0: t_Buf v_T |} : t_Buf (Alloc.Boxed.t_Box v_T Alloc.Alloc.t_Global)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_2:t_Buf (t_Slice u8)
|
||||
|
||||
(* [@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_3 (#v_T: Type0) {| i1: Core_models.Convert.t_AsRef v_T (t_Slice u8) |}
|
||||
: t_Buf (Std.Io.Cursor.t_Cursor v_T)
|
||||
|
||||
val v__assert_trait_object (v__b: dyn 1 (fun z -> t_Buf z))
|
||||
: Prims.Pure Prims.unit Prims.l_True (fun _ -> Prims.l_True) *)
|
||||
@@ -0,0 +1,251 @@
|
||||
module Bytes.Buf.Buf_mut
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
|
||||
val t_BufMut: Type0 -> Type0
|
||||
|
||||
(* item error backend: (DirectAndMut) The mutation of this [1m&mut[0m is not allowed here.
|
||||
Last available AST for this item:
|
||||
|
||||
/** A trait for values that provide sequential write access to bytes.*//***//** Write bytes to a buffer*//***//** A buffer stores bytes in memory such that write operations are infallible.*//** The underlying storage may or may not be in contiguous memory. A `BufMut`*//** value is a cursor into the buffer. Writing to `BufMut` advances the cursor*//** position.*//***//** The simplest `BufMut` is a `Vec<u8>`.*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//***//** buf.put(&b"hello world"[..]);*//***//** assert_eq!(buf, b"hello world");*//** ```*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]unsafe trait t_BufMut<Self_>{/** Returns the number of bytes that can be written from the current*//** position until the end of the buffer is reached.*//***//** This value is greater than or equal to the length of the slice returned*//** by `chunk_mut()`.*//***//** Writing to a `BufMut` may involve allocating more memory on the fly.*//** Implementations may fail before reaching the number of bytes indicated*//** by this method if they encounter an allocation failure.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut dst = [0; 10];*//** let mut buf = &mut dst[..];*//***//** let original_remaining = buf.remaining_mut();*//** buf.put(&b"hello"[..]);*//***//** assert_eq!(original_remaining - 5, buf.remaining_mut());*//** ```*//***//** # Implementer notes*//***//** Implementations of `remaining_mut` should ensure that the return value*//** does not change unless a call is made to `advance_mut` or any other*//** function that is documented to change the `BufMut`'s current position.*//***//** # Note*//***//** `remaining_mut` may return value smaller than actual available space.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_remaining_mut<Anonymous: 'unk>(_: &Self) -> int;
|
||||
/** Advance the internal cursor of the BufMut*//***//** The next call to `chunk_mut` will return a slice starting `cnt` bytes*//** further into the underlying buffer.*//***//** # Safety*//***//** The caller must ensure that the next `cnt` bytes of `chunk` are*//** initialized.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = Vec::with_capacity(16);*//***//** // Write some data*//** buf.chunk_mut()[0..2].copy_from_slice(b"he");*//** unsafe { buf.advance_mut(2) };*//***//** // write more bytes*//** buf.chunk_mut()[0..3].copy_from_slice(b"llo");*//***//** unsafe { buf.advance_mut(3); }*//***//** assert_eq!(5, buf.len());*//** assert_eq!(buf, b"hello");*//** ```*//***//** # Panics*//***//** This function **may** panic if `cnt > self.remaining_mut()`.*//***//** # Implementer notes*//***//** It is recommended for implementations of `advance_mut` to panic if*//** `cnt > self.remaining_mut()`. If the implementation does not panic,*//** the call must behave as if `cnt == self.remaining_mut()`.*//***//** A call with `cnt == 0` should never panic and be a no-op.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_advance_mut<Anonymous: 'unk>(_: Self,_: int) -> Self;
|
||||
/** Returns true if there is space in `self` for more bytes.*//***//** This is equivalent to `self.remaining_mut() != 0`.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut dst = [0; 5];*//** let mut buf = &mut dst[..];*//***//** assert!(buf.has_remaining_mut());*//***//** buf.put(&b"hello"[..]);*//***//** assert!(!buf.has_remaining_mut());*//** ```*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_has_remaining_mut<Anonymous: 'unk>((self: &Self)) -> bool{{core::cmp::PartialOrd::gt(bytes::buf::buf_mut::f_remaining_mut(&(deref(self))),0)}}
|
||||
/** Returns a mutable slice starting at the current BufMut position and of*//** length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the*//** whole remainder of the buffer (this allows non-continuous implementation).*//***//** This is a lower level function. Most operations are done with other*//** functions.*//***//** The returned byte slice may represent uninitialized memory.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = Vec::with_capacity(16);*//***//** unsafe {*//** // MaybeUninit::as_mut_ptr*//** buf.chunk_mut()[0..].as_mut_ptr().write(b'h');*//** buf.chunk_mut()[1..].as_mut_ptr().write(b'e');*//***//** buf.advance_mut(2);*//***//** buf.chunk_mut()[0..].as_mut_ptr().write(b'l');*//** buf.chunk_mut()[1..].as_mut_ptr().write(b'l');*//** buf.chunk_mut()[2..].as_mut_ptr().write(b'o');*//***//** buf.advance_mut(3);*//** }*//***//** assert_eq!(5, buf.len());*//** assert_eq!(buf, b"hello");*//** ```*//***//** # Implementer notes*//***//** This function should never panic. `chunk_mut()` should return an empty*//** slice **if and only if** `remaining_mut()` returns 0. In other words,*//** `chunk_mut()` returning an empty slice implies that `remaining_mut()` will*//** return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will*//** return an empty slice.*//***//** This function may trigger an out-of-memory abort if it tries to allocate*//** memory and fails to do so.*/#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_chunk_mut<Anonymous: 'unk>(_: Self) -> tuple2<Self, &mut bytes::buf::uninit_slice::t_UninitSlice>;
|
||||
/** Transfer bytes into `self` from `src` and advance the cursor by the*//** number of bytes written.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//***//** buf.put_u8(b'h');*//** buf.put(&b"ello"[..]);*//** buf.put(&b" world"[..]);*//***//** assert_eq!(buf, b"hello world");*//** ```*//***//** # Panics*//***//** Panics if `self` does not have enough capacity to contain `src`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put<T, Anonymous: 'unk>((mut self: Self,mut src: T)) -> tuple0 where _: bytes::buf::buf_impl::t_Buf<T>{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_mut::f_remaining_mut(&(self)),bytes::buf::buf_impl::f_remaining(&(src))){rust_primitives::hax::never_to_any({bytes::panic_advance(&(deref(&(bytes::TryGetError{f_requested:bytes::buf::buf_impl::f_remaining(&(src)),f_available:bytes::buf::buf_mut::f_remaining_mut(&(self)),}))))})})};{let _: tuple0 = {{{while bytes::buf::buf_impl::f_has_remaining(&(src)) { {let s: &[int] = {bytes::buf::buf_impl::f_chunk(&(src))};{let d: &mut bytes::buf::uninit_slice::t_UninitSlice = {bytes::buf::buf_mut::f_chunk_mut(&mut (self))};{let cnt: int = {core::cmp::f_min(core::slice::impl__len::<int>(&(deref(s))),bytes::buf::uninit_slice::impl__UninitSlice__len(&(deref(d))))};{let _: tuple0 = {bytes::buf::uninit_slice::impl__UninitSlice__copy_from_slice(&mut (deref(core::ops::index::f_index_mut(&mut (deref(d)),core::ops::range::RangeTo{f_end:cnt,}))),&(deref(core::ops::index::f_index(&(deref(s)),core::ops::range::RangeTo{f_end:cnt,}))))};{let _: tuple0 = {unsafe {bytes::buf::buf_mut::f_advance_mut(&mut (self),cnt)}};{let _: tuple0 = {bytes::buf::buf_impl::f_advance(&mut (src),cnt)};Tuple0}}}}}} }}}};self}}}
|
||||
/** Transfer bytes into `self` from `src` and advance the cursor by the*//** number of bytes written.*//***//** `self` must have enough remaining capacity to contain all of `src`.*//***//** ```*//** use bytes::BufMut;*//***//** let mut dst = [0; 6];*//***//** {*//** let mut buf = &mut dst[..];*//** buf.put_slice(b"hello");*//***//** assert_eq!(1, buf.remaining_mut());*//** }*//***//** assert_eq!(b"hello\0", &dst);*//** ```*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_slice<Anonymous: 'unk, Anonymous: 'unk>((mut self: Self,mut src: &[int])) -> tuple0{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_mut::f_remaining_mut(&(self)),core::slice::impl__len::<int>(&(deref(src)))){rust_primitives::hax::never_to_any({bytes::panic_advance(&(deref(&(bytes::TryGetError{f_requested:core::slice::impl__len::<int>(&(deref(src))),f_available:bytes::buf::buf_mut::f_remaining_mut(&(self)),}))))})})};{let _: tuple0 = {{{while core::ops::bit::Not::not(core::slice::impl__is_empty::<int>(&(deref(src)))) { {let dst: &mut bytes::buf::uninit_slice::t_UninitSlice = {bytes::buf::buf_mut::f_chunk_mut(&mut (self))};{let cnt: int = {core::cmp::f_min(core::slice::impl__len::<int>(&(deref(src))),bytes::buf::uninit_slice::impl__UninitSlice__len(&(deref(dst))))};{let _: tuple0 = {bytes::buf::uninit_slice::impl__UninitSlice__copy_from_slice(&mut (deref(core::ops::index::f_index_mut(&mut (deref(dst)),core::ops::range::RangeTo{f_end:cnt,}))),&(deref(core::ops::index::f_index(&(deref(src)),core::ops::range::RangeTo{f_end:cnt,}))))};{let _: tuple0 = {(src = &(deref(core::ops::index::f_index(&(deref(src)),core::ops::range::RangeFrom{f_start:cnt,}))))};{let _: tuple0 = {unsafe {bytes::buf::buf_mut::f_advance_mut(&mut (self),cnt)}};Tuple0}}}}} }}}};self}}}
|
||||
/** Put `cnt` bytes `val` into `self`.*//***//** Logically equivalent to calling `self.put_u8(val)` `cnt` times, but may work faster.*//***//** `self` must have at least `cnt` remaining capacity.*//***//** ```*//** use bytes::BufMut;*//***//** let mut dst = [0; 6];*//***//** {*//** let mut buf = &mut dst[..];*//** buf.put_bytes(b'a', 4);*//***//** assert_eq!(2, buf.remaining_mut());*//** }*//***//** assert_eq!(b"aaaa\0\0", &dst);*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_bytes<Anonymous: 'unk>((mut self: Self,val: int,mut cnt: int)) -> tuple0{{let _: tuple0 = {(if core::cmp::PartialOrd::lt(bytes::buf::buf_mut::f_remaining_mut(&(self)),cnt){{rust_primitives::hax::never_to_any(bytes::panic_advance(&(deref(&(bytes::TryGetError{f_requested:cnt,f_available:bytes::buf::buf_mut::f_remaining_mut(&(self)),})))))}})};{let _: tuple0 = {{{while core::cmp::PartialOrd::gt(cnt,0) { {let dst: &mut bytes::buf::uninit_slice::t_UninitSlice = {bytes::buf::buf_mut::f_chunk_mut(&mut (self))};{let dst_len: int = {core::cmp::f_min(bytes::buf::uninit_slice::impl__UninitSlice__len(&(deref(dst))),cnt)};{let _: tuple0 = {unsafe {rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","core::intrinsics::write_bytes")::<int>(rust_primitives::hax::failure("(reject_RawOrMutPointer) ExplicitRejection { reason: \"a node of kind [Raw_pointer] have been found in the AST\" }","bytes::buf::uninit_slice::impl__UninitSlice__as_mut_ptr(&mut (deref(dst)))"),val,dst_len)}};{let _: tuple0 = {unsafe {bytes::buf::buf_mut::f_advance_mut(&mut (self),dst_len)}};{let _: tuple0 = {(cnt = core::ops::arith::Sub::sub(cnt,dst_len))};Tuple0}}}}} }}}};self}}}
|
||||
/** Writes an unsigned 8 bit integer to `self`.*//***//** The current position is advanced by 1.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u8(0x01);*//** assert_eq!(buf, b"\x01");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u8<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let src: [int;1] = {[n]};{let _: tuple0 = {bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(src)))))};self}}}
|
||||
/** Writes a signed 8 bit integer to `self`.*//***//** The current position is advanced by 1.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i8(0x01);*//** assert_eq!(buf, b"\x01");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i8<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let src: [int;1] = {[cast(n)]};{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(src)))))}};self}}}
|
||||
/** Writes an unsigned 16 bit integer to `self` in big-endian byte order.*//***//** The current position is advanced by 2.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u16(0x0809);*//** assert_eq!(buf, b"\x08\x09");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u16<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__u16__to_be_bytes(n))))))}};self}}
|
||||
/** Writes an unsigned 16 bit integer to `self` in little-endian byte order.*//***//** The current position is advanced by 2.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u16_le(0x0809);*//** assert_eq!(buf, b"\x09\x08");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u16_le<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__u16__to_le_bytes(n))))))}};self}}
|
||||
/** Writes an unsigned 16 bit integer to `self` in native-endian byte order.*//***//** The current position is advanced by 2.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u16_ne(0x0809);*//** if cfg!(target_endian = "big") {*//** assert_eq!(buf, b"\x08\x09");*//** } else {*//** assert_eq!(buf, b"\x09\x08");*//** }*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u16_ne<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__u16__to_ne_bytes(n))))))}};self}}
|
||||
/** Writes a signed 16 bit integer to `self` in big-endian byte order.*//***//** The current position is advanced by 2.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i16(0x0809);*//** assert_eq!(buf, b"\x08\x09");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i16<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__i16__to_be_bytes(n))))))}};self}}
|
||||
/** Writes a signed 16 bit integer to `self` in little-endian byte order.*//***//** The current position is advanced by 2.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i16_le(0x0809);*//** assert_eq!(buf, b"\x09\x08");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i16_le<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__i16__to_le_bytes(n))))))}};self}}
|
||||
/** Writes a signed 16 bit integer to `self` in native-endian byte order.*//***//** The current position is advanced by 2.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i16_ne(0x0809);*//** if cfg!(target_endian = "big") {*//** assert_eq!(buf, b"\x08\x09");*//** } else {*//** assert_eq!(buf, b"\x09\x08");*//** }*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i16_ne<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__i16__to_ne_bytes(n))))))}};self}}
|
||||
/** Writes an unsigned 32 bit integer to `self` in big-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u32(0x0809A0A1);*//** assert_eq!(buf, b"\x08\x09\xA0\xA1");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u32<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__u32__to_be_bytes(n))))))}};self}}
|
||||
/** Writes an unsigned 32 bit integer to `self` in little-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u32_le(0x0809A0A1);*//** assert_eq!(buf, b"\xA1\xA0\x09\x08");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u32_le<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__u32__to_le_bytes(n))))))}};self}}
|
||||
/** Writes an unsigned 32 bit integer to `self` in native-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u32_ne(0x0809A0A1);*//** if cfg!(target_endian = "big") {*//** assert_eq!(buf, b"\x08\x09\xA0\xA1");*//** } else {*//** assert_eq!(buf, b"\xA1\xA0\x09\x08");*//** }*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u32_ne<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__u32__to_ne_bytes(n))))))}};self}}
|
||||
/** Writes a signed 32 bit integer to `self` in big-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i32(0x0809A0A1);*//** assert_eq!(buf, b"\x08\x09\xA0\xA1");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i32<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__i32__to_be_bytes(n))))))}};self}}
|
||||
/** Writes a signed 32 bit integer to `self` in little-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i32_le(0x0809A0A1);*//** assert_eq!(buf, b"\xA1\xA0\x09\x08");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i32_le<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__i32__to_le_bytes(n))))))}};self}}
|
||||
/** Writes a signed 32 bit integer to `self` in native-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i32_ne(0x0809A0A1);*//** if cfg!(target_endian = "big") {*//** assert_eq!(buf, b"\x08\x09\xA0\xA1");*//** } else {*//** assert_eq!(buf, b"\xA1\xA0\x09\x08");*//** }*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i32_ne<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__i32__to_ne_bytes(n))))))}};self}}
|
||||
/** Writes an unsigned 64 bit integer to `self` in the big-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u64(0x0102030405060708);*//** assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u64<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__u64__to_be_bytes(n))))))}};self}}
|
||||
/** Writes an unsigned 64 bit integer to `self` in little-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u64_le(0x0102030405060708);*//** assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u64_le<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__u64__to_le_bytes(n))))))}};self}}
|
||||
/** Writes an unsigned 64 bit integer to `self` in native-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u64_ne(0x0102030405060708);*//** if cfg!(target_endian = "big") {*//** assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08");*//** } else {*//** assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01");*//** }*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u64_ne<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__u64__to_ne_bytes(n))))))}};self}}
|
||||
/** Writes a signed 64 bit integer to `self` in the big-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i64(0x0102030405060708);*//** assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i64<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__i64__to_be_bytes(n))))))}};self}}
|
||||
/** Writes a signed 64 bit integer to `self` in little-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i64_le(0x0102030405060708);*//** assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i64_le<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__i64__to_le_bytes(n))))))}};self}}
|
||||
/** Writes a signed 64 bit integer to `self` in native-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i64_ne(0x0102030405060708);*//** if cfg!(target_endian = "big") {*//** assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08");*//** } else {*//** assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01");*//** }*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i64_ne<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__i64__to_ne_bytes(n))))))}};self}}
|
||||
/** Writes an unsigned 128 bit integer to `self` in the big-endian byte order.*//***//** The current position is advanced by 16.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u128(0x01020304050607080910111213141516);*//** assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u128<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__u128__to_be_bytes(n))))))}};self}}
|
||||
/** Writes an unsigned 128 bit integer to `self` in little-endian byte order.*//***//** The current position is advanced by 16.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u128_le(0x01020304050607080910111213141516);*//** assert_eq!(buf, b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u128_le<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__u128__to_le_bytes(n))))))}};self}}
|
||||
/** Writes an unsigned 128 bit integer to `self` in native-endian byte order.*//***//** The current position is advanced by 16.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_u128_ne(0x01020304050607080910111213141516);*//** if cfg!(target_endian = "big") {*//** assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16");*//** } else {*//** assert_eq!(buf, b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01");*//** }*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_u128_ne<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__u128__to_ne_bytes(n))))))}};self}}
|
||||
/** Writes a signed 128 bit integer to `self` in the big-endian byte order.*//***//** The current position is advanced by 16.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i128(0x01020304050607080910111213141516);*//** assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i128<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__i128__to_be_bytes(n))))))}};self}}
|
||||
/** Writes a signed 128 bit integer to `self` in little-endian byte order.*//***//** The current position is advanced by 16.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i128_le(0x01020304050607080910111213141516);*//** assert_eq!(buf, b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i128_le<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__i128__to_le_bytes(n))))))}};self}}
|
||||
/** Writes a signed 128 bit integer to `self` in native-endian byte order.*//***//** The current position is advanced by 16.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_i128_ne(0x01020304050607080910111213141516);*//** if cfg!(target_endian = "big") {*//** assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16");*//** } else {*//** assert_eq!(buf, b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01");*//** }*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_i128_ne<Anonymous: 'unk>((mut self: Self,n: int)) -> tuple0{{let _: tuple0 = {{bytes::buf::buf_mut::f_put_slice(&mut (self),rust_primitives::unsize(&(deref(&(core::num::impl__i128__to_ne_bytes(n))))))}};self}}
|
||||
/** Writes an unsigned n-byte integer to `self` in big-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_uint(0x010203, 3);*//** assert_eq!(buf, b"\x01\x02\x03");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self` or if `nbytes` is greater than 8.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_uint<Anonymous: 'unk>((mut self: Self,n: int,nbytes: int)) -> tuple0{{let start: int = {(match (core::num::impl__usize__checked_sub(core::mem::size_of_val::<int>(&(deref(&(n)))),nbytes)) {core::option::Option_Some(start) => {start},core::option::Option_None => {rust_primitives::hax::never_to_any(bytes::panic_does_not_fit(nbytes,core::mem::size_of_val::<int>(&(deref(&(n))))))}})};{let _: tuple0 = {bytes::buf::buf_mut::f_put_slice(&mut (self),&(deref(&(deref(core::ops::index::f_index(&(core::num::impl__u64__to_be_bytes(n)),core::ops::range::RangeFrom{f_start:start,}))))))};self}}}
|
||||
/** Writes an unsigned n-byte integer to `self` in the little-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_uint_le(0x010203, 3);*//** assert_eq!(buf, b"\x03\x02\x01");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self` or if `nbytes` is greater than 8.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_uint_le<Anonymous: 'unk>((mut self: Self,n: int,nbytes: int)) -> tuple0{{let slice: [int;8] = {core::num::impl__u64__to_le_bytes(n)};{let slice: &[int] = {(match (core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(rust_primitives::unsize(&(slice)),core::ops::range::RangeTo{f_end:nbytes,})) {core::option::Option_Some(slice) => {slice},core::option::Option_None => {rust_primitives::hax::never_to_any(bytes::panic_does_not_fit(nbytes,core::slice::impl__len::<int>(rust_primitives::unsize(&(slice)))))}})};{let _: tuple0 = {bytes::buf::buf_mut::f_put_slice(&mut (self),&(deref(slice)))};self}}}}
|
||||
/** Writes an unsigned n-byte integer to `self` in the native-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_uint_ne(0x010203, 3);*//** if cfg!(target_endian = "big") {*//** assert_eq!(buf, b"\x01\x02\x03");*//** } else {*//** assert_eq!(buf, b"\x03\x02\x01");*//** }*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self` or if `nbytes` is greater than 8.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_uint_ne<Anonymous: 'unk>((mut self: Self,n: int,nbytes: int)) -> tuple0{{let _: tuple0 = {{(if false{{bytes::buf::buf_mut::f_put_uint(&mut (self),n,nbytes)}} else {{bytes::buf::buf_mut::f_put_uint_le(&mut (self),n,nbytes)}})}};self}}
|
||||
/** Writes low `nbytes` of a signed integer to `self` in big-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_int(0x0504010203, 3);*//** assert_eq!(buf, b"\x01\x02\x03");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self` or if `nbytes` is greater than 8.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_int<Anonymous: 'unk>((mut self: Self,n: int,nbytes: int)) -> tuple0{{let start: int = {(match (core::num::impl__usize__checked_sub(core::mem::size_of_val::<int>(&(deref(&(n)))),nbytes)) {core::option::Option_Some(start) => {start},core::option::Option_None => {rust_primitives::hax::never_to_any(bytes::panic_does_not_fit(nbytes,core::mem::size_of_val::<int>(&(deref(&(n))))))}})};{let _: tuple0 = {bytes::buf::buf_mut::f_put_slice(&mut (self),&(deref(&(deref(core::ops::index::f_index(&(core::num::impl__i64__to_be_bytes(n)),core::ops::range::RangeFrom{f_start:start,}))))))};self}}}
|
||||
/** Writes low `nbytes` of a signed integer to `self` in little-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_int_le(0x0504010203, 3);*//** assert_eq!(buf, b"\x03\x02\x01");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self` or if `nbytes` is greater than 8.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_int_le<Anonymous: 'unk>((mut self: Self,n: int,nbytes: int)) -> tuple0{{let slice: [int;8] = {core::num::impl__i64__to_le_bytes(n)};{let slice: &[int] = {(match (core::slice::impl__get::<int,core::ops::range::t_RangeTo<int>>(rust_primitives::unsize(&(slice)),core::ops::range::RangeTo{f_end:nbytes,})) {core::option::Option_Some(slice) => {slice},core::option::Option_None => {rust_primitives::hax::never_to_any(bytes::panic_does_not_fit(nbytes,core::slice::impl__len::<int>(rust_primitives::unsize(&(slice)))))}})};{let _: tuple0 = {bytes::buf::buf_mut::f_put_slice(&mut (self),&(deref(slice)))};self}}}}
|
||||
/** Writes low `nbytes` of a signed integer to `self` in native-endian byte order.*//***//** The current position is advanced by `nbytes`.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_int_ne(0x010203, 3);*//** if cfg!(target_endian = "big") {*//** assert_eq!(buf, b"\x01\x02\x03");*//** } else {*//** assert_eq!(buf, b"\x03\x02\x01");*//** }*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self` or if `nbytes` is greater than 8.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_int_ne<Anonymous: 'unk>((mut self: Self,n: int,nbytes: int)) -> tuple0{{let _: tuple0 = {{(if false{{bytes::buf::buf_mut::f_put_int(&mut (self),n,nbytes)}} else {{bytes::buf::buf_mut::f_put_int_le(&mut (self),n,nbytes)}})}};self}}
|
||||
/** Writes an IEEE754 single-precision (4 bytes) floating point number to*//** `self` in big-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_f32(1.2f32);*//** assert_eq!(buf, b"\x3F\x99\x99\x9A");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_f32<Anonymous: 'unk>((mut self: Self,n: float)) -> tuple0{{let _: tuple0 = {bytes::buf::buf_mut::f_put_u32(&mut (self),core::f32::impl__f32__to_bits(n))};self}}
|
||||
/** Writes an IEEE754 single-precision (4 bytes) floating point number to*//** `self` in little-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_f32_le(1.2f32);*//** assert_eq!(buf, b"\x9A\x99\x99\x3F");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_f32_le<Anonymous: 'unk>((mut self: Self,n: float)) -> tuple0{{let _: tuple0 = {bytes::buf::buf_mut::f_put_u32_le(&mut (self),core::f32::impl__f32__to_bits(n))};self}}
|
||||
/** Writes an IEEE754 single-precision (4 bytes) floating point number to*//** `self` in native-endian byte order.*//***//** The current position is advanced by 4.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_f32_ne(1.2f32);*//** if cfg!(target_endian = "big") {*//** assert_eq!(buf, b"\x3F\x99\x99\x9A");*//** } else {*//** assert_eq!(buf, b"\x9A\x99\x99\x3F");*//** }*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_f32_ne<Anonymous: 'unk>((mut self: Self,n: float)) -> tuple0{{let _: tuple0 = {bytes::buf::buf_mut::f_put_u32_ne(&mut (self),core::f32::impl__f32__to_bits(n))};self}}
|
||||
/** Writes an IEEE754 double-precision (8 bytes) floating point number to*//** `self` in big-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_f64(1.2f64);*//** assert_eq!(buf, b"\x3F\xF3\x33\x33\x33\x33\x33\x33");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_f64<Anonymous: 'unk>((mut self: Self,n: float)) -> tuple0{{let _: tuple0 = {bytes::buf::buf_mut::f_put_u64(&mut (self),core::f64::impl__f64__to_bits(n))};self}}
|
||||
/** Writes an IEEE754 double-precision (8 bytes) floating point number to*//** `self` in little-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_f64_le(1.2f64);*//** assert_eq!(buf, b"\x33\x33\x33\x33\x33\x33\xF3\x3F");*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_f64_le<Anonymous: 'unk>((mut self: Self,n: float)) -> tuple0{{let _: tuple0 = {bytes::buf::buf_mut::f_put_u64_le(&mut (self),core::f64::impl__f64__to_bits(n))};self}}
|
||||
/** Writes an IEEE754 double-precision (8 bytes) floating point number to*//** `self` in native-endian byte order.*//***//** The current position is advanced by 8.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut buf = vec![];*//** buf.put_f64_ne(1.2f64);*//** if cfg!(target_endian = "big") {*//** assert_eq!(buf, b"\x3F\xF3\x33\x33\x33\x33\x33\x33");*//** } else {*//** assert_eq!(buf, b"\x33\x33\x33\x33\x33\x33\xF3\x3F");*//** }*//** ```*//***//** # Panics*//***//** This function panics if there is not enough remaining capacity in*//** `self`.*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_put_f64_ne<Anonymous: 'unk>((mut self: Self,n: float)) -> tuple0{{let _: tuple0 = {bytes::buf::buf_mut::f_put_u64_ne(&mut (self),core::f64::impl__f64__to_bits(n))};self}}
|
||||
/** Creates an adaptor which can write at most `limit` bytes to `self`.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let arr = &mut [0u8; 128][..];*//** assert_eq!(arr.remaining_mut(), 128);*//***//** let dst = arr.limit(10);*//** assert_eq!(dst.remaining_mut(), 10);*//** ```*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_limit((self: Self,limit: int)) -> bytes::buf::limit::t_Limit<Self>{{bytes::buf::limit::new::<Self>(self,limit)}}
|
||||
/** Creates an adaptor which implements the `Write` trait for `self`.*//***//** This function returns a new value which implements `Write` by adapting*//** the `Write` trait functions to the `BufMut` trait functions. Given that*//** `BufMut` operations are infallible, none of the `Write` functions will*//** return with `Err`.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//** use std::io::Write;*//***//** let mut buf = vec![].writer();*//***//** let num = buf.write(&b"hello world"[..]).unwrap();*//** assert_eq!(11, num);*//***//** let buf = buf.into_inner();*//***//** assert_eq!(*buf, b"hello world"[..]);*//** ```*/#[cfg(feature = "std")]#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_writer((self: Self)) -> bytes::buf::writer::t_Writer<Self>{{bytes::buf::writer::new::<Self>(self)}}
|
||||
/** Creates an adapter which will chain this buffer with another.*//***//** The returned `BufMut` instance will first write to all bytes from*//** `self`. Afterwards, it will write to `next`.*//***//** # Examples*//***//** ```*//** use bytes::BufMut;*//***//** let mut a = [0u8; 5];*//** let mut b = [0u8; 6];*//***//** let mut chain = (&mut a[..]).chain_mut(&mut b[..]);*//***//** chain.put_slice(b"hello world");*//***//** assert_eq!(&a[..], b"hello");*//** assert_eq!(&b[..], b" world");*//** ```*/#[inline()]#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]#[doc(test(no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]#[no_std()]#[feature(register_tool)]#[register_tool(_hax)]fn f_chain_mut<U>((self: Self,next: U)) -> bytes::buf::chain::t_Chain<Self, U> where _: bytes::buf::buf_mut::t_BufMut<U>{{bytes::buf::chain::impl__new::<Self,U>(self,next)}}}
|
||||
|
||||
Last AST:
|
||||
/** print_rust: pitem: not implemented (item: { Concrete_ident.T.def_id =
|
||||
{ Concrete_ident.Imported.krate = "bytes";
|
||||
path =
|
||||
[{ Concrete_ident.Imported.data = (Concrete_ident.Imported.TypeNs "buf");
|
||||
disambiguator = 0 };
|
||||
{ Concrete_ident.Imported.data =
|
||||
(Concrete_ident.Imported.TypeNs "buf_mut"); disambiguator = 0 };
|
||||
{ Concrete_ident.Imported.data =
|
||||
(Concrete_ident.Imported.TypeNs "BufMut"); disambiguator = 0 }
|
||||
]
|
||||
};
|
||||
kind = Concrete_ident.Kind.Value }) */
|
||||
const _: () = ();
|
||||
*)
|
||||
|
||||
(* item error backend: (DirectAndMut) The mutation of this [1m&mut[0m is not allowed here.
|
||||
Last available AST for this item:
|
||||
|
||||
#[_hax::json("\"Erased\"")]
|
||||
#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
|
||||
#[doc(
|
||||
test(
|
||||
no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||
)
|
||||
)]
|
||||
#[no_std()]
|
||||
#[feature(register_tool)]
|
||||
#[register_tool(_hax)]
|
||||
unsafe impl<T, Anonymous: 'unk> bytes::buf::buf_mut::t_BufMut<&mut T> for &mut T
|
||||
where
|
||||
_: bytes::buf::buf_mut::t_BufMut<T>,
|
||||
{
|
||||
fn dropped_body(_: tuple0) -> tuple0 {
|
||||
Tuple0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Last AST:
|
||||
/** print_rust: pitem: not implemented (item: { Concrete_ident.T.def_id =
|
||||
{ Concrete_ident.Imported.krate = "bytes";
|
||||
path =
|
||||
[{ Concrete_ident.Imported.data = (Concrete_ident.Imported.TypeNs "buf");
|
||||
disambiguator = 0 };
|
||||
{ Concrete_ident.Imported.data =
|
||||
(Concrete_ident.Imported.TypeNs "buf_mut"); disambiguator = 0 };
|
||||
{ Concrete_ident.Imported.data = Concrete_ident.Imported.Impl;
|
||||
disambiguator = 0 }
|
||||
]
|
||||
};
|
||||
kind = Concrete_ident.Kind.Value }) */
|
||||
const _: () = ();
|
||||
*)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_1 (#v_T: Type0) {| i0: t_BufMut v_T |}
|
||||
: t_BufMut (Alloc.Boxed.t_Box v_T Alloc.Alloc.t_Global)
|
||||
|
||||
(* item error backend: (DirectAndMut) The mutation of this [1m&mut[0m is not allowed here.
|
||||
Last available AST for this item:
|
||||
|
||||
#[_hax::json("\"Erased\"")]
|
||||
#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
|
||||
#[doc(
|
||||
test(
|
||||
no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||
)
|
||||
)]
|
||||
#[no_std()]
|
||||
#[feature(register_tool)]
|
||||
#[register_tool(_hax)]
|
||||
unsafe impl<Anonymous: 'unk> bytes::buf::buf_mut::t_BufMut<&mut [int]> for &mut [int] {
|
||||
fn dropped_body(_: tuple0) -> tuple0 {
|
||||
Tuple0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Last AST:
|
||||
/** print_rust: pitem: not implemented (item: { Concrete_ident.T.def_id =
|
||||
{ Concrete_ident.Imported.krate = "bytes";
|
||||
path =
|
||||
[{ Concrete_ident.Imported.data = (Concrete_ident.Imported.TypeNs "buf");
|
||||
disambiguator = 0 };
|
||||
{ Concrete_ident.Imported.data =
|
||||
(Concrete_ident.Imported.TypeNs "buf_mut"); disambiguator = 0 };
|
||||
{ Concrete_ident.Imported.data = Concrete_ident.Imported.Impl;
|
||||
disambiguator = 2 }
|
||||
]
|
||||
};
|
||||
kind = Concrete_ident.Kind.Value }) */
|
||||
const _: () = ();
|
||||
*)
|
||||
|
||||
(* item error backend: (DirectAndMut) The mutation of this [1m&mut[0m is not allowed here.
|
||||
Last available AST for this item:
|
||||
|
||||
#[_hax::json("\"Erased\"")]
|
||||
#[warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
|
||||
#[doc(
|
||||
test(
|
||||
no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||
)
|
||||
)]
|
||||
#[no_std()]
|
||||
#[feature(register_tool)]
|
||||
#[register_tool(_hax)]
|
||||
unsafe impl<
|
||||
Anonymous: 'unk,
|
||||
> bytes::buf::buf_mut::t_BufMut<&mut [core::mem::maybe_uninit::t_MaybeUninit<int>]>
|
||||
for &mut [core::mem::maybe_uninit::t_MaybeUninit<int>] {
|
||||
fn dropped_body(_: tuple0) -> tuple0 {
|
||||
Tuple0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Last AST:
|
||||
/** print_rust: pitem: not implemented (item: { Concrete_ident.T.def_id =
|
||||
{ Concrete_ident.Imported.krate = "bytes";
|
||||
path =
|
||||
[{ Concrete_ident.Imported.data = (Concrete_ident.Imported.TypeNs "buf");
|
||||
disambiguator = 0 };
|
||||
{ Concrete_ident.Imported.data =
|
||||
(Concrete_ident.Imported.TypeNs "buf_mut"); disambiguator = 0 };
|
||||
{ Concrete_ident.Imported.data = Concrete_ident.Imported.Impl;
|
||||
disambiguator = 3 }
|
||||
]
|
||||
};
|
||||
kind = Concrete_ident.Kind.Value }) */
|
||||
const _: () = ();
|
||||
*)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_4:t_BufMut (Alloc.Vec.t_Vec u8 Alloc.Alloc.t_Global)
|
||||
|
||||
val v__assert_trait_object (v__b: dyn 1 (fun z -> t_BufMut z))
|
||||
: Prims.Pure Prims.unit Prims.l_True (fun _ -> Prims.l_True)
|
||||
@@ -0,0 +1,96 @@
|
||||
module Libcrux_hmac
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
/// The HMAC algorithm defining the used hash function.
|
||||
type t_Algorithm =
|
||||
| Algorithm_Sha1 : t_Algorithm
|
||||
| Algorithm_Sha256 : t_Algorithm
|
||||
| Algorithm_Sha384 : t_Algorithm
|
||||
| Algorithm_Sha512 : t_Algorithm
|
||||
|
||||
val t_Algorithm_cast_to_repr (x: t_Algorithm)
|
||||
: Prims.Pure isize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_1:Core_models.Clone.t_Clone t_Algorithm
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl:Core_models.Marker.t_Copy t_Algorithm
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_2:Core_models.Fmt.t_Debug t_Algorithm
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_3:Core_models.Marker.t_StructuralPartialEq t_Algorithm
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_4:Core_models.Cmp.t_PartialEq t_Algorithm t_Algorithm
|
||||
|
||||
/// Get the tag size for a given algorithm.
|
||||
val tag_size (alg: t_Algorithm) : Prims.Pure usize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Compute the HMAC value with the given `alg` and `key` on `data` with an
|
||||
/// output tag length of `tag_length`.
|
||||
/// Returns a vector of length `tag_length`.
|
||||
/// Panics if either `key` or `data` are longer than `u32::MAX`.
|
||||
val hmac (alg: t_Algorithm) (key data: t_Slice u8) (tag_length: Core_models.Option.t_Option usize)
|
||||
: Prims.Pure (Alloc.Vec.t_Vec u8 Alloc.Alloc.t_Global)
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:Alloc.Vec.t_Vec u8 Alloc.Alloc.t_Global = result in
|
||||
let native_tag_length:usize =
|
||||
match alg <: t_Algorithm with
|
||||
| Algorithm_Sha1 -> mk_usize 20
|
||||
| Algorithm_Sha256 -> mk_usize 32
|
||||
| Algorithm_Sha384 -> mk_usize 48
|
||||
| Algorithm_Sha512 -> mk_usize 64
|
||||
in
|
||||
match
|
||||
(match tag_length <: Core_models.Option.t_Option usize with
|
||||
| Core_models.Option.Option_Some l ->
|
||||
(match l <=. native_tag_length <: bool with
|
||||
| true ->
|
||||
Core_models.Option.Option_Some
|
||||
((Alloc.Vec.impl_1__len #u8 #Alloc.Alloc.t_Global result <: usize) =. l)
|
||||
<:
|
||||
Core_models.Option.t_Option bool
|
||||
| _ -> Core_models.Option.Option_None <: Core_models.Option.t_Option bool)
|
||||
| _ -> Core_models.Option.Option_None <: Core_models.Option.t_Option bool)
|
||||
<:
|
||||
Core_models.Option.t_Option bool
|
||||
with
|
||||
| Core_models.Option.Option_Some x -> x
|
||||
| Core_models.Option.Option_None ->
|
||||
(Alloc.Vec.impl_1__len #u8 #Alloc.Alloc.t_Global result <: usize) =. native_tag_length)
|
||||
|
||||
(* item error backend: (DirectAndMut) The mutation of this [1m&mut[0m is not allowed here.
|
||||
Last available AST for this item:
|
||||
|
||||
#[_hax::json("\"Erased\"")]
|
||||
#[inline(always)]
|
||||
#[no_std()]
|
||||
#[feature(register_tool)]
|
||||
#[register_tool(_hax)]
|
||||
fn wrap_bufalloc<const N: int, F>(f: F) -> alloc::vec::t_Vec<int, alloc::alloc::t_Global>
|
||||
where
|
||||
_: core_models::ops::function::t_Fn<F, tuple1<&mut [int; N]>>,
|
||||
F: core_models::ops::function::t_FnOnce<f_Output = tuple0>,
|
||||
{
|
||||
rust_primitives::hax::dropped_body
|
||||
}
|
||||
|
||||
|
||||
Last AST:
|
||||
/** print_rust: pitem: not implemented (item: { Concrete_ident.T.def_id =
|
||||
{ Concrete_ident.Imported.krate = "libcrux_hmac";
|
||||
path =
|
||||
[{ Concrete_ident.Imported.data =
|
||||
(Concrete_ident.Imported.ValueNs "wrap_bufalloc"); disambiguator = 0 }
|
||||
]
|
||||
};
|
||||
kind = Concrete_ident.Kind.Value }) */
|
||||
const _: () = ();
|
||||
*)
|
||||
@@ -0,0 +1,39 @@
|
||||
module Libcrux_ml_kem.Constants
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
/// Each field element needs floor(log_2(FIELD_MODULUS)) + 1 = 12 bits to represent
|
||||
let v_BITS_PER_COEFFICIENT: usize = mk_usize 12
|
||||
|
||||
/// Coefficients per ring element
|
||||
let v_COEFFICIENTS_IN_RING_ELEMENT: usize = mk_usize 256
|
||||
|
||||
/// Bits required per (uncompressed) ring element
|
||||
let v_BITS_PER_RING_ELEMENT: usize = v_COEFFICIENTS_IN_RING_ELEMENT *! mk_usize 12
|
||||
|
||||
/// Bytes required per (uncompressed) ring element
|
||||
let v_BYTES_PER_RING_ELEMENT: usize = v_BITS_PER_RING_ELEMENT /! mk_usize 8
|
||||
|
||||
/// The size of an ML-KEM shared secret.
|
||||
let v_SHARED_SECRET_SIZE: usize = mk_usize 32
|
||||
|
||||
let v_CPA_PKE_KEY_GENERATION_SEED_SIZE: usize = mk_usize 32
|
||||
|
||||
/// SHA3 256 digest size
|
||||
let v_H_DIGEST_SIZE: usize = mk_usize 32
|
||||
|
||||
/// SHA3 512 digest size
|
||||
let v_G_DIGEST_SIZE: usize = mk_usize 64
|
||||
|
||||
/// K * BITS_PER_RING_ELEMENT / 8
|
||||
/// [eurydice] Note that we can\'t use const generics here because that breaks
|
||||
/// C extraction with eurydice.
|
||||
let ranked_bytes_per_ring_element (rank: usize)
|
||||
: Prims.Pure usize
|
||||
(requires rank <=. mk_usize 4)
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:usize = result in
|
||||
result =. ((rank *! v_BITS_PER_RING_ELEMENT <: usize) /! mk_usize 8 <: usize)) =
|
||||
(rank *! v_BITS_PER_RING_ELEMENT <: usize) /! mk_usize 8
|
||||
@@ -0,0 +1,57 @@
|
||||
module Libcrux_ml_kem.Hash_functions.Portable
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
/// The state.
|
||||
/// It\'s only used for SHAKE128.
|
||||
/// All other functions don\'t actually use any members.
|
||||
val t_PortableHash (v_K: usize) : eqtype
|
||||
|
||||
val v_G (input: t_Slice u8)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 64))
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array u8 (mk_usize 64) = result in
|
||||
result == Spec.Utils.v_G input)
|
||||
|
||||
val v_H (input: t_Slice u8)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 32))
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array u8 (mk_usize 32) = result in
|
||||
result == Spec.Utils.v_H input)
|
||||
|
||||
val v_PRF (v_LEN: usize) (input: t_Slice u8)
|
||||
: Prims.Pure (t_Array u8 v_LEN)
|
||||
(requires v v_LEN < pow2 32)
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array u8 v_LEN = result in
|
||||
result == Spec.Utils.v_PRF v_LEN input)
|
||||
|
||||
val v_PRFxN (v_K v_LEN: usize) (input: t_Array (t_Array u8 (mk_usize 33)) v_K)
|
||||
: Prims.Pure (t_Array (t_Array u8 v_LEN) v_K)
|
||||
(requires v v_LEN < pow2 32 /\ (v v_K == 2 \/ v v_K == 3 \/ v v_K == 4))
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array (t_Array u8 v_LEN) v_K = result in
|
||||
result == Spec.Utils.v_PRFxN v_K v_LEN input)
|
||||
|
||||
val shake128_init_absorb_final (v_K: usize) (input: t_Array (t_Array u8 (mk_usize 34)) v_K)
|
||||
: Prims.Pure (t_PortableHash v_K) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val shake128_squeeze_first_three_blocks (v_K: usize) (st: t_PortableHash v_K)
|
||||
: Prims.Pure (t_PortableHash v_K & t_Array (t_Array u8 (mk_usize 504)) v_K)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val shake128_squeeze_next_block (v_K: usize) (st: t_PortableHash v_K)
|
||||
: Prims.Pure (t_PortableHash v_K & t_Array (t_Array u8 (mk_usize 168)) v_K)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl (v_K: usize) : Libcrux_ml_kem.Hash_functions.t_Hash (t_PortableHash v_K) v_K
|
||||
@@ -0,0 +1,72 @@
|
||||
module Libcrux_ml_kem.Hash_functions
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
/// The SHA3 block size.
|
||||
let v_BLOCK_SIZE: usize = mk_usize 168
|
||||
|
||||
/// The size of 3 SHA3 blocks.
|
||||
let v_THREE_BLOCKS: usize = v_BLOCK_SIZE *! mk_usize 3
|
||||
|
||||
/// Abstraction for the hashing, to pick the fastest version depending on the
|
||||
/// platform features available.
|
||||
/// There are 3 instantiations of this trait right now, using the libcrux-sha3 crate.
|
||||
/// - AVX2
|
||||
/// - NEON
|
||||
/// - Portable
|
||||
class t_Hash (v_Self: Type0) (v_K: usize) = {
|
||||
f_G_pre:input: t_Slice u8 -> pred: Type0{true ==> pred};
|
||||
f_G_post:input: t_Slice u8 -> result: t_Array u8 (mk_usize 64)
|
||||
-> pred: Type0{pred ==> result == Spec.Utils.v_G input};
|
||||
f_G:x0: t_Slice u8
|
||||
-> Prims.Pure (t_Array u8 (mk_usize 64)) (f_G_pre x0) (fun result -> f_G_post x0 result);
|
||||
f_H_pre:input: t_Slice u8 -> pred: Type0{true ==> pred};
|
||||
f_H_post:input: t_Slice u8 -> result: t_Array u8 (mk_usize 32)
|
||||
-> pred: Type0{pred ==> result == Spec.Utils.v_H input};
|
||||
f_H:x0: t_Slice u8
|
||||
-> Prims.Pure (t_Array u8 (mk_usize 32)) (f_H_pre x0) (fun result -> f_H_post x0 result);
|
||||
f_PRF_pre:v_LEN: usize -> input: t_Slice u8 -> pred: Type0{v v_LEN < pow2 32 ==> pred};
|
||||
f_PRF_post:v_LEN: usize -> input: t_Slice u8 -> result: t_Array u8 v_LEN
|
||||
-> pred: Type0{pred ==> v v_LEN < pow2 32 ==> result == Spec.Utils.v_PRF v_LEN input};
|
||||
f_PRF:v_LEN: usize -> x0: t_Slice u8
|
||||
-> Prims.Pure (t_Array u8 v_LEN) (f_PRF_pre v_LEN x0) (fun result -> f_PRF_post v_LEN x0 result);
|
||||
f_PRFxN_pre:v_LEN: usize -> input: t_Array (t_Array u8 (mk_usize 33)) v_K
|
||||
-> pred: Type0{v v_LEN < pow2 32 /\ (v v_K == 2 \/ v v_K == 3 \/ v v_K == 4) ==> pred};
|
||||
f_PRFxN_post:
|
||||
v_LEN: usize ->
|
||||
input: t_Array (t_Array u8 (mk_usize 33)) v_K ->
|
||||
result: t_Array (t_Array u8 v_LEN) v_K
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
(v v_LEN < pow2 32 /\ (v v_K == 2 \/ v v_K == 3 \/ v v_K == 4)) ==>
|
||||
result == Spec.Utils.v_PRFxN v_K v_LEN input };
|
||||
f_PRFxN:v_LEN: usize -> x0: t_Array (t_Array u8 (mk_usize 33)) v_K
|
||||
-> Prims.Pure (t_Array (t_Array u8 v_LEN) v_K)
|
||||
(f_PRFxN_pre v_LEN x0)
|
||||
(fun result -> f_PRFxN_post v_LEN x0 result);
|
||||
f_shake128_init_absorb_final_pre:input: t_Array (t_Array u8 (mk_usize 34)) v_K
|
||||
-> pred: Type0{true ==> pred};
|
||||
f_shake128_init_absorb_final_post:t_Array (t_Array u8 (mk_usize 34)) v_K -> v_Self -> Type0;
|
||||
f_shake128_init_absorb_final:x0: t_Array (t_Array u8 (mk_usize 34)) v_K
|
||||
-> Prims.Pure v_Self
|
||||
(f_shake128_init_absorb_final_pre x0)
|
||||
(fun result -> f_shake128_init_absorb_final_post x0 result);
|
||||
f_shake128_squeeze_first_three_blocks_pre:self_: v_Self -> pred: Type0{true ==> pred};
|
||||
f_shake128_squeeze_first_three_blocks_post:
|
||||
v_Self ->
|
||||
(v_Self & t_Array (t_Array u8 (mk_usize 504)) v_K)
|
||||
-> Type0;
|
||||
f_shake128_squeeze_first_three_blocks:x0: v_Self
|
||||
-> Prims.Pure (v_Self & t_Array (t_Array u8 (mk_usize 504)) v_K)
|
||||
(f_shake128_squeeze_first_three_blocks_pre x0)
|
||||
(fun result -> f_shake128_squeeze_first_three_blocks_post x0 result);
|
||||
f_shake128_squeeze_next_block_pre:self_: v_Self -> pred: Type0{true ==> pred};
|
||||
f_shake128_squeeze_next_block_post:v_Self -> (v_Self & t_Array (t_Array u8 (mk_usize 168)) v_K)
|
||||
-> Type0;
|
||||
f_shake128_squeeze_next_block:x0: v_Self
|
||||
-> Prims.Pure (v_Self & t_Array (t_Array u8 (mk_usize 168)) v_K)
|
||||
(f_shake128_squeeze_next_block_pre x0)
|
||||
(fun result -> f_shake128_squeeze_next_block_post x0 result)
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
module Libcrux_ml_kem.Ind_cca.Incremental.Types
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
let _ =
|
||||
(* This module has implicit dependencies, here we make them explicit. *)
|
||||
(* The implicit dependencies arise from typeclasses instances. *)
|
||||
let open Libcrux_ml_kem.Ind_cpa.Unpacked in
|
||||
let open Libcrux_ml_kem.Vector.Traits in
|
||||
()
|
||||
|
||||
/// Errors
|
||||
type t_Error =
|
||||
| Error_InvalidInputLength : t_Error
|
||||
| Error_InvalidOutputLength : t_Error
|
||||
| Error_InvalidPublicKey : t_Error
|
||||
| Error_InsufficientRandomness : t_Error
|
||||
|
||||
val t_Error_cast_to_repr (x: t_Error) : Prims.Pure isize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_15:Core_models.Fmt.t_Debug t_Error
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_16:Core_models.Clone.t_Clone t_Error
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_17:Core_models.Marker.t_Copy t_Error
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_18:Core_models.Marker.t_StructuralPartialEq t_Error
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_19:Core_models.Cmp.t_PartialEq t_Error t_Error
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_20:Core_models.Cmp.t_Eq t_Error
|
||||
|
||||
/// Incremental trait for unpacked key pairs.
|
||||
class t_IncrementalKeyPair (v_Self: Type0) = {
|
||||
f_pk1_bytes_pre:v_Self -> t_Slice u8 -> Type0;
|
||||
f_pk1_bytes_post:v_Self -> t_Slice u8 -> (t_Slice u8 & Core_models.Result.t_Result Prims.unit t_Error)
|
||||
-> Type0;
|
||||
f_pk1_bytes:x0: v_Self -> x1: t_Slice u8
|
||||
-> Prims.Pure (t_Slice u8 & Core_models.Result.t_Result Prims.unit t_Error)
|
||||
(f_pk1_bytes_pre x0 x1)
|
||||
(fun result -> f_pk1_bytes_post x0 x1 result);
|
||||
f_pk2_bytes_pre:v_Self -> t_Slice u8 -> Type0;
|
||||
f_pk2_bytes_post:v_Self -> t_Slice u8 -> t_Slice u8 -> Type0;
|
||||
f_pk2_bytes:x0: v_Self -> x1: t_Slice u8
|
||||
-> Prims.Pure (t_Slice u8) (f_pk2_bytes_pre x0 x1) (fun result -> f_pk2_bytes_post x0 x1 result)
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
: t_IncrementalKeyPair (Libcrux_ml_kem.Ind_cca.Unpacked.t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
|
||||
/// The incremental public key that allows generating [`Ciphertext1`].
|
||||
type t_PublicKey1 = {
|
||||
f_seed:t_Array u8 (mk_usize 32);
|
||||
f_hash:t_Array u8 (mk_usize 32)
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_21:Core_models.Default.t_Default t_PublicKey1
|
||||
|
||||
/// Get the size of the first public key in bytes.
|
||||
val impl_PublicKey1__len: Prims.unit -> Prims.Pure usize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_2: Core_models.Convert.t_TryFrom t_PublicKey1 (t_Slice u8) =
|
||||
{
|
||||
f_Error = t_Error;
|
||||
f_try_from_pre = (fun (value: t_Slice u8) -> true);
|
||||
f_try_from_post
|
||||
=
|
||||
(fun (value: t_Slice u8) (out: Core_models.Result.t_Result t_PublicKey1 t_Error) -> true);
|
||||
f_try_from
|
||||
=
|
||||
fun (value: t_Slice u8) ->
|
||||
if (Core_models.Slice.impl__len #u8 value <: usize) <. mk_usize 64
|
||||
then
|
||||
Core_models.Result.Result_Err (Error_InvalidInputLength <: t_Error)
|
||||
<:
|
||||
Core_models.Result.t_Result t_PublicKey1 t_Error
|
||||
else
|
||||
let seed:t_Array u8 (mk_usize 32) = Rust_primitives.Hax.repeat (mk_u8 0) (mk_usize 32) in
|
||||
let seed:t_Array u8 (mk_usize 32) =
|
||||
Core_models.Slice.impl__copy_from_slice #u8
|
||||
seed
|
||||
(value.[ { Core_models.Ops.Range.f_start = mk_usize 0; Core_models.Ops.Range.f_end = mk_usize 32 }
|
||||
<:
|
||||
Core_models.Ops.Range.t_Range usize ]
|
||||
<:
|
||||
t_Slice u8)
|
||||
in
|
||||
let hash:t_Array u8 (mk_usize 32) = Rust_primitives.Hax.repeat (mk_u8 0) (mk_usize 32) in
|
||||
let hash:t_Array u8 (mk_usize 32) =
|
||||
Core_models.Slice.impl__copy_from_slice #u8
|
||||
hash
|
||||
(value.[ { Core_models.Ops.Range.f_start = mk_usize 32; Core_models.Ops.Range.f_end = mk_usize 64 }
|
||||
<:
|
||||
Core_models.Ops.Range.t_Range usize ]
|
||||
<:
|
||||
t_Slice u8)
|
||||
in
|
||||
Core_models.Result.Result_Ok ({ f_seed = seed; f_hash = hash } <: t_PublicKey1)
|
||||
<:
|
||||
Core_models.Result.t_Result t_PublicKey1 t_Error
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_3:Core_models.Convert.t_From t_PublicKey1 (t_Array u8 (mk_usize 64))
|
||||
|
||||
/// The incremental public key that allows generating [`Ciphertext2`].
|
||||
/// This public key is serialized to safe bytes on the wire.
|
||||
type t_PublicKey2 (v_LEN: usize) = { f_tt_as_ntt:t_Array u8 v_LEN }
|
||||
|
||||
/// Get the size of the second public key in bytes.
|
||||
val impl_4__len: v_LEN: usize -> Prims.unit -> Prims.Pure usize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Deserialize the public key.
|
||||
val impl_4__deserialize
|
||||
(v_LEN v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_PublicKey2 v_LEN)
|
||||
: Prims.Pure (t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// The partial ciphertext c1 - first part.
|
||||
type t_Ciphertext1 (v_LEN: usize) = { f_value:t_Array u8 v_LEN }
|
||||
|
||||
/// The size of the ciphertext.
|
||||
val impl_5__len: v_LEN: usize -> Prims.unit -> Prims.Pure usize Prims.l_True
|
||||
(ensures fun res -> let res:usize = res in res =. v_LEN)
|
||||
|
||||
/// The partial ciphertext c2 - second part.
|
||||
type t_Ciphertext2 (v_LEN: usize) = { f_value:t_Array u8 v_LEN }
|
||||
|
||||
/// The size of the ciphertext.
|
||||
val impl_6__len: v_LEN: usize -> Prims.unit -> Prims.Pure usize Prims.l_True
|
||||
(ensures fun res -> let res:usize = res in res =. v_LEN)
|
||||
|
||||
/// The incremental state for encapsulate.
|
||||
type t_EncapsState
|
||||
(v_K: usize) (v_Vector: Type0) {| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
= {
|
||||
f_r_as_ntt:t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K;
|
||||
f_error2:Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector;
|
||||
f_randomness:t_Array u8 (mk_usize 32)
|
||||
}
|
||||
|
||||
/// Get the number of bytes, required for the state.
|
||||
val impl_7__num_bytes:
|
||||
v_K: usize ->
|
||||
#v_Vector: Type0 ->
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |} ->
|
||||
Prims.unit
|
||||
-> Prims.Pure usize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Get the state as bytes
|
||||
val impl_7__to_bytes
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_EncapsState v_K v_Vector)
|
||||
(state: t_Slice u8)
|
||||
: Prims.Pure (t_Slice u8 & Core_models.Result.t_Result Prims.unit t_Error)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Build a state from bytes
|
||||
val impl_7__try_from_bytes
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(bytes: t_Slice u8)
|
||||
: Prims.Pure (Core_models.Result.t_Result (t_EncapsState v_K v_Vector) t_Error)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Build a state from bytes
|
||||
val impl_7__from_bytes
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
(v_STATE_LEN: usize)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(bytes: t_Array u8 v_STATE_LEN)
|
||||
: Prims.Pure (t_EncapsState v_K v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Convert [`MlKemPublicKeyUnpacked`] to a [`PublicKey1`]
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_8
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
: Core_models.Convert.t_From t_PublicKey1
|
||||
(Libcrux_ml_kem.Ind_cca.Unpacked.t_MlKemPublicKeyUnpacked v_K v_Vector)
|
||||
|
||||
/// Convert [`MlKemPublicKeyUnpacked`] to a [`PublicKey2`].
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_9
|
||||
(v_K v_LEN: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
: Core_models.Convert.t_From (t_PublicKey2 v_LEN)
|
||||
(Libcrux_ml_kem.Ind_cca.Unpacked.t_MlKemPublicKeyUnpacked v_K v_Vector)
|
||||
|
||||
/// Convert a byte slice `&[u8]` to a [`PublicKey2`].
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_10 (v_LEN: usize) : Core_models.Convert.t_TryFrom (t_PublicKey2 v_LEN) (t_Slice u8) =
|
||||
{
|
||||
f_Error = t_Error;
|
||||
f_try_from_pre = (fun (value: t_Slice u8) -> true);
|
||||
f_try_from_post
|
||||
=
|
||||
(fun (value: t_Slice u8) (out: Core_models.Result.t_Result (t_PublicKey2 v_LEN) t_Error) -> true);
|
||||
f_try_from
|
||||
=
|
||||
fun (value: t_Slice u8) ->
|
||||
if (Core_models.Slice.impl__len #u8 value <: usize) <. v_LEN
|
||||
then
|
||||
Core_models.Result.Result_Err (Error_InvalidInputLength <: t_Error)
|
||||
<:
|
||||
Core_models.Result.t_Result (t_PublicKey2 v_LEN) t_Error
|
||||
else
|
||||
let tt_as_ntt:t_Array u8 v_LEN = Rust_primitives.Hax.repeat (mk_u8 0) v_LEN in
|
||||
let tt_as_ntt:t_Array u8 v_LEN =
|
||||
Core_models.Slice.impl__copy_from_slice #u8
|
||||
tt_as_ntt
|
||||
(value.[ { Core_models.Ops.Range.f_start = mk_usize 0; Core_models.Ops.Range.f_end = v_LEN }
|
||||
<:
|
||||
Core_models.Ops.Range.t_Range usize ]
|
||||
<:
|
||||
t_Slice u8)
|
||||
in
|
||||
Core_models.Result.Result_Ok ({ f_tt_as_ntt = tt_as_ntt } <: t_PublicKey2 v_LEN)
|
||||
<:
|
||||
Core_models.Result.t_Result (t_PublicKey2 v_LEN) t_Error
|
||||
}
|
||||
|
||||
/// Convert bytes `&[u8; LEN]` to a [`PublicKey2`].
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_11 (v_LEN: usize) : Core_models.Convert.t_From (t_PublicKey2 v_LEN) (t_Array u8 v_LEN)
|
||||
|
||||
type t_KeyPair
|
||||
(v_K: usize) (v_PK2_LEN: usize) (v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
= {
|
||||
f_pk1:t_PublicKey1;
|
||||
f_pk2:t_PublicKey2 v_PK2_LEN;
|
||||
f_sk:Libcrux_ml_kem.Ind_cca.Unpacked.t_MlKemPrivateKeyUnpacked v_K v_Vector;
|
||||
f_matrix:t_Array (t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K) v_K
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_12
|
||||
(v_K v_PK2_LEN: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
: Core_models.Convert.t_From (t_KeyPair v_K v_PK2_LEN v_Vector)
|
||||
(Libcrux_ml_kem.Ind_cca.Unpacked.t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_13
|
||||
(v_K v_PK2_LEN: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
: Core_models.Convert.t_From (Libcrux_ml_kem.Ind_cca.Unpacked.t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
(t_KeyPair v_K v_PK2_LEN v_Vector)
|
||||
|
||||
/// Write `value` into `out` at `offset`.
|
||||
val write (out value: t_Slice u8) (offset: usize)
|
||||
: Prims.Pure (t_Slice u8 & usize) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Get [`PublicKey1`] as bytes.
|
||||
val impl_14__pk1_bytes
|
||||
(v_K v_PK2_LEN: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_KeyPair v_K v_PK2_LEN v_Vector)
|
||||
(pk1: t_Slice u8)
|
||||
: Prims.Pure (t_Slice u8 & Core_models.Result.t_Result Prims.unit t_Error)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Get [`PublicKey2`] as bytes.
|
||||
val impl_14__pk2_bytes
|
||||
(v_K v_PK2_LEN: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_KeyPair v_K v_PK2_LEN v_Vector)
|
||||
(pk2: t_Slice u8)
|
||||
: Prims.Pure (t_Slice u8 & Core_models.Result.t_Result Prims.unit t_Error)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// The byte size of this key pair.
|
||||
val impl_14__num_bytes:
|
||||
v_K: usize ->
|
||||
v_PK2_LEN: usize ->
|
||||
#v_Vector: Type0 ->
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |} ->
|
||||
Prims.unit
|
||||
-> Prims.Pure usize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Write this key pair into the `key` bytes.
|
||||
/// `key` must be at least of length `num_bytes()`
|
||||
val impl_14__to_bytes
|
||||
(v_K v_PK2_LEN: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_KeyPair v_K v_PK2_LEN v_Vector)
|
||||
(key: t_Slice u8)
|
||||
: Prims.Pure (t_Slice u8 & Core_models.Result.t_Result Prims.unit t_Error)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Write this key pair into the `key` bytes.
|
||||
/// This is the compressed private key.
|
||||
/// `key` must be at least of length secret key size
|
||||
/// Layout: dk | ek | H(ek) | z
|
||||
val impl_14__to_bytes_compressed
|
||||
(v_K v_PK2_LEN: usize)
|
||||
(#v_Vector: Type0)
|
||||
(v_KEY_SIZE v_VEC_SIZE: usize)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_KeyPair v_K v_PK2_LEN v_Vector)
|
||||
(key: t_Array u8 v_KEY_SIZE)
|
||||
: Prims.Pure (t_Array u8 v_KEY_SIZE) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Read a key pair from the `key` bytes.
|
||||
/// `key` must be at least of length `num_bytes()`
|
||||
val impl_14__from_bytes
|
||||
(v_K v_PK2_LEN: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(key: t_Slice u8)
|
||||
: Prims.Pure (Core_models.Result.t_Result (t_KeyPair v_K v_PK2_LEN v_Vector) t_Error)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
@@ -0,0 +1,446 @@
|
||||
module Libcrux_ml_kem.Ind_cca.Unpacked
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
let _ =
|
||||
(* This module has implicit dependencies, here we make them explicit. *)
|
||||
(* The implicit dependencies arise from typeclasses instances. *)
|
||||
let open Libcrux_ml_kem.Hash_functions in
|
||||
let open Libcrux_ml_kem.Hash_functions.Portable in
|
||||
let open Libcrux_ml_kem.Ind_cpa.Unpacked in
|
||||
let open Libcrux_ml_kem.Polynomial in
|
||||
let open Libcrux_ml_kem.Types in
|
||||
let open Libcrux_ml_kem.Variant in
|
||||
let open Libcrux_ml_kem.Vector.Traits in
|
||||
()
|
||||
|
||||
/// An unpacked ML-KEM IND-CCA Private Key
|
||||
type t_MlKemPrivateKeyUnpacked
|
||||
(v_K: usize) (v_Vector: Type0) {| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
= {
|
||||
f_ind_cpa_private_key:Libcrux_ml_kem.Ind_cpa.Unpacked.t_IndCpaPrivateKeyUnpacked v_K v_Vector;
|
||||
f_implicit_rejection_value:t_Array u8 (mk_usize 32)
|
||||
}
|
||||
|
||||
/// An unpacked ML-KEM IND-CCA Private Key
|
||||
type t_MlKemPublicKeyUnpacked
|
||||
(v_K: usize) (v_Vector: Type0) {| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
= {
|
||||
f_ind_cpa_public_key:Libcrux_ml_kem.Ind_cpa.Unpacked.t_IndCpaPublicKeyUnpacked v_K v_Vector;
|
||||
f_public_key_hash:t_Array u8 (mk_usize 32)
|
||||
}
|
||||
|
||||
let impl_2
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
(#[FStar.Tactics.Typeclasses.tcresolve ()] i1: Core_models.Clone.t_Clone v_Vector)
|
||||
(#[FStar.Tactics.Typeclasses.tcresolve ()]
|
||||
i2:
|
||||
Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector)
|
||||
: Core_models.Clone.t_Clone (t_MlKemPublicKeyUnpacked v_K v_Vector) = { f_clone = (fun x -> x); f_clone_pre = (fun _ -> True); f_clone_post = (fun _ _ -> True) }
|
||||
|
||||
/// An unpacked ML-KEM KeyPair
|
||||
type t_MlKemKeyPairUnpacked
|
||||
(v_K: usize) (v_Vector: Type0) {| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
= {
|
||||
f_private_key:t_MlKemPrivateKeyUnpacked v_K v_Vector;
|
||||
f_public_key:t_MlKemPublicKeyUnpacked v_K v_Vector
|
||||
}
|
||||
|
||||
/// Generate an unpacked key from a serialized key.
|
||||
val unpack_public_key
|
||||
(v_K v_T_AS_NTT_ENCODED_SIZE v_PUBLIC_KEY_SIZE: usize)
|
||||
(#v_Hasher #v_Vector: Type0)
|
||||
{| i2: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |}
|
||||
{| i3: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(public_key: Libcrux_ml_kem.Types.t_MlKemPublicKey v_PUBLIC_KEY_SIZE)
|
||||
(unpacked_public_key: t_MlKemPublicKeyUnpacked v_K v_Vector)
|
||||
: Prims.Pure (t_MlKemPublicKeyUnpacked v_K v_Vector)
|
||||
(requires
|
||||
Spec.MLKEM.is_rank v_K /\ v_PUBLIC_KEY_SIZE == Spec.MLKEM.v_CPA_PUBLIC_KEY_SIZE v_K /\
|
||||
v_T_AS_NTT_ENCODED_SIZE == Spec.MLKEM.v_T_AS_NTT_ENCODED_SIZE v_K)
|
||||
(ensures
|
||||
fun unpacked_public_key_future ->
|
||||
let unpacked_public_key_future:t_MlKemPublicKeyUnpacked v_K v_Vector =
|
||||
unpacked_public_key_future
|
||||
in
|
||||
let unpacked_public_key_future:t_MlKemPublicKeyUnpacked v_K v_Vector =
|
||||
unpacked_public_key_future
|
||||
in
|
||||
let public_key_hash, (seed, (deserialized_pk, (matrix_A, valid))) =
|
||||
Spec.MLKEM.ind_cca_unpack_public_key v_K public_key.f_value
|
||||
in
|
||||
(valid ==>
|
||||
Libcrux_ml_kem.Polynomial.to_spec_matrix_t #v_K
|
||||
#v_Vector
|
||||
unpacked_public_key_future.f_ind_cpa_public_key.Libcrux_ml_kem.Ind_cpa.Unpacked.f_A ==
|
||||
matrix_A) /\
|
||||
Libcrux_ml_kem.Polynomial.to_spec_vector_t #v_K
|
||||
#v_Vector
|
||||
unpacked_public_key_future.f_ind_cpa_public_key
|
||||
.Libcrux_ml_kem.Ind_cpa.Unpacked.f_tt_as_ntt ==
|
||||
deserialized_pk /\
|
||||
unpacked_public_key_future.f_ind_cpa_public_key
|
||||
.Libcrux_ml_kem.Ind_cpa.Unpacked.f_seed_for_A ==
|
||||
seed /\ unpacked_public_key_future.f_public_key_hash == public_key_hash)
|
||||
|
||||
/// Get the serialized public key.
|
||||
val impl_3__serialized_mut
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
(v_PUBLIC_KEY_SIZE: usize)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_MlKemPublicKeyUnpacked v_K v_Vector)
|
||||
(serialized: Libcrux_ml_kem.Types.t_MlKemPublicKey v_PUBLIC_KEY_SIZE)
|
||||
: Prims.Pure (Libcrux_ml_kem.Types.t_MlKemPublicKey v_PUBLIC_KEY_SIZE)
|
||||
(requires
|
||||
(let self = self in
|
||||
Spec.MLKEM.is_rank v_K /\ v_PUBLIC_KEY_SIZE == Spec.MLKEM.v_CPA_PUBLIC_KEY_SIZE v_K /\
|
||||
(forall (i: nat).
|
||||
i < v v_K ==>
|
||||
Libcrux_ml_kem.Serialize.coefficients_field_modulus_range (Seq.index self
|
||||
.f_ind_cpa_public_key
|
||||
.Libcrux_ml_kem.Ind_cpa.Unpacked.f_tt_as_ntt
|
||||
i))))
|
||||
(ensures
|
||||
fun serialized_future ->
|
||||
let serialized_future:Libcrux_ml_kem.Types.t_MlKemPublicKey v_PUBLIC_KEY_SIZE =
|
||||
serialized_future
|
||||
in
|
||||
let self = self in
|
||||
serialized_future.f_value ==
|
||||
Seq.append (Spec.MLKEM.vector_encode_12 #v_K
|
||||
(Libcrux_ml_kem.Polynomial.to_spec_vector_t #v_K
|
||||
#v_Vector
|
||||
self.f_ind_cpa_public_key.Libcrux_ml_kem.Ind_cpa.Unpacked.f_tt_as_ntt))
|
||||
self.f_ind_cpa_public_key.Libcrux_ml_kem.Ind_cpa.Unpacked.f_seed_for_A)
|
||||
|
||||
/// Get the serialized public key.
|
||||
val impl_3__serialized
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
(v_PUBLIC_KEY_SIZE: usize)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_MlKemPublicKeyUnpacked v_K v_Vector)
|
||||
: Prims.Pure (Libcrux_ml_kem.Types.t_MlKemPublicKey v_PUBLIC_KEY_SIZE)
|
||||
(requires
|
||||
(let self = self in
|
||||
Spec.MLKEM.is_rank v_K /\ v_PUBLIC_KEY_SIZE == Spec.MLKEM.v_CPA_PUBLIC_KEY_SIZE v_K /\
|
||||
(forall (i: nat).
|
||||
i < v v_K ==>
|
||||
Libcrux_ml_kem.Serialize.coefficients_field_modulus_range (Seq.index self
|
||||
.f_ind_cpa_public_key
|
||||
.Libcrux_ml_kem.Ind_cpa.Unpacked.f_tt_as_ntt
|
||||
i))))
|
||||
(ensures
|
||||
fun res ->
|
||||
let res:Libcrux_ml_kem.Types.t_MlKemPublicKey v_PUBLIC_KEY_SIZE = res in
|
||||
let self = self in
|
||||
res.Libcrux_ml_kem.Types.f_value ==
|
||||
Seq.append (Spec.MLKEM.vector_encode_12 #v_K
|
||||
(Libcrux_ml_kem.Polynomial.to_spec_vector_t #v_K
|
||||
#v_Vector
|
||||
self.f_ind_cpa_public_key.Libcrux_ml_kem.Ind_cpa.Unpacked.f_tt_as_ntt))
|
||||
self.f_ind_cpa_public_key.Libcrux_ml_kem.Ind_cpa.Unpacked.f_seed_for_A)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
: Core_models.Default.t_Default (t_MlKemPublicKeyUnpacked v_K v_Vector)
|
||||
|
||||
/// Take a serialized private key and generate an unpacked key pair from it.
|
||||
val keys_from_private_key
|
||||
(v_K v_SECRET_KEY_SIZE v_CPA_SECRET_KEY_SIZE v_PUBLIC_KEY_SIZE v_T_AS_NTT_ENCODED_SIZE: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(private_key: Libcrux_ml_kem.Types.t_MlKemPrivateKey v_SECRET_KEY_SIZE)
|
||||
(key_pair: t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
: Prims.Pure (t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
(requires
|
||||
Spec.MLKEM.is_rank v_K /\ v_SECRET_KEY_SIZE == Spec.MLKEM.v_CCA_PRIVATE_KEY_SIZE v_K /\
|
||||
v_CPA_SECRET_KEY_SIZE == Spec.MLKEM.v_CPA_PRIVATE_KEY_SIZE v_K /\
|
||||
v_PUBLIC_KEY_SIZE == Spec.MLKEM.v_CPA_PUBLIC_KEY_SIZE v_K /\
|
||||
v_T_AS_NTT_ENCODED_SIZE == Spec.MLKEM.v_T_AS_NTT_ENCODED_SIZE v_K)
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Get the serialized public key.
|
||||
val impl_4__public_key
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
: Prims.Pure (t_MlKemPublicKeyUnpacked v_K v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Get the serialized public key.
|
||||
val impl_4__private_key
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
: Prims.Pure (t_MlKemPrivateKeyUnpacked v_K v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Get the serialized public key.
|
||||
val impl_4__serialized_public_key_mut
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
(v_PUBLIC_KEY_SIZE: usize)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
(serialized: Libcrux_ml_kem.Types.t_MlKemPublicKey v_PUBLIC_KEY_SIZE)
|
||||
: Prims.Pure (Libcrux_ml_kem.Types.t_MlKemPublicKey v_PUBLIC_KEY_SIZE)
|
||||
(requires
|
||||
(let self = self in
|
||||
Spec.MLKEM.is_rank v_K /\ v_PUBLIC_KEY_SIZE == Spec.MLKEM.v_CPA_PUBLIC_KEY_SIZE v_K /\
|
||||
(forall (i: nat).
|
||||
i < v v_K ==>
|
||||
Libcrux_ml_kem.Serialize.coefficients_field_modulus_range (Seq.index self.f_public_key
|
||||
.f_ind_cpa_public_key
|
||||
.Libcrux_ml_kem.Ind_cpa.Unpacked.f_tt_as_ntt
|
||||
i))))
|
||||
(ensures
|
||||
fun serialized_future ->
|
||||
let serialized_future:Libcrux_ml_kem.Types.t_MlKemPublicKey v_PUBLIC_KEY_SIZE =
|
||||
serialized_future
|
||||
in
|
||||
let self = self in
|
||||
serialized_future.f_value ==
|
||||
Seq.append (Spec.MLKEM.vector_encode_12 #v_K
|
||||
(Libcrux_ml_kem.Polynomial.to_spec_vector_t #v_K
|
||||
#v_Vector
|
||||
self.f_public_key.f_ind_cpa_public_key
|
||||
.Libcrux_ml_kem.Ind_cpa.Unpacked.f_tt_as_ntt))
|
||||
self.f_public_key.f_ind_cpa_public_key.Libcrux_ml_kem.Ind_cpa.Unpacked.f_seed_for_A)
|
||||
|
||||
/// Get the serialized public key.
|
||||
val impl_4__serialized_public_key
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
(v_PUBLIC_KEY_SIZE: usize)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
: Prims.Pure (Libcrux_ml_kem.Types.t_MlKemPublicKey v_PUBLIC_KEY_SIZE)
|
||||
(requires
|
||||
(let self = self in
|
||||
Spec.MLKEM.is_rank v_K /\ v_PUBLIC_KEY_SIZE == Spec.MLKEM.v_CPA_PUBLIC_KEY_SIZE v_K /\
|
||||
(forall (i: nat).
|
||||
i < v v_K ==>
|
||||
Libcrux_ml_kem.Serialize.coefficients_field_modulus_range (Seq.index self.f_public_key
|
||||
.f_ind_cpa_public_key
|
||||
.Libcrux_ml_kem.Ind_cpa.Unpacked.f_tt_as_ntt
|
||||
i))))
|
||||
(ensures
|
||||
fun res ->
|
||||
let res:Libcrux_ml_kem.Types.t_MlKemPublicKey v_PUBLIC_KEY_SIZE = res in
|
||||
let self = self in
|
||||
res.f_value ==
|
||||
Seq.append (Spec.MLKEM.vector_encode_12 #v_K
|
||||
(Libcrux_ml_kem.Polynomial.to_spec_vector_t #v_K
|
||||
#v_Vector
|
||||
self.f_public_key.f_ind_cpa_public_key
|
||||
.Libcrux_ml_kem.Ind_cpa.Unpacked.f_tt_as_ntt))
|
||||
self.f_public_key.f_ind_cpa_public_key.Libcrux_ml_kem.Ind_cpa.Unpacked.f_seed_for_A)
|
||||
|
||||
/// Get the serialized private key.
|
||||
val impl_4__serialized_private_key_mut
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
(v_CPA_PRIVATE_KEY_SIZE v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE: usize)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
(serialized: Libcrux_ml_kem.Types.t_MlKemPrivateKey v_PRIVATE_KEY_SIZE)
|
||||
: Prims.Pure (Libcrux_ml_kem.Types.t_MlKemPrivateKey v_PRIVATE_KEY_SIZE)
|
||||
(requires
|
||||
Spec.MLKEM.is_rank v_K /\ v_PRIVATE_KEY_SIZE == Spec.MLKEM.v_CCA_PRIVATE_KEY_SIZE v_K /\
|
||||
v_CPA_PRIVATE_KEY_SIZE == Spec.MLKEM.v_CPA_PRIVATE_KEY_SIZE v_K /\
|
||||
v_PUBLIC_KEY_SIZE == Spec.MLKEM.v_CPA_PUBLIC_KEY_SIZE v_K)
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Get the serialized private key.
|
||||
val impl_4__serialized_private_key
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
(v_CPA_PRIVATE_KEY_SIZE v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE: usize)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
: Prims.Pure (Libcrux_ml_kem.Types.t_MlKemPrivateKey v_PRIVATE_KEY_SIZE)
|
||||
(requires
|
||||
Spec.MLKEM.is_rank v_K /\ v_PRIVATE_KEY_SIZE == Spec.MLKEM.v_CCA_PRIVATE_KEY_SIZE v_K /\
|
||||
v_CPA_PRIVATE_KEY_SIZE == Spec.MLKEM.v_CPA_PRIVATE_KEY_SIZE v_K /\
|
||||
v_PUBLIC_KEY_SIZE == Spec.MLKEM.v_CPA_PUBLIC_KEY_SIZE v_K)
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_1
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
: Core_models.Default.t_Default (t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
|
||||
/// Create a new empty unpacked key pair.
|
||||
val impl_4__new:
|
||||
v_K: usize ->
|
||||
#v_Vector: Type0 ->
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |} ->
|
||||
Prims.unit
|
||||
-> Prims.Pure (t_MlKemKeyPairUnpacked v_K v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Take a serialized private key and generate an unpacked key pair from it.
|
||||
val impl_4__from_private_key
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
(v_SECRET_KEY_SIZE v_CPA_SECRET_KEY_SIZE v_PUBLIC_KEY_SIZE v_T_AS_NTT_ENCODED_SIZE: usize)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(private_key: Libcrux_ml_kem.Types.t_MlKemPrivateKey v_SECRET_KEY_SIZE)
|
||||
: Prims.Pure (t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
(requires
|
||||
Spec.MLKEM.is_rank v_K /\ v_SECRET_KEY_SIZE == Spec.MLKEM.v_CCA_PRIVATE_KEY_SIZE v_K /\
|
||||
v_CPA_SECRET_KEY_SIZE == Spec.MLKEM.v_CPA_PRIVATE_KEY_SIZE v_K /\
|
||||
v_PUBLIC_KEY_SIZE == Spec.MLKEM.v_CPA_PUBLIC_KEY_SIZE v_K /\
|
||||
v_T_AS_NTT_ENCODED_SIZE == Spec.MLKEM.v_T_AS_NTT_ENCODED_SIZE v_K)
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val transpose_a
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(ind_cpa_a:
|
||||
t_Array (t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K) v_K)
|
||||
: Prims.Pure
|
||||
(t_Array (t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K) v_K)
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array
|
||||
(t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K) v_K =
|
||||
result
|
||||
in
|
||||
forall (i: nat).
|
||||
i < v v_K ==>
|
||||
(forall (j: nat).
|
||||
j < v v_K ==>
|
||||
Seq.index (Seq.index result i) j == Seq.index (Seq.index ind_cpa_a j) i))
|
||||
|
||||
/// Generate Unpacked Keys
|
||||
val generate_keypair
|
||||
(v_K v_CPA_PRIVATE_KEY_SIZE v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE v_ETA1 v_ETA1_RANDOMNESS_SIZE:
|
||||
usize)
|
||||
(#v_Vector #v_Hasher #v_Scheme: Type0)
|
||||
{| i3: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
{| i4: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |}
|
||||
{| i5: Libcrux_ml_kem.Variant.t_Variant v_Scheme |}
|
||||
(randomness: t_Array u8 (mk_usize 64))
|
||||
(out: t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
: Prims.Pure (t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
(requires
|
||||
Spec.MLKEM.is_rank v_K /\ v_ETA1_RANDOMNESS_SIZE == Spec.MLKEM.v_ETA1_RANDOMNESS_SIZE v_K /\
|
||||
v_ETA1 == Spec.MLKEM.v_ETA1 v_K /\ v_PUBLIC_KEY_SIZE == Spec.MLKEM.v_CPA_PUBLIC_KEY_SIZE v_K
|
||||
)
|
||||
(ensures
|
||||
fun out_future ->
|
||||
let out_future:t_MlKemKeyPairUnpacked v_K v_Vector = out_future in
|
||||
let ((m_A, public_key_hash), implicit_rejection_value), valid =
|
||||
Spec.MLKEM.ind_cca_unpack_generate_keypair v_K randomness
|
||||
in
|
||||
valid ==>
|
||||
Libcrux_ml_kem.Polynomial.to_spec_matrix_t #v_K
|
||||
#v_Vector
|
||||
out_future.f_public_key.f_ind_cpa_public_key.f_A ==
|
||||
m_A /\ out_future.f_public_key.f_public_key_hash == public_key_hash /\
|
||||
out_future.f_private_key.f_implicit_rejection_value == implicit_rejection_value)
|
||||
|
||||
val encaps_prepare
|
||||
(v_K: usize)
|
||||
(#v_Hasher: Type0)
|
||||
{| i1: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |}
|
||||
(randomness pk_hash: t_Slice u8)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 64))
|
||||
(requires
|
||||
(Core_models.Slice.impl__len #u8 randomness <: usize) =. mk_usize 32 &&
|
||||
(Core_models.Slice.impl__len #u8 pk_hash <: usize) =. mk_usize 32)
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array u8 (mk_usize 64) = result in
|
||||
result == Spec.Utils.v_G (concat randomness pk_hash))
|
||||
|
||||
val encapsulate
|
||||
(v_K v_CIPHERTEXT_SIZE v_PUBLIC_KEY_SIZE v_T_AS_NTT_ENCODED_SIZE v_C1_SIZE v_C2_SIZE v_VECTOR_U_COMPRESSION_FACTOR v_VECTOR_V_COMPRESSION_FACTOR v_VECTOR_U_BLOCK_LEN v_ETA1 v_ETA1_RANDOMNESS_SIZE v_ETA2 v_ETA2_RANDOMNESS_SIZE:
|
||||
usize)
|
||||
(#v_Vector #v_Hasher: Type0)
|
||||
{| i2: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
{| i3: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |}
|
||||
(public_key: t_MlKemPublicKeyUnpacked v_K v_Vector)
|
||||
(randomness: t_Array u8 (mk_usize 32))
|
||||
: Prims.Pure
|
||||
(Libcrux_ml_kem.Types.t_MlKemCiphertext v_CIPHERTEXT_SIZE & t_Array u8 (mk_usize 32))
|
||||
(requires
|
||||
Spec.MLKEM.is_rank v_K /\ v_ETA1 == Spec.MLKEM.v_ETA1 v_K /\
|
||||
v_ETA1_RANDOMNESS_SIZE == Spec.MLKEM.v_ETA1_RANDOMNESS_SIZE v_K /\
|
||||
v_ETA2 == Spec.MLKEM.v_ETA2 v_K /\
|
||||
v_ETA2_RANDOMNESS_SIZE == Spec.MLKEM.v_ETA2_RANDOMNESS_SIZE v_K /\
|
||||
v_C1_SIZE == Spec.MLKEM.v_C1_SIZE v_K /\ v_C2_SIZE == Spec.MLKEM.v_C2_SIZE v_K /\
|
||||
v_VECTOR_U_COMPRESSION_FACTOR == Spec.MLKEM.v_VECTOR_U_COMPRESSION_FACTOR v_K /\
|
||||
v_VECTOR_V_COMPRESSION_FACTOR == Spec.MLKEM.v_VECTOR_V_COMPRESSION_FACTOR v_K /\
|
||||
v_VECTOR_U_BLOCK_LEN == Spec.MLKEM.v_C1_BLOCK_SIZE v_K /\
|
||||
v_CIPHERTEXT_SIZE == Spec.MLKEM.v_CPA_CIPHERTEXT_SIZE v_K)
|
||||
(ensures
|
||||
fun temp_0_ ->
|
||||
let ciphertext_result, shared_secret_array:(Libcrux_ml_kem.Types.t_MlKemCiphertext
|
||||
v_CIPHERTEXT_SIZE &
|
||||
t_Array u8 (mk_usize 32)) =
|
||||
temp_0_
|
||||
in
|
||||
let ciphertext, shared_secret =
|
||||
Spec.MLKEM.ind_cca_unpack_encapsulate v_K
|
||||
public_key.f_public_key_hash
|
||||
(Libcrux_ml_kem.Polynomial.to_spec_vector_t #v_K
|
||||
#v_Vector
|
||||
public_key.f_ind_cpa_public_key.Libcrux_ml_kem.Ind_cpa.Unpacked.f_tt_as_ntt)
|
||||
(Libcrux_ml_kem.Polynomial.to_spec_matrix_t #v_K
|
||||
#v_Vector
|
||||
public_key.f_ind_cpa_public_key.Libcrux_ml_kem.Ind_cpa.Unpacked.f_A)
|
||||
randomness
|
||||
in
|
||||
ciphertext_result.f_value == ciphertext /\ shared_secret_array == shared_secret)
|
||||
|
||||
val decapsulate
|
||||
(v_K v_SECRET_KEY_SIZE v_CPA_SECRET_KEY_SIZE v_PUBLIC_KEY_SIZE v_CIPHERTEXT_SIZE v_T_AS_NTT_ENCODED_SIZE v_C1_SIZE v_C2_SIZE v_VECTOR_U_COMPRESSION_FACTOR v_VECTOR_V_COMPRESSION_FACTOR v_C1_BLOCK_SIZE v_ETA1 v_ETA1_RANDOMNESS_SIZE v_ETA2 v_ETA2_RANDOMNESS_SIZE v_IMPLICIT_REJECTION_HASH_INPUT_SIZE:
|
||||
usize)
|
||||
(#v_Vector #v_Hasher: Type0)
|
||||
{| i2: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
{| i3: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |}
|
||||
(key_pair: t_MlKemKeyPairUnpacked v_K v_Vector)
|
||||
(ciphertext: Libcrux_ml_kem.Types.t_MlKemCiphertext v_CIPHERTEXT_SIZE)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 32))
|
||||
(requires
|
||||
Spec.MLKEM.is_rank v_K /\ v_ETA1 == Spec.MLKEM.v_ETA1 v_K /\
|
||||
v_ETA1_RANDOMNESS_SIZE == Spec.MLKEM.v_ETA1_RANDOMNESS_SIZE v_K /\
|
||||
v_ETA2 == Spec.MLKEM.v_ETA2 v_K /\
|
||||
v_ETA2_RANDOMNESS_SIZE == Spec.MLKEM.v_ETA2_RANDOMNESS_SIZE v_K /\
|
||||
v_C1_SIZE == Spec.MLKEM.v_C1_SIZE v_K /\ v_C2_SIZE == Spec.MLKEM.v_C2_SIZE v_K /\
|
||||
v_VECTOR_U_COMPRESSION_FACTOR == Spec.MLKEM.v_VECTOR_U_COMPRESSION_FACTOR v_K /\
|
||||
v_VECTOR_V_COMPRESSION_FACTOR == Spec.MLKEM.v_VECTOR_V_COMPRESSION_FACTOR v_K /\
|
||||
v_C1_BLOCK_SIZE == Spec.MLKEM.v_C1_BLOCK_SIZE v_K /\
|
||||
v_CIPHERTEXT_SIZE == Spec.MLKEM.v_CPA_CIPHERTEXT_SIZE v_K /\
|
||||
v_IMPLICIT_REJECTION_HASH_INPUT_SIZE == Spec.MLKEM.v_IMPLICIT_REJECTION_HASH_INPUT_SIZE v_K)
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array u8 (mk_usize 32) = result in
|
||||
result ==
|
||||
Spec.MLKEM.ind_cca_unpack_decapsulate v_K
|
||||
key_pair.f_public_key.f_public_key_hash
|
||||
key_pair.f_private_key.f_implicit_rejection_value
|
||||
ciphertext.Libcrux_ml_kem.Types.f_value
|
||||
(Libcrux_ml_kem.Polynomial.to_spec_vector_t #v_K
|
||||
#v_Vector
|
||||
key_pair.f_private_key.f_ind_cpa_private_key
|
||||
.Libcrux_ml_kem.Ind_cpa.Unpacked.f_secret_as_ntt)
|
||||
(Libcrux_ml_kem.Polynomial.to_spec_vector_t #v_K
|
||||
#v_Vector
|
||||
key_pair.f_public_key.f_ind_cpa_public_key
|
||||
.Libcrux_ml_kem.Ind_cpa.Unpacked.f_tt_as_ntt)
|
||||
(Libcrux_ml_kem.Polynomial.to_spec_matrix_t #v_K
|
||||
#v_Vector
|
||||
key_pair.f_public_key.f_ind_cpa_public_key.Libcrux_ml_kem.Ind_cpa.Unpacked.f_A))
|
||||
@@ -0,0 +1,47 @@
|
||||
module Libcrux_ml_kem.Ind_cpa.Unpacked
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
let _ =
|
||||
(* This module has implicit dependencies, here we make them explicit. *)
|
||||
(* The implicit dependencies arise from typeclasses instances. *)
|
||||
let open Libcrux_ml_kem.Vector.Traits in
|
||||
()
|
||||
|
||||
/// An unpacked ML-KEM IND-CPA Private Key
|
||||
type t_IndCpaPrivateKeyUnpacked
|
||||
(v_K: usize) (v_Vector: Type0) {| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
= { f_secret_as_ntt:t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K }
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
: Core_models.Default.t_Default (t_IndCpaPrivateKeyUnpacked v_K v_Vector)
|
||||
|
||||
/// An unpacked ML-KEM IND-CPA Public Key
|
||||
type t_IndCpaPublicKeyUnpacked
|
||||
(v_K: usize) (v_Vector: Type0) {| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
= {
|
||||
f_tt_as_ntt:t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K;
|
||||
f_seed_for_A:t_Array u8 (mk_usize 32);
|
||||
f_A:t_Array (t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K) v_K
|
||||
}
|
||||
|
||||
let impl_2
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
(#[FStar.Tactics.Typeclasses.tcresolve ()] i1: Core_models.Clone.t_Clone v_Vector)
|
||||
(#[FStar.Tactics.Typeclasses.tcresolve ()]
|
||||
i2:
|
||||
Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector)
|
||||
: Core_models.Clone.t_Clone (t_IndCpaPublicKeyUnpacked v_K v_Vector) = { f_clone = (fun x -> x); f_clone_pre = (fun _ -> True); f_clone_post = (fun _ _ -> True) }
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_1
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
: Core_models.Default.t_Default (t_IndCpaPublicKeyUnpacked v_K v_Vector)
|
||||
@@ -0,0 +1,181 @@
|
||||
module Libcrux_ml_kem.Mlkem768.Incremental
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
let _ =
|
||||
(* This module has implicit dependencies, here we make them explicit. *)
|
||||
(* The implicit dependencies arise from typeclasses instances. *)
|
||||
let open Libcrux_ml_kem.Ind_cca.Incremental.Types in
|
||||
let open Rand_core in
|
||||
()
|
||||
|
||||
/// Get the size of the first public key in bytes.
|
||||
val pk1_len: Prims.unit -> Prims.Pure usize Prims.l_True
|
||||
(ensures fun res -> let res:usize = res in res =. mk_usize 64)
|
||||
|
||||
/// Get the size of the second public key in bytes.
|
||||
val pk2_len: Prims.unit -> Prims.Pure usize Prims.l_True (ensures fun res -> res =. mk_usize 1152)
|
||||
|
||||
/// The size of a compressed key pair in bytes.
|
||||
let v_COMPRESSED_KEYPAIR_LEN: usize = Libcrux_ml_kem.Mlkem768.v_SECRET_KEY_SIZE
|
||||
|
||||
/// The size of the key pair in bytes.
|
||||
val key_pair_len: Prims.unit -> Prims.Pure usize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// The size of the compressed key pair in bytes.
|
||||
val key_pair_compressed_len: Prims.unit -> Prims.Pure usize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// The size of the encaps state in bytes.
|
||||
val encaps_state_len: Prims.unit -> Prims.Pure usize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// The size of the shared secret.
|
||||
val shared_secret_size: Prims.unit -> Prims.Pure usize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// An encoded, incremental key pair.
|
||||
type t_KeyPairBytes = { f_value:t_Array u8 (mk_usize 7392) }
|
||||
|
||||
/// Get the raw bytes.
|
||||
val impl_KeyPairBytes__to_bytes (self: t_KeyPairBytes)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 7392)) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Get the PK1 bytes from the serialized key pair bytes
|
||||
val impl_KeyPairBytes__pk1 (self: t_KeyPairBytes)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 64)) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Get the PK2 bytes from the serialized key pair bytes
|
||||
val impl_KeyPairBytes__pk2 (self: t_KeyPairBytes)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 1152)) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_1:Core_models.Convert.t_AsRef t_KeyPairBytes (t_Slice u8)
|
||||
|
||||
/// Generate a key pair and write it into `key_pair`.
|
||||
/// This uses unpacked keys and does not compress the keys.
|
||||
/// `key_pair.len()` must be of size `key_pair_len()`.
|
||||
/// The function returns an error if this is not the case.
|
||||
val generate_key_pair (randomness: t_Array u8 (mk_usize 64)) (key_pair: t_Slice u8)
|
||||
: Prims.Pure
|
||||
(t_Slice u8 & Core_models.Result.t_Result Prims.unit Libcrux_ml_kem.Ind_cca.Incremental.Types.t_Error
|
||||
) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Generate a new key pair.
|
||||
/// This uses unpacked keys and does not compress the keys.
|
||||
val impl_KeyPairBytes__from_seed (randomness: t_Array u8 (mk_usize 64))
|
||||
: Prims.Pure t_KeyPairBytes Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Generate a new key pair.
|
||||
/// This uses unpacked keys and does not compress the keys.
|
||||
val impl_KeyPairBytes__generate
|
||||
(#iimpl_277843321_: Type0)
|
||||
{| i1: Rand_core.t_RngCore iimpl_277843321_ |}
|
||||
{| i2: Rand_core.t_CryptoRng iimpl_277843321_ |}
|
||||
(rng: iimpl_277843321_)
|
||||
: Prims.Pure (iimpl_277843321_ & t_KeyPairBytes) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// An encoded, compressed, incremental key pair.
|
||||
/// Layout: dk | (t | ⍴) | H(ek) | z
|
||||
type t_KeyPairCompressedBytes = { f_value:t_Array u8 (mk_usize 2400) }
|
||||
|
||||
/// Get the raw bytes.
|
||||
val impl_KeyPairCompressedBytes__to_bytes (self: t_KeyPairCompressedBytes)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 2400)) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Get the serialized private for decapsulation.
|
||||
val impl_KeyPairCompressedBytes__sk (self: t_KeyPairCompressedBytes)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 2400)) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
let impl_KeyPairCompressedBytes__pk1__v_START: usize =
|
||||
mk_usize 2 *! Libcrux_ml_kem.Mlkem768.v_RANKED_BYTES_PER_RING_ELEMENT
|
||||
|
||||
/// Get the PK1 bytes from the serialized key pair bytes
|
||||
val impl_KeyPairCompressedBytes__pk1 (self: t_KeyPairCompressedBytes)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 64)) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
let impl_KeyPairCompressedBytes__pk2__v_START: usize =
|
||||
Libcrux_ml_kem.Mlkem768.v_RANKED_BYTES_PER_RING_ELEMENT
|
||||
|
||||
/// Get the PK2 bytes from the serialized key pair bytes
|
||||
val impl_KeyPairCompressedBytes__pk2 (self: t_KeyPairCompressedBytes)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 1152)) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_3:Core_models.Convert.t_AsRef t_KeyPairCompressedBytes (t_Slice u8)
|
||||
|
||||
/// Generate a key pair and write it into `key_pair`.
|
||||
/// This compresses the keys.
|
||||
val generate_key_pair_compressed
|
||||
(randomness: t_Array u8 (mk_usize 64))
|
||||
(key_pair: t_Array u8 (mk_usize 2400))
|
||||
: Prims.Pure (t_Array u8 (mk_usize 2400)) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Generate a new key pair.
|
||||
/// This uses unpacked keys and does not compress the keys.
|
||||
val impl_KeyPairCompressedBytes__from_seed (randomness: t_Array u8 (mk_usize 64))
|
||||
: Prims.Pure t_KeyPairCompressedBytes Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Generate a new key pair.
|
||||
/// This uses unpacked keys and does not compress the keys.
|
||||
val impl_KeyPairCompressedBytes__generate
|
||||
(#iimpl_277843321_: Type0)
|
||||
{| i1: Rand_core.t_RngCore iimpl_277843321_ |}
|
||||
{| i2: Rand_core.t_CryptoRng iimpl_277843321_ |}
|
||||
(rng: iimpl_277843321_)
|
||||
: Prims.Pure (iimpl_277843321_ & t_KeyPairCompressedBytes) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Get the PK1 bytes from the serialized key pair bytes
|
||||
val pk1 (keypair: t_Array u8 (mk_usize 7392))
|
||||
: Prims.Pure (t_Slice u8) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Get the PK2 bytes from the serialized key pair bytes
|
||||
val pk2 (keypair: t_Array u8 (mk_usize 7392))
|
||||
: Prims.Pure (t_Slice u8) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Validate that the two parts `pk1` and `pk2` are consistent.
|
||||
val validate_pk (pk1: Libcrux_ml_kem.Ind_cca.Incremental.Types.t_PublicKey1) (pk2: t_Slice u8)
|
||||
: Prims.Pure (Core_models.Result.t_Result Prims.unit Libcrux_ml_kem.Ind_cca.Incremental.Types.t_Error)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Validate that the two parts `pk1` and `pk2` are consistent.
|
||||
val validate_pk_bytes (pk1 pk2: t_Slice u8)
|
||||
: Prims.Pure (Core_models.Result.t_Result Prims.unit Libcrux_ml_kem.Ind_cca.Incremental.Types.t_Error)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Encapsulate the first part of the ciphertext.
|
||||
/// Returns an [`Error`] if the provided input or output don't have
|
||||
/// the appropriate sizes.
|
||||
val encapsulate1
|
||||
(pk1: t_Slice u8)
|
||||
(randomness: t_Array u8 (mk_usize 32))
|
||||
(state shared_secret: t_Slice u8)
|
||||
: Prims.Pure
|
||||
(t_Slice u8 & t_Slice u8 &
|
||||
Core_models.Result.t_Result (Libcrux_ml_kem.Ind_cca.Incremental.Types.t_Ciphertext1 (mk_usize 960))
|
||||
Libcrux_ml_kem.Ind_cca.Incremental.Types.t_Error) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Encapsulate the second part of the ciphertext.
|
||||
/// The second part of the public key is passed in as byte slice.
|
||||
/// [`Error::InvalidInputLength`] is returned if `public_key_part` is too
|
||||
/// short.
|
||||
val encapsulate2 (state: t_Array u8 (mk_usize 2080)) (public_key_part: t_Array u8 (mk_usize 1152))
|
||||
: Prims.Pure (Libcrux_ml_kem.Ind_cca.Incremental.Types.t_Ciphertext2 (mk_usize 128))
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Decapsulate incremental ciphertexts.
|
||||
val decapsulate_incremental_key
|
||||
(private_key: t_Slice u8)
|
||||
(ciphertext1: Libcrux_ml_kem.Ind_cca.Incremental.Types.t_Ciphertext1 (mk_usize 960))
|
||||
(ciphertext2: Libcrux_ml_kem.Ind_cca.Incremental.Types.t_Ciphertext2 (mk_usize 128))
|
||||
: Prims.Pure
|
||||
(Core_models.Result.t_Result (t_Array u8 (mk_usize 32))
|
||||
Libcrux_ml_kem.Ind_cca.Incremental.Types.t_Error) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Decapsulate incremental ciphertexts.
|
||||
val decapsulate_compressed_key
|
||||
(private_key: t_Array u8 (mk_usize 2400))
|
||||
(ciphertext1: Libcrux_ml_kem.Ind_cca.Incremental.Types.t_Ciphertext1 (mk_usize 960))
|
||||
(ciphertext2: Libcrux_ml_kem.Ind_cca.Incremental.Types.t_Ciphertext2 (mk_usize 128))
|
||||
: Prims.Pure (t_Array u8 (mk_usize 32)) Prims.l_True (fun _ -> Prims.l_True)
|
||||
@@ -0,0 +1,125 @@
|
||||
module Libcrux_ml_kem.Mlkem768
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
let v_RANK: usize = mk_usize 3
|
||||
|
||||
let v_RANKED_BYTES_PER_RING_ELEMENT: usize =
|
||||
(v_RANK *! Libcrux_ml_kem.Constants.v_BITS_PER_RING_ELEMENT <: usize) /! mk_usize 8
|
||||
|
||||
let v_T_AS_NTT_ENCODED_SIZE: usize =
|
||||
((v_RANK *! Libcrux_ml_kem.Constants.v_COEFFICIENTS_IN_RING_ELEMENT <: usize) *!
|
||||
Libcrux_ml_kem.Constants.v_BITS_PER_COEFFICIENT
|
||||
<:
|
||||
usize) /!
|
||||
mk_usize 8
|
||||
|
||||
let v_VECTOR_U_COMPRESSION_FACTOR: usize = mk_usize 10
|
||||
|
||||
let v_C1_BLOCK_SIZE: usize =
|
||||
(Libcrux_ml_kem.Constants.v_COEFFICIENTS_IN_RING_ELEMENT *! v_VECTOR_U_COMPRESSION_FACTOR <: usize
|
||||
) /!
|
||||
mk_usize 8
|
||||
|
||||
let v_C1_SIZE: usize = v_C1_BLOCK_SIZE *! v_RANK
|
||||
|
||||
let v_VECTOR_V_COMPRESSION_FACTOR: usize = mk_usize 4
|
||||
|
||||
let v_C2_SIZE: usize =
|
||||
(Libcrux_ml_kem.Constants.v_COEFFICIENTS_IN_RING_ELEMENT *! v_VECTOR_V_COMPRESSION_FACTOR <: usize
|
||||
) /!
|
||||
mk_usize 8
|
||||
|
||||
let v_CPA_PKE_SECRET_KEY_SIZE: usize =
|
||||
((v_RANK *! Libcrux_ml_kem.Constants.v_COEFFICIENTS_IN_RING_ELEMENT <: usize) *!
|
||||
Libcrux_ml_kem.Constants.v_BITS_PER_COEFFICIENT
|
||||
<:
|
||||
usize) /!
|
||||
mk_usize 8
|
||||
|
||||
let v_CPA_PKE_PUBLIC_KEY_SIZE: usize = v_T_AS_NTT_ENCODED_SIZE +! mk_usize 32
|
||||
|
||||
let v_CPA_PKE_CIPHERTEXT_SIZE: usize = v_C1_SIZE +! v_C2_SIZE
|
||||
|
||||
let v_SECRET_KEY_SIZE: usize =
|
||||
((v_CPA_PKE_SECRET_KEY_SIZE +! v_CPA_PKE_PUBLIC_KEY_SIZE <: usize) +!
|
||||
Libcrux_ml_kem.Constants.v_H_DIGEST_SIZE
|
||||
<:
|
||||
usize) +!
|
||||
Libcrux_ml_kem.Constants.v_SHARED_SECRET_SIZE
|
||||
|
||||
let v_ETA1: usize = mk_usize 2
|
||||
|
||||
let v_ETA1_RANDOMNESS_SIZE: usize = v_ETA1 *! mk_usize 64
|
||||
|
||||
let v_ETA2: usize = mk_usize 2
|
||||
|
||||
let v_ETA2_RANDOMNESS_SIZE: usize = v_ETA2 *! mk_usize 64
|
||||
|
||||
let v_IMPLICIT_REJECTION_HASH_INPUT_SIZE: usize =
|
||||
Libcrux_ml_kem.Constants.v_SHARED_SECRET_SIZE +! v_CPA_PKE_CIPHERTEXT_SIZE
|
||||
|
||||
/// Validate a public key.
|
||||
/// Returns `true` if valid, and `false` otherwise.
|
||||
val validate_public_key (public_key: Libcrux_ml_kem.Types.t_MlKemPublicKey (mk_usize 1184))
|
||||
: Prims.Pure bool Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Validate a private key.
|
||||
/// Returns `true` if valid, and `false` otherwise.
|
||||
val validate_private_key
|
||||
(private_key: Libcrux_ml_kem.Types.t_MlKemPrivateKey (mk_usize 2400))
|
||||
(ciphertext: Libcrux_ml_kem.Types.t_MlKemCiphertext (mk_usize 1088))
|
||||
: Prims.Pure bool Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Generate ML-KEM 768 Key Pair
|
||||
/// Generate an ML-KEM key pair. The input is a byte array of size
|
||||
/// [`KEY_GENERATION_SEED_SIZE`].
|
||||
/// This function returns an [`MlKem768KeyPair`].
|
||||
val generate_key_pair (randomness: t_Array u8 (mk_usize 64))
|
||||
: Prims.Pure (Libcrux_ml_kem.Types.t_MlKemKeyPair (mk_usize 2400) (mk_usize 1184))
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun res ->
|
||||
let res:Libcrux_ml_kem.Types.t_MlKemKeyPair (mk_usize 2400) (mk_usize 1184) = res in
|
||||
let (secret_key, public_key), valid =
|
||||
Spec.MLKEM.Instances.mlkem768_generate_keypair randomness
|
||||
in
|
||||
valid ==> (res.f_sk.f_value == secret_key /\ res.f_pk.f_value == public_key))
|
||||
|
||||
/// Encapsulate ML-KEM 768
|
||||
/// Generates an ([`MlKem768Ciphertext`], [`MlKemSharedSecret`]) tuple.
|
||||
/// The input is a reference to an [`MlKem768PublicKey`] and [`SHARED_SECRET_SIZE`]
|
||||
/// bytes of `randomness`.
|
||||
val encapsulate
|
||||
(public_key: Libcrux_ml_kem.Types.t_MlKemPublicKey (mk_usize 1184))
|
||||
(randomness: t_Array u8 (mk_usize 32))
|
||||
: Prims.Pure (Libcrux_ml_kem.Types.t_MlKemCiphertext (mk_usize 1088) & t_Array u8 (mk_usize 32))
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun res ->
|
||||
let res:(Libcrux_ml_kem.Types.t_MlKemCiphertext (mk_usize 1088) & t_Array u8 (mk_usize 32)
|
||||
) =
|
||||
res
|
||||
in
|
||||
let (ciphertext, shared_secret), valid =
|
||||
Spec.MLKEM.Instances.mlkem768_encapsulate public_key.f_value randomness
|
||||
in
|
||||
let res_ciphertext, res_shared_secret = res in
|
||||
valid ==> (res_ciphertext.f_value == ciphertext /\ res_shared_secret == shared_secret))
|
||||
|
||||
/// Decapsulate ML-KEM 768
|
||||
/// Generates an [`MlKemSharedSecret`].
|
||||
/// The input is a reference to an [`MlKem768PrivateKey`] and an [`MlKem768Ciphertext`].
|
||||
val decapsulate
|
||||
(private_key: Libcrux_ml_kem.Types.t_MlKemPrivateKey (mk_usize 2400))
|
||||
(ciphertext: Libcrux_ml_kem.Types.t_MlKemCiphertext (mk_usize 1088))
|
||||
: Prims.Pure (t_Array u8 (mk_usize 32))
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun res ->
|
||||
let res:t_Array u8 (mk_usize 32) = res in
|
||||
let shared_secret, valid =
|
||||
Spec.MLKEM.Instances.mlkem768_decapsulate private_key.f_value ciphertext.f_value
|
||||
in
|
||||
valid ==> res == shared_secret)
|
||||
@@ -0,0 +1,343 @@
|
||||
module Libcrux_ml_kem.Polynomial
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
let _ =
|
||||
(* This module has implicit dependencies, here we make them explicit. *)
|
||||
(* The implicit dependencies arise from typeclasses instances. *)
|
||||
let open Libcrux_ml_kem.Vector.Traits in
|
||||
()
|
||||
|
||||
let v_ZETAS_TIMES_MONTGOMERY_R: t_Array i16 (mk_usize 128) =
|
||||
let _:Prims.unit = assert_norm (pow2 16 == 65536) in
|
||||
let list =
|
||||
[
|
||||
mk_i16 (-1044); mk_i16 (-758); mk_i16 (-359); mk_i16 (-1517); mk_i16 1493; mk_i16 1422;
|
||||
mk_i16 287; mk_i16 202; mk_i16 (-171); mk_i16 622; mk_i16 1577; mk_i16 182; mk_i16 962;
|
||||
mk_i16 (-1202); mk_i16 (-1474); mk_i16 1468; mk_i16 573; mk_i16 (-1325); mk_i16 264;
|
||||
mk_i16 383; mk_i16 (-829); mk_i16 1458; mk_i16 (-1602); mk_i16 (-130); mk_i16 (-681);
|
||||
mk_i16 1017; mk_i16 732; mk_i16 608; mk_i16 (-1542); mk_i16 411; mk_i16 (-205); mk_i16 (-1571);
|
||||
mk_i16 1223; mk_i16 652; mk_i16 (-552); mk_i16 1015; mk_i16 (-1293); mk_i16 1491;
|
||||
mk_i16 (-282); mk_i16 (-1544); mk_i16 516; mk_i16 (-8); mk_i16 (-320); mk_i16 (-666);
|
||||
mk_i16 (-1618); mk_i16 (-1162); mk_i16 126; mk_i16 1469; mk_i16 (-853); mk_i16 (-90);
|
||||
mk_i16 (-271); mk_i16 830; mk_i16 107; mk_i16 (-1421); mk_i16 (-247); mk_i16 (-951);
|
||||
mk_i16 (-398); mk_i16 961; mk_i16 (-1508); mk_i16 (-725); mk_i16 448; mk_i16 (-1065);
|
||||
mk_i16 677; mk_i16 (-1275); mk_i16 (-1103); mk_i16 430; mk_i16 555; mk_i16 843; mk_i16 (-1251);
|
||||
mk_i16 871; mk_i16 1550; mk_i16 105; mk_i16 422; mk_i16 587; mk_i16 177; mk_i16 (-235);
|
||||
mk_i16 (-291); mk_i16 (-460); mk_i16 1574; mk_i16 1653; mk_i16 (-246); mk_i16 778; mk_i16 1159;
|
||||
mk_i16 (-147); mk_i16 (-777); mk_i16 1483; mk_i16 (-602); mk_i16 1119; mk_i16 (-1590);
|
||||
mk_i16 644; mk_i16 (-872); mk_i16 349; mk_i16 418; mk_i16 329; mk_i16 (-156); mk_i16 (-75);
|
||||
mk_i16 817; mk_i16 1097; mk_i16 603; mk_i16 610; mk_i16 1322; mk_i16 (-1285); mk_i16 (-1465);
|
||||
mk_i16 384; mk_i16 (-1215); mk_i16 (-136); mk_i16 1218; mk_i16 (-1335); mk_i16 (-874);
|
||||
mk_i16 220; mk_i16 (-1187); mk_i16 (-1659); mk_i16 (-1185); mk_i16 (-1530); mk_i16 (-1278);
|
||||
mk_i16 794; mk_i16 (-1510); mk_i16 (-854); mk_i16 (-870); mk_i16 478; mk_i16 (-108);
|
||||
mk_i16 (-308); mk_i16 996; mk_i16 991; mk_i16 958; mk_i16 (-1460); mk_i16 1522; mk_i16 1628
|
||||
]
|
||||
in
|
||||
FStar.Pervasives.assert_norm (Prims.eq2 (List.Tot.length list) 128);
|
||||
Rust_primitives.Hax.array_of_list 128 list
|
||||
|
||||
val zeta (i: usize)
|
||||
: Prims.Pure i16
|
||||
(requires i <. mk_usize 128)
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:i16 = result in
|
||||
Spec.Utils.is_i16b 1664 result)
|
||||
|
||||
let v_VECTORS_IN_RING_ELEMENT: usize =
|
||||
Libcrux_ml_kem.Constants.v_COEFFICIENTS_IN_RING_ELEMENT /!
|
||||
Libcrux_ml_kem.Vector.Traits.v_FIELD_ELEMENTS_IN_VECTOR
|
||||
|
||||
type t_PolynomialRingElement
|
||||
(v_Vector: Type0) {| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
= { f_coefficients:t_Array v_Vector (mk_usize 16) }
|
||||
|
||||
let to_spec_poly_t (#v_Vector: Type0)
|
||||
{| i2: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(p: t_PolynomialRingElement v_Vector) : Spec.MLKEM.polynomial =
|
||||
createi (sz 256) (fun i -> Spec.MLKEM.Math.to_spec_fe
|
||||
(Seq.index (i2._super_15138760880757129450.f_repr
|
||||
(Seq.index p.f_coefficients (v i / 16))) (v i % 16)))
|
||||
let to_spec_vector_t (#r:Spec.MLKEM.rank) (#v_Vector: Type0)
|
||||
{| i2: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(m:t_Array (t_PolynomialRingElement v_Vector) r) : Spec.MLKEM.vector r =
|
||||
createi r (fun i -> to_spec_poly_t #v_Vector (m.[i]))
|
||||
let to_spec_matrix_t (#r:Spec.MLKEM.rank) (#v_Vector: Type0)
|
||||
{| i2: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(m:t_Array (t_Array (t_PolynomialRingElement v_Vector) r) r) : Spec.MLKEM.matrix r =
|
||||
createi r (fun i -> to_spec_vector_t #r #v_Vector (m.[i]))
|
||||
|
||||
let impl
|
||||
(#v_Vector: Type0)
|
||||
(#[FStar.Tactics.Typeclasses.tcresolve ()] i1: Core_models.Clone.t_Clone v_Vector)
|
||||
(#[FStar.Tactics.Typeclasses.tcresolve ()]
|
||||
i2:
|
||||
Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector)
|
||||
: Core_models.Clone.t_Clone (t_PolynomialRingElement v_Vector) = { f_clone = (fun x -> x); f_clone_pre = (fun _ -> True); f_clone_post = (fun _ _ -> True) }
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_1
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Core_models.Marker.t_Copy v_Vector |}
|
||||
{| i2: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
: Core_models.Marker.t_Copy (t_PolynomialRingElement v_Vector)
|
||||
|
||||
val v_ZERO:
|
||||
#v_Vector: Type0 ->
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |} ->
|
||||
Prims.unit
|
||||
-> Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val from_i16_array
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(a: t_Slice i16)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector)
|
||||
(requires
|
||||
(v_VECTORS_IN_RING_ELEMENT *! mk_usize 16 <: usize) <=.
|
||||
(Core_models.Slice.impl__len #i16 a <: usize))
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val to_i16_array
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(re: t_PolynomialRingElement v_Vector)
|
||||
(out: t_Slice i16)
|
||||
: Prims.Pure (t_Slice i16)
|
||||
(requires
|
||||
(Core_models.Slice.impl__len #i16 out <: usize) >=.
|
||||
(v_VECTORS_IN_RING_ELEMENT *! mk_usize 16 <: usize))
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val from_bytes
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(bytes: t_Slice u8)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector)
|
||||
(requires
|
||||
((v_VECTORS_IN_RING_ELEMENT *! mk_usize 16 <: usize) *! mk_usize 2 <: usize) <=.
|
||||
(Core_models.Slice.impl__len #u8 bytes <: usize))
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val to_bytes
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(re: t_PolynomialRingElement v_Vector)
|
||||
(out: t_Slice u8)
|
||||
: Prims.Pure (t_Slice u8)
|
||||
(requires
|
||||
((v_VECTORS_IN_RING_ELEMENT *! mk_usize 16 <: usize) *! mk_usize 2 <: usize) <=.
|
||||
(Core_models.Slice.impl__len #u8 out <: usize))
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Given two polynomial ring elements `lhs` and `rhs`, compute the pointwise
|
||||
/// sum of their constituent coefficients.
|
||||
val add_to_ring_element
|
||||
(#v_Vector: Type0)
|
||||
(v_K: usize)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(myself rhs: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val poly_barrett_reduce
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(myself: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val subtract_reduce
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(myself b: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val add_message_error_reduce
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(myself message result: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val add_error_reduce
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(myself error: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val add_standard_error_reduce
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(myself error: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Given two `KyberPolynomialRingElement`s in their NTT representations,
|
||||
/// compute their product. Given two polynomials in the NTT domain `f^` and `ĵ`,
|
||||
/// the `iᵗʰ` coefficient of the product `k̂` is determined by the calculation:
|
||||
/// ```plaintext
|
||||
/// ĥ[2·i] + ĥ[2·i + 1]X = (f^[2·i] + f^[2·i + 1]X)·(ĝ[2·i] + ĝ[2·i + 1]X) mod (X² - ζ^(2·BitRev₇(i) + 1))
|
||||
/// ```
|
||||
/// This function almost implements <strong>Algorithm 10</strong> of the
|
||||
/// NIST FIPS 203 standard, which is reproduced below:
|
||||
/// ```plaintext
|
||||
/// Input: Two arrays fˆ ∈ ℤ₂₅₆ and ĝ ∈ ℤ₂₅₆.
|
||||
/// Output: An array ĥ ∈ ℤq.
|
||||
/// for(i ← 0; i < 128; i++)
|
||||
/// (ĥ[2i], ĥ[2i+1]) ← BaseCaseMultiply(fˆ[2i], fˆ[2i+1], ĝ[2i], ĝ[2i+1], ζ^(2·BitRev₇(i) + 1))
|
||||
/// end for
|
||||
/// return ĥ
|
||||
/// ```
|
||||
/// We say "almost" because the coefficients of the ring element output by
|
||||
/// this function are in the Montgomery domain.
|
||||
/// The NIST FIPS 203 standard can be found at
|
||||
/// <https://csrc.nist.gov/pubs/fips/203/ipd>.
|
||||
val ntt_multiply
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(myself rhs: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__ZERO:
|
||||
#v_Vector: Type0 ->
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |} ->
|
||||
Prims.unit
|
||||
-> Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Given two polynomial ring elements `lhs` and `rhs`, compute the pointwise
|
||||
/// sum of their constituent coefficients.
|
||||
val impl_2__add_to_ring_element
|
||||
(#v_Vector: Type0)
|
||||
(v_K: usize)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self rhs: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__poly_barrett_reduce
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__subtract_reduce
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self b: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__add_message_error_reduce
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self message result: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__add_error_reduce
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self error: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__add_standard_error_reduce
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self error: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__ntt_multiply
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self rhs: t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Size of a ring element in bytes.
|
||||
val impl_2__num_bytes:
|
||||
#v_Vector: Type0 ->
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |} ->
|
||||
Prims.unit
|
||||
-> Prims.Pure usize
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:usize = result in
|
||||
result =. mk_usize 512)
|
||||
|
||||
/// The length of a vector of ring elements in bytes
|
||||
val vec_len_bytes:
|
||||
v_K: usize ->
|
||||
#v_Vector: Type0 ->
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |} ->
|
||||
Prims.unit
|
||||
-> Prims.Pure usize (requires v_K <=. mk_usize 4) (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__from_i16_array
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(a: t_Slice i16)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector)
|
||||
(requires
|
||||
(v_VECTORS_IN_RING_ELEMENT *! mk_usize 16 <: usize) <=.
|
||||
(Core_models.Slice.impl__len #i16 a <: usize))
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__to_i16_array
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_PolynomialRingElement v_Vector)
|
||||
(out: t_Slice i16)
|
||||
: Prims.Pure (t_Slice i16)
|
||||
(requires
|
||||
(v_VECTORS_IN_RING_ELEMENT *! mk_usize 16 <: usize) <=.
|
||||
(Core_models.Slice.impl__len #i16 out <: usize))
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__from_bytes
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(bytes: t_Slice u8)
|
||||
: Prims.Pure (t_PolynomialRingElement v_Vector)
|
||||
(requires
|
||||
((v_VECTORS_IN_RING_ELEMENT *! mk_usize 16 <: usize) *! mk_usize 2 <: usize) <=.
|
||||
(Core_models.Slice.impl__len #u8 bytes <: usize))
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Build a vector of ring elements from `bytes`.
|
||||
val vec_from_bytes
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(bytes: t_Slice u8)
|
||||
(out: t_Slice (t_PolynomialRingElement v_Vector))
|
||||
: Prims.Pure (t_Slice (t_PolynomialRingElement v_Vector))
|
||||
(requires
|
||||
(Core_models.Slice.impl__len #(t_PolynomialRingElement v_Vector) out <: usize) <=. mk_usize 4 &&
|
||||
(((v_VECTORS_IN_RING_ELEMENT *! mk_usize 16 <: usize) *! mk_usize 2 <: usize) *!
|
||||
(Core_models.Slice.impl__len #(t_PolynomialRingElement v_Vector) out <: usize)
|
||||
<:
|
||||
usize) <=.
|
||||
(Core_models.Slice.impl__len #u8 bytes <: usize))
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__to_bytes
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(self: t_PolynomialRingElement v_Vector)
|
||||
(out: t_Slice u8)
|
||||
: Prims.Pure (t_Slice u8)
|
||||
(requires
|
||||
((v_VECTORS_IN_RING_ELEMENT *! mk_usize 16 <: usize) *! mk_usize 2 <: usize) <=.
|
||||
(Core_models.Slice.impl__len #u8 out <: usize))
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Get the bytes of the vector of ring elements in `re` and write them to `out`.
|
||||
val vec_to_bytes
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(re: t_Slice (t_PolynomialRingElement v_Vector))
|
||||
(out: t_Slice u8)
|
||||
: Prims.Pure (t_Slice u8)
|
||||
(requires
|
||||
(Core_models.Slice.impl__len #(t_PolynomialRingElement v_Vector) re <: usize) <=. mk_usize 4 &&
|
||||
(((v_VECTORS_IN_RING_ELEMENT *! mk_usize 16 <: usize) *! mk_usize 2 <: usize) *!
|
||||
(Core_models.Slice.impl__len #(t_PolynomialRingElement v_Vector) re <: usize)
|
||||
<:
|
||||
usize) <=.
|
||||
(Core_models.Slice.impl__len #u8 out <: usize))
|
||||
(fun _ -> Prims.l_True)
|
||||
@@ -0,0 +1,281 @@
|
||||
module Libcrux_ml_kem.Serialize
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
let _ =
|
||||
(* This module has implicit dependencies, here we make them explicit. *)
|
||||
(* The implicit dependencies arise from typeclasses instances. *)
|
||||
let open Libcrux_ml_kem.Vector.Traits in
|
||||
()
|
||||
|
||||
[@@ "opaque_to_smt"]
|
||||
let field_modulus_range (#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(a: v_Vector) =
|
||||
let coef = Libcrux_ml_kem.Vector.Traits.f_to_i16_array a in
|
||||
forall (i:nat). i < 16 ==> v (Seq.index coef i) > -(v Libcrux_ml_kem.Vector.Traits.v_FIELD_MODULUS) /\
|
||||
v (Seq.index coef i) < v Libcrux_ml_kem.Vector.Traits.v_FIELD_MODULUS
|
||||
|
||||
[@@ "opaque_to_smt"]
|
||||
let coefficients_field_modulus_range (#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(re: Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) =
|
||||
forall (i:nat). i < 16 ==> field_modulus_range (Seq.index re.f_coefficients i)
|
||||
|
||||
val to_unsigned_field_modulus
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(a: v_Vector)
|
||||
: Prims.Pure v_Vector
|
||||
(requires field_modulus_range a)
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:v_Vector = result in
|
||||
forall (i: nat).
|
||||
i < 16 ==>
|
||||
v (Seq.index (Libcrux_ml_kem.Vector.Traits.f_to_i16_array result) i) >= 0 /\
|
||||
v (Seq.index (Libcrux_ml_kem.Vector.Traits.f_to_i16_array result) i) <
|
||||
v Libcrux_ml_kem.Vector.Traits.v_FIELD_MODULUS)
|
||||
|
||||
val compress_then_serialize_message
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(re: Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 32))
|
||||
(requires coefficients_field_modulus_range re)
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array u8 (mk_usize 32) = result in
|
||||
result ==
|
||||
Spec.MLKEM.compress_then_encode_message (Libcrux_ml_kem.Polynomial.to_spec_poly_t #v_Vector
|
||||
re))
|
||||
|
||||
val deserialize_then_decompress_message
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(serialized: t_Array u8 (mk_usize 32))
|
||||
: Prims.Pure (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector = result in
|
||||
Libcrux_ml_kem.Polynomial.to_spec_poly_t #v_Vector result ==
|
||||
Spec.MLKEM.decode_then_decompress_message serialized)
|
||||
|
||||
val serialize_uncompressed_ring_element
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(re: Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_Array u8 (mk_usize 384))
|
||||
(requires coefficients_field_modulus_range re)
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array u8 (mk_usize 384) = result in
|
||||
result ==
|
||||
Spec.MLKEM.byte_encode 12 (Libcrux_ml_kem.Polynomial.to_spec_poly_t #v_Vector re))
|
||||
|
||||
val deserialize_to_uncompressed_ring_element
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(serialized: t_Slice u8)
|
||||
: Prims.Pure (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
(requires
|
||||
(Core_models.Slice.impl__len #u8 serialized <: usize) =.
|
||||
Libcrux_ml_kem.Constants.v_BYTES_PER_RING_ELEMENT)
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector = result in
|
||||
Libcrux_ml_kem.Polynomial.to_spec_poly_t #v_Vector result ==
|
||||
Spec.MLKEM.byte_decode 12 serialized)
|
||||
|
||||
/// Only use with public values.
|
||||
/// This MUST NOT be used with secret inputs, like its caller `deserialize_ring_elements_reduced`.
|
||||
val deserialize_to_reduced_ring_element
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(serialized: t_Slice u8)
|
||||
: Prims.Pure (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
(requires
|
||||
(Core_models.Slice.impl__len #u8 serialized <: usize) =.
|
||||
Libcrux_ml_kem.Constants.v_BYTES_PER_RING_ELEMENT)
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// See [deserialize_ring_elements_reduced_out].
|
||||
val deserialize_ring_elements_reduced
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(public_key: t_Slice u8)
|
||||
(deserialized_pk: t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K)
|
||||
: Prims.Pure (t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K)
|
||||
(requires
|
||||
Spec.MLKEM.is_rank v_K /\
|
||||
Seq.length public_key == v (Spec.MLKEM.v_T_AS_NTT_ENCODED_SIZE v_K))
|
||||
(ensures
|
||||
fun deserialized_pk_future ->
|
||||
let deserialized_pk_future:t_Array
|
||||
(Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K =
|
||||
deserialized_pk_future
|
||||
in
|
||||
Libcrux_ml_kem.Polynomial.to_spec_vector_t #v_K #v_Vector deserialized_pk_future ==
|
||||
Spec.MLKEM.vector_decode_12 #v_K public_key)
|
||||
|
||||
/// This function deserializes ring elements and reduces the result by the field
|
||||
/// modulus.
|
||||
/// This function MUST NOT be used on secret inputs.
|
||||
val deserialize_ring_elements_reduced_out
|
||||
(v_K: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(public_key: t_Slice u8)
|
||||
: Prims.Pure (t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K)
|
||||
(requires
|
||||
Spec.MLKEM.is_rank v_K /\
|
||||
Seq.length public_key == v (Spec.MLKEM.v_T_AS_NTT_ENCODED_SIZE v_K))
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector) v_K =
|
||||
result
|
||||
in
|
||||
forall (i: nat). i < v v_K ==> coefficients_field_modulus_range (Seq.index result i))
|
||||
|
||||
val compress_then_serialize_10_
|
||||
(v_OUT_LEN: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(re: Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_Array u8 v_OUT_LEN)
|
||||
(requires v v_OUT_LEN == 320 /\ coefficients_field_modulus_range re)
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val compress_then_serialize_11_
|
||||
(v_OUT_LEN: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(re: Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_Array u8 v_OUT_LEN) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val compress_then_serialize_ring_element_u
|
||||
(v_COMPRESSION_FACTOR v_OUT_LEN: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(re: Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
: Prims.Pure (t_Array u8 v_OUT_LEN)
|
||||
(requires
|
||||
(v v_COMPRESSION_FACTOR == 10 \/ v v_COMPRESSION_FACTOR == 11) /\
|
||||
v v_OUT_LEN == 32 * v v_COMPRESSION_FACTOR /\ coefficients_field_modulus_range re)
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array u8 v_OUT_LEN = result in
|
||||
result ==
|
||||
Spec.MLKEM.compress_then_byte_encode (v v_COMPRESSION_FACTOR)
|
||||
(Libcrux_ml_kem.Polynomial.to_spec_poly_t #v_Vector re))
|
||||
|
||||
val compress_then_serialize_4_
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(re: Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
(serialized: t_Slice u8)
|
||||
: Prims.Pure (t_Slice u8)
|
||||
(requires Seq.length serialized == 128 /\ coefficients_field_modulus_range re)
|
||||
(ensures
|
||||
fun serialized_future ->
|
||||
let serialized_future:t_Slice u8 = serialized_future in
|
||||
Core_models.Slice.impl__len #u8 serialized_future == Core_models.Slice.impl__len #u8 serialized)
|
||||
|
||||
val compress_then_serialize_5_
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(re: Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
(serialized: t_Slice u8)
|
||||
: Prims.Pure (t_Slice u8)
|
||||
(requires (Core_models.Slice.impl__len #u8 serialized <: usize) =. mk_usize 160)
|
||||
(ensures
|
||||
fun serialized_future ->
|
||||
let serialized_future:t_Slice u8 = serialized_future in
|
||||
Core_models.Slice.impl__len #u8 serialized_future == Core_models.Slice.impl__len #u8 serialized)
|
||||
|
||||
val compress_then_serialize_ring_element_v
|
||||
(v_K v_COMPRESSION_FACTOR v_OUT_LEN: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(re: Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
(out: t_Slice u8)
|
||||
: Prims.Pure (t_Slice u8)
|
||||
(requires
|
||||
Spec.MLKEM.is_rank v_K /\
|
||||
v_COMPRESSION_FACTOR == Spec.MLKEM.v_VECTOR_V_COMPRESSION_FACTOR v_K /\
|
||||
Seq.length out == v v_OUT_LEN /\ v v_OUT_LEN == 32 * v v_COMPRESSION_FACTOR /\
|
||||
coefficients_field_modulus_range re)
|
||||
(ensures
|
||||
fun out_future ->
|
||||
let out_future:t_Slice u8 = out_future in
|
||||
Core_models.Slice.impl__len #u8 out_future == Core_models.Slice.impl__len #u8 out /\
|
||||
out_future ==
|
||||
Spec.MLKEM.compress_then_encode_v #v_K
|
||||
(Libcrux_ml_kem.Polynomial.to_spec_poly_t #v_Vector re))
|
||||
|
||||
val deserialize_then_decompress_10_
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(serialized: t_Slice u8)
|
||||
: Prims.Pure (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
(requires (Core_models.Slice.impl__len #u8 serialized <: usize) =. mk_usize 320)
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val deserialize_then_decompress_11_
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(serialized: t_Slice u8)
|
||||
: Prims.Pure (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
(requires (Core_models.Slice.impl__len #u8 serialized <: usize) =. mk_usize 352)
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val deserialize_then_decompress_ring_element_u
|
||||
(v_COMPRESSION_FACTOR: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(serialized: t_Slice u8)
|
||||
: Prims.Pure (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
(requires
|
||||
(v_COMPRESSION_FACTOR =. mk_usize 10 || v_COMPRESSION_FACTOR =. mk_usize 11) &&
|
||||
(Core_models.Slice.impl__len #u8 serialized <: usize) =.
|
||||
(mk_usize 32 *! v_COMPRESSION_FACTOR <: usize))
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector = result in
|
||||
Libcrux_ml_kem.Polynomial.to_spec_poly_t #v_Vector result ==
|
||||
Spec.MLKEM.byte_decode_then_decompress (v v_COMPRESSION_FACTOR) serialized)
|
||||
|
||||
val deserialize_then_decompress_4_
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(serialized: t_Slice u8)
|
||||
: Prims.Pure (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
(requires (Core_models.Slice.impl__len #u8 serialized <: usize) =. mk_usize 128)
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val deserialize_then_decompress_5_
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(serialized: t_Slice u8)
|
||||
: Prims.Pure (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
(requires (Core_models.Slice.impl__len #u8 serialized <: usize) =. mk_usize 160)
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
val deserialize_then_decompress_ring_element_v
|
||||
(v_K v_COMPRESSION_FACTOR: usize)
|
||||
(#v_Vector: Type0)
|
||||
{| i1: Libcrux_ml_kem.Vector.Traits.t_Operations v_Vector |}
|
||||
(serialized: t_Slice u8)
|
||||
: Prims.Pure (Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector)
|
||||
(requires
|
||||
Spec.MLKEM.is_rank v_K /\
|
||||
v_COMPRESSION_FACTOR == Spec.MLKEM.v_VECTOR_V_COMPRESSION_FACTOR v_K /\
|
||||
Seq.length serialized == 32 * v v_COMPRESSION_FACTOR)
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:Libcrux_ml_kem.Polynomial.t_PolynomialRingElement v_Vector = result in
|
||||
Libcrux_ml_kem.Polynomial.to_spec_poly_t #v_Vector result ==
|
||||
Spec.MLKEM.decode_then_decompress_v #v_K serialized)
|
||||
@@ -0,0 +1,422 @@
|
||||
module Libcrux_ml_kem.Types
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
///An ML-KEM Ciphertext
|
||||
type t_MlKemCiphertext (v_SIZE: usize) = { f_value:t_Array u8 v_SIZE }
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl (v_SIZE: usize) : Core_models.Default.t_Default (t_MlKemCiphertext v_SIZE) =
|
||||
{
|
||||
f_default_pre = (fun (_: Prims.unit) -> true);
|
||||
f_default_post = (fun (_: Prims.unit) (out: t_MlKemCiphertext v_SIZE) -> true);
|
||||
f_default
|
||||
=
|
||||
fun (_: Prims.unit) ->
|
||||
{ f_value = Rust_primitives.Hax.repeat (mk_u8 0) v_SIZE } <: t_MlKemCiphertext v_SIZE
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_4 (v_SIZE: usize) : Core_models.Convert.t_AsRef (t_MlKemCiphertext v_SIZE) (t_Slice u8) =
|
||||
{
|
||||
f_as_ref_pre = (fun (self: t_MlKemCiphertext v_SIZE) -> true);
|
||||
f_as_ref_post
|
||||
=
|
||||
(fun (self_: t_MlKemCiphertext v_SIZE) (result: t_Slice u8) -> result = self_.f_value);
|
||||
f_as_ref = fun (self: t_MlKemCiphertext v_SIZE) -> self.f_value <: t_Slice u8
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_5 (v_SIZE: usize) : Core_models.Convert.t_From (t_MlKemCiphertext v_SIZE) (t_Array u8 v_SIZE) =
|
||||
{
|
||||
f_from_pre = (fun (value: t_Array u8 v_SIZE) -> true);
|
||||
f_from_post
|
||||
=
|
||||
(fun (value: t_Array u8 v_SIZE) (result: t_MlKemCiphertext v_SIZE) -> result.f_value = value);
|
||||
f_from = fun (value: t_Array u8 v_SIZE) -> { f_value = value } <: t_MlKemCiphertext v_SIZE
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_1 (v_SIZE: usize) : Core_models.Convert.t_From (t_MlKemCiphertext v_SIZE) (t_Array u8 v_SIZE) =
|
||||
{
|
||||
f_from_pre = (fun (value: t_Array u8 v_SIZE) -> true);
|
||||
f_from_post = (fun (value: t_Array u8 v_SIZE) (out: t_MlKemCiphertext v_SIZE) -> true);
|
||||
f_from
|
||||
=
|
||||
fun (value: t_Array u8 v_SIZE) ->
|
||||
{ f_value = Core_models.Clone.f_clone #(t_Array u8 v_SIZE) #FStar.Tactics.Typeclasses.solve value }
|
||||
<:
|
||||
t_MlKemCiphertext v_SIZE
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_2 (v_SIZE: usize) : Core_models.Convert.t_From (t_Array u8 v_SIZE) (t_MlKemCiphertext v_SIZE) =
|
||||
{
|
||||
f_from_pre = (fun (value: t_MlKemCiphertext v_SIZE) -> true);
|
||||
f_from_post = (fun (value: t_MlKemCiphertext v_SIZE) (out: t_Array u8 v_SIZE) -> true);
|
||||
f_from = fun (value: t_MlKemCiphertext v_SIZE) -> value.f_value
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_3 (v_SIZE: usize) : Core_models.Convert.t_TryFrom (t_MlKemCiphertext v_SIZE) (t_Slice u8) =
|
||||
{
|
||||
f_Error = Core_models.Array.t_TryFromSliceError;
|
||||
f_try_from_pre = (fun (value: t_Slice u8) -> true);
|
||||
f_try_from_post
|
||||
=
|
||||
(fun
|
||||
(value: t_Slice u8)
|
||||
(out: Core_models.Result.t_Result (t_MlKemCiphertext v_SIZE) Core_models.Array.t_TryFromSliceError)
|
||||
->
|
||||
true);
|
||||
f_try_from
|
||||
=
|
||||
fun (value: t_Slice u8) ->
|
||||
match
|
||||
Core_models.Convert.f_try_into #(t_Slice u8)
|
||||
#(t_Array u8 v_SIZE)
|
||||
#FStar.Tactics.Typeclasses.solve
|
||||
value
|
||||
<:
|
||||
Core_models.Result.t_Result (t_Array u8 v_SIZE) Core_models.Array.t_TryFromSliceError
|
||||
with
|
||||
| Core_models.Result.Result_Ok value ->
|
||||
Core_models.Result.Result_Ok ({ f_value = value } <: t_MlKemCiphertext v_SIZE)
|
||||
<:
|
||||
Core_models.Result.t_Result (t_MlKemCiphertext v_SIZE) Core_models.Array.t_TryFromSliceError
|
||||
| Core_models.Result.Result_Err e ->
|
||||
Core_models.Result.Result_Err e
|
||||
<:
|
||||
Core_models.Result.t_Result (t_MlKemCiphertext v_SIZE) Core_models.Array.t_TryFromSliceError
|
||||
}
|
||||
|
||||
/// The number of bytes
|
||||
let impl_6__len (v_SIZE: usize) (_: Prims.unit) : usize = v_SIZE
|
||||
|
||||
/// A reference to the raw byte slice.
|
||||
let impl_6__as_slice (v_SIZE: usize) (self: t_MlKemCiphertext v_SIZE)
|
||||
: Prims.Pure (t_Array u8 v_SIZE)
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array u8 v_SIZE = result in
|
||||
result == self.f_value) = self.f_value
|
||||
|
||||
///An ML-KEM Private key
|
||||
type t_MlKemPrivateKey (v_SIZE: usize) = { f_value:t_Array u8 v_SIZE }
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_7 (v_SIZE: usize) : Core_models.Default.t_Default (t_MlKemPrivateKey v_SIZE) =
|
||||
{
|
||||
f_default_pre = (fun (_: Prims.unit) -> true);
|
||||
f_default_post = (fun (_: Prims.unit) (out: t_MlKemPrivateKey v_SIZE) -> true);
|
||||
f_default
|
||||
=
|
||||
fun (_: Prims.unit) ->
|
||||
{ f_value = Rust_primitives.Hax.repeat (mk_u8 0) v_SIZE } <: t_MlKemPrivateKey v_SIZE
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_11 (v_SIZE: usize) : Core_models.Convert.t_AsRef (t_MlKemPrivateKey v_SIZE) (t_Slice u8) =
|
||||
{
|
||||
f_as_ref_pre = (fun (self: t_MlKemPrivateKey v_SIZE) -> true);
|
||||
f_as_ref_post
|
||||
=
|
||||
(fun (self_: t_MlKemPrivateKey v_SIZE) (result: t_Slice u8) -> result = self_.f_value);
|
||||
f_as_ref = fun (self: t_MlKemPrivateKey v_SIZE) -> self.f_value <: t_Slice u8
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_12 (v_SIZE: usize) : Core_models.Convert.t_From (t_MlKemPrivateKey v_SIZE) (t_Array u8 v_SIZE) =
|
||||
{
|
||||
f_from_pre = (fun (value: t_Array u8 v_SIZE) -> true);
|
||||
f_from_post
|
||||
=
|
||||
(fun (value: t_Array u8 v_SIZE) (result: t_MlKemPrivateKey v_SIZE) -> result.f_value = value);
|
||||
f_from = fun (value: t_Array u8 v_SIZE) -> { f_value = value } <: t_MlKemPrivateKey v_SIZE
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_8 (v_SIZE: usize) : Core_models.Convert.t_From (t_MlKemPrivateKey v_SIZE) (t_Array u8 v_SIZE) =
|
||||
{
|
||||
f_from_pre = (fun (value: t_Array u8 v_SIZE) -> true);
|
||||
f_from_post = (fun (value: t_Array u8 v_SIZE) (out: t_MlKemPrivateKey v_SIZE) -> true);
|
||||
f_from
|
||||
=
|
||||
fun (value: t_Array u8 v_SIZE) ->
|
||||
{ f_value = Core_models.Clone.f_clone #(t_Array u8 v_SIZE) #FStar.Tactics.Typeclasses.solve value }
|
||||
<:
|
||||
t_MlKemPrivateKey v_SIZE
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_9 (v_SIZE: usize) : Core_models.Convert.t_From (t_Array u8 v_SIZE) (t_MlKemPrivateKey v_SIZE) =
|
||||
{
|
||||
f_from_pre = (fun (value: t_MlKemPrivateKey v_SIZE) -> true);
|
||||
f_from_post = (fun (value: t_MlKemPrivateKey v_SIZE) (out: t_Array u8 v_SIZE) -> true);
|
||||
f_from = fun (value: t_MlKemPrivateKey v_SIZE) -> value.f_value
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_10 (v_SIZE: usize) : Core_models.Convert.t_TryFrom (t_MlKemPrivateKey v_SIZE) (t_Slice u8) =
|
||||
{
|
||||
f_Error = Core_models.Array.t_TryFromSliceError;
|
||||
f_try_from_pre = (fun (value: t_Slice u8) -> true);
|
||||
f_try_from_post
|
||||
=
|
||||
(fun
|
||||
(value: t_Slice u8)
|
||||
(out: Core_models.Result.t_Result (t_MlKemPrivateKey v_SIZE) Core_models.Array.t_TryFromSliceError)
|
||||
->
|
||||
true);
|
||||
f_try_from
|
||||
=
|
||||
fun (value: t_Slice u8) ->
|
||||
match
|
||||
Core_models.Convert.f_try_into #(t_Slice u8)
|
||||
#(t_Array u8 v_SIZE)
|
||||
#FStar.Tactics.Typeclasses.solve
|
||||
value
|
||||
<:
|
||||
Core_models.Result.t_Result (t_Array u8 v_SIZE) Core_models.Array.t_TryFromSliceError
|
||||
with
|
||||
| Core_models.Result.Result_Ok value ->
|
||||
Core_models.Result.Result_Ok ({ f_value = value } <: t_MlKemPrivateKey v_SIZE)
|
||||
<:
|
||||
Core_models.Result.t_Result (t_MlKemPrivateKey v_SIZE) Core_models.Array.t_TryFromSliceError
|
||||
| Core_models.Result.Result_Err e ->
|
||||
Core_models.Result.Result_Err e
|
||||
<:
|
||||
Core_models.Result.t_Result (t_MlKemPrivateKey v_SIZE) Core_models.Array.t_TryFromSliceError
|
||||
}
|
||||
|
||||
/// The number of bytes
|
||||
let impl_13__len (v_SIZE: usize) (_: Prims.unit) : usize = v_SIZE
|
||||
|
||||
/// A reference to the raw byte slice.
|
||||
let impl_13__as_slice (v_SIZE: usize) (self: t_MlKemPrivateKey v_SIZE)
|
||||
: Prims.Pure (t_Array u8 v_SIZE)
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array u8 v_SIZE = result in
|
||||
result == self.f_value) = self.f_value
|
||||
|
||||
///An ML-KEM Public key
|
||||
type t_MlKemPublicKey (v_SIZE: usize) = { f_value:t_Array u8 v_SIZE }
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_14 (v_SIZE: usize) : Core_models.Default.t_Default (t_MlKemPublicKey v_SIZE) =
|
||||
{
|
||||
f_default_pre = (fun (_: Prims.unit) -> true);
|
||||
f_default_post = (fun (_: Prims.unit) (out: t_MlKemPublicKey v_SIZE) -> true);
|
||||
f_default
|
||||
=
|
||||
fun (_: Prims.unit) ->
|
||||
{ f_value = Rust_primitives.Hax.repeat (mk_u8 0) v_SIZE } <: t_MlKemPublicKey v_SIZE
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_18 (v_SIZE: usize) : Core_models.Convert.t_AsRef (t_MlKemPublicKey v_SIZE) (t_Slice u8) =
|
||||
{
|
||||
f_as_ref_pre = (fun (self: t_MlKemPublicKey v_SIZE) -> true);
|
||||
f_as_ref_post
|
||||
=
|
||||
(fun (self_: t_MlKemPublicKey v_SIZE) (result: t_Slice u8) -> result = self_.f_value);
|
||||
f_as_ref = fun (self: t_MlKemPublicKey v_SIZE) -> self.f_value <: t_Slice u8
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_19 (v_SIZE: usize) : Core_models.Convert.t_From (t_MlKemPublicKey v_SIZE) (t_Array u8 v_SIZE) =
|
||||
{
|
||||
f_from_pre = (fun (value: t_Array u8 v_SIZE) -> true);
|
||||
f_from_post
|
||||
=
|
||||
(fun (value: t_Array u8 v_SIZE) (result: t_MlKemPublicKey v_SIZE) -> result.f_value = value);
|
||||
f_from = fun (value: t_Array u8 v_SIZE) -> { f_value = value } <: t_MlKemPublicKey v_SIZE
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_15 (v_SIZE: usize) : Core_models.Convert.t_From (t_MlKemPublicKey v_SIZE) (t_Array u8 v_SIZE) =
|
||||
{
|
||||
f_from_pre = (fun (value: t_Array u8 v_SIZE) -> true);
|
||||
f_from_post = (fun (value: t_Array u8 v_SIZE) (out: t_MlKemPublicKey v_SIZE) -> true);
|
||||
f_from
|
||||
=
|
||||
fun (value: t_Array u8 v_SIZE) ->
|
||||
{ f_value = Core_models.Clone.f_clone #(t_Array u8 v_SIZE) #FStar.Tactics.Typeclasses.solve value }
|
||||
<:
|
||||
t_MlKemPublicKey v_SIZE
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_16 (v_SIZE: usize) : Core_models.Convert.t_From (t_Array u8 v_SIZE) (t_MlKemPublicKey v_SIZE) =
|
||||
{
|
||||
f_from_pre = (fun (value: t_MlKemPublicKey v_SIZE) -> true);
|
||||
f_from_post = (fun (value: t_MlKemPublicKey v_SIZE) (out: t_Array u8 v_SIZE) -> true);
|
||||
f_from = fun (value: t_MlKemPublicKey v_SIZE) -> value.f_value
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_17 (v_SIZE: usize) : Core_models.Convert.t_TryFrom (t_MlKemPublicKey v_SIZE) (t_Slice u8) =
|
||||
{
|
||||
f_Error = Core_models.Array.t_TryFromSliceError;
|
||||
f_try_from_pre = (fun (value: t_Slice u8) -> true);
|
||||
f_try_from_post
|
||||
=
|
||||
(fun
|
||||
(value: t_Slice u8)
|
||||
(out: Core_models.Result.t_Result (t_MlKemPublicKey v_SIZE) Core_models.Array.t_TryFromSliceError)
|
||||
->
|
||||
true);
|
||||
f_try_from
|
||||
=
|
||||
fun (value: t_Slice u8) ->
|
||||
match
|
||||
Core_models.Convert.f_try_into #(t_Slice u8)
|
||||
#(t_Array u8 v_SIZE)
|
||||
#FStar.Tactics.Typeclasses.solve
|
||||
value
|
||||
<:
|
||||
Core_models.Result.t_Result (t_Array u8 v_SIZE) Core_models.Array.t_TryFromSliceError
|
||||
with
|
||||
| Core_models.Result.Result_Ok value ->
|
||||
Core_models.Result.Result_Ok ({ f_value = value } <: t_MlKemPublicKey v_SIZE)
|
||||
<:
|
||||
Core_models.Result.t_Result (t_MlKemPublicKey v_SIZE) Core_models.Array.t_TryFromSliceError
|
||||
| Core_models.Result.Result_Err e ->
|
||||
Core_models.Result.Result_Err e
|
||||
<:
|
||||
Core_models.Result.t_Result (t_MlKemPublicKey v_SIZE) Core_models.Array.t_TryFromSliceError
|
||||
}
|
||||
|
||||
/// The number of bytes
|
||||
let impl_20__len (v_SIZE: usize) (_: Prims.unit) : usize = v_SIZE
|
||||
|
||||
/// A reference to the raw byte slice.
|
||||
let impl_20__as_slice (v_SIZE: usize) (self: t_MlKemPublicKey v_SIZE)
|
||||
: Prims.Pure (t_Array u8 v_SIZE)
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_Array u8 v_SIZE = result in
|
||||
result == self.f_value) = self.f_value
|
||||
|
||||
/// An ML-KEM key pair
|
||||
type t_MlKemKeyPair (v_PRIVATE_KEY_SIZE: usize) (v_PUBLIC_KEY_SIZE: usize) = {
|
||||
f_sk:t_MlKemPrivateKey v_PRIVATE_KEY_SIZE;
|
||||
f_pk:t_MlKemPublicKey v_PUBLIC_KEY_SIZE
|
||||
}
|
||||
|
||||
/// Creates a new [`MlKemKeyPair`].
|
||||
let impl_21__new
|
||||
(v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE: usize)
|
||||
(sk: t_Array u8 v_PRIVATE_KEY_SIZE)
|
||||
(pk: t_Array u8 v_PUBLIC_KEY_SIZE)
|
||||
: t_MlKemKeyPair v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE =
|
||||
{
|
||||
f_sk
|
||||
=
|
||||
Core_models.Convert.f_into #(t_Array u8 v_PRIVATE_KEY_SIZE)
|
||||
#(t_MlKemPrivateKey v_PRIVATE_KEY_SIZE)
|
||||
#FStar.Tactics.Typeclasses.solve
|
||||
sk;
|
||||
f_pk
|
||||
=
|
||||
Core_models.Convert.f_into #(t_Array u8 v_PUBLIC_KEY_SIZE)
|
||||
#(t_MlKemPublicKey v_PUBLIC_KEY_SIZE)
|
||||
#FStar.Tactics.Typeclasses.solve
|
||||
pk
|
||||
}
|
||||
<:
|
||||
t_MlKemKeyPair v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE
|
||||
|
||||
/// Get a reference to the [`MlKemPublicKey<PUBLIC_KEY_SIZE>`].
|
||||
let impl_21__public_key
|
||||
(v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE: usize)
|
||||
(self: t_MlKemKeyPair v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE)
|
||||
: t_MlKemPublicKey v_PUBLIC_KEY_SIZE = self.f_pk
|
||||
|
||||
/// Get a reference to the [`MlKemPrivateKey<PRIVATE_KEY_SIZE>`].
|
||||
let impl_21__private_key
|
||||
(v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE: usize)
|
||||
(self: t_MlKemKeyPair v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE)
|
||||
: t_MlKemPrivateKey v_PRIVATE_KEY_SIZE = self.f_sk
|
||||
|
||||
/// Get a reference to the raw public key bytes.
|
||||
let impl_21__pk
|
||||
(v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE: usize)
|
||||
(self: t_MlKemKeyPair v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE)
|
||||
: t_Array u8 v_PUBLIC_KEY_SIZE = impl_20__as_slice v_PUBLIC_KEY_SIZE self.f_pk
|
||||
|
||||
/// Get a reference to the raw private key bytes.
|
||||
let impl_21__sk
|
||||
(v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE: usize)
|
||||
(self: t_MlKemKeyPair v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE)
|
||||
: t_Array u8 v_PRIVATE_KEY_SIZE = impl_13__as_slice v_PRIVATE_KEY_SIZE self.f_sk
|
||||
|
||||
/// Separate this key into the public and private key.
|
||||
let impl_21__into_parts
|
||||
(v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE: usize)
|
||||
(self: t_MlKemKeyPair v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE)
|
||||
: (t_MlKemPrivateKey v_PRIVATE_KEY_SIZE & t_MlKemPublicKey v_PUBLIC_KEY_SIZE) =
|
||||
self.f_sk, self.f_pk
|
||||
<:
|
||||
(t_MlKemPrivateKey v_PRIVATE_KEY_SIZE & t_MlKemPublicKey v_PUBLIC_KEY_SIZE)
|
||||
|
||||
/// Create a new [`MlKemKeyPair`] from the secret and public key.
|
||||
let impl_21__from
|
||||
(v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE: usize)
|
||||
(sk: t_MlKemPrivateKey v_PRIVATE_KEY_SIZE)
|
||||
(pk: t_MlKemPublicKey v_PUBLIC_KEY_SIZE)
|
||||
: Prims.Pure (t_MlKemKeyPair v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE)
|
||||
Prims.l_True
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:t_MlKemKeyPair v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE = result in
|
||||
result.f_sk == sk /\ result.f_pk == pk) =
|
||||
{ f_sk = sk; f_pk = pk } <: t_MlKemKeyPair v_PRIVATE_KEY_SIZE v_PUBLIC_KEY_SIZE
|
||||
|
||||
/// Unpack an incoming private key into it\'s different parts.
|
||||
/// We have this here in types to extract into a common core for C.
|
||||
let unpack_private_key (v_CPA_SECRET_KEY_SIZE v_PUBLIC_KEY_SIZE: usize) (private_key: t_Slice u8)
|
||||
: Prims.Pure (t_Slice u8 & t_Slice u8 & t_Slice u8 & t_Slice u8)
|
||||
(requires
|
||||
Seq.length private_key >=
|
||||
v v_CPA_SECRET_KEY_SIZE + v v_PUBLIC_KEY_SIZE + v Libcrux_ml_kem.Constants.v_H_DIGEST_SIZE)
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:(t_Slice u8 & t_Slice u8 & t_Slice u8 & t_Slice u8) = result in
|
||||
let ind_cpa_secret_key_s, rest = split private_key v_CPA_SECRET_KEY_SIZE in
|
||||
let ind_cpa_public_key_s, rest = split rest v_PUBLIC_KEY_SIZE in
|
||||
let ind_cpa_public_key_hash_s, implicit_rejection_value_s =
|
||||
split rest Libcrux_ml_kem.Constants.v_H_DIGEST_SIZE
|
||||
in
|
||||
let
|
||||
ind_cpa_secret_key, ind_cpa_public_key, ind_cpa_public_key_hash, implicit_rejection_value
|
||||
=
|
||||
result
|
||||
in
|
||||
ind_cpa_secret_key_s == ind_cpa_secret_key /\ ind_cpa_public_key_s == ind_cpa_public_key /\
|
||||
ind_cpa_public_key_hash_s == ind_cpa_public_key_hash /\
|
||||
implicit_rejection_value_s == implicit_rejection_value /\
|
||||
Seq.length ind_cpa_secret_key == v v_CPA_SECRET_KEY_SIZE /\
|
||||
Seq.length ind_cpa_public_key == v v_PUBLIC_KEY_SIZE /\
|
||||
Seq.length ind_cpa_public_key_hash == v Libcrux_ml_kem.Constants.v_H_DIGEST_SIZE /\
|
||||
Seq.length implicit_rejection_value ==
|
||||
Seq.length private_key -
|
||||
(v v_CPA_SECRET_KEY_SIZE + v v_PUBLIC_KEY_SIZE +
|
||||
v Libcrux_ml_kem.Constants.v_H_DIGEST_SIZE)) =
|
||||
let ind_cpa_secret_key, secret_key:(t_Slice u8 & t_Slice u8) =
|
||||
Core_models.Slice.impl__split_at #u8 private_key v_CPA_SECRET_KEY_SIZE
|
||||
in
|
||||
let ind_cpa_public_key, secret_key:(t_Slice u8 & t_Slice u8) =
|
||||
Core_models.Slice.impl__split_at #u8 secret_key v_PUBLIC_KEY_SIZE
|
||||
in
|
||||
let ind_cpa_public_key_hash, implicit_rejection_value:(t_Slice u8 & t_Slice u8) =
|
||||
Core_models.Slice.impl__split_at #u8 secret_key Libcrux_ml_kem.Constants.v_H_DIGEST_SIZE
|
||||
in
|
||||
ind_cpa_secret_key, ind_cpa_public_key, ind_cpa_public_key_hash, implicit_rejection_value
|
||||
<:
|
||||
(t_Slice u8 & t_Slice u8 & t_Slice u8 & t_Slice u8)
|
||||
@@ -0,0 +1,101 @@
|
||||
module Libcrux_ml_kem.Variant
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
let _ =
|
||||
(* This module has implicit dependencies, here we make them explicit. *)
|
||||
(* The implicit dependencies arise from typeclasses instances. *)
|
||||
let open Libcrux_ml_kem.Hash_functions in
|
||||
()
|
||||
|
||||
/// This trait collects differences in specification between ML-KEM
|
||||
/// (FIPS 203) and the Round 3 CRYSTALS-Kyber submission in the
|
||||
/// NIST PQ competition.
|
||||
/// cf. FIPS 203, Appendix C
|
||||
class t_Variant (v_Self: Type0) = {
|
||||
f_kdf_pre:
|
||||
v_K: usize ->
|
||||
v_CIPHERTEXT_SIZE: usize ->
|
||||
#v_Hasher: Type0 ->
|
||||
{| i1: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |} ->
|
||||
shared_secret: t_Slice u8 ->
|
||||
ciphertext: Libcrux_ml_kem.Types.t_MlKemCiphertext v_CIPHERTEXT_SIZE
|
||||
-> pred: Type0{(Core_models.Slice.impl__len #u8 shared_secret <: usize) =. mk_usize 32 ==> pred};
|
||||
f_kdf_post:
|
||||
v_K: usize ->
|
||||
v_CIPHERTEXT_SIZE: usize ->
|
||||
#v_Hasher: Type0 ->
|
||||
{| i1: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |} ->
|
||||
shared_secret: t_Slice u8 ->
|
||||
ciphertext: Libcrux_ml_kem.Types.t_MlKemCiphertext v_CIPHERTEXT_SIZE ->
|
||||
res: t_Array u8 (mk_usize 32)
|
||||
-> pred: Type0{pred ==> res == shared_secret};
|
||||
f_kdf:
|
||||
v_K: usize ->
|
||||
v_CIPHERTEXT_SIZE: usize ->
|
||||
#v_Hasher: Type0 ->
|
||||
{| i1: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |} ->
|
||||
x0: t_Slice u8 ->
|
||||
x1: Libcrux_ml_kem.Types.t_MlKemCiphertext v_CIPHERTEXT_SIZE
|
||||
-> Prims.Pure (t_Array u8 (mk_usize 32))
|
||||
(f_kdf_pre v_K v_CIPHERTEXT_SIZE #v_Hasher #i1 x0 x1)
|
||||
(fun result -> f_kdf_post v_K v_CIPHERTEXT_SIZE #v_Hasher #i1 x0 x1 result);
|
||||
f_entropy_preprocess_pre:
|
||||
v_K: usize ->
|
||||
#v_Hasher: Type0 ->
|
||||
{| i3: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |} ->
|
||||
randomness: t_Slice u8
|
||||
-> pred: Type0{(Core_models.Slice.impl__len #u8 randomness <: usize) =. mk_usize 32 ==> pred};
|
||||
f_entropy_preprocess_post:
|
||||
v_K: usize ->
|
||||
#v_Hasher: Type0 ->
|
||||
{| i3: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |} ->
|
||||
randomness: t_Slice u8 ->
|
||||
res: t_Array u8 (mk_usize 32)
|
||||
-> pred: Type0{pred ==> res == randomness};
|
||||
f_entropy_preprocess:
|
||||
v_K: usize ->
|
||||
#v_Hasher: Type0 ->
|
||||
{| i3: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |} ->
|
||||
x0: t_Slice u8
|
||||
-> Prims.Pure (t_Array u8 (mk_usize 32))
|
||||
(f_entropy_preprocess_pre v_K #v_Hasher #i3 x0)
|
||||
(fun result -> f_entropy_preprocess_post v_K #v_Hasher #i3 x0 result);
|
||||
f_cpa_keygen_seed_pre:
|
||||
v_K: usize ->
|
||||
#v_Hasher: Type0 ->
|
||||
{| i3: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |} ->
|
||||
seed: t_Slice u8
|
||||
-> pred: Type0{(Core_models.Slice.impl__len #u8 seed <: usize) =. mk_usize 32 ==> pred};
|
||||
f_cpa_keygen_seed_post:
|
||||
v_K: usize ->
|
||||
#v_Hasher: Type0 ->
|
||||
{| i3: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |} ->
|
||||
seed: t_Slice u8 ->
|
||||
res: t_Array u8 (mk_usize 64)
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
Seq.length seed == 32 ==>
|
||||
res == Spec.Utils.v_G (Seq.append seed (Seq.create 1 (cast v_K <: u8))) };
|
||||
f_cpa_keygen_seed:
|
||||
v_K: usize ->
|
||||
#v_Hasher: Type0 ->
|
||||
{| i3: Libcrux_ml_kem.Hash_functions.t_Hash v_Hasher v_K |} ->
|
||||
x0: t_Slice u8
|
||||
-> Prims.Pure (t_Array u8 (mk_usize 64))
|
||||
(f_cpa_keygen_seed_pre v_K #v_Hasher #i3 x0)
|
||||
(fun result -> f_cpa_keygen_seed_post v_K #v_Hasher #i3 x0 result)
|
||||
}
|
||||
|
||||
/// Implements [`Variant`], to perform the ML-KEM-specific actions
|
||||
/// during encapsulation and decapsulation.
|
||||
/// Specifically,
|
||||
/// * during key generation, the seed hash is domain separated (this is a difference from the FIPS 203 IPD and Kyber)
|
||||
/// * during encapsulation, the initial randomness is used without prior hashing,
|
||||
/// * the derivation of the shared secret does not include a hash of the ML-KEM ciphertext.
|
||||
type t_MlKem = | MlKem : t_MlKem
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl:t_Variant t_MlKem
|
||||
@@ -0,0 +1,451 @@
|
||||
module Libcrux_ml_kem.Vector.Traits
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
let v_MONTGOMERY_R_SQUARED_MOD_FIELD_MODULUS: i16 = mk_i16 1353
|
||||
|
||||
let v_FIELD_MODULUS: i16 = mk_i16 3329
|
||||
|
||||
let v_FIELD_ELEMENTS_IN_VECTOR: usize = mk_usize 16
|
||||
|
||||
let v_INVERSE_OF_MODULUS_MOD_MONTGOMERY_R: u32 = mk_u32 62209
|
||||
|
||||
let v_BARRETT_SHIFT: i32 = mk_i32 26
|
||||
|
||||
let v_BARRETT_R: i32 = mk_i32 1 <<! v_BARRETT_SHIFT
|
||||
|
||||
class t_Repr (v_Self: Type0) = {
|
||||
[@@@ FStar.Tactics.Typeclasses.no_method]_super_5883514518384729217:Core_models.Marker.t_Copy v_Self;
|
||||
[@@@ FStar.Tactics.Typeclasses.no_method]_super_16027770981543256320:Core_models.Clone.t_Clone v_Self;
|
||||
f_repr_pre:x: v_Self -> pred: Type0{true ==> pred};
|
||||
f_repr_post:v_Self -> t_Array i16 (mk_usize 16) -> Type0;
|
||||
f_repr:x0: v_Self
|
||||
-> Prims.Pure (t_Array i16 (mk_usize 16)) (f_repr_pre x0) (fun result -> f_repr_post x0 result)
|
||||
}
|
||||
|
||||
class t_Operations (v_Self: Type0) = {
|
||||
[@@@ FStar.Tactics.Typeclasses.no_method]_super_5883514518384729217:Core_models.Marker.t_Copy v_Self;
|
||||
[@@@ FStar.Tactics.Typeclasses.no_method]_super_16027770981543256320:Core_models.Clone.t_Clone v_Self;
|
||||
[@@@ FStar.Tactics.Typeclasses.no_method]_super_15138760880757129450:t_Repr v_Self;
|
||||
f_ZERO_pre:x: Prims.unit
|
||||
-> pred:
|
||||
Type0
|
||||
{ (let _:Prims.unit = x in
|
||||
true) ==>
|
||||
pred };
|
||||
f_ZERO_post:x: Prims.unit -> result: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
(let _:Prims.unit = x in
|
||||
f_repr result == Seq.create 16 (mk_i16 0)) };
|
||||
f_ZERO:x0: Prims.unit -> Prims.Pure v_Self (f_ZERO_pre x0) (fun result -> f_ZERO_post x0 result);
|
||||
f_from_i16_array_pre:array: t_Slice i16
|
||||
-> pred: Type0{(Core_models.Slice.impl__len #i16 array <: usize) =. mk_usize 16 ==> pred};
|
||||
f_from_i16_array_post:array: t_Slice i16 -> result: v_Self
|
||||
-> pred: Type0{pred ==> f_repr result == array};
|
||||
f_from_i16_array:x0: t_Slice i16
|
||||
-> Prims.Pure v_Self (f_from_i16_array_pre x0) (fun result -> f_from_i16_array_post x0 result);
|
||||
f_to_i16_array_pre:x: v_Self -> pred: Type0{true ==> pred};
|
||||
f_to_i16_array_post:x: v_Self -> result: t_Array i16 (mk_usize 16)
|
||||
-> pred: Type0{pred ==> f_repr x == result};
|
||||
f_to_i16_array:x0: v_Self
|
||||
-> Prims.Pure (t_Array i16 (mk_usize 16))
|
||||
(f_to_i16_array_pre x0)
|
||||
(fun result -> f_to_i16_array_post x0 result);
|
||||
f_from_bytes_pre:array: t_Slice u8
|
||||
-> pred: Type0{(Core_models.Slice.impl__len #u8 array <: usize) >=. mk_usize 32 ==> pred};
|
||||
f_from_bytes_post:t_Slice u8 -> v_Self -> Type0;
|
||||
f_from_bytes:x0: t_Slice u8
|
||||
-> Prims.Pure v_Self (f_from_bytes_pre x0) (fun result -> f_from_bytes_post x0 result);
|
||||
f_to_bytes_pre:x: v_Self -> bytes: t_Slice u8
|
||||
-> pred: Type0{(Core_models.Slice.impl__len #u8 bytes <: usize) >=. mk_usize 32 ==> pred};
|
||||
f_to_bytes_post:v_Self -> t_Slice u8 -> t_Slice u8 -> Type0;
|
||||
f_to_bytes:x0: v_Self -> x1: t_Slice u8
|
||||
-> Prims.Pure (t_Slice u8) (f_to_bytes_pre x0 x1) (fun result -> f_to_bytes_post x0 x1 result);
|
||||
f_add_pre:lhs: v_Self -> rhs: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{ (forall i.
|
||||
i < 16 ==>
|
||||
Spec.Utils.is_intb (pow2 15 - 1)
|
||||
(v (Seq.index (f_repr lhs) i) + v (Seq.index (f_repr rhs) i))) ==>
|
||||
pred };
|
||||
f_add_post:lhs: v_Self -> rhs: v_Self -> result: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
(forall i.
|
||||
i < 16 ==>
|
||||
(v (Seq.index (f_repr result) i) ==
|
||||
v (Seq.index (f_repr lhs) i) + v (Seq.index (f_repr rhs) i))) };
|
||||
f_add:x0: v_Self -> x1: v_Self
|
||||
-> Prims.Pure v_Self (f_add_pre x0 x1) (fun result -> f_add_post x0 x1 result);
|
||||
f_sub_pre:lhs: v_Self -> rhs: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{ (forall i.
|
||||
i < 16 ==>
|
||||
Spec.Utils.is_intb (pow2 15 - 1)
|
||||
(v (Seq.index (f_repr lhs) i) - v (Seq.index (f_repr rhs) i))) ==>
|
||||
pred };
|
||||
f_sub_post:lhs: v_Self -> rhs: v_Self -> result: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
(forall i.
|
||||
i < 16 ==>
|
||||
(v (Seq.index (f_repr result) i) ==
|
||||
v (Seq.index (f_repr lhs) i) - v (Seq.index (f_repr rhs) i))) };
|
||||
f_sub:x0: v_Self -> x1: v_Self
|
||||
-> Prims.Pure v_Self (f_sub_pre x0 x1) (fun result -> f_sub_post x0 x1 result);
|
||||
f_multiply_by_constant_pre:vec: v_Self -> c: i16
|
||||
-> pred:
|
||||
Type0
|
||||
{ (forall i.
|
||||
i < 16 ==> Spec.Utils.is_intb (pow2 15 - 1) (v (Seq.index (f_repr vec) i) * v c)) ==>
|
||||
pred };
|
||||
f_multiply_by_constant_post:vec: v_Self -> c: i16 -> result: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
(forall i.
|
||||
i < 16 ==> (v (Seq.index (f_repr result) i) == v (Seq.index (f_repr vec) i) * v c)) };
|
||||
f_multiply_by_constant:x0: v_Self -> x1: i16
|
||||
-> Prims.Pure v_Self
|
||||
(f_multiply_by_constant_pre x0 x1)
|
||||
(fun result -> f_multiply_by_constant_post x0 x1 result);
|
||||
f_bitwise_and_with_constant_pre:v: v_Self -> c: i16 -> pred: Type0{true ==> pred};
|
||||
f_bitwise_and_with_constant_post:v: v_Self -> c: i16 -> result: v_Self
|
||||
-> pred: Type0{pred ==> f_repr result == Spec.Utils.map_array (fun x -> x &. c) (f_repr v)};
|
||||
f_bitwise_and_with_constant:x0: v_Self -> x1: i16
|
||||
-> Prims.Pure v_Self
|
||||
(f_bitwise_and_with_constant_pre x0 x1)
|
||||
(fun result -> f_bitwise_and_with_constant_post x0 x1 result);
|
||||
f_shift_right_pre:v_SHIFT_BY: i32 -> v: v_Self
|
||||
-> pred: Type0{v_SHIFT_BY >=. mk_i32 0 && v_SHIFT_BY <. mk_i32 16 ==> pred};
|
||||
f_shift_right_post:v_SHIFT_BY: i32 -> v: v_Self -> result: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
(v_SHIFT_BY >=. (mk_i32 0) /\ v_SHIFT_BY <. (mk_i32 16)) ==>
|
||||
f_repr result == Spec.Utils.map_array (fun x -> x >>! v_SHIFT_BY) (f_repr v) };
|
||||
f_shift_right:v_SHIFT_BY: i32 -> x0: v_Self
|
||||
-> Prims.Pure v_Self
|
||||
(f_shift_right_pre v_SHIFT_BY x0)
|
||||
(fun result -> f_shift_right_post v_SHIFT_BY x0 result);
|
||||
f_cond_subtract_3329__pre:v: v_Self
|
||||
-> pred: Type0{Spec.Utils.is_i16b_array (pow2 12 - 1) (f_repr v) ==> pred};
|
||||
f_cond_subtract_3329__post:v: v_Self -> result: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
f_repr result ==
|
||||
Spec.Utils.map_array (fun x -> if x >=. (mk_i16 3329) then x -! (mk_i16 3329) else x)
|
||||
(f_repr v) };
|
||||
f_cond_subtract_3329_:x0: v_Self
|
||||
-> Prims.Pure v_Self
|
||||
(f_cond_subtract_3329__pre x0)
|
||||
(fun result -> f_cond_subtract_3329__post x0 result);
|
||||
f_barrett_reduce_pre:vector: v_Self
|
||||
-> pred: Type0{Spec.Utils.is_i16b_array 28296 (f_repr vector) ==> pred};
|
||||
f_barrett_reduce_post:v_Self -> v_Self -> Type0;
|
||||
f_barrett_reduce:x0: v_Self
|
||||
-> Prims.Pure v_Self (f_barrett_reduce_pre x0) (fun result -> f_barrett_reduce_post x0 result);
|
||||
f_montgomery_multiply_by_constant_pre:v: v_Self -> c: i16
|
||||
-> pred: Type0{Spec.Utils.is_i16b 1664 c ==> pred};
|
||||
f_montgomery_multiply_by_constant_post:v_Self -> i16 -> v_Self -> Type0;
|
||||
f_montgomery_multiply_by_constant:x0: v_Self -> x1: i16
|
||||
-> Prims.Pure v_Self
|
||||
(f_montgomery_multiply_by_constant_pre x0 x1)
|
||||
(fun result -> f_montgomery_multiply_by_constant_post x0 x1 result);
|
||||
f_compress_1__pre:a: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{ (forall (i: nat).
|
||||
i < 16 ==> v (Seq.index (f_repr a) i) >= 0 /\ v (Seq.index (f_repr a) i) < 3329) ==>
|
||||
pred };
|
||||
f_compress_1__post:a: v_Self -> result: v_Self
|
||||
-> pred: Type0{pred ==> (forall (i: nat). i < 16 ==> bounded (Seq.index (f_repr result) i) 1)};
|
||||
f_compress_1_:x0: v_Self
|
||||
-> Prims.Pure v_Self (f_compress_1__pre x0) (fun result -> f_compress_1__post x0 result);
|
||||
f_compress_pre:v_COEFFICIENT_BITS: i32 -> a: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{ (v v_COEFFICIENT_BITS == 4 \/ v v_COEFFICIENT_BITS == 5 \/ v v_COEFFICIENT_BITS == 10 \/
|
||||
v v_COEFFICIENT_BITS == 11) /\
|
||||
(forall (i: nat).
|
||||
i < 16 ==> v (Seq.index (f_repr a) i) >= 0 /\ v (Seq.index (f_repr a) i) < 3329) ==>
|
||||
pred };
|
||||
f_compress_post:v_COEFFICIENT_BITS: i32 -> a: v_Self -> result: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
(v v_COEFFICIENT_BITS == 4 \/ v v_COEFFICIENT_BITS == 5 \/ v v_COEFFICIENT_BITS == 10 \/
|
||||
v v_COEFFICIENT_BITS == 11) ==>
|
||||
(forall (i: nat). i < 16 ==> bounded (Seq.index (f_repr result) i) (v v_COEFFICIENT_BITS))
|
||||
};
|
||||
f_compress:v_COEFFICIENT_BITS: i32 -> x0: v_Self
|
||||
-> Prims.Pure v_Self
|
||||
(f_compress_pre v_COEFFICIENT_BITS x0)
|
||||
(fun result -> f_compress_post v_COEFFICIENT_BITS x0 result);
|
||||
f_decompress_ciphertext_coefficient_pre:v_COEFFICIENT_BITS: i32 -> a: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{ (v v_COEFFICIENT_BITS == 4 \/ v v_COEFFICIENT_BITS == 5 \/ v v_COEFFICIENT_BITS == 10 \/
|
||||
v v_COEFFICIENT_BITS == 11) /\
|
||||
(forall (i: nat).
|
||||
i < 16 ==>
|
||||
v (Seq.index (f_repr a) i) >= 0 /\
|
||||
v (Seq.index (f_repr a) i) < pow2 (v v_COEFFICIENT_BITS)) ==>
|
||||
pred };
|
||||
f_decompress_ciphertext_coefficient_post:v_COEFFICIENT_BITS: i32 -> v_Self -> v_Self -> Type0;
|
||||
f_decompress_ciphertext_coefficient:v_COEFFICIENT_BITS: i32 -> x0: v_Self
|
||||
-> Prims.Pure v_Self
|
||||
(f_decompress_ciphertext_coefficient_pre v_COEFFICIENT_BITS x0)
|
||||
(fun result -> f_decompress_ciphertext_coefficient_post v_COEFFICIENT_BITS x0 result);
|
||||
f_ntt_layer_1_step_pre:a: v_Self -> zeta0: i16 -> zeta1: i16 -> zeta2: i16 -> zeta3: i16
|
||||
-> pred:
|
||||
Type0
|
||||
{ Spec.Utils.is_i16b 1664 zeta0 /\ Spec.Utils.is_i16b 1664 zeta1 /\
|
||||
Spec.Utils.is_i16b 1664 zeta2 /\ Spec.Utils.is_i16b 1664 zeta3 /\
|
||||
Spec.Utils.is_i16b_array (11207 + 5 * 3328) (f_repr a) ==>
|
||||
pred };
|
||||
f_ntt_layer_1_step_post:
|
||||
a: v_Self ->
|
||||
zeta0: i16 ->
|
||||
zeta1: i16 ->
|
||||
zeta2: i16 ->
|
||||
zeta3: i16 ->
|
||||
out: v_Self
|
||||
-> pred: Type0{pred ==> Spec.Utils.is_i16b_array (11207 + 6 * 3328) (f_repr out)};
|
||||
f_ntt_layer_1_step:x0: v_Self -> x1: i16 -> x2: i16 -> x3: i16 -> x4: i16
|
||||
-> Prims.Pure v_Self
|
||||
(f_ntt_layer_1_step_pre x0 x1 x2 x3 x4)
|
||||
(fun result -> f_ntt_layer_1_step_post x0 x1 x2 x3 x4 result);
|
||||
f_ntt_layer_2_step_pre:a: v_Self -> zeta0: i16 -> zeta1: i16
|
||||
-> pred:
|
||||
Type0
|
||||
{ Spec.Utils.is_i16b 1664 zeta0 /\ Spec.Utils.is_i16b 1664 zeta1 /\
|
||||
Spec.Utils.is_i16b_array (11207 + 4 * 3328) (f_repr a) ==>
|
||||
pred };
|
||||
f_ntt_layer_2_step_post:a: v_Self -> zeta0: i16 -> zeta1: i16 -> out: v_Self
|
||||
-> pred: Type0{pred ==> Spec.Utils.is_i16b_array (11207 + 5 * 3328) (f_repr out)};
|
||||
f_ntt_layer_2_step:x0: v_Self -> x1: i16 -> x2: i16
|
||||
-> Prims.Pure v_Self
|
||||
(f_ntt_layer_2_step_pre x0 x1 x2)
|
||||
(fun result -> f_ntt_layer_2_step_post x0 x1 x2 result);
|
||||
f_ntt_layer_3_step_pre:a: v_Self -> zeta: i16
|
||||
-> pred:
|
||||
Type0
|
||||
{ Spec.Utils.is_i16b 1664 zeta /\ Spec.Utils.is_i16b_array (11207 + 3 * 3328) (f_repr a) ==>
|
||||
pred };
|
||||
f_ntt_layer_3_step_post:a: v_Self -> zeta: i16 -> out: v_Self
|
||||
-> pred: Type0{pred ==> Spec.Utils.is_i16b_array (11207 + 4 * 3328) (f_repr out)};
|
||||
f_ntt_layer_3_step:x0: v_Self -> x1: i16
|
||||
-> Prims.Pure v_Self
|
||||
(f_ntt_layer_3_step_pre x0 x1)
|
||||
(fun result -> f_ntt_layer_3_step_post x0 x1 result);
|
||||
f_inv_ntt_layer_1_step_pre:a: v_Self -> zeta0: i16 -> zeta1: i16 -> zeta2: i16 -> zeta3: i16
|
||||
-> pred:
|
||||
Type0
|
||||
{ Spec.Utils.is_i16b 1664 zeta0 /\ Spec.Utils.is_i16b 1664 zeta1 /\
|
||||
Spec.Utils.is_i16b 1664 zeta2 /\ Spec.Utils.is_i16b 1664 zeta3 /\
|
||||
Spec.Utils.is_i16b_array (4 * 3328) (f_repr a) ==>
|
||||
pred };
|
||||
f_inv_ntt_layer_1_step_post:
|
||||
a: v_Self ->
|
||||
zeta0: i16 ->
|
||||
zeta1: i16 ->
|
||||
zeta2: i16 ->
|
||||
zeta3: i16 ->
|
||||
out: v_Self
|
||||
-> pred: Type0{pred ==> Spec.Utils.is_i16b_array 3328 (f_repr out)};
|
||||
f_inv_ntt_layer_1_step:x0: v_Self -> x1: i16 -> x2: i16 -> x3: i16 -> x4: i16
|
||||
-> Prims.Pure v_Self
|
||||
(f_inv_ntt_layer_1_step_pre x0 x1 x2 x3 x4)
|
||||
(fun result -> f_inv_ntt_layer_1_step_post x0 x1 x2 x3 x4 result);
|
||||
f_inv_ntt_layer_2_step_pre:a: v_Self -> zeta0: i16 -> zeta1: i16
|
||||
-> pred:
|
||||
Type0
|
||||
{ Spec.Utils.is_i16b 1664 zeta0 /\ Spec.Utils.is_i16b 1664 zeta1 /\
|
||||
Spec.Utils.is_i16b_array 3328 (f_repr a) ==>
|
||||
pred };
|
||||
f_inv_ntt_layer_2_step_post:a: v_Self -> zeta0: i16 -> zeta1: i16 -> out: v_Self
|
||||
-> pred: Type0{pred ==> Spec.Utils.is_i16b_array 3328 (f_repr out)};
|
||||
f_inv_ntt_layer_2_step:x0: v_Self -> x1: i16 -> x2: i16
|
||||
-> Prims.Pure v_Self
|
||||
(f_inv_ntt_layer_2_step_pre x0 x1 x2)
|
||||
(fun result -> f_inv_ntt_layer_2_step_post x0 x1 x2 result);
|
||||
f_inv_ntt_layer_3_step_pre:a: v_Self -> zeta: i16
|
||||
-> pred:
|
||||
Type0{Spec.Utils.is_i16b 1664 zeta /\ Spec.Utils.is_i16b_array 3328 (f_repr a) ==> pred};
|
||||
f_inv_ntt_layer_3_step_post:a: v_Self -> zeta: i16 -> out: v_Self
|
||||
-> pred: Type0{pred ==> Spec.Utils.is_i16b_array 3328 (f_repr out)};
|
||||
f_inv_ntt_layer_3_step:x0: v_Self -> x1: i16
|
||||
-> Prims.Pure v_Self
|
||||
(f_inv_ntt_layer_3_step_pre x0 x1)
|
||||
(fun result -> f_inv_ntt_layer_3_step_post x0 x1 result);
|
||||
f_ntt_multiply_pre:
|
||||
lhs: v_Self ->
|
||||
rhs: v_Self ->
|
||||
zeta0: i16 ->
|
||||
zeta1: i16 ->
|
||||
zeta2: i16 ->
|
||||
zeta3: i16
|
||||
-> pred:
|
||||
Type0
|
||||
{ Spec.Utils.is_i16b 1664 zeta0 /\ Spec.Utils.is_i16b 1664 zeta1 /\
|
||||
Spec.Utils.is_i16b 1664 zeta2 /\ Spec.Utils.is_i16b 1664 zeta3 /\
|
||||
Spec.Utils.is_i16b_array 3328 (f_repr lhs) /\ Spec.Utils.is_i16b_array 3328 (f_repr rhs) ==>
|
||||
pred };
|
||||
f_ntt_multiply_post:
|
||||
lhs: v_Self ->
|
||||
rhs: v_Self ->
|
||||
zeta0: i16 ->
|
||||
zeta1: i16 ->
|
||||
zeta2: i16 ->
|
||||
zeta3: i16 ->
|
||||
out: v_Self
|
||||
-> pred: Type0{pred ==> Spec.Utils.is_i16b_array 3328 (f_repr out)};
|
||||
f_ntt_multiply:x0: v_Self -> x1: v_Self -> x2: i16 -> x3: i16 -> x4: i16 -> x5: i16
|
||||
-> Prims.Pure v_Self
|
||||
(f_ntt_multiply_pre x0 x1 x2 x3 x4 x5)
|
||||
(fun result -> f_ntt_multiply_post x0 x1 x2 x3 x4 x5 result);
|
||||
f_serialize_1__pre:a: v_Self -> pred: Type0{Spec.MLKEM.serialize_pre 1 (f_repr a) ==> pred};
|
||||
f_serialize_1__post:a: v_Self -> result: t_Array u8 (mk_usize 2)
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
Spec.MLKEM.serialize_pre 1 (f_repr a) ==> Spec.MLKEM.serialize_post 1 (f_repr a) result };
|
||||
f_serialize_1_:x0: v_Self
|
||||
-> Prims.Pure (t_Array u8 (mk_usize 2))
|
||||
(f_serialize_1__pre x0)
|
||||
(fun result -> f_serialize_1__post x0 result);
|
||||
f_deserialize_1__pre:a: t_Slice u8
|
||||
-> pred: Type0{(Core_models.Slice.impl__len #u8 a <: usize) =. mk_usize 2 ==> pred};
|
||||
f_deserialize_1__post:a: t_Slice u8 -> result: v_Self
|
||||
-> pred:
|
||||
Type0{pred ==> sz (Seq.length a) =. sz 2 ==> Spec.MLKEM.deserialize_post 1 a (f_repr result)};
|
||||
f_deserialize_1_:x0: t_Slice u8
|
||||
-> Prims.Pure v_Self (f_deserialize_1__pre x0) (fun result -> f_deserialize_1__post x0 result);
|
||||
f_serialize_4__pre:a: v_Self -> pred: Type0{Spec.MLKEM.serialize_pre 4 (f_repr a) ==> pred};
|
||||
f_serialize_4__post:a: v_Self -> result: t_Array u8 (mk_usize 8)
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
Spec.MLKEM.serialize_pre 4 (f_repr a) ==> Spec.MLKEM.serialize_post 4 (f_repr a) result };
|
||||
f_serialize_4_:x0: v_Self
|
||||
-> Prims.Pure (t_Array u8 (mk_usize 8))
|
||||
(f_serialize_4__pre x0)
|
||||
(fun result -> f_serialize_4__post x0 result);
|
||||
f_deserialize_4__pre:a: t_Slice u8
|
||||
-> pred: Type0{(Core_models.Slice.impl__len #u8 a <: usize) =. mk_usize 8 ==> pred};
|
||||
f_deserialize_4__post:a: t_Slice u8 -> result: v_Self
|
||||
-> pred:
|
||||
Type0{pred ==> sz (Seq.length a) =. sz 8 ==> Spec.MLKEM.deserialize_post 4 a (f_repr result)};
|
||||
f_deserialize_4_:x0: t_Slice u8
|
||||
-> Prims.Pure v_Self (f_deserialize_4__pre x0) (fun result -> f_deserialize_4__post x0 result);
|
||||
f_serialize_5__pre:v_Self -> Type0;
|
||||
f_serialize_5__post:v_Self -> t_Array u8 (mk_usize 10) -> Type0;
|
||||
f_serialize_5_:x0: v_Self
|
||||
-> Prims.Pure (t_Array u8 (mk_usize 10))
|
||||
(f_serialize_5__pre x0)
|
||||
(fun result -> f_serialize_5__post x0 result);
|
||||
f_deserialize_5__pre:a: t_Slice u8
|
||||
-> pred: Type0{(Core_models.Slice.impl__len #u8 a <: usize) =. mk_usize 10 ==> pred};
|
||||
f_deserialize_5__post:t_Slice u8 -> v_Self -> Type0;
|
||||
f_deserialize_5_:x0: t_Slice u8
|
||||
-> Prims.Pure v_Self (f_deserialize_5__pre x0) (fun result -> f_deserialize_5__post x0 result);
|
||||
f_serialize_10__pre:a: v_Self -> pred: Type0{Spec.MLKEM.serialize_pre 10 (f_repr a) ==> pred};
|
||||
f_serialize_10__post:a: v_Self -> result: t_Array u8 (mk_usize 20)
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
Spec.MLKEM.serialize_pre 10 (f_repr a) ==> Spec.MLKEM.serialize_post 10 (f_repr a) result
|
||||
};
|
||||
f_serialize_10_:x0: v_Self
|
||||
-> Prims.Pure (t_Array u8 (mk_usize 20))
|
||||
(f_serialize_10__pre x0)
|
||||
(fun result -> f_serialize_10__post x0 result);
|
||||
f_deserialize_10__pre:a: t_Slice u8
|
||||
-> pred: Type0{(Core_models.Slice.impl__len #u8 a <: usize) =. mk_usize 20 ==> pred};
|
||||
f_deserialize_10__post:a: t_Slice u8 -> result: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{pred ==> sz (Seq.length a) =. sz 20 ==> Spec.MLKEM.deserialize_post 10 a (f_repr result)};
|
||||
f_deserialize_10_:x0: t_Slice u8
|
||||
-> Prims.Pure v_Self (f_deserialize_10__pre x0) (fun result -> f_deserialize_10__post x0 result);
|
||||
f_serialize_11__pre:v_Self -> Type0;
|
||||
f_serialize_11__post:v_Self -> t_Array u8 (mk_usize 22) -> Type0;
|
||||
f_serialize_11_:x0: v_Self
|
||||
-> Prims.Pure (t_Array u8 (mk_usize 22))
|
||||
(f_serialize_11__pre x0)
|
||||
(fun result -> f_serialize_11__post x0 result);
|
||||
f_deserialize_11__pre:a: t_Slice u8
|
||||
-> pred: Type0{(Core_models.Slice.impl__len #u8 a <: usize) =. mk_usize 22 ==> pred};
|
||||
f_deserialize_11__post:t_Slice u8 -> v_Self -> Type0;
|
||||
f_deserialize_11_:x0: t_Slice u8
|
||||
-> Prims.Pure v_Self (f_deserialize_11__pre x0) (fun result -> f_deserialize_11__post x0 result);
|
||||
f_serialize_12__pre:a: v_Self -> pred: Type0{Spec.MLKEM.serialize_pre 12 (f_repr a) ==> pred};
|
||||
f_serialize_12__post:a: v_Self -> result: t_Array u8 (mk_usize 24)
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
Spec.MLKEM.serialize_pre 12 (f_repr a) ==> Spec.MLKEM.serialize_post 12 (f_repr a) result
|
||||
};
|
||||
f_serialize_12_:x0: v_Self
|
||||
-> Prims.Pure (t_Array u8 (mk_usize 24))
|
||||
(f_serialize_12__pre x0)
|
||||
(fun result -> f_serialize_12__post x0 result);
|
||||
f_deserialize_12__pre:a: t_Slice u8
|
||||
-> pred: Type0{(Core_models.Slice.impl__len #u8 a <: usize) =. mk_usize 24 ==> pred};
|
||||
f_deserialize_12__post:a: t_Slice u8 -> result: v_Self
|
||||
-> pred:
|
||||
Type0
|
||||
{pred ==> sz (Seq.length a) =. sz 24 ==> Spec.MLKEM.deserialize_post 12 a (f_repr result)};
|
||||
f_deserialize_12_:x0: t_Slice u8
|
||||
-> Prims.Pure v_Self (f_deserialize_12__pre x0) (fun result -> f_deserialize_12__post x0 result);
|
||||
f_rej_sample_pre:a: t_Slice u8 -> out: t_Slice i16
|
||||
-> pred:
|
||||
Type0
|
||||
{ (Core_models.Slice.impl__len #u8 a <: usize) =. mk_usize 24 &&
|
||||
(Core_models.Slice.impl__len #i16 out <: usize) =. mk_usize 16 ==>
|
||||
pred };
|
||||
f_rej_sample_post:a: t_Slice u8 -> out: t_Slice i16 -> x: (t_Slice i16 & usize)
|
||||
-> pred:
|
||||
Type0
|
||||
{ pred ==>
|
||||
(let out_future, result:(t_Slice i16 & usize) = x in
|
||||
Seq.length out_future == Seq.length out /\ v result <= 16) };
|
||||
f_rej_sample:x0: t_Slice u8 -> x1: t_Slice i16
|
||||
-> Prims.Pure (t_Slice i16 & usize)
|
||||
(f_rej_sample_pre x0 x1)
|
||||
(fun result -> f_rej_sample_post x0 x1 result)
|
||||
}
|
||||
|
||||
val montgomery_multiply_fe (#v_T: Type0) {| i1: t_Operations v_T |} (v: v_T) (fer: i16)
|
||||
: Prims.Pure v_T (requires Spec.Utils.is_i16b 1664 fer) (fun _ -> Prims.l_True)
|
||||
|
||||
val to_standard_domain (#v_T: Type0) {| i1: t_Operations v_T |} (v: v_T)
|
||||
: Prims.Pure v_T Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val to_unsigned_representative (#v_T: Type0) {| i1: t_Operations v_T |} (a: v_T)
|
||||
: Prims.Pure v_T
|
||||
(requires Spec.Utils.is_i16b_array 3328 (i1._super_15138760880757129450.f_repr a))
|
||||
(ensures
|
||||
fun result ->
|
||||
let result:v_T = result in
|
||||
forall i.
|
||||
(let x = Seq.index (i1._super_15138760880757129450.f_repr a) i in
|
||||
let y = Seq.index (i1._super_15138760880757129450.f_repr result) i in
|
||||
(v y >= 0 /\ v y <= 3328 /\ (v y % 3329 == v x % 3329))))
|
||||
|
||||
val decompress_1_ (#v_T: Type0) {| i1: t_Operations v_T |} (vec: v_T)
|
||||
: Prims.Pure v_T
|
||||
(requires
|
||||
forall i.
|
||||
let x = Seq.index (i1._super_15138760880757129450.f_repr vec) i in
|
||||
(x == mk_i16 0 \/ x == mk_i16 1))
|
||||
(fun _ -> Prims.l_True)
|
||||
@@ -0,0 +1,271 @@
|
||||
# This is a generically useful Makefile for F* that is self-contained
|
||||
#
|
||||
# We expect:
|
||||
# 1. `fstar.exe` to be in PATH (alternatively, you can also set
|
||||
# $FSTAR_HOME to be set to your F* repo/install directory)
|
||||
#
|
||||
# 2. `cargo`, `rustup`, `hax` and `jq` to be installed and in PATH.
|
||||
#
|
||||
# 3. the extracted Cargo crate to have "hax-lib" as a dependency:
|
||||
# `hax-lib = { version = "0.1.0-pre.1", git = "https://github.com/hacspec/hax"}`
|
||||
#
|
||||
# Optionally, you can set `HACL_HOME`.
|
||||
#
|
||||
# ROOTS contains all the top-level F* files you wish to verify
|
||||
# The default target `verify` verified ROOTS and its dependencies
|
||||
# To lax-check instead, set `OTHERFLAGS="--lax"` on the command-line
|
||||
#
|
||||
# To make F* emacs mode use the settings in this file, you need to
|
||||
# add the following lines to your .emacs
|
||||
#
|
||||
# (setq-default fstar-executable "<YOUR_FSTAR_HOME>/bin/fstar.exe")
|
||||
# (setq-default fstar-smt-executable "<YOUR_Z3_HOME>/bin/z3")
|
||||
#
|
||||
# (defun my-fstar-compute-prover-args-using-make ()
|
||||
# "Construct arguments to pass to F* by calling make."
|
||||
# (with-demoted-errors "Error when constructing arg string: %S"
|
||||
# (let* ((fname (file-name-nondirectory buffer-file-name))
|
||||
# (target (concat fname "-in"))
|
||||
# (argstr (car (process-lines "make" "--quiet" target))))
|
||||
# (split-string argstr))))
|
||||
# (setq fstar-subp-prover-args #'my-fstar-compute-prover-args-using-make)
|
||||
#
|
||||
|
||||
PATH_TO_CHILD_MAKEFILE := "$(abspath $(firstword $(MAKEFILE_LIST)))"
|
||||
PATH_TO_TEMPLATE_MAKEFILE := "$(abspath $(lastword $(MAKEFILE_LIST)))"
|
||||
|
||||
HACL_HOME ?= $(HOME)/.hax/hacl_home
|
||||
# Expand variable FSTAR_BIN_DETECT now, so that we don't run this over and over
|
||||
|
||||
FSTAR_BIN_DETECT := $(if $(shell command -v fstar.exe), fstar.exe, $(FSTAR_HOME)/bin/fstar.exe)
|
||||
FSTAR_BIN ?= $(FSTAR_BIN_DETECT)
|
||||
|
||||
GIT_ROOT_DIR := $(shell git rev-parse --show-toplevel)/
|
||||
CACHE_DIR ?= ${GIT_ROOT_DIR}.fstar-cache/checked
|
||||
HINT_DIR ?= ${GIT_ROOT_DIR}.fstar-cache/hints
|
||||
|
||||
# Makes command quiet by default
|
||||
Q ?= @
|
||||
|
||||
# Verify the required executable are in PATH
|
||||
EXECUTABLES = cargo cargo-hax jq
|
||||
K := $(foreach exec,$(EXECUTABLES),\
|
||||
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
|
||||
|
||||
export ANSI_COLOR_BLUE=\033[34m
|
||||
export ANSI_COLOR_RED=\033[31m
|
||||
export ANSI_COLOR_BBLUE=\033[1;34m
|
||||
export ANSI_COLOR_GRAY=\033[90m
|
||||
export ANSI_COLOR_TONE=\033[35m
|
||||
export ANSI_COLOR_RESET=\033[0m
|
||||
|
||||
ifdef NO_COLOR
|
||||
export ANSI_COLOR_BLUE=
|
||||
export ANSI_COLOR_RED=
|
||||
export ANSI_COLOR_BBLUE=
|
||||
export ANSI_COLOR_GRAY=
|
||||
export ANSI_COLOR_TONE=
|
||||
export ANSI_COLOR_RESET=
|
||||
endif
|
||||
|
||||
# The following is a bash script that discovers F* libraries.
|
||||
# Due to incompatibilities with make 4.3, I had to make a "oneliner" bash script...
|
||||
define FINDLIBS
|
||||
: "Prints a path if and only if it exists. Takes one argument: the path."; \
|
||||
function print_if_exists() { \
|
||||
if [ -d "$$1" ]; then \
|
||||
echo "$$1"; \
|
||||
fi; \
|
||||
} ; \
|
||||
: "Asks Cargo all the dependencies for the current crate or workspace,"; \
|
||||
: "and extract all "root" directories for each. Takes zero argument."; \
|
||||
function dependencies() { \
|
||||
cargo metadata --format-version 1 | \
|
||||
jq -r ".packages | .[] | .manifest_path | split(\"/\") | .[:-1] | join(\"/\")"; \
|
||||
} ; \
|
||||
: "Find hax libraries *around* a given path. Takes one argument: the"; \
|
||||
: "path."; \
|
||||
function find_hax_libraries_at_path() { \
|
||||
path="$$1" ; \
|
||||
: "if there is a [proofs/fstar/extraction] subfolder, then that s a F* library" ; \
|
||||
print_if_exists "$$path/proofs/fstar/extraction" ; \
|
||||
: "Maybe the [proof-libs] folder of hax is around?" ; \
|
||||
MAYBE_PROOF_LIBS=$$(realpath -q "$$path/../proof-libs/fstar") ; \
|
||||
if [ $$? -eq 0 ]; then \
|
||||
print_if_exists "$$MAYBE_PROOF_LIBS/core" ; \
|
||||
print_if_exists "$$MAYBE_PROOF_LIBS/rust_primitives" ; \
|
||||
fi ; \
|
||||
} ; \
|
||||
{ while IFS= read path; do \
|
||||
find_hax_libraries_at_path "$$path"; \
|
||||
done < <(dependencies) ; } | sort -u
|
||||
endef
|
||||
export FINDLIBS
|
||||
|
||||
FSTAR_INCLUDE_DIRS_EXTRA ?=
|
||||
FINDLIBS_OUTPUT := $(shell bash -c '${FINDLIBS}')
|
||||
FSTAR_INCLUDE_DIRS = $(HACL_HOME)/lib $(FSTAR_INCLUDE_DIRS_EXTRA) $(FINDLIBS_OUTPUT) ../models
|
||||
|
||||
# Make sure FSTAR_INCLUDE_DIRS has the `proof-libs`, print hints and
|
||||
# an error message otherwise
|
||||
ifneq (,$(findstring proof-libs/fstar,$(FSTAR_INCLUDE_DIRS)))
|
||||
else
|
||||
K += $(info )
|
||||
ERROR := $(shell printf '${ANSI_COLOR_RED}Error: could not detect `proof-libs`!${ANSI_COLOR_RESET}')
|
||||
K += $(info ${ERROR})
|
||||
ERROR := $(shell printf ' > Do you have `${ANSI_COLOR_BLUE}hax-lib${ANSI_COLOR_RESET}` in your `${ANSI_COLOR_BLUE}Cargo.toml${ANSI_COLOR_RESET}` as a ${ANSI_COLOR_BLUE}git${ANSI_COLOR_RESET} or ${ANSI_COLOR_BLUE}path${ANSI_COLOR_RESET} dependency?')
|
||||
K += $(info ${ERROR})
|
||||
ERROR := $(shell printf ' ${ANSI_COLOR_BLUE}> Tip: you may want to run `cargo add --git https://github.com/hacspec/hax hax-lib`${ANSI_COLOR_RESET}')
|
||||
K += $(info ${ERROR})
|
||||
K += $(info )
|
||||
K += $(error Fatal error: `proof-libs` is required.)
|
||||
endif
|
||||
|
||||
.PHONY: all verify clean
|
||||
|
||||
all:
|
||||
$(Q)rm -f .depend
|
||||
$(Q)$(MAKE) -f $(PATH_TO_CHILD_MAKEFILE) .depend hax.fst.config.json verify
|
||||
|
||||
all-keep-going:
|
||||
$(Q)rm -f .depend
|
||||
$(Q)$(MAKE) -f $(PATH_TO_CHILD_MAKEFILE) --keep-going .depend hax.fst.config.json verify
|
||||
|
||||
# If $HACL_HOME doesn't exist, clone it
|
||||
${HACL_HOME}:
|
||||
$(Q)mkdir -p "${HACL_HOME}"
|
||||
$(info Cloning Hacl* in ${HACL_HOME}...)
|
||||
git clone --depth 1 https://github.com/hacl-star/hacl-star.git "${HACL_HOME}"
|
||||
$(info Cloning Hacl* in ${HACL_HOME}... done!)
|
||||
|
||||
# If no any F* file is detected, we run hax
|
||||
ifeq "$(wildcard *.fst *fsti)" ""
|
||||
$(shell cargo hax into fstar)
|
||||
endif
|
||||
|
||||
# By default, we process all the files in the current directory
|
||||
ROOTS ?= $(wildcard *.fst *fsti)
|
||||
ADMIT_MODULES ?=
|
||||
|
||||
ADMIT_MODULE_FLAGS ?= --admit_smt_queries true
|
||||
|
||||
# Can be useful for debugging purposes
|
||||
FINDLIBS.sh:
|
||||
$(Q)echo '${FINDLIBS}' > FINDLIBS.sh
|
||||
include-dirs:
|
||||
$(Q)bash -c '${FINDLIBS}'
|
||||
|
||||
FSTAR_FLAGS = \
|
||||
--warn_error -321-331-241-274-239-271 \
|
||||
--ext context_pruning --z3version 4.13.3 --query_stats \
|
||||
--cache_checked_modules --cache_dir $(CACHE_DIR) \
|
||||
--already_cached "+Prims+FStar+LowStar+C+Spec.Loops+TestLib" \
|
||||
$(addprefix --include ,$(FSTAR_INCLUDE_DIRS))
|
||||
|
||||
FSTAR := $(FSTAR_BIN) $(FSTAR_FLAGS)
|
||||
|
||||
.depend: $(HINT_DIR) $(CACHE_DIR) $(ROOTS) $(HACL_HOME)
|
||||
@$(FSTAR) --dep full $(ROOTS) --extract '* -Prims -LowStar -FStar' > $@
|
||||
|
||||
include .depend
|
||||
|
||||
$(HINT_DIR) $(CACHE_DIR):
|
||||
$(Q)mkdir -p $@
|
||||
|
||||
define HELPMESSAGE
|
||||
echo "hax' default Makefile for F*"
|
||||
echo ""
|
||||
echo "The available targets are:"
|
||||
echo ""
|
||||
function target() {
|
||||
printf ' ${ANSI_COLOR_BLUE}%-20b${ANSI_COLOR_RESET} %s\n' "$$1" "$$2"
|
||||
}
|
||||
target "all" "Verify every F* files (stops whenever an F* fails first)"
|
||||
target "all-keep-going" "Verify every F* files (tries as many F* module as possible)"
|
||||
target "" ""
|
||||
target "run/${ANSI_COLOR_TONE}<MyModule.fst> " 'Runs F* on `MyModule.fst` only'
|
||||
target "" ""
|
||||
target "vscode" 'Generates a `hax.fst.config.json` file'
|
||||
target "${ANSI_COLOR_TONE}<MyModule.fst>${ANSI_COLOR_BLUE}-in " 'Useful for Emacs, outputs the F* prefix command to be used'
|
||||
target "" ""
|
||||
target "clean" 'Cleanup the target'
|
||||
target "include-dirs" 'List the F* include directories'
|
||||
target "" ""
|
||||
target "describe" 'List the F* root modules, and describe the environment.'
|
||||
echo ""
|
||||
echo "Variables:"
|
||||
target "NO_COLOR" "Set to anything to disable colors"
|
||||
target "ADMIT_MODULES" "List of modules where F* will assume every SMT query"
|
||||
target "FSTAR_INCLUDE_DIRS_EXTRA" "List of extra include F* dirs"
|
||||
endef
|
||||
export HELPMESSAGE
|
||||
|
||||
describe:
|
||||
@printf '${ANSI_COLOR_BBLUE}F* roots:${ANSI_COLOR_RESET}\n'
|
||||
@for root in ${ROOTS}; do \
|
||||
filename=$$(basename -- "$$root") ;\
|
||||
ext="$${filename##*.}" ;\
|
||||
noext="$${filename%.*}" ;\
|
||||
printf "${ANSI_COLOR_GRAY}$$(dirname -- "$$root")/${ANSI_COLOR_RESET}%s${ANSI_COLOR_GRAY}.${ANSI_COLOR_TONE}%s${ANSI_COLOR_RESET}%b\n" "$$noext" "$$ext" $$([[ "${ADMIT_MODULES}" =~ (^| )$$root($$| ) ]] && echo '${ANSI_COLOR_RED}\t[ADMITTED]${ANSI_COLOR_RESET}'); \
|
||||
done
|
||||
@printf '\n${ANSI_COLOR_BBLUE}Environment:${ANSI_COLOR_RESET}\n'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}HACL_HOME${ANSI_COLOR_RESET} = %s\n' '${HACL_HOME}'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}FSTAR_BIN${ANSI_COLOR_RESET} = %s\n' '${FSTAR_BIN}'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}GIT_ROOT_DIR${ANSI_COLOR_RESET} = %s\n' '${GIT_ROOT_DIR}'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}CACHE_DIR${ANSI_COLOR_RESET} = %s\n' '${CACHE_DIR}'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}HINT_DIR${ANSI_COLOR_RESET} = %s\n' '${HINT_DIR}'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}ADMIT_MODULE_FLAGS${ANSI_COLOR_RESET} = %s\n' '${ADMIT_MODULE_FLAGS}'
|
||||
@printf ' - ${ANSI_COLOR_BLUE}FSTAR_INCLUDE_DIRS_EXTRA${ANSI_COLOR_RESET} = %s\n' '${FSTAR_INCLUDE_DIRS_EXTRA}'
|
||||
|
||||
help: ;@bash -c "$$HELPMESSAGE"
|
||||
h: ;@bash -c "$$HELPMESSAGE"
|
||||
|
||||
HEADER = $(Q)printf '${ANSI_COLOR_BBLUE}[CHECK] %s ${ANSI_COLOR_RESET}\n' "$(basename $(notdir $@))"
|
||||
|
||||
run/%: | .depend $(HINT_DIR) $(CACHE_DIR) $(HACL_HOME)
|
||||
${HEADER}
|
||||
$(Q)$(FSTAR) $(OTHERFLAGS) $(@:run/%=%)
|
||||
|
||||
VERIFIED_CHECKED = $(addsuffix .checked, $(addprefix $(CACHE_DIR)/,$(ROOTS)))
|
||||
ADMIT_CHECKED = $(addsuffix .checked, $(addprefix $(CACHE_DIR)/,$(ADMIT_MODULES)))
|
||||
|
||||
$(ADMIT_CHECKED):
|
||||
$(Q)printf '${ANSI_COLOR_BBLUE}[${ANSI_COLOR_TONE}ADMIT${ANSI_COLOR_BBLUE}] %s ${ANSI_COLOR_RESET}\n' "$(basename $(notdir $@))"
|
||||
$(Q)$(FSTAR) $(OTHERFLAGS) $(ADMIT_MODULE_FLAGS) $< $(ENABLE_HINTS) --hint_file $(HINT_DIR)/$(notdir $*).hints || { \
|
||||
echo "" ; \
|
||||
exit 1 ; \
|
||||
}
|
||||
$(Q)printf "\n\n"
|
||||
|
||||
$(CACHE_DIR)/%.checked: | .depend $(HINT_DIR) $(CACHE_DIR) $(HACL_HOME)
|
||||
${HEADER}
|
||||
$(Q)$(FSTAR) $(OTHERFLAGS) $< $(ENABLE_HINTS) --hint_file $(HINT_DIR)/$(notdir $*).hints || { \
|
||||
echo "" ; \
|
||||
exit 1 ; \
|
||||
}
|
||||
touch $@
|
||||
$(Q)printf "\n\n"
|
||||
|
||||
verify: $(VERIFIED_CHECKED) $(ADMIT_CHECKED)
|
||||
|
||||
# Targets for Emacs
|
||||
%.fst-in:
|
||||
$(info $(FSTAR_FLAGS) \
|
||||
$(ENABLE_HINTS) --hint_file $(HINT_DIR)/$(basename $@).fst.hints)
|
||||
%.fsti-in:
|
||||
$(info $(FSTAR_FLAGS) \
|
||||
$(ENABLE_HINTS) --hint_file $(HINT_DIR)/$(basename $@).fsti.hints)
|
||||
|
||||
# Targets for VSCode
|
||||
hax.fst.config.json: .depend
|
||||
$(Q)echo "$(FSTAR_INCLUDE_DIRS)" | jq --arg fstar "$(FSTAR_BIN)" -R 'split(" ") | {fstar_exe: $$fstar | gsub("^\\s+|\\s+$$";""), include_dirs: .}' > $@
|
||||
vscode:
|
||||
$(Q)rm -f .depend
|
||||
$(Q)$(MAKE) -f $(PATH_TO_CHILD_MAKEFILE) hax.fst.config.json
|
||||
|
||||
SHELL=bash
|
||||
|
||||
# Clean target
|
||||
clean:
|
||||
rm -rf $(CACHE_DIR)/*
|
||||
rm *.fst
|
||||
@@ -0,0 +1,59 @@
|
||||
module MkSeq
|
||||
open Core_models
|
||||
|
||||
open FStar.Tactics.V2
|
||||
|
||||
private let init (len: nat) (f: (i:nat{i < len}) -> Tac 'a): Tac (list 'a)
|
||||
= let rec h (i: nat {i <= len}): Tac (list 'a)
|
||||
= if i = len then [] else f i :: h (i + 1)
|
||||
in h 0
|
||||
|
||||
private let tuple_proj (n: nat) (i: nat): Tac term
|
||||
= if n = 1 then `(id) else
|
||||
let name = "__proj__Mktuple" ^ string_of_int n ^ "__item___" ^ string_of_int (i + 1) in
|
||||
Tv_FVar (pack_fv ["FStar";"Pervasives";"Native";name])
|
||||
|
||||
private let tuple_type (n: nat): Tac term
|
||||
= if n = 1 then `(id) else
|
||||
let name = "tuple" ^ string_of_int n in
|
||||
Tv_FVar (pack_fv ["FStar";"Pervasives";"Native";name])
|
||||
|
||||
open Rust_primitives.Integers
|
||||
|
||||
private let create_gen_tac (n: nat): Tac sigelt
|
||||
= let typ_bd = {fresh_binder_named "t" (`Type0) with qual = FStar.Reflection.V2.Q_Implicit} in
|
||||
let typ = binder_to_term typ_bd in
|
||||
let input_typ = mk_e_app (tuple_type n) (init n (fun _ -> typ)) in
|
||||
let input_bd = fresh_binder_named "tup" input_typ in
|
||||
let output_type = `t_Array (`#typ) (sz (`@n)) in
|
||||
let nth i = `((`#(tuple_proj n i)) (`#input_bd)) in
|
||||
let mk_and: term -> term -> Tac term = fun t u -> `(`#t /\ `#u) in
|
||||
let post =
|
||||
let mk_inv s i = `(Seq.index (`#s) (`@i) == (`#(tuple_proj n i)) (`#input_bd)) in
|
||||
let invs s = Tactics.fold_left mk_and (`(Seq.length (`#s) == (`@n))) (init n (mk_inv s)) in
|
||||
let bd = fresh_binder_named "s" output_type in
|
||||
mk_abs [bd] (invs bd)
|
||||
in
|
||||
let comp = C_Eff [] ["Prims"; "Pure"]
|
||||
(`t_Array (`#typ) (sz (`@n)))
|
||||
[ (`(requires True), Q_Explicit); (post, Q_Explicit)] []
|
||||
in
|
||||
let args = [typ_bd; input_bd] in
|
||||
let l = Tactics.fold_right (fun hd tl -> `((`#hd)::(`#tl))) (init n nth) (`[]) in
|
||||
let indexes =
|
||||
let f i = `((`#(nth i)) == List.Tot.index (`#l) (`@i)) in
|
||||
Tactics.fold_left mk_and (`True) (init n f)
|
||||
in
|
||||
let lb_def = mk_abs args (`(
|
||||
let l = `#l in
|
||||
let s = Seq.createL l <: t_Array (`#typ) (sz (`@n)) in
|
||||
FStar.Classical.forall_intro (Seq.lemma_index_is_nth s);
|
||||
assert (`#indexes) by (Tactics.norm [primops; iota; delta; zeta]);
|
||||
s
|
||||
)) in
|
||||
let lb_typ = mk_arr args (pack_comp comp) in
|
||||
let open FStar.List.Tot in
|
||||
let lb_fv = pack_fv (cur_module () @ ["create" ^ string_of_int n]) in
|
||||
Sg_Let { isrec = false; lbs = [{ lb_fv; lb_us = []; lb_typ; lb_def }] }
|
||||
|
||||
%splice[] (init 13 (fun i -> create_gen_tac (i + 1)))
|
||||
@@ -0,0 +1,121 @@
|
||||
module Num_enum
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
(* item error backend: (reject_TraitItemDefault) ExplicitRejection { reason: "a node of kind [Trait_item_default] have been found in the AST" }
|
||||
Last available AST for this item:
|
||||
|
||||
#[feature(register_tool)]#[register_tool(_hax)]trait t_UnsafeFromPrimitive<Self_>{type f_Primitive: TodoPrintRustBoundsTyp;
|
||||
fn f_from_unchecked((number: proj_asso_type!())) -> Self{num_enum::f_unchecked_transmute_from(number)}
|
||||
#[_hax::json("\"TraitMethodNoPrePost\"")]fn f_unchecked_transmute_from_pre(_: proj_asso_type!()) -> bool;
|
||||
#[_hax::json("\"TraitMethodNoPrePost\"")]fn f_unchecked_transmute_from_post(_: proj_asso_type!(),_: Self) -> bool;
|
||||
fn f_unchecked_transmute_from(_: proj_asso_type!()) -> Self;}
|
||||
|
||||
Last AST:
|
||||
/** print_rust: pitem: not implemented (item: { Concrete_ident.T.def_id =
|
||||
{ Explicit_def_id.T.is_constructor = false;
|
||||
def_id =
|
||||
{ Types.index = (0, 0); is_local = true; kind = Types.Trait;
|
||||
krate = "num_enum";
|
||||
parent =
|
||||
(Some { Types.contents =
|
||||
{ Types.id = 0;
|
||||
value =
|
||||
{ Types.index = (0, 0); is_local = true; kind = Types.Mod;
|
||||
krate = "num_enum"; parent = None; path = [] }
|
||||
}
|
||||
});
|
||||
path =
|
||||
[{ Types.data = (Types.TypeNs "UnsafeFromPrimitive"); disambiguator = 0
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
moved = None; suffix = None }) */
|
||||
const _: () = ();
|
||||
*)
|
||||
|
||||
class t_CannotDeriveBothFromPrimitiveAndTryFromPrimitive (v_Self: Type0) = {
|
||||
__marker_trait:Prims.unit
|
||||
}
|
||||
|
||||
(* class t_FromPrimitive (v_Self: Type0) = {
|
||||
f_Primitive:Type0;
|
||||
f_Primitive_8876061459599834537:Core_models.Marker.t_Copy f_Primitive;
|
||||
f_Primitive_17391871992276743015:Core_models.Cmp.t_Eq f_Primitive;
|
||||
f_from_primitive_pre:f_Primitive -> Type0;
|
||||
f_from_primitive_post:f_Primitive -> v_Self -> Type0;
|
||||
f_from_primitive:x0: f_Primitive
|
||||
-> Prims.Pure v_Self (f_from_primitive_pre x0) (fun result -> f_from_primitive_post x0 result)
|
||||
} *)
|
||||
|
||||
class t_TryFromPrimitive (v_Self: Type0) = {
|
||||
f_Primitive:Type0;
|
||||
(* f_Primitive_12399228673407067350:Core_models.Marker.t_Copy f_Primitive;
|
||||
f_Primitive_5629480169667985622:Core_models.Cmp.t_Eq f_Primitive;
|
||||
f_Primitive_10837566226016321784:Core_models.Fmt.t_Debug f_Primitive; *)
|
||||
f_Error:Type0;
|
||||
f_NAME:string;
|
||||
f_try_from_primitive_pre:f_Primitive -> Type0;
|
||||
f_try_from_primitive_post:f_Primitive -> Core_models.Result.t_Result v_Self f_Error -> Type0;
|
||||
f_try_from_primitive:x0: f_Primitive
|
||||
-> Prims.Pure (Core_models.Result.t_Result v_Self f_Error)
|
||||
(f_try_from_primitive_pre x0)
|
||||
(fun result -> f_try_from_primitive_post x0 result)
|
||||
}
|
||||
|
||||
type t_TryFromPrimitiveError (v_Enum: Type0) (* {| i1: t_TryFromPrimitive v_Enum |} *) = {
|
||||
f_number:(* i1.f_Primitive *) u8
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_5
|
||||
(#v_Enum: Type0)
|
||||
{| i1: Core_models.Clone.t_Clone v_Enum |}
|
||||
{| i2: t_TryFromPrimitive v_Enum |}
|
||||
{| i3: Core_models.Clone.t_Clone i2.f_Primitive |}
|
||||
: Core_models.Clone.t_Clone (t_TryFromPrimitiveError v_Enum)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_4
|
||||
(#v_Enum: Type0)
|
||||
{| i1: Core_models.Marker.t_Copy v_Enum |}
|
||||
{| i2: t_TryFromPrimitive v_Enum |}
|
||||
{| i3: Core_models.Marker.t_Copy i2.f_Primitive |}
|
||||
: Core_models.Marker.t_Copy (t_TryFromPrimitiveError v_Enum)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_6 (#v_Enum: Type0) {| i1: t_TryFromPrimitive v_Enum |}
|
||||
: Core_models.Marker.t_StructuralPartialEq (t_TryFromPrimitiveError v_Enum)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_7
|
||||
(#v_Enum: Type0)
|
||||
{| i1: Core_models.Cmp.t_PartialEq v_Enum v_Enum |}
|
||||
{| i2: t_TryFromPrimitive v_Enum |}
|
||||
{| i3: Core_models.Cmp.t_PartialEq i2.f_Primitive i2.f_Primitive |}
|
||||
: Core_models.Cmp.t_PartialEq (t_TryFromPrimitiveError v_Enum) (t_TryFromPrimitiveError v_Enum)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_8
|
||||
(#v_Enum: Type0)
|
||||
{| i1: Core_models.Cmp.t_Eq v_Enum |}
|
||||
{| i2: t_TryFromPrimitive v_Enum |}
|
||||
{| i3: Core_models.Cmp.t_Eq i2.f_Primitive |}
|
||||
: Core_models.Cmp.t_Eq (t_TryFromPrimitiveError v_Enum)
|
||||
|
||||
val impl__new (#v_Enum: Type0) {| i1: t_TryFromPrimitive v_Enum |} (number: i1.f_Primitive)
|
||||
: Prims.Pure (t_TryFromPrimitiveError v_Enum) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_1 (#v_Enum: Type0) {| i1: t_TryFromPrimitive v_Enum |}
|
||||
: Core_models.Fmt.t_Debug (t_TryFromPrimitiveError v_Enum)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_2 (#v_Enum: Type0) {| i1: t_TryFromPrimitive v_Enum |}
|
||||
: Core_models.Fmt.t_Display (t_TryFromPrimitiveError v_Enum)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_3 (#v_Enum: Type0) {| i1: t_TryFromPrimitive v_Enum |}
|
||||
: Core_models.Error.t_Error (t_TryFromPrimitiveError v_Enum)
|
||||
@@ -0,0 +1,26 @@
|
||||
module Prost.Encoding.Wire_type
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
type t_WireType =
|
||||
| WireType_Varint : t_WireType
|
||||
| WireType_SixtyFourBit : t_WireType
|
||||
| WireType_LengthDelimited : t_WireType
|
||||
| WireType_StartGroup : t_WireType
|
||||
| WireType_EndGroup : t_WireType
|
||||
| WireType_ThirtyTwoBit : t_WireType
|
||||
|
||||
let discriminant_WireType_Varint: isize = mk_isize 0
|
||||
|
||||
let discriminant_WireType_SixtyFourBit: isize = mk_isize 1
|
||||
|
||||
let discriminant_WireType_LengthDelimited: isize = mk_isize 2
|
||||
|
||||
let discriminant_WireType_StartGroup: isize = mk_isize 3
|
||||
|
||||
let discriminant_WireType_EndGroup: isize = mk_isize 4
|
||||
|
||||
let discriminant_WireType_ThirtyTwoBit: isize = mk_isize 5
|
||||
|
||||
val t_WireType_cast_to_repr (x: t_WireType) : Prims.Pure isize Prims.l_True (fun _ -> Prims.l_True)
|
||||
@@ -0,0 +1,6 @@
|
||||
module Prost.Encoding
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
type t_DecodeContext = { f_recurse_count:u32 }
|
||||
@@ -0,0 +1,123 @@
|
||||
module Prost.Error
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
type t_Inner = {
|
||||
f_description:Alloc.Borrow.t_Cow string;
|
||||
f_stack:Alloc.Vec.t_Vec (string & string) Alloc.Alloc.t_Global
|
||||
}
|
||||
|
||||
/// A Protobuf message decoding error.
|
||||
/// `DecodeError` indicates that the input buffer does not contain a valid
|
||||
/// Protobuf message. The error details should be considered 'best effort': in
|
||||
/// general it is not possible to exactly pinpoint why data is malformed.
|
||||
type t_DecodeError = { f_inner:Alloc.Boxed.t_Box t_Inner Alloc.Alloc.t_Global }
|
||||
|
||||
let impl_6: Core_models.Clone.t_Clone t_DecodeError = { f_clone = (fun x -> x); f_clone_pre = (fun _ -> True); f_clone_post = (fun _ _ -> True) }
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_7:Core_models.Marker.t_StructuralPartialEq t_DecodeError
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_8:Core_models.Cmp.t_PartialEq t_DecodeError t_DecodeError
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_9:Core_models.Cmp.t_Eq t_DecodeError
|
||||
|
||||
let impl_10: Core_models.Clone.t_Clone t_Inner = { f_clone = (fun x -> x); f_clone_pre = (fun _ -> True); f_clone_post = (fun _ _ -> True) }
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_11:Core_models.Marker.t_StructuralPartialEq t_Inner
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_12:Core_models.Cmp.t_PartialEq t_Inner t_Inner
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_13:Core_models.Cmp.t_Eq t_Inner
|
||||
|
||||
/// Creates a new `DecodeError` with a 'best effort' root cause description.
|
||||
/// Meant to be used only by `Message` implementations.
|
||||
val impl_DecodeError__new
|
||||
(#iimpl_270350286_: Type0)
|
||||
{| i1: Core_models.Convert.t_Into iimpl_270350286_ (Alloc.Borrow.t_Cow string) |}
|
||||
(description: iimpl_270350286_)
|
||||
: Prims.Pure t_DecodeError Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Pushes a (message, field) name location pair on to the location stack.
|
||||
/// Meant to be used only by `Message` implementations.
|
||||
val impl_DecodeError__push (self: t_DecodeError) (message field: string)
|
||||
: Prims.Pure t_DecodeError Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_1:Core_models.Fmt.t_Debug t_DecodeError
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_2:Core_models.Fmt.t_Display t_DecodeError
|
||||
|
||||
/// A Protobuf message encoding error.
|
||||
/// `EncodeError` always indicates that a message failed to encode because the
|
||||
/// provided buffer had insufficient capacity. Message encoding is otherwise
|
||||
/// infallible.
|
||||
type t_EncodeError = {
|
||||
f_required:usize;
|
||||
f_remaining:usize
|
||||
}
|
||||
|
||||
let impl_15: Core_models.Clone.t_Clone t_EncodeError = { f_clone = (fun x -> x); f_clone_pre = (fun _ -> True); f_clone_post = (fun _ _ -> True) }
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_14:Core_models.Marker.t_Copy t_EncodeError
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_16:Core_models.Fmt.t_Debug t_EncodeError
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_17:Core_models.Marker.t_StructuralPartialEq t_EncodeError
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_18:Core_models.Cmp.t_PartialEq t_EncodeError t_EncodeError
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_19:Core_models.Cmp.t_Eq t_EncodeError
|
||||
|
||||
/// Creates a new `EncodeError`.
|
||||
val impl_EncodeError__new (required remaining: usize)
|
||||
: Prims.Pure t_EncodeError Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Returns the required buffer capacity to encode the message.
|
||||
val impl_EncodeError__required_capacity (self: t_EncodeError)
|
||||
: Prims.Pure usize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Returns the remaining length in the provided buffer at the time of encoding.
|
||||
val impl_EncodeError__remaining (self: t_EncodeError)
|
||||
: Prims.Pure usize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_4:Core_models.Fmt.t_Display t_EncodeError
|
||||
|
||||
/// An error indicating that an unknown enumeration value was encountered.
|
||||
/// The Protobuf spec mandates that enumeration value sets are ‘open’, so this
|
||||
/// error's value represents an integer value unrecognized by the
|
||||
/// presently used enum definition.
|
||||
type t_UnknownEnumValue = | UnknownEnumValue : i32 -> t_UnknownEnumValue
|
||||
|
||||
let impl_21: Core_models.Clone.t_Clone t_UnknownEnumValue = { f_clone = (fun x -> x); f_clone_pre = (fun _ -> True); f_clone_post = (fun _ _ -> True) }
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_20:Core_models.Marker.t_Copy t_UnknownEnumValue
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_22:Core_models.Fmt.t_Debug t_UnknownEnumValue
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_23:Core_models.Marker.t_StructuralPartialEq t_UnknownEnumValue
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_24:Core_models.Cmp.t_PartialEq t_UnknownEnumValue t_UnknownEnumValue
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_25:Core_models.Cmp.t_Eq t_UnknownEnumValue
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_5:Core_models.Fmt.t_Display t_UnknownEnumValue
|
||||
@@ -0,0 +1,70 @@
|
||||
module Prost.Message
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
let _ =
|
||||
(* This module has implicit dependencies, here we make them explicit. *)
|
||||
(* The implicit dependencies arise from typeclasses instances. *)
|
||||
let open Bytes.Buf.Buf_impl in
|
||||
let open Bytes.Buf.Buf_mut in
|
||||
()
|
||||
|
||||
/// A Protocol Buffers message.
|
||||
class t_Message (v_Self: Type0) = {
|
||||
[@@@ FStar.Tactics.Typeclasses.no_method]_super_7459769351467436346:Core_models.Fmt.t_Debug v_Self;
|
||||
[@@@ FStar.Tactics.Typeclasses.no_method]_super_10374730180605511532:Core_models.Marker.t_Send v_Self;
|
||||
[@@@ FStar.Tactics.Typeclasses.no_method]_super_6360119584534035317:Core_models.Marker.t_Sync v_Self;
|
||||
f_encode_pre:
|
||||
#impl_806524398_: Type0 ->
|
||||
{| i2: Bytes.Buf.Buf_mut.t_BufMut impl_806524398_ |} ->
|
||||
v_Self ->
|
||||
impl_806524398_
|
||||
-> Type0;
|
||||
f_encode_post:
|
||||
#impl_806524398_: Type0 ->
|
||||
{| i2: Bytes.Buf.Buf_mut.t_BufMut impl_806524398_ |} ->
|
||||
v_Self ->
|
||||
impl_806524398_ ->
|
||||
(impl_806524398_ & Core_models.Result.t_Result Prims.unit Prost.Error.t_EncodeError)
|
||||
-> Type0;
|
||||
f_encode:
|
||||
#impl_806524398_: Type0 ->
|
||||
{| i2: Bytes.Buf.Buf_mut.t_BufMut impl_806524398_ |} ->
|
||||
x0: v_Self ->
|
||||
x1: impl_806524398_
|
||||
-> Prims.Pure
|
||||
(impl_806524398_ & Core_models.Result.t_Result Prims.unit Prost.Error.t_EncodeError)
|
||||
(f_encode_pre #impl_806524398_ #i2 x0 x1)
|
||||
(fun result -> f_encode_post #impl_806524398_ #i2 x0 x1 result);
|
||||
f_encode_to_vec_pre:v_Self -> res:Type0 {true ==> res};
|
||||
f_encode_to_vec_post:v_Self -> Alloc.Vec.t_Vec u8 Alloc.Alloc.t_Global -> Type0;
|
||||
f_encode_to_vec:x0: v_Self
|
||||
-> Prims.Pure (Alloc.Vec.t_Vec u8 Alloc.Alloc.t_Global)
|
||||
(f_encode_to_vec_pre x0)
|
||||
(fun result -> f_encode_to_vec_post x0 result);
|
||||
f_decode_pre:
|
||||
#impl_75985673_: Type0 ->
|
||||
{| i4: Core_models.Default.t_Default v_Self |} ->
|
||||
{| i5: Bytes.Buf.Buf_impl.t_Buf impl_75985673_ |} ->
|
||||
impl_75985673_
|
||||
-> res:Type0 {true ==> res};
|
||||
f_decode_post:
|
||||
#impl_75985673_: Type0 ->
|
||||
{| i4: Core_models.Default.t_Default v_Self |} ->
|
||||
{| i5: Bytes.Buf.Buf_impl.t_Buf impl_75985673_ |} ->
|
||||
impl_75985673_ ->
|
||||
Core_models.Result.t_Result v_Self Prost.Error.t_DecodeError
|
||||
-> Type0;
|
||||
f_decode:
|
||||
#impl_75985673_: Type0 ->
|
||||
{| i4: Core_models.Default.t_Default v_Self |} ->
|
||||
{| i5: Bytes.Buf.Buf_impl.t_Buf impl_75985673_ |} ->
|
||||
x0: impl_75985673_
|
||||
-> Prims.Pure (Core_models.Result.t_Result v_Self Prost.Error.t_DecodeError)
|
||||
(f_decode_pre #impl_75985673_ #i4 #i5 x0)
|
||||
(fun result -> f_decode_post #impl_75985673_ #i4 #i5 x0 result);
|
||||
f_clear_pre:v_Self -> Type0;
|
||||
f_clear_post:v_Self -> v_Self -> Type0;
|
||||
f_clear:x0: v_Self -> Prims.Pure v_Self (f_clear_pre x0) (fun result -> f_clear_post x0 result)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
module Rand.Rng
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
class t_Rng (t: Type) = {
|
||||
dummy: unit
|
||||
}
|
||||
@@ -0,0 +1,662 @@
|
||||
module Sorted_vec
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
|
||||
open Core_models
|
||||
open FStar.Mul
|
||||
|
||||
/// Forward sorted vector
|
||||
type t_SortedVec (v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} = {
|
||||
f_vec:Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global
|
||||
}
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_18 (#v_T: Type0) {| i1: Core_models.Clone.t_Clone v_T |} {| i2: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Clone.t_Clone (t_SortedVec v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_19 (#v_T: Type0) {| i1: Core_models.Fmt.t_Debug v_T |} {| i2: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Fmt.t_Debug (t_SortedVec v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_22 (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Marker.t_StructuralPartialEq (t_SortedVec v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_23 (#v_T: Type0) {| i1: Core_models.Cmp.t_PartialEq v_T v_T |} {| i2: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Cmp.t_PartialEq (t_SortedVec v_T) (t_SortedVec v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_20 (#v_T: Type0) {| i1: Core_models.Cmp.t_Eq v_T |} {| i2: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Cmp.t_Eq (t_SortedVec v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_24 (#v_T: Type0) {| i1: Core_models.Cmp.t_PartialOrd v_T v_T |} {| i2: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Cmp.t_PartialOrd (t_SortedVec v_T) (t_SortedVec v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_21 (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} : Core_models.Cmp.t_Ord (t_SortedVec v_T)
|
||||
|
||||
/// Forward sorted set
|
||||
type t_SortedSet (v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} = { f_set:t_SortedVec v_T }
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_25 (#v_T: Type0) {| i1: Core_models.Clone.t_Clone v_T |} {| i2: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Clone.t_Clone (t_SortedSet v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_26 (#v_T: Type0) {| i1: Core_models.Fmt.t_Debug v_T |} {| i2: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Fmt.t_Debug (t_SortedSet v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_29 (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Marker.t_StructuralPartialEq (t_SortedSet v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_30 (#v_T: Type0) {| i1: Core_models.Cmp.t_PartialEq v_T v_T |} {| i2: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Cmp.t_PartialEq (t_SortedSet v_T) (t_SortedSet v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_27 (#v_T: Type0) {| i1: Core_models.Cmp.t_Eq v_T |} {| i2: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Cmp.t_Eq (t_SortedSet v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_31 (#v_T: Type0) {| i1: Core_models.Cmp.t_PartialOrd v_T v_T |} {| i2: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Cmp.t_PartialOrd (t_SortedSet v_T) (t_SortedSet v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_28 (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} : Core_models.Cmp.t_Ord (t_SortedSet v_T)
|
||||
|
||||
/// Value returned when find_or_insert is used.
|
||||
type t_FindOrInsert =
|
||||
| FindOrInsert_Found : usize -> t_FindOrInsert
|
||||
| FindOrInsert_Inserted : usize -> t_FindOrInsert
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_32:Core_models.Marker.t_StructuralPartialEq t_FindOrInsert
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_33:Core_models.Cmp.t_PartialEq t_FindOrInsert t_FindOrInsert
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_34:Core_models.Cmp.t_PartialOrd t_FindOrInsert t_FindOrInsert
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_35:Core_models.Cmp.t_Eq t_FindOrInsert
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_36:Core_models.Cmp.t_Ord t_FindOrInsert
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_37:Core_models.Fmt.t_Debug t_FindOrInsert
|
||||
|
||||
(* [@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_38:Core_models.Hash.t_Hash t_FindOrInsert *)
|
||||
|
||||
/// Converts from the binary_search result type into the FindOrInsert type
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl:Core_models.Convert.t_From t_FindOrInsert (Core_models.Result.t_Result usize usize)
|
||||
|
||||
/// Get the index of the element that was either found or inserted.
|
||||
val impl_FindOrInsert__index (self: t_FindOrInsert)
|
||||
: Prims.Pure usize Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// If an equivalent element was found in the container, get the value of
|
||||
/// its index. Otherwise get None.
|
||||
val impl_FindOrInsert__found (self: t_FindOrInsert)
|
||||
: Prims.Pure (Core_models.Option.t_Option usize) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// If the provided element was inserted into the container, get the value
|
||||
/// of its index. Otherwise get None.
|
||||
val impl_FindOrInsert__inserted (self: t_FindOrInsert)
|
||||
: Prims.Pure (Core_models.Option.t_Option usize) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Returns true if the element was found.
|
||||
val impl_FindOrInsert__is_found (self: t_FindOrInsert)
|
||||
: Prims.Pure bool Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Returns true if the element was inserted.
|
||||
val impl_FindOrInsert__is_inserted (self: t_FindOrInsert)
|
||||
: Prims.Pure bool Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__new: #v_T: Type0 -> {| i1: Core_models.Cmp.t_Ord v_T |} -> Prims.unit
|
||||
-> Prims.Pure (t_SortedVec v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__with_capacity (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (capacity: usize)
|
||||
: Prims.Pure (t_SortedVec v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Uses `sort_unstable()` to sort in place.
|
||||
val impl_2__from_unsorted
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(vec: Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global)
|
||||
: Prims.Pure (t_SortedVec v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Insert an element into sorted position, returning the order index at which
|
||||
/// it was placed.
|
||||
val impl_2__insert (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (self: t_SortedVec v_T) (element: v_T)
|
||||
: Prims.Pure (t_SortedVec v_T & usize) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Find the element and return the index with `Ok`, otherwise insert the
|
||||
/// element and return the new element index with `Err`.
|
||||
val impl_2__find_or_insert
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(self: t_SortedVec v_T)
|
||||
(element: v_T)
|
||||
: Prims.Pure (t_SortedVec v_T & t_FindOrInsert) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Same as insert, except performance is O(1) when the element belongs at the
|
||||
/// back of the container. This avoids an O(log(N)) search for inserting
|
||||
/// elements at the back.
|
||||
val impl_2__push (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (self: t_SortedVec v_T) (element: v_T)
|
||||
: Prims.Pure (t_SortedVec v_T & usize) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Reserves additional capacity in the underlying vector.
|
||||
/// See std::vec::Vec::reserve.
|
||||
val impl_2__reserve
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(self: t_SortedVec v_T)
|
||||
(additional: usize)
|
||||
: Prims.Pure (t_SortedVec v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Same as find_or_insert, except performance is O(1) when the element
|
||||
/// belongs at the back of the container.
|
||||
val impl_2__find_or_push
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(self: t_SortedVec v_T)
|
||||
(element: v_T)
|
||||
: Prims.Pure (t_SortedVec v_T & t_FindOrInsert) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__remove_item
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(self: t_SortedVec v_T)
|
||||
(item: v_T)
|
||||
: Prims.Pure (t_SortedVec v_T & Core_models.Option.t_Option v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Panics if index is out of bounds
|
||||
val impl_2__remove_index
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(self: t_SortedVec v_T)
|
||||
(index: usize)
|
||||
: Prims.Pure (t_SortedVec v_T & v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__pop (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (self: t_SortedVec v_T)
|
||||
: Prims.Pure (t_SortedVec v_T & Core_models.Option.t_Option v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__clear (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (self: t_SortedVec v_T)
|
||||
: Prims.Pure (t_SortedVec v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_2__dedup (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (self: t_SortedVec v_T)
|
||||
: Prims.Pure (t_SortedVec v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
(* item error backend: (DirectAndMut) The mutation of this [1m&mut[0m is not allowed here.
|
||||
Last available AST for this item:
|
||||
|
||||
#[_hax::json("\"Erased\"")]
|
||||
#[inline()]
|
||||
#[feature(register_tool)]
|
||||
#[register_tool(_hax)]
|
||||
fn impl_2__dedup_by_key<Anonymous: 'unk, T, F, K>(
|
||||
mut self: sorted_vec::t_SortedVec<T>,
|
||||
key: F,
|
||||
) -> tuple0
|
||||
where
|
||||
_: core::cmp::t_Ord<T>,
|
||||
_: core::ops::function::t_FnMut<F, tuple1<&mut T>>,
|
||||
F: core::ops::function::t_FnOnce<f_Output = K>,
|
||||
_: core::cmp::t_PartialEq<K, K>,
|
||||
{
|
||||
{
|
||||
let _: tuple0 = { rust_primitives::hax::dropped_body };
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Last AST:
|
||||
/** print_rust: pitem: not implemented (item: { Concrete_ident.T.def_id =
|
||||
{ Explicit_def_id.T.is_constructor = false;
|
||||
def_id =
|
||||
{ Types.index = (0, 0); is_local = true; kind = Types.AssocFn;
|
||||
krate = "sorted_vec";
|
||||
parent =
|
||||
(Some { Types.contents =
|
||||
{ Types.id = 0;
|
||||
value =
|
||||
{ Types.index = (0, 0); is_local = true;
|
||||
kind = Types.Impl {of_trait = false}; krate = "sorted_vec";
|
||||
parent =
|
||||
(Some { Types.contents =
|
||||
{ Types.id = 0;
|
||||
value =
|
||||
{ Types.index = (0, 0); is_local = true;
|
||||
kind = Types.Mod; krate = "sorted_vec";
|
||||
parent = None; path = [] }
|
||||
}
|
||||
});
|
||||
path = [{ Types.data = Types.Impl; disambiguator = 2 }] }
|
||||
}
|
||||
});
|
||||
path =
|
||||
[{ Types.data = Types.Impl; disambiguator = 2 };
|
||||
{ Types.data = (Types.ValueNs "dedup_by_key"); disambiguator = 0 }]
|
||||
}
|
||||
};
|
||||
moved = None; suffix = None }) */
|
||||
const _: () = ();
|
||||
*)
|
||||
|
||||
(* val impl_2__drain
|
||||
(#v_T #v_R: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
{| i7: Core_models.Ops.Range.t_RangeBounds v_R usize |}
|
||||
(self: t_SortedVec v_T)
|
||||
(range: v_R)
|
||||
: Prims.Pure (t_SortedVec v_T & Alloc.Vec.Drain.t_Drain v_T Alloc.Alloc.t_Global)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True) *)
|
||||
|
||||
(* val impl_2__retain
|
||||
(#v_T #v_F: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
{| i8: Core_models.Ops.Function.t_FnMut v_F v_T |}
|
||||
(self: t_SortedVec v_T)
|
||||
(f: v_F)
|
||||
: Prims.Pure (t_SortedVec v_T) Prims.l_True (fun _ -> Prims.l_True) *)
|
||||
|
||||
/// NOTE: to_vec() is a slice method that is accessible through deref, use
|
||||
/// this instead to avoid cloning
|
||||
val impl_2__into_vec (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (self: t_SortedVec v_T)
|
||||
: Prims.Pure (Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
(* item error backend: (DirectAndMut) The mutation of this [1m&mut[0m is not allowed here.
|
||||
Last available AST for this item:
|
||||
|
||||
#[_hax::json("\"Erased\"")]
|
||||
/// Apply a closure mutating the sorted vector and use `sort_unstable()`
|
||||
/// to re-sort the mutated vector
|
||||
#[feature(register_tool)]
|
||||
#[register_tool(_hax)]
|
||||
fn impl_2__mutate_vec<Anonymous: 'unk, T, F, O>(
|
||||
mut self: sorted_vec::t_SortedVec<T>,
|
||||
f: F,
|
||||
) -> O
|
||||
where
|
||||
_: core::cmp::t_Ord<T>,
|
||||
_: core::ops::function::t_FnOnce<
|
||||
F,
|
||||
tuple1<&mut alloc::vec::t_Vec<T, alloc::alloc::t_Global>>,
|
||||
>,
|
||||
F: core::ops::function::t_FnOnce<f_Output = O>,
|
||||
{
|
||||
{
|
||||
let hax_temp_output: O = { rust_primitives::hax::dropped_body };
|
||||
Tuple2(self, hax_temp_output)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Last AST:
|
||||
/** print_rust: pitem: not implemented (item: { Concrete_ident.T.def_id =
|
||||
{ Explicit_def_id.T.is_constructor = false;
|
||||
def_id =
|
||||
{ Types.index = (0, 0); is_local = true; kind = Types.AssocFn;
|
||||
krate = "sorted_vec";
|
||||
parent =
|
||||
(Some { Types.contents =
|
||||
{ Types.id = 0;
|
||||
value =
|
||||
{ Types.index = (0, 0); is_local = true;
|
||||
kind = Types.Impl {of_trait = false}; krate = "sorted_vec";
|
||||
parent =
|
||||
(Some { Types.contents =
|
||||
{ Types.id = 0;
|
||||
value =
|
||||
{ Types.index = (0, 0); is_local = true;
|
||||
kind = Types.Mod; krate = "sorted_vec";
|
||||
parent = None; path = [] }
|
||||
}
|
||||
});
|
||||
path = [{ Types.data = Types.Impl; disambiguator = 2 }] }
|
||||
}
|
||||
});
|
||||
path =
|
||||
[{ Types.data = Types.Impl; disambiguator = 2 };
|
||||
{ Types.data = (Types.ValueNs "mutate_vec"); disambiguator = 0 }]
|
||||
}
|
||||
};
|
||||
moved = None; suffix = None }) */
|
||||
const _: () = ();
|
||||
*)
|
||||
|
||||
/// The caller must ensure that the provided vector is already sorted.
|
||||
val impl_2__from_sorted
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(vec: Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global)
|
||||
: Prims.Pure (t_SortedVec v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Unsafe access to the underlying vector. The caller must ensure that any
|
||||
/// changes to the values in the vector do not impact the ordering of the
|
||||
/// elements inside, or else this container will misbehave.
|
||||
(* val impl_2__get_unchecked_mut_vec (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (self: t_SortedVec v_T)
|
||||
: Prims.Pure Rust_primitives.Hax.failure Prims.l_True (fun _ -> Prims.l_True) *)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_3 (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} : Core_models.Default.t_Default (t_SortedVec v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_4 (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Convert.t_From (t_SortedVec v_T) (Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_5 (#v_T: Type0) (#[FStar.Tactics.Typeclasses.tcresolve ()] i1: Core_models.Cmp.t_Ord v_T)
|
||||
: Core_models.Ops.Deref.t_Deref (t_SortedVec v_T) =
|
||||
{
|
||||
f_Target = Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global;(*
|
||||
f_deref_pre = (fun (self: t_SortedVec v_T) -> true);
|
||||
f_deref_post
|
||||
=
|
||||
(fun (self: t_SortedVec v_T) (out: Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global) -> true); *)
|
||||
f_deref = fun (self: t_SortedVec v_T) -> self.f_vec
|
||||
}
|
||||
|
||||
(* [@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_6 (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Iter.Traits.Collect.t_Extend (t_SortedVec v_T) v_T *)
|
||||
|
||||
(* [@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_7 (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} {| i2: Core_models.Hash.t_Hash v_T |}
|
||||
: Core_models.Hash.t_Hash (t_SortedVec v_T) *)
|
||||
|
||||
val impl_10__new: #v_T: Type0 -> {| i1: Core_models.Cmp.t_Ord v_T |} -> Prims.unit
|
||||
-> Prims.Pure (t_SortedSet v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_10__with_capacity (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (capacity: usize)
|
||||
: Prims.Pure (t_SortedSet v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Uses `sort_unstable()` to sort in place and `dedup()` to remove
|
||||
/// duplicates.
|
||||
val impl_10__from_unsorted
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(vec: Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global)
|
||||
: Prims.Pure (t_SortedSet v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Insert an element into sorted position, returning the order index at which
|
||||
/// it was placed. If an existing item was found it will be returned.
|
||||
val impl_10__replace
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(self: t_SortedSet v_T)
|
||||
(element: v_T)
|
||||
: Prims.Pure (t_SortedSet v_T & (usize & Core_models.Option.t_Option v_T))
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Find the element and return the index with `Ok`, otherwise insert the
|
||||
/// element and return the new element index with `Err`.
|
||||
val impl_10__find_or_insert
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(self: t_SortedSet v_T)
|
||||
(element: v_T)
|
||||
: Prims.Pure (t_SortedSet v_T & t_FindOrInsert) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Same as replace, except performance is O(1) when the element belongs at
|
||||
/// the back of the container. This avoids an O(log(N)) search for inserting
|
||||
/// elements at the back.
|
||||
val impl_10__push (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (self: t_SortedSet v_T) (element: v_T)
|
||||
: Prims.Pure (t_SortedSet v_T & (usize & Core_models.Option.t_Option v_T))
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True)
|
||||
|
||||
/// Reserves additional capacity in the underlying vector.
|
||||
/// See std::vec::Vec::reserve.
|
||||
val impl_10__reserve
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(self: t_SortedSet v_T)
|
||||
(additional: usize)
|
||||
: Prims.Pure (t_SortedSet v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Same as find_or_insert, except performance is O(1) when the element
|
||||
/// belongs at the back of the container.
|
||||
val impl_10__find_or_push
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(self: t_SortedSet v_T)
|
||||
(element: v_T)
|
||||
: Prims.Pure (t_SortedSet v_T & t_FindOrInsert) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_10__remove_item
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(self: t_SortedSet v_T)
|
||||
(item: v_T)
|
||||
: Prims.Pure (t_SortedSet v_T & Core_models.Option.t_Option v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Panics if index is out of bounds
|
||||
val impl_10__remove_index
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(self: t_SortedSet v_T)
|
||||
(index: usize)
|
||||
: Prims.Pure (t_SortedSet v_T & v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_10__pop (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (self: t_SortedSet v_T)
|
||||
: Prims.Pure (t_SortedSet v_T & Core_models.Option.t_Option v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
val impl_10__clear (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (self: t_SortedSet v_T)
|
||||
: Prims.Pure (t_SortedSet v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
(* val impl_10__drain
|
||||
(#v_T #v_R: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
{| i3: Core_models.Ops.Range.t_RangeBounds v_R usize |}
|
||||
(self: t_SortedSet v_T)
|
||||
(range: v_R)
|
||||
: Prims.Pure (t_SortedSet v_T & Alloc.Vec.Drain.t_Drain v_T Alloc.Alloc.t_Global)
|
||||
Prims.l_True
|
||||
(fun _ -> Prims.l_True) *)
|
||||
|
||||
(* val impl_10__retain
|
||||
(#v_T #v_F: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
{| i5: Core_models.Ops.Function.t_FnMut v_F v_T |}
|
||||
(self: t_SortedSet v_T)
|
||||
(f: v_F)
|
||||
: Prims.Pure (t_SortedSet v_T) Prims.l_True (fun _ -> Prims.l_True) *)
|
||||
|
||||
/// NOTE: to_vec() is a slice method that is accessible through deref, use
|
||||
/// this instead to avoid cloning
|
||||
val impl_10__into_vec (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} (self: t_SortedSet v_T)
|
||||
: Prims.Pure (Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
(* item error backend: (DirectAndMut) The mutation of this [1m&mut[0m is not allowed here.
|
||||
Last available AST for this item:
|
||||
|
||||
#[_hax::json("\"Erased\"")]
|
||||
/// Apply a closure mutating the sorted vector and use `sort_unstable()`
|
||||
/// to re-sort the mutated vector and `dedup()` to remove any duplicate
|
||||
/// values
|
||||
#[feature(register_tool)]
|
||||
#[register_tool(_hax)]
|
||||
fn impl_10__mutate_vec<Anonymous: 'unk, T, F, O>(
|
||||
mut self: sorted_vec::t_SortedSet<T>,
|
||||
f: F,
|
||||
) -> O
|
||||
where
|
||||
_: core::cmp::t_Ord<T>,
|
||||
_: core::ops::function::t_FnOnce<
|
||||
F,
|
||||
tuple1<&mut alloc::vec::t_Vec<T, alloc::alloc::t_Global>>,
|
||||
>,
|
||||
F: core::ops::function::t_FnOnce<f_Output = O>,
|
||||
{
|
||||
{
|
||||
let hax_temp_output: O = { rust_primitives::hax::dropped_body };
|
||||
Tuple2(self, hax_temp_output)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Last AST:
|
||||
/** print_rust: pitem: not implemented (item: { Concrete_ident.T.def_id =
|
||||
{ Explicit_def_id.T.is_constructor = false;
|
||||
def_id =
|
||||
{ Types.index = (0, 0); is_local = true; kind = Types.AssocFn;
|
||||
krate = "sorted_vec";
|
||||
parent =
|
||||
(Some { Types.contents =
|
||||
{ Types.id = 0;
|
||||
value =
|
||||
{ Types.index = (0, 0); is_local = true;
|
||||
kind = Types.Impl {of_trait = false}; krate = "sorted_vec";
|
||||
parent =
|
||||
(Some { Types.contents =
|
||||
{ Types.id = 0;
|
||||
value =
|
||||
{ Types.index = (0, 0); is_local = true;
|
||||
kind = Types.Mod; krate = "sorted_vec";
|
||||
parent = None; path = [] }
|
||||
}
|
||||
});
|
||||
path = [{ Types.data = Types.Impl; disambiguator = 10 }] }
|
||||
}
|
||||
});
|
||||
path =
|
||||
[{ Types.data = Types.Impl; disambiguator = 10 };
|
||||
{ Types.data = (Types.ValueNs "mutate_vec"); disambiguator = 0 }]
|
||||
}
|
||||
};
|
||||
moved = None; suffix = None }) */
|
||||
const _: () = ();
|
||||
*)
|
||||
|
||||
/// The caller must ensure that the provided vector is already sorted and
|
||||
/// deduped.
|
||||
val impl_10__from_sorted
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(vec: Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global)
|
||||
: Prims.Pure (t_SortedSet v_T) Prims.l_True (fun _ -> Prims.l_True)
|
||||
|
||||
/// Unsafe access to the underlying vector. The caller must ensure that any
|
||||
/// changes to the values in the vector do not impact the ordering of the
|
||||
/// elements inside, or else this container will misbehave.
|
||||
(* val impl_10__get_unchecked_mut_vec
|
||||
(#v_T: Type0)
|
||||
{| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
(self: t_SortedSet v_T)
|
||||
: Prims.Pure Rust_primitives.Hax.failure Prims.l_True (fun _ -> Prims.l_True) *)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_11 (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} : Core_models.Default.t_Default (t_SortedSet v_T)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_12 (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Convert.t_From (t_SortedSet v_T) (Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global)
|
||||
|
||||
[@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_13 (#v_T: Type0) (#[FStar.Tactics.Typeclasses.tcresolve ()] i1: Core_models.Cmp.t_Ord v_T)
|
||||
: Core_models.Ops.Deref.t_Deref (t_SortedSet v_T) =
|
||||
{
|
||||
f_Target = t_SortedVec v_T;
|
||||
(* f_deref_pre = (fun (self: t_SortedSet v_T) -> true);
|
||||
f_deref_post = (fun (self: t_SortedSet v_T) (out: t_SortedVec v_T) -> true); *)
|
||||
f_deref = fun (self: t_SortedSet v_T) -> self.f_set
|
||||
}
|
||||
|
||||
(* [@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_14 (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |}
|
||||
: Core_models.Iter.Traits.Collect.t_Extend (t_SortedSet v_T) v_T *)
|
||||
|
||||
(* [@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
val impl_15 (#v_T: Type0) {| i1: Core_models.Cmp.t_Ord v_T |} {| i2: Core_models.Hash.t_Hash v_T |}
|
||||
: Core_models.Hash.t_Hash (t_SortedSet v_T) *)
|
||||
|
||||
(* [@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_8 (#v_T: Type0) (#[FStar.Tactics.Typeclasses.tcresolve ()] i1: Core_models.Cmp.t_Ord v_T)
|
||||
: Core_models.Iter.Traits.Collect.t_IntoIterator (t_SortedVec v_T) =
|
||||
{
|
||||
f_Item = v_T;
|
||||
f_IntoIter = Alloc.Vec.Into_iter.t_IntoIter v_T Alloc.Alloc.t_Global;
|
||||
f_IntoIter_8492263130362933403 = FStar.Tactics.Typeclasses.solve;
|
||||
f_into_iter_pre = (fun (self: t_SortedVec v_T) -> true);
|
||||
f_into_iter_post
|
||||
=
|
||||
(fun (self: t_SortedVec v_T) (out: Alloc.Vec.Into_iter.t_IntoIter v_T Alloc.Alloc.t_Global) ->
|
||||
true);
|
||||
f_into_iter
|
||||
=
|
||||
fun (self: t_SortedVec v_T) ->
|
||||
Core_models.Iter.Traits.Collect.f_into_iter #(Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global)
|
||||
#FStar.Tactics.Typeclasses.solve
|
||||
self.f_vec
|
||||
} *)
|
||||
|
||||
(* [@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_9 (#v_T: Type0) (#[FStar.Tactics.Typeclasses.tcresolve ()] i1: Core_models.Cmp.t_Ord v_T)
|
||||
: Core_models.Iter.Traits.Collect.t_IntoIterator (t_SortedVec v_T) =
|
||||
{
|
||||
f_Item = v_T;
|
||||
f_IntoIter = Core_models.Slice.Iter.t_Iter v_T;
|
||||
f_IntoIter_8492263130362933403 = FStar.Tactics.Typeclasses.solve;
|
||||
f_into_iter_pre = (fun (self: t_SortedVec v_T) -> true);
|
||||
f_into_iter_post = (fun (self: t_SortedVec v_T) (out: Core_models.Slice.Iter.t_Iter v_T) -> true);
|
||||
f_into_iter
|
||||
=
|
||||
fun (self: t_SortedVec v_T) ->
|
||||
Core_models.Slice.impl__iter #v_T
|
||||
(Core_models.Ops.Deref.f_deref #(Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global)
|
||||
#FStar.Tactics.Typeclasses.solve
|
||||
self.f_vec
|
||||
<:
|
||||
t_Slice v_T)
|
||||
} *)
|
||||
|
||||
(* [@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_17 (#v_T: Type0) (#[FStar.Tactics.Typeclasses.tcresolve ()] i1: Core_models.Cmp.t_Ord v_T)
|
||||
: Core_models.Iter.Traits.Collect.t_IntoIterator (t_SortedSet v_T) =
|
||||
{
|
||||
f_Item = v_T;
|
||||
f_IntoIter = Core_models.Slice.Iter.t_Iter v_T;
|
||||
f_IntoIter_8492263130362933403 = FStar.Tactics.Typeclasses.solve;
|
||||
f_into_iter_pre = (fun (self: t_SortedSet v_T) -> true);
|
||||
f_into_iter_post = (fun (self: t_SortedSet v_T) (out: Core_models.Slice.Iter.t_Iter v_T) -> true);
|
||||
f_into_iter
|
||||
=
|
||||
fun (self: t_SortedSet v_T) ->
|
||||
Core_models.Slice.impl__iter #v_T
|
||||
(Core_models.Ops.Deref.f_deref #(Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global)
|
||||
#FStar.Tactics.Typeclasses.solve
|
||||
(Core_models.Ops.Deref.f_deref #(t_SortedVec v_T) #FStar.Tactics.Typeclasses.solve self.f_set
|
||||
<:
|
||||
Alloc.Vec.t_Vec v_T Alloc.Alloc.t_Global)
|
||||
<:
|
||||
t_Slice v_T)
|
||||
} *)
|
||||
|
||||
(* [@@ FStar.Tactics.Typeclasses.tcinstance]
|
||||
let impl_16 (#v_T: Type0) (#[FStar.Tactics.Typeclasses.tcresolve ()] i1: Core_models.Cmp.t_Ord v_T)
|
||||
: Core_models.Iter.Traits.Collect.t_IntoIterator (t_SortedSet v_T) =
|
||||
{
|
||||
f_Item = v_T;
|
||||
f_IntoIter = Alloc.Vec.Into_iter.t_IntoIter v_T Alloc.Alloc.t_Global;
|
||||
f_IntoIter_8492263130362933403 = FStar.Tactics.Typeclasses.solve;
|
||||
f_into_iter_pre = (fun (self: t_SortedSet v_T) -> true);
|
||||
f_into_iter_post
|
||||
=
|
||||
(fun (self: t_SortedSet v_T) (out: Alloc.Vec.Into_iter.t_IntoIter v_T Alloc.Alloc.t_Global) ->
|
||||
true);
|
||||
f_into_iter
|
||||
=
|
||||
fun (self: t_SortedSet v_T) ->
|
||||
Core_models.Iter.Traits.Collect.f_into_iter #(t_SortedVec v_T)
|
||||
#FStar.Tactics.Typeclasses.solve
|
||||
self.f_set
|
||||
} *)
|
||||
@@ -0,0 +1,221 @@
|
||||
module Spec.GF16
|
||||
open Core_models
|
||||
|
||||
(** Boolean Operations **)
|
||||
|
||||
let bool_xor (x:bool) (y:bool) : bool =
|
||||
match (x,y) with
|
||||
| (true, true) -> false
|
||||
| (false, false) -> false
|
||||
| (true, false) -> true
|
||||
| (false, true) -> true
|
||||
|
||||
let bool_or (x:bool) (y:bool) : bool = x || y
|
||||
|
||||
let bool_and (x:bool) (y:bool) : bool = x && y
|
||||
|
||||
let bool_not (x:bool) : bool = not x
|
||||
|
||||
(** Sequence Operations **)
|
||||
|
||||
(* The basic definition of a sequence as equivalent to a map function *)
|
||||
assume val createi #a (len:nat) (f: (i:nat{i < len}) -> a)
|
||||
: x:Seq.seq a{Seq.length x == len /\ (forall i. Seq.index x i == f i)}
|
||||
|
||||
let (.[]) #a (x:Seq.seq a) (i:nat{i < Seq.length x}) = Seq.index x i
|
||||
|
||||
let map2 #a #b #c (f: a -> b -> c) (x: Seq.seq a) (y: Seq.seq b{Seq.length x == Seq.length y})
|
||||
: r:Seq.seq c{Seq.length r == Seq.length x} =
|
||||
createi (Seq.length x) (fun i -> f x.[i] y.[i])
|
||||
|
||||
(** Bit Vectors **)
|
||||
|
||||
type bv (n:nat) = x:Seq.seq bool{Seq.length x == n}
|
||||
|
||||
let zero (#n:nat) : bv n = createi n (fun i -> false)
|
||||
|
||||
let lift (#n:nat) (x: bv n) (k:nat{k >= n}) : bv k =
|
||||
createi k (fun i -> if i < n then x.[i] else false)
|
||||
|
||||
let lower1 (#n:pos) (x: bv n{x.[n-1] = false}) : bv (n-1) =
|
||||
createi (n-1) (fun i -> x.[i])
|
||||
|
||||
let rec lower (#n:nat) (x: bv n) (k:nat{k <= n /\ (forall j. (j >= k /\ j < n) ==> x.[j] = false)}) : bv k =
|
||||
if n = k then x
|
||||
else lower (lower1 x) k
|
||||
|
||||
let bv_eq_intro #n (x y: bv n) :
|
||||
Lemma (requires (forall (i:nat). i < n ==> x.[i] = y.[i]))
|
||||
(ensures x == y) =
|
||||
Seq.lemma_eq_intro x y
|
||||
|
||||
(** Galois Field Arithmetic **)
|
||||
|
||||
(* Addition and Subtraction *)
|
||||
|
||||
let max i j = if i < j then j else i
|
||||
|
||||
let gf_add #n #m (x: bv n) (y: bv m) : bv (max n m) =
|
||||
map2 bool_xor (lift x (max n m)) (lift y (max n m))
|
||||
|
||||
let gf_sub #n #m (x: bv n) (y: bv m) : bv (max n m) =
|
||||
gf_add x y
|
||||
|
||||
let lemma_add_zero (#n:nat) (x: bv n):
|
||||
Lemma (gf_add x (zero #n) == x /\ gf_add (zero #n) x == x) =
|
||||
bv_eq_intro (gf_add x (zero #n)) x;
|
||||
bv_eq_intro (gf_add (zero #n) x) x
|
||||
|
||||
let lemma_add_lift (#n:nat) (#k:nat{k >= n}) (x: bv n) (y:bv k):
|
||||
Lemma (gf_add x y == gf_add (lift x k) y /\
|
||||
gf_add y x == gf_add y (lift x k)) =
|
||||
bv_eq_intro (gf_add x y) (gf_add (lift x k) y);
|
||||
bv_eq_intro (gf_add y x) (gf_add y (lift x k))
|
||||
|
||||
(* Polynomial (carry-less) Multiplication *)
|
||||
|
||||
let poly_mul_x_k #n (x: bv n) (k:nat) : bv (n+k) =
|
||||
createi (n+k) (fun i -> if i < k then false else x.[i-k])
|
||||
|
||||
let rec poly_mul_i #n (x: bv n) (y: bv n) (i: nat{i <= n})
|
||||
: Tot (bv (n+n)) (decreases i) =
|
||||
if i = 0 then zero #(n+n)
|
||||
else
|
||||
let prev = poly_mul_i x y (i-1) in
|
||||
if y.[i-1] then
|
||||
gf_add prev (poly_mul_x_k x (i-1))
|
||||
else prev
|
||||
|
||||
let poly_mul #n (x y: bv n) : bv (n+n) =
|
||||
poly_mul_i x y n
|
||||
|
||||
(* Galois Field Assumptions *)
|
||||
|
||||
class galois_field = {
|
||||
n: nat;
|
||||
norm: #k:nat -> bv k -> bv n;
|
||||
irred: p:bv (n+1){p.[n] /\ norm p == zero #n};
|
||||
lemma_norm_lower1: #m:pos -> (x: bv m) -> Lemma(x.[m-1] = false ==> norm x == norm (lower1 x));
|
||||
lemma_norm_lift: (#m:nat{m <= n}) -> (x: bv m) -> Lemma(norm x == lift x n);
|
||||
lemma_norm_add: (#m: nat) -> (#o: nat) -> (x: bv m) -> (y: bv o) -> Lemma(norm (gf_add x y) = gf_add (norm x) (norm y));
|
||||
lemma_norm_mul_x_k: (#m: nat) -> (x: bv m) -> (k:nat) -> Lemma(norm (poly_mul_x_k x k) == norm (poly_mul_x_k (norm x) k));
|
||||
}
|
||||
|
||||
(* Reduction *)
|
||||
|
||||
assume val poly_reduce (#gf: galois_field) (#m:nat) (x:bv m)
|
||||
: y:bv n{y == norm x}
|
||||
|
||||
let gf_mul (#gf: galois_field) (x:bv n) (y: bv n) : bv n =
|
||||
poly_reduce (poly_mul x y)
|
||||
|
||||
(* Lemmas *)
|
||||
let rec lemma_norm_zero (#gf: galois_field) (k:nat):
|
||||
Lemma (gf.norm (zero #k) == zero #gf.n) =
|
||||
if k <= gf.n then (
|
||||
gf.lemma_norm_lift (zero #k);
|
||||
bv_eq_intro (lift (zero #k) n) (zero #n))
|
||||
else (
|
||||
assert (k > 0);
|
||||
let zero_k_minus_1 = lower1 (zero #k) in
|
||||
gf.lemma_norm_lower1 (zero #k);
|
||||
lemma_norm_zero #gf (k-1);
|
||||
bv_eq_intro (lower1 (zero #k)) (zero #(k-1))
|
||||
)
|
||||
|
||||
let lemma_norm_irred_mul_x_k (#gf: galois_field) (k:nat):
|
||||
Lemma (gf.norm (poly_mul_x_k irred k) == zero #gf.n) =
|
||||
lemma_norm_mul_x_k irred k;
|
||||
bv_eq_intro (poly_mul_x_k zero k) (zero #(n+k));
|
||||
lemma_norm_zero #gf (n+k)
|
||||
|
||||
let rec lemma_norm_lower (#gf: galois_field) (m:nat) (x:bv m):
|
||||
Lemma
|
||||
(requires (m >= gf.n /\ (forall j. (j >= n /\ j < m) ==> x.[j] = false)))
|
||||
(ensures (gf.norm (lower x n) == gf.norm x)) =
|
||||
if n = m then ()
|
||||
else (
|
||||
lemma_norm_lower1 x;
|
||||
lemma_norm_lower #gf (m-1) (lower1 x)
|
||||
)
|
||||
|
||||
(** Integers as Bit Vectors **)
|
||||
|
||||
(* Mappings between machine integers and int ops to bit vectors *)
|
||||
|
||||
assume val to_bv #t (u: int_t t) : bv (bits t)
|
||||
// Concretely: to_bv u -> createi (bits t) (fun i -> (v u / pow2 i) % 2 = 0)
|
||||
|
||||
(* Axioms about integer operations *)
|
||||
|
||||
assume val zero_lemma #t:
|
||||
Lemma (to_bv ( mk_int #t 0 ) == zero #(bits t))
|
||||
|
||||
assume val xor_lemma #t (x: int_t t) (y: int_t t):
|
||||
Lemma (to_bv ( x ^. y) == map2 bool_xor (to_bv x) (to_bv y))
|
||||
|
||||
assume val or_lemma #t (x: int_t t) (y: int_t t):
|
||||
Lemma (to_bv ( x |. y) == map2 bool_or (to_bv x) (to_bv y))
|
||||
|
||||
assume val and_lemma #t (x: int_t t) (y: int_t t):
|
||||
Lemma (to_bv ( x &. y) == map2 bool_and (to_bv x) (to_bv y))
|
||||
|
||||
assume val shift_left_lemma #t #t' (x: int_t t) (y: int_t t'):
|
||||
Lemma
|
||||
(requires (v y >= 0 /\ v y < bits t))
|
||||
(ensures to_bv ( x <<! y) ==
|
||||
createi (bits t) (fun i -> if i < v y then false else (to_bv x).[i - v y]))
|
||||
|
||||
assume val up_cast_lemma #t (#t':inttype{bits t' >= bits t}) (x:int_t t):
|
||||
Lemma (to_bv (cast (x <: int_t t) <: int_t t') == lift (to_bv x) (bits t'))
|
||||
|
||||
|
||||
(* Lemmas lining integer arithmetic to bit-vector operations *)
|
||||
|
||||
assume val shift_left_bit_select_lemma #t #t' (x: int_t t) (i: int_t t'{v i >= 0 /\ v i < bits t}):
|
||||
Lemma (((x &. (mk_int #t 1 <<! i)) == mk_int #t 0) <==>
|
||||
((to_bv x).[v i] == false))
|
||||
|
||||
(* GF16 Lemmas *)
|
||||
|
||||
assume val up_cast_shift_left_lemma (x: u16) (shift: u32{v shift < 16}):
|
||||
Lemma (to_bv ((cast x <: u32) <<! shift) ==
|
||||
lift (poly_mul_x_k (to_bv x) (v shift)) 32)
|
||||
|
||||
let xor_is_gf_add_lemma #t (x y: int_t t):
|
||||
Lemma (to_bv (x ^. y) == gf_add (to_bv x) (to_bv y)) =
|
||||
xor_lemma x y;
|
||||
bv_eq_intro (to_bv (x ^. y)) (gf_add (to_bv x) (to_bv y))
|
||||
|
||||
|
||||
(* GF16 Implementation *)
|
||||
|
||||
instance gf16: galois_field = {
|
||||
n = 16;
|
||||
irred = to_bv (mk_i16 0x1100b);
|
||||
norm = admit();
|
||||
lemma_norm_lower1 = (fun x -> admit());
|
||||
lemma_norm_lift = (fun x -> admit());
|
||||
lemma_norm_add = (fun x -> fun y -> admit());
|
||||
lemma_norm_mul_x_k = (fun x -> fun k -> admit())
|
||||
}
|
||||
|
||||
let gf16_mul = gf_mul #gf16
|
||||
|
||||
(*
|
||||
let rec clmul_aux #n1 #n2 (x: bv n1) (y: bv n2) (i: nat{i <= n2}):
|
||||
Tot (bv (n1+n2)) (decreases (n2 - i)) =
|
||||
if i = n2 then zero
|
||||
else
|
||||
let next = clmul_aux x y (i+1) in
|
||||
if y.[i] then
|
||||
add (mul_x_k x i) next
|
||||
else next
|
||||
*)
|
||||
|
||||
|
||||
|
||||
(*
|
||||
bv_intro (add x (zero #n)) x;
|
||||
bv_intro (add (zero #n) x) x
|
||||
*)
|
||||
@@ -0,0 +1,64 @@
|
||||
module Spec.MLKEM.Instances
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 30"
|
||||
open FStar.Mul
|
||||
open Core_models
|
||||
open Spec.Utils
|
||||
open Spec.MLKEM.Math
|
||||
open Spec.MLKEM
|
||||
|
||||
|
||||
(** MLKEM-768 Instantiation *)
|
||||
|
||||
let mlkem768_rank : rank = sz 3
|
||||
|
||||
#set-options "--z3rlimit 350"
|
||||
let mlkem768_generate_keypair (randomness:t_Array u8 (sz 64)):
|
||||
(t_Array u8 (sz 2400) & t_Array u8 (sz 1184)) & bool =
|
||||
ind_cca_generate_keypair mlkem768_rank randomness
|
||||
|
||||
let mlkem768_encapsulate (public_key: t_Array u8 (sz 1184)) (randomness: t_Array u8 (sz 32)):
|
||||
(t_Array u8 (sz 1088) & t_Array u8 (sz 32)) & bool =
|
||||
assert (v_CPA_CIPHERTEXT_SIZE mlkem768_rank == sz 1088);
|
||||
ind_cca_encapsulate mlkem768_rank public_key randomness
|
||||
|
||||
let mlkem768_decapsulate (secret_key: t_Array u8 (sz 2400)) (ciphertext: t_Array u8 (sz 1088)):
|
||||
t_Array u8 (sz 32) & bool =
|
||||
ind_cca_decapsulate mlkem768_rank secret_key ciphertext
|
||||
|
||||
(** MLKEM-1024 Instantiation *)
|
||||
|
||||
let mlkem1024_rank = sz 4
|
||||
|
||||
let mlkem1024_generate_keypair (randomness:t_Array u8 (sz 64)):
|
||||
(t_Array u8 (sz 3168) & t_Array u8 (sz 1568)) & bool =
|
||||
ind_cca_generate_keypair mlkem1024_rank randomness
|
||||
|
||||
let mlkem1024_encapsulate (public_key: t_Array u8 (sz 1568)) (randomness: t_Array u8 (sz 32)):
|
||||
(t_Array u8 (sz 1568) & t_Array u8 (sz 32)) & bool =
|
||||
assert (v_CPA_CIPHERTEXT_SIZE mlkem1024_rank == sz 1568);
|
||||
ind_cca_encapsulate mlkem1024_rank public_key randomness
|
||||
|
||||
let mlkem1024_decapsulate (secret_key: t_Array u8 (sz 3168)) (ciphertext: t_Array u8 (sz 1568)):
|
||||
t_Array u8 (sz 32) & bool =
|
||||
ind_cca_decapsulate mlkem1024_rank secret_key ciphertext
|
||||
|
||||
(** MLKEM-512 Instantiation *)
|
||||
|
||||
let mlkem512_rank : rank = sz 2
|
||||
|
||||
let mlkem512_generate_keypair (randomness:t_Array u8 (sz 64)):
|
||||
(t_Array u8 (sz 1632) & t_Array u8 (sz 800)) & bool =
|
||||
ind_cca_generate_keypair mlkem512_rank randomness
|
||||
|
||||
let mlkem512_encapsulate (public_key: t_Array u8 (sz 800)) (randomness: t_Array u8 (sz 32)):
|
||||
(t_Array u8 (sz 768) & t_Array u8 (sz 32)) & bool =
|
||||
assert (v_CPA_CIPHERTEXT_SIZE mlkem512_rank == sz 768);
|
||||
ind_cca_encapsulate mlkem512_rank public_key randomness
|
||||
|
||||
|
||||
let mlkem512_decapsulate (secret_key: t_Array u8 (sz 1632)) (ciphertext: t_Array u8 (sz 768)):
|
||||
t_Array u8 (sz 32) & bool =
|
||||
ind_cca_decapsulate mlkem512_rank secret_key ciphertext
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,299 @@
|
||||
module Spec.MLKEM.Math
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
|
||||
open FStar.Mul
|
||||
open Core_models
|
||||
open Spec.Utils
|
||||
|
||||
let v_FIELD_MODULUS: i32 = mk_i32 3329
|
||||
let is_rank (r:usize) = r == sz 2 \/ r == sz 3 \/ r == sz 4
|
||||
|
||||
type rank = r:usize{is_rank r}
|
||||
|
||||
(** MLKEM Math and Sampling *)
|
||||
|
||||
type field_element = n:nat{n < v v_FIELD_MODULUS}
|
||||
type polynomial = t_Array field_element (sz 256)
|
||||
type vector (r:rank) = t_Array polynomial r
|
||||
type matrix (r:rank) = t_Array (vector r) r
|
||||
|
||||
val field_add: field_element -> field_element -> field_element
|
||||
let field_add a b = (a + b) % v v_FIELD_MODULUS
|
||||
|
||||
val field_sub: field_element -> field_element -> field_element
|
||||
let field_sub a b = (a - b) % v v_FIELD_MODULUS
|
||||
|
||||
val field_neg: field_element -> field_element
|
||||
let field_neg a = (0 - a) % v v_FIELD_MODULUS
|
||||
|
||||
val field_mul: field_element -> field_element -> field_element
|
||||
let field_mul a b = (a * b) % v v_FIELD_MODULUS
|
||||
|
||||
val poly_add: polynomial -> polynomial -> polynomial
|
||||
let poly_add a b = map2 field_add a b
|
||||
|
||||
val poly_sub: polynomial -> polynomial -> polynomial
|
||||
let poly_sub a b = map2 field_sub a b
|
||||
|
||||
let int_to_spec_fe (m:int) : field_element =
|
||||
let m_v = m % v v_FIELD_MODULUS in
|
||||
assert (m_v > - v v_FIELD_MODULUS);
|
||||
if m_v < 0 then
|
||||
m_v + v v_FIELD_MODULUS
|
||||
else m_v
|
||||
|
||||
(* Convert concrete code types to spec types *)
|
||||
|
||||
let to_spec_fe (m:i16) : field_element =
|
||||
int_to_spec_fe (v m)
|
||||
|
||||
let to_spec_array #len (m:t_Array i16 len) : t_Array field_element len =
|
||||
createi #field_element len (fun i -> to_spec_fe (m.[i]))
|
||||
|
||||
let to_spec_poly (m:t_Array i16 (sz 256)) : polynomial =
|
||||
to_spec_array m
|
||||
|
||||
let to_spec_vector (#r:rank)
|
||||
(m:t_Array (t_Array i16 (sz 256)) r)
|
||||
: (vector r) =
|
||||
createi r (fun i -> to_spec_poly (m.[i]))
|
||||
|
||||
let to_spec_matrix (#r:rank)
|
||||
(m:t_Array (t_Array (t_Array i16 (sz 256)) r) r)
|
||||
: (matrix r) =
|
||||
createi r (fun i -> to_spec_vector (m.[i]))
|
||||
|
||||
(* Specifying NTT:
|
||||
bitrev7 = [int('{:07b}'.format(x)[::-1], 2) for x in range(0,128)]
|
||||
zetas = [pow(17,x) % 3329 for x in bitrev7]
|
||||
zetas_mont = [pow(2,16) * x % 3329 for x in zetas]
|
||||
zetas_mont_r = [(x - 3329 if x > 1664 else x) for x in zetas_mont]
|
||||
|
||||
bitrev7 is
|
||||
[0, 64, 32, 96, 16, 80, 48, 112, 8, 72, 40, 104, 24, 88, 56, 120, 4, 68, 36, 100, 20, 84, 52, 116, 12, 76, 44, 108, 28, 92, 60, 124, 2, 66, 34, 98, 18, 82, 50, 114, 10, 74, 42, 106, 26, 90, 58, 122, 6, 70, 38, 102, 22, 86, 54, 118, 14, 78, 46, 110, 30, 94, 62, 126, 1, 65, 33, 97, 17, 81, 49, 113, 9, 73, 41, 105, 25, 89, 57, 121, 5, 69, 37, 101, 21, 85, 53, 117, 13, 77, 45, 109, 29, 93, 61, 125, 3, 67, 35, 99, 19, 83, 51, 115, 11, 75, 43, 107, 27, 91, 59, 123, 7, 71, 39, 103, 23, 87, 55, 119, 15, 79, 47, 111, 31, 95, 63, 127]
|
||||
|
||||
zetas = 17^bitrev7 is
|
||||
[1, 1729, 2580, 3289, 2642, 630, 1897, 848, 1062, 1919, 193, 797, 2786, 3260, 569, 1746, 296, 2447, 1339, 1476, 3046, 56, 2240, 1333, 1426, 2094, 535, 2882, 2393, 2879, 1974, 821, 289, 331, 3253, 1756, 1197, 2304, 2277, 2055, 650, 1977, 2513, 632, 2865, 33, 1320, 1915, 2319, 1435, 807, 452, 1438, 2868, 1534, 2402, 2647, 2617, 1481, 648, 2474, 3110, 1227, 910, 17, 2761, 583, 2649, 1637, 723, 2288, 1100, 1409, 2662, 3281, 233, 756, 2156, 3015, 3050, 1703, 1651, 2789, 1789, 1847, 952, 1461, 2687, 939, 2308, 2437, 2388, 733, 2337, 268, 641, 1584, 2298, 2037, 3220, 375, 2549, 2090, 1645, 1063, 319, 2773, 757, 2099, 561, 2466, 2594, 2804, 1092, 403, 1026, 1143, 2150, 2775, 886, 1722, 1212, 1874, 1029, 2110, 2935, 885, 2154]
|
||||
|
||||
zetas_mont = zetas * 2^16 is
|
||||
[2285, 2571, 2970, 1812, 1493, 1422, 287, 202, 3158, 622, 1577, 182, 962, 2127, 1855, 1468, 573, 2004, 264, 383, 2500, 1458, 1727, 3199, 2648, 1017, 732, 608, 1787, 411, 3124, 1758, 1223, 652, 2777, 1015, 2036, 1491, 3047, 1785, 516, 3321, 3009, 2663, 1711, 2167, 126, 1469, 2476, 3239, 3058, 830, 107, 1908, 3082, 2378, 2931, 961, 1821, 2604, 448, 2264, 677, 2054, 2226, 430, 555, 843, 2078, 871, 1550, 105, 422, 587, 177, 3094, 3038, 2869, 1574, 1653, 3083, 778, 1159, 3182, 2552, 1483, 2727, 1119, 1739, 644, 2457, 349, 418, 329, 3173, 3254, 817, 1097, 603, 610, 1322, 2044, 1864, 384, 2114, 3193, 1218, 1994, 2455, 220, 2142, 1670, 2144, 1799, 2051, 794, 1819, 2475, 2459, 478, 3221, 3021, 996, 991, 958, 1869, 1522, 1628]
|
||||
|
||||
zetas_mont_r = zetas_mont - 3329 if zetas_mont > 1664 else zetas_mont is
|
||||
[-1044, -758, -359, -1517, 1493, 1422, 287, 202, -171, 622, 1577, 182, 962, -1202, -1474, 1468, 573, -1325, 264, 383, -829, 1458, -1602, -130, -681, 1017, 732, 608, -1542, 411, -205, -1571, 1223, 652, -552, 1015, -1293, 1491, -282, -1544, 516, -8, -320, -666, -1618, -1162, 126, 1469, -853, -90, -271, 830, 107, -1421, -247, -951, -398, 961, -1508, -725, 448, -1065, 677, -1275, -1103, 430, 555, 843, -1251, 871, 1550, 105, 422, 587, 177, -235, -291, -460, 1574, 1653, -246, 778, 1159, -147, -777, 1483, -602, 1119, -1590, 644, -872, 349, 418, 329, -156, -75, 817, 1097, 603, 610, 1322, -1285, -1465, 384, -1215, -136, 1218, -1335, -874, 220, -1187, -1659, -1185, -1530, -1278, 794, -1510, -854, -870, 478, -108, -308, 996, 991, 958, -1460, 1522, 1628]
|
||||
*)
|
||||
|
||||
let zetas_list : list field_element = [1; 1729; 2580; 3289; 2642; 630; 1897; 848; 1062; 1919; 193; 797; 2786; 3260; 569; 1746; 296; 2447; 1339; 1476; 3046; 56; 2240; 1333; 1426; 2094; 535; 2882; 2393; 2879; 1974; 821; 289; 331; 3253; 1756; 1197; 2304; 2277; 2055; 650; 1977; 2513; 632; 2865; 33; 1320; 1915; 2319; 1435; 807; 452; 1438; 2868; 1534; 2402; 2647; 2617; 1481; 648; 2474; 3110; 1227; 910; 17; 2761; 583; 2649; 1637; 723; 2288; 1100; 1409; 2662; 3281; 233; 756; 2156; 3015; 3050; 1703; 1651; 2789; 1789; 1847; 952; 1461; 2687; 939; 2308; 2437; 2388; 733; 2337; 268; 641; 1584; 2298; 2037; 3220; 375; 2549; 2090; 1645; 1063; 319; 2773; 757; 2099; 561; 2466; 2594; 2804; 1092; 403; 1026; 1143; 2150; 2775; 886; 1722; 1212; 1874; 1029; 2110; 2935; 885; 2154]
|
||||
|
||||
let zetas : t_Array field_element (sz 128) =
|
||||
assert_norm(List.Tot.length zetas_list == 128);
|
||||
Rust_primitives.Arrays.of_list zetas_list
|
||||
|
||||
let poly_ntt_step (a:field_element) (b:field_element) (i:nat{i < 128}) =
|
||||
let t = field_mul b zetas.[sz i] in
|
||||
let b = field_sub a t in
|
||||
let a = field_add a t in
|
||||
(a,b)
|
||||
|
||||
#push-options "--split_queries always"
|
||||
let poly_ntt_layer (p:polynomial) (l:nat{l > 0 /\ l < 8}) : polynomial =
|
||||
let len = pow2 l in
|
||||
let k = (128 / len) - 1 in
|
||||
Rust_primitives.Arrays.createi (sz 256) (fun i ->
|
||||
let round = v i / (2 * len) in
|
||||
let idx = v i % (2 * len) in
|
||||
let (idx0, idx1) = if idx < len then (idx, idx+len) else (idx-len,idx) in
|
||||
let (a_ntt, b_ntt) = poly_ntt_step p.[sz idx0] p.[sz idx1] (round + k) in
|
||||
if idx < len then a_ntt else b_ntt)
|
||||
#pop-options
|
||||
|
||||
val poly_ntt: polynomial -> polynomial
|
||||
[@ "opaque_to_smt"]
|
||||
let poly_ntt p =
|
||||
let p = poly_ntt_layer p 7 in
|
||||
let p = poly_ntt_layer p 6 in
|
||||
let p = poly_ntt_layer p 5 in
|
||||
let p = poly_ntt_layer p 4 in
|
||||
let p = poly_ntt_layer p 3 in
|
||||
let p = poly_ntt_layer p 2 in
|
||||
let p = poly_ntt_layer p 1 in
|
||||
p
|
||||
|
||||
let poly_inv_ntt_step (a:field_element) (b:field_element) (i:nat{i < 128}) =
|
||||
let b_minus_a = field_sub b a in
|
||||
let a = field_add a b in
|
||||
let b = field_mul b_minus_a zetas.[sz i] in
|
||||
(a,b)
|
||||
|
||||
#push-options "--z3rlimit 150"
|
||||
let poly_inv_ntt_layer (p:polynomial) (l:nat{l > 0 /\ l < 8}) : polynomial =
|
||||
let len = pow2 l in
|
||||
let k = (256 / len) - 1 in
|
||||
Rust_primitives.Arrays.createi (sz 256) (fun i ->
|
||||
let round = v i / (2 * len) in
|
||||
let idx = v i % (2 * len) in
|
||||
let (idx0, idx1) = if idx < len then (idx, idx+len) else (idx-len,idx) in
|
||||
let (a_ntt, b_ntt) = poly_inv_ntt_step p.[sz idx0] p.[sz idx1] (k - round) in
|
||||
if idx < len then a_ntt else b_ntt)
|
||||
#pop-options
|
||||
|
||||
val poly_inv_ntt: polynomial -> polynomial
|
||||
let poly_inv_ntt p =
|
||||
let p = poly_inv_ntt_layer p 1 in
|
||||
let p = poly_inv_ntt_layer p 2 in
|
||||
let p = poly_inv_ntt_layer p 3 in
|
||||
let p = poly_inv_ntt_layer p 4 in
|
||||
let p = poly_inv_ntt_layer p 5 in
|
||||
let p = poly_inv_ntt_layer p 6 in
|
||||
let p = poly_inv_ntt_layer p 7 in
|
||||
p
|
||||
|
||||
let poly_base_case_multiply (a0 a1 b0 b1 zeta:field_element) =
|
||||
let c0 = field_add (field_mul a0 b0) (field_mul (field_mul a1 b1) zeta) in
|
||||
let c1 = field_add (field_mul a0 b1) (field_mul a1 b0) in
|
||||
(c0,c1)
|
||||
|
||||
val poly_mul_ntt: polynomial -> polynomial -> polynomial
|
||||
let poly_mul_ntt a b =
|
||||
Rust_primitives.Arrays.createi (sz 256) (fun i ->
|
||||
let a0 = a.[sz (2 * (v i / 2))] in
|
||||
let a1 = a.[sz (2 * (v i / 2) + 1)] in
|
||||
let b0 = b.[sz (2 * (v i / 2))] in
|
||||
let b1 = b.[sz (2 * (v i / 2) + 1)] in
|
||||
let zeta_4 = zetas.[sz (64 + (v i/4))] in
|
||||
let zeta = if v i % 4 < 2 then zeta_4 else field_neg zeta_4 in
|
||||
let (c0,c1) = poly_base_case_multiply a0 a1 b0 b1 zeta in
|
||||
if v i % 2 = 0 then c0 else c1)
|
||||
|
||||
|
||||
val vector_add: #r:rank -> vector r -> vector r -> vector r
|
||||
let vector_add #p a b = map2 poly_add a b
|
||||
|
||||
val vector_ntt: #r:rank -> vector r -> vector r
|
||||
let vector_ntt #p v = map_array poly_ntt v
|
||||
|
||||
val vector_inv_ntt: #r:rank -> vector r -> vector r
|
||||
let vector_inv_ntt #p v = map_array poly_inv_ntt v
|
||||
|
||||
val vector_mul_ntt: #r:rank -> vector r -> vector r -> vector r
|
||||
let vector_mul_ntt #p a b = map2 poly_mul_ntt a b
|
||||
|
||||
val vector_sum: #r:rank -> vector r -> polynomial
|
||||
let vector_sum #r a = repeati (r -! sz 1)
|
||||
(fun i x -> assert (v i < v r - 1); poly_add x (a.[i +! sz 1])) a.[sz 0]
|
||||
|
||||
val vector_dot_product_ntt: #r:rank -> vector r -> vector r -> polynomial
|
||||
let vector_dot_product_ntt a b = vector_sum (vector_mul_ntt a b)
|
||||
|
||||
val matrix_transpose: #r:rank -> matrix r -> matrix r
|
||||
[@ "opaque_to_smt"]
|
||||
let matrix_transpose #r m =
|
||||
createi r (fun i ->
|
||||
createi r (fun j ->
|
||||
m.[j].[i]))
|
||||
|
||||
val matrix_vector_mul_ntt: #r:rank -> matrix r -> vector r -> vector r
|
||||
let matrix_vector_mul_ntt #r m v =
|
||||
createi r (fun i -> vector_dot_product_ntt m.[i] v)
|
||||
|
||||
val compute_As_plus_e_ntt: #r:rank -> a:matrix r -> s:vector r -> e:vector r -> vector r
|
||||
[@ "opaque_to_smt"]
|
||||
let compute_As_plus_e_ntt #p a s e = vector_add (matrix_vector_mul_ntt a s) e
|
||||
|
||||
|
||||
|
||||
type dT = d: nat {d = 1 \/ d = 4 \/ d = 5 \/ d = 10 \/ d = 11 \/ d = 12}
|
||||
let max_d (d:dT) = if d < 12 then pow2 d else v v_FIELD_MODULUS
|
||||
type field_element_d (d:dT) = n:nat{n < max_d d}
|
||||
type polynomial_d (d:dT) = t_Array (field_element_d d) (sz 256)
|
||||
type vector_d (r:rank) (d:dT) = t_Array (polynomial_d d) r
|
||||
|
||||
let bits_to_bytes (#bytes: usize) (bv: bit_vec (v bytes * 8))
|
||||
: Pure (t_Array u8 bytes)
|
||||
(requires True)
|
||||
(ensures fun r -> (forall i. bit_vec_of_int_t_array r 8 i == bv i))
|
||||
= bit_vec_to_int_t_array 8 bv
|
||||
|
||||
let bytes_to_bits (#bytes: usize) (r: t_Array u8 bytes)
|
||||
: Pure (i: bit_vec (v bytes * 8))
|
||||
(requires True)
|
||||
(ensures fun f -> (forall i. bit_vec_of_int_t_array r 8 i == f i))
|
||||
= bit_vec_of_int_t_array r 8
|
||||
|
||||
unfold let retype_bit_vector #a #b (#_:unit{a == b}) (x: a): b = x
|
||||
|
||||
|
||||
let compress_d (d: dT {d <> 12}) (x: field_element): field_element_d d
|
||||
= let r = (pow2 d * x + 1664) / v v_FIELD_MODULUS in
|
||||
assert (r * v v_FIELD_MODULUS <= pow2 d * x + 1664);
|
||||
assert (r * v v_FIELD_MODULUS <= pow2 d * (v v_FIELD_MODULUS - 1) + 1664);
|
||||
Math.Lemmas.lemma_div_le (r * v v_FIELD_MODULUS) (pow2 d * (v v_FIELD_MODULUS - 1) + 1664) (v v_FIELD_MODULUS);
|
||||
Math.Lemmas.cancel_mul_div r (v v_FIELD_MODULUS);
|
||||
assert (r <= (pow2 d * (v v_FIELD_MODULUS - 1) + 1664) / v v_FIELD_MODULUS);
|
||||
Math.Lemmas.lemma_div_mod_plus (1664 - pow2 d) (pow2 d) (v v_FIELD_MODULUS);
|
||||
assert (r <= pow2 d + (1664 - pow2 d) / v v_FIELD_MODULUS);
|
||||
assert (r <= pow2 d);
|
||||
if r = pow2 d then 0 else r
|
||||
|
||||
let decompress_d (d: dT {d <> 12}) (x: field_element_d d): field_element
|
||||
= let r = (x * v v_FIELD_MODULUS + 1664) / pow2 d in
|
||||
r
|
||||
|
||||
[@ "opaque_to_smt"]
|
||||
let byte_encode (d: dT) (coefficients: polynomial_d d): t_Array u8 (sz (32 * d))
|
||||
= let coefficients' : t_Array nat (sz 256) = map_array #(field_element_d d) (fun x -> x <: nat) coefficients in
|
||||
bits_to_bytes #(sz (32 * d))
|
||||
(retype_bit_vector (bit_vec_of_nat_array coefficients' d))
|
||||
|
||||
[@ "opaque_to_smt"]
|
||||
let byte_decode (d: dT) (coefficients: t_Array u8 (sz (32 * d))): polynomial_d d
|
||||
= let bv = bytes_to_bits coefficients in
|
||||
let arr: t_Array nat (sz 256) = bit_vec_to_nat_array d (retype_bit_vector bv) in
|
||||
let p: polynomial_d d =
|
||||
createi (sz 256) (fun i ->
|
||||
let x_f : field_element = arr.[i] % v v_FIELD_MODULUS in
|
||||
assert (d < 12 ==> arr.[i] < pow2 d);
|
||||
let x_m : field_element_d d = x_f in
|
||||
x_m)
|
||||
in
|
||||
p
|
||||
|
||||
let coerce_polynomial_12 (p:polynomial): polynomial_d 12 = p
|
||||
let coerce_vector_12 (#r:rank) (v:vector r): vector_d r 12 = v
|
||||
|
||||
[@ "opaque_to_smt"]
|
||||
let compress_then_byte_encode (d: dT {d <> 12}) (coefficients: polynomial): t_Array u8 (sz (32 * d))
|
||||
= let coefs: t_Array (field_element_d d) (sz 256) = map_array (compress_d d) coefficients
|
||||
in
|
||||
byte_encode d coefs
|
||||
|
||||
[@ "opaque_to_smt"]
|
||||
let byte_decode_then_decompress (d: dT {d <> 12}) (b:t_Array u8 (sz (32 * d))): polynomial
|
||||
= map_array (decompress_d d) (byte_decode d b)
|
||||
|
||||
|
||||
(**** Definitions to move or to rework *)
|
||||
let serialize_pre
|
||||
(d1: dT)
|
||||
(coefficients: t_Array i16 (sz 16))
|
||||
= forall i. i < 16 ==> bounded (Seq.index coefficients i) d1
|
||||
|
||||
// TODO: this is an alternative version of byte_encode
|
||||
// rename to encoded bytes
|
||||
#push-options "--z3rlimit 80 --split_queries always"
|
||||
let serialize_post
|
||||
(d1: dT)
|
||||
(coefficients: t_Array i16 (sz 16) { serialize_pre d1 coefficients })
|
||||
(output: t_Array u8 (sz (d1 * 2)))
|
||||
= BitVecEq.int_t_array_bitwise_eq coefficients d1
|
||||
output 8
|
||||
|
||||
// TODO: this is an alternative version of byte_decode
|
||||
// rename to decoded bytes
|
||||
let deserialize_post
|
||||
(d1: dT)
|
||||
(bytes: t_Array u8 (sz (d1 * 2)))
|
||||
(output: t_Array i16 (sz 16))
|
||||
= BitVecEq.int_t_array_bitwise_eq bytes 8
|
||||
output d1 /\
|
||||
forall (i:nat). i < 16 ==> bounded (Seq.index output i) d1
|
||||
#pop-options
|
||||
@@ -0,0 +1,453 @@
|
||||
module Spec.MLKEM
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 80"
|
||||
open FStar.Mul
|
||||
open Core_models
|
||||
|
||||
include Spec.Utils
|
||||
include Spec.MLKEM.Math
|
||||
|
||||
(** ML-KEM Constants *)
|
||||
let v_BITS_PER_COEFFICIENT: usize = sz 12
|
||||
|
||||
let v_COEFFICIENTS_IN_RING_ELEMENT: usize = sz 256
|
||||
|
||||
let v_BITS_PER_RING_ELEMENT: usize = sz 3072 // v_COEFFICIENTS_IN_RING_ELEMENT *! sz 12
|
||||
|
||||
let v_BYTES_PER_RING_ELEMENT: usize = sz 384 // v_BITS_PER_RING_ELEMENT /! sz 8
|
||||
|
||||
let v_CPA_KEY_GENERATION_SEED_SIZE: usize = sz 32
|
||||
|
||||
let v_H_DIGEST_SIZE: usize = sz 32
|
||||
// same as Libcrux.Digest.digest_size (Libcrux.Digest.Algorithm_Sha3_256_ <: Libcrux.Digest.t_Algorithm)
|
||||
|
||||
let v_REJECTION_SAMPLING_SEED_SIZE: usize = sz 840 // sz 168 *! sz 5
|
||||
|
||||
let v_SHARED_SECRET_SIZE: usize = v_H_DIGEST_SIZE
|
||||
|
||||
val v_ETA1 (r:rank) : u:usize{u == sz 3 \/ u == sz 2}
|
||||
let v_ETA1 (r:rank) : usize =
|
||||
if r = sz 2 then sz 3 else
|
||||
if r = sz 3 then sz 2 else
|
||||
if r = sz 4 then sz 2 else (
|
||||
assert (false);
|
||||
sz 0)
|
||||
|
||||
|
||||
let v_ETA2 (r:rank) : usize = sz 2
|
||||
|
||||
val v_VECTOR_U_COMPRESSION_FACTOR (r:rank) : u:usize{u == sz 10 \/ u == sz 11}
|
||||
let v_VECTOR_U_COMPRESSION_FACTOR (r:rank) : usize =
|
||||
if r = sz 2 then sz 10 else
|
||||
if r = sz 3 then sz 10 else
|
||||
if r = sz 4 then sz 11 else (
|
||||
assert (false);
|
||||
sz 0)
|
||||
|
||||
val v_VECTOR_V_COMPRESSION_FACTOR (r:rank) : u:usize{u == sz 4 \/ u == sz 5}
|
||||
let v_VECTOR_V_COMPRESSION_FACTOR (r:rank) : usize =
|
||||
if r = sz 2 then sz 4 else
|
||||
if r = sz 3 then sz 4 else
|
||||
if r = sz 4 then sz 5 else (
|
||||
assert (false);
|
||||
sz 0)
|
||||
|
||||
val v_ETA1_RANDOMNESS_SIZE (r:rank) : u:usize{u == sz 128 \/ u == sz 192}
|
||||
let v_ETA1_RANDOMNESS_SIZE (r:rank) = v_ETA1 r *! sz 64
|
||||
|
||||
val v_ETA2_RANDOMNESS_SIZE (r:rank) : u:usize{u == sz 128}
|
||||
let v_ETA2_RANDOMNESS_SIZE (r:rank) = v_ETA2 r *! sz 64
|
||||
|
||||
val v_RANKED_BYTES_PER_RING_ELEMENT (r:rank) : u:usize{u = sz 768 \/ u = sz 1152 \/ u = sz 1536}
|
||||
let v_RANKED_BYTES_PER_RING_ELEMENT (r:rank) = r *! v_BYTES_PER_RING_ELEMENT
|
||||
|
||||
let v_T_AS_NTT_ENCODED_SIZE (r:rank) = v_RANKED_BYTES_PER_RING_ELEMENT r
|
||||
let v_CPA_PRIVATE_KEY_SIZE (r:rank) = v_RANKED_BYTES_PER_RING_ELEMENT r
|
||||
|
||||
val v_CPA_PUBLIC_KEY_SIZE (r:rank) : u:usize{u = sz 800 \/ u = sz 1184 \/ u = sz 1568}
|
||||
let v_CPA_PUBLIC_KEY_SIZE (r:rank) = v_RANKED_BYTES_PER_RING_ELEMENT r +! sz 32
|
||||
|
||||
val v_CCA_PRIVATE_KEY_SIZE (r:rank) : u:usize{u = sz 1632 \/ u = sz 2400 \/ u = sz 3168}
|
||||
let v_CCA_PRIVATE_KEY_SIZE (r:rank) =
|
||||
(v_CPA_PRIVATE_KEY_SIZE r +! v_CPA_PUBLIC_KEY_SIZE r +! v_H_DIGEST_SIZE +! v_SHARED_SECRET_SIZE)
|
||||
|
||||
let v_CCA_PUBLIC_KEY_SIZE (r:rank) = v_CPA_PUBLIC_KEY_SIZE r
|
||||
|
||||
val v_C1_BLOCK_SIZE (r:rank): u:usize{(u = sz 320 \/ u = sz 352) /\ v u == 32 * v (v_VECTOR_U_COMPRESSION_FACTOR r)}
|
||||
let v_C1_BLOCK_SIZE (r:rank) = sz 32 *! v_VECTOR_U_COMPRESSION_FACTOR r
|
||||
|
||||
val v_C1_SIZE (r:rank) : u:usize{(u >=. sz 640 /\ u <=. sz 1448) /\
|
||||
v u == v (v_C1_BLOCK_SIZE r) * v r}
|
||||
let v_C1_SIZE (r:rank) = v_C1_BLOCK_SIZE r *! r
|
||||
|
||||
val v_C2_SIZE (r:rank) : u:usize{(u = sz 128 \/ u = sz 160) /\ v u == 32 * v (v_VECTOR_V_COMPRESSION_FACTOR r)}
|
||||
let v_C2_SIZE (r:rank) = sz 32 *! v_VECTOR_V_COMPRESSION_FACTOR r
|
||||
|
||||
val v_CPA_CIPHERTEXT_SIZE (r:rank) : u:usize {v u = v (v_C1_SIZE r) + v (v_C2_SIZE r)}
|
||||
let v_CPA_CIPHERTEXT_SIZE (r:rank) = v_C1_SIZE r +! v_C2_SIZE r
|
||||
|
||||
let v_CCA_CIPHERTEXT_SIZE (r:rank) = v_CPA_CIPHERTEXT_SIZE r
|
||||
|
||||
val v_IMPLICIT_REJECTION_HASH_INPUT_SIZE (r:rank): u:usize{v u == v v_SHARED_SECRET_SIZE +
|
||||
v (v_CPA_CIPHERTEXT_SIZE r)}
|
||||
let v_IMPLICIT_REJECTION_HASH_INPUT_SIZE (r:rank) =
|
||||
v_SHARED_SECRET_SIZE +! v_CPA_CIPHERTEXT_SIZE r
|
||||
|
||||
val v_KEY_GENERATION_SEED_SIZE: u:usize{u = sz 64}
|
||||
let v_KEY_GENERATION_SEED_SIZE: usize =
|
||||
v_CPA_KEY_GENERATION_SEED_SIZE +!
|
||||
v_SHARED_SECRET_SIZE
|
||||
|
||||
|
||||
(** ML-KEM Types *)
|
||||
|
||||
type t_MLKEMPublicKey (r:rank) = t_Array u8 (v_CPA_PUBLIC_KEY_SIZE r)
|
||||
type t_MLKEMPrivateKey (r:rank) = t_Array u8 (v_CCA_PRIVATE_KEY_SIZE r)
|
||||
type t_MLKEMKeyPair (r:rank) = t_MLKEMPrivateKey r & t_MLKEMPublicKey r
|
||||
|
||||
type t_MLKEMCPAPrivateKey (r:rank) = t_Array u8 (v_CPA_PRIVATE_KEY_SIZE r)
|
||||
type t_MLKEMCPAKeyPair (r:rank) = t_MLKEMCPAPrivateKey r & t_MLKEMPublicKey r
|
||||
|
||||
type t_MLKEMCiphertext (r:rank) = t_Array u8 (v_CPA_CIPHERTEXT_SIZE r)
|
||||
type t_MLKEMSharedSecret = t_Array u8 (v_SHARED_SECRET_SIZE)
|
||||
|
||||
|
||||
assume val sample_max: n:usize{v n < pow2 32 /\ v n >= 128 * 3 /\ v n % 3 = 0}
|
||||
|
||||
val sample_polynomial_ntt: seed:t_Array u8 (sz 34) -> (polynomial & bool)
|
||||
let sample_polynomial_ntt seed =
|
||||
let randomness = v_XOF sample_max seed in
|
||||
let bv = bytes_to_bits randomness in
|
||||
assert (v sample_max * 8 == (((v sample_max / 3) * 2) * 12));
|
||||
let bv: bit_vec ((v (sz ((v sample_max / 3) * 2))) * 12) = retype_bit_vector bv in
|
||||
let i16s = bit_vec_to_nat_array #(sz ((v sample_max / 3) * 2)) 12 bv in
|
||||
assert ((v sample_max / 3) * 2 >= 256);
|
||||
let poly0: polynomial = Seq.create 256 0 in
|
||||
let index_t = n:nat{n <= 256} in
|
||||
let (sampled, poly1) =
|
||||
repeati #(index_t & polynomial) (sz ((v sample_max / 3) * 2))
|
||||
(fun i (sampled,acc) ->
|
||||
if sampled < 256 then
|
||||
let sample = Seq.index i16s (v i) in
|
||||
if sample < 3329 then
|
||||
(sampled+1, Rust_primitives.Hax.update_at acc (sz sampled) sample)
|
||||
else (sampled, acc)
|
||||
else (sampled, acc))
|
||||
(0,poly0) in
|
||||
if sampled < 256 then poly0, false else poly1, true
|
||||
|
||||
let sample_polynomial_ntt_at_index (seed:t_Array u8 (sz 32)) (i j: (x:usize{v x <= 4})) : polynomial & bool =
|
||||
let seed34 = Seq.append seed (Seq.create 2 (mk_u8 0)) in
|
||||
let seed34 = Rust_primitives.Hax.update_at seed34 (sz 32) (mk_int #u8_inttype (v i)) in
|
||||
let seed34 = Rust_primitives.Hax.update_at seed34 (sz 33) (mk_int #u8_inttype (v j)) in
|
||||
sample_polynomial_ntt seed34
|
||||
|
||||
val sample_matrix_A_ntt: #r:rank -> seed:t_Array u8 (sz 32) -> (matrix r & bool)
|
||||
[@ "opaque_to_smt"]
|
||||
let sample_matrix_A_ntt #r seed =
|
||||
let m =
|
||||
createi r (fun i ->
|
||||
createi r (fun j ->
|
||||
let (p,b) = sample_polynomial_ntt_at_index seed i j in
|
||||
p))
|
||||
in
|
||||
let sufficient_randomness =
|
||||
repeati r (fun i b ->
|
||||
repeati r (fun j b ->
|
||||
let (p,v) = sample_polynomial_ntt_at_index seed i j in
|
||||
b && v) b) true in
|
||||
(m, sufficient_randomness)
|
||||
|
||||
assume val sample_poly_cbd: v_ETA:usize{v v_ETA == 2 \/ v v_ETA == 3} -> t_Array u8 (v_ETA *! sz 64) -> polynomial
|
||||
|
||||
open Rust_primitives.Integers
|
||||
|
||||
val sample_poly_cbd2: #r:rank -> seed:t_Array u8 (sz 32) -> domain_sep:usize{v domain_sep < 256} -> polynomial
|
||||
let sample_poly_cbd2 #r seed domain_sep =
|
||||
let prf_input = Seq.append seed (Seq.create 1 (mk_int #u8_inttype (v domain_sep))) in
|
||||
let prf_output = v_PRF (v_ETA2_RANDOMNESS_SIZE r) prf_input in
|
||||
sample_poly_cbd (v_ETA2 r) prf_output
|
||||
|
||||
let sample_vector_cbd1_prf_input (#r:rank) (seed:t_Array u8 (sz 32)) (domain_sep:usize{v domain_sep < 2 * v r}) (i:usize{i <. r}) : t_Array u8 (sz 33) =
|
||||
Seq.append seed (Seq.create 1 (mk_int #u8_inttype (v domain_sep + v i)))
|
||||
|
||||
let sample_vector_cbd1_prf_output (#r:rank) (prf_output:t_Array (t_Array u8 (v_ETA1_RANDOMNESS_SIZE r)) r) (i:usize{i <. r}) : polynomial =
|
||||
sample_poly_cbd (v_ETA1 r) prf_output.[i]
|
||||
|
||||
let sample_vector_cbd1 (#r:rank) (seed:t_Array u8 (sz 32)) (domain_sep:usize{v domain_sep < 2 * v r}) : vector r =
|
||||
let prf_input = createi r (sample_vector_cbd1_prf_input #r seed domain_sep) in
|
||||
let prf_output = v_PRFxN r (v_ETA1_RANDOMNESS_SIZE r) prf_input in
|
||||
createi r (sample_vector_cbd1_prf_output #r prf_output)
|
||||
|
||||
let sample_vector_cbd2_prf_input (#r:rank) (seed:t_Array u8 (sz 32)) (domain_sep:usize{v domain_sep < 2 * v r}) (i:usize{i <. r}) : t_Array u8 (sz 33) =
|
||||
Seq.append seed (Seq.create 1 (mk_int #u8_inttype (v domain_sep + v i)))
|
||||
|
||||
let sample_vector_cbd2_prf_output (#r:rank) (prf_output:t_Array (t_Array u8 (v_ETA2_RANDOMNESS_SIZE r)) r) (i:usize{i <. r}) : polynomial =
|
||||
sample_poly_cbd (v_ETA2 r) prf_output.[i]
|
||||
|
||||
let sample_vector_cbd2 (#r:rank) (seed:t_Array u8 (sz 32)) (domain_sep:usize{v domain_sep < 2 * v r}) : vector r =
|
||||
let prf_input = createi r (sample_vector_cbd2_prf_input #r seed domain_sep) in
|
||||
let prf_output = v_PRFxN r (v_ETA2_RANDOMNESS_SIZE r) prf_input in
|
||||
createi r (sample_vector_cbd2_prf_output #r prf_output)
|
||||
|
||||
[@ "opaque_to_smt"]
|
||||
let sample_vector_cbd_then_ntt (#r:rank) (seed:t_Array u8 (sz 32)) (domain_sep:usize{v domain_sep < 2 * v r}) : vector r =
|
||||
vector_ntt (sample_vector_cbd1 #r seed domain_sep)
|
||||
|
||||
[@ "opaque_to_smt"]
|
||||
let vector_encode_12 (#r:rank) (v: vector r) : t_Array u8 (v_T_AS_NTT_ENCODED_SIZE r)
|
||||
= let s: t_Array (t_Array _ (sz 384)) r = map_array (byte_encode 12) (coerce_vector_12 v) in
|
||||
flatten s
|
||||
|
||||
let vector_decode_12 (#r:rank) (arr: t_Array u8 (v_T_AS_NTT_ENCODED_SIZE r)): vector r
|
||||
= createi r (fun block ->
|
||||
let block_size = (sz (32 * 12)) in
|
||||
let slice = Seq.slice arr (v block * v block_size)
|
||||
(v block * v block_size + v block_size) in
|
||||
byte_decode 12 slice
|
||||
)
|
||||
|
||||
let compress_then_encode_message (p:polynomial) : t_Array u8 v_SHARED_SECRET_SIZE
|
||||
= compress_then_byte_encode 1 p
|
||||
|
||||
let decode_then_decompress_message (b:t_Array u8 v_SHARED_SECRET_SIZE): polynomial
|
||||
= byte_decode_then_decompress 1 b
|
||||
|
||||
let compress_then_encode_u (#r:rank) (vec: vector r): t_Array u8 (v_C1_SIZE r)
|
||||
= let d = v (v_VECTOR_U_COMPRESSION_FACTOR r) in
|
||||
flatten (map_array (compress_then_byte_encode d) vec)
|
||||
|
||||
let decode_then_decompress_u (#r:rank) (arr: t_Array u8 (v_C1_SIZE r)): vector r
|
||||
= let d = v_VECTOR_U_COMPRESSION_FACTOR r in
|
||||
createi r (fun block ->
|
||||
let block_size = v_C1_BLOCK_SIZE r in
|
||||
let slice = Seq.slice arr (v block * v block_size)
|
||||
(v block * v block_size + v block_size) in
|
||||
byte_decode_then_decompress (v d) slice
|
||||
)
|
||||
|
||||
let compress_then_encode_v (#r:rank): polynomial -> t_Array u8 (v_C2_SIZE r)
|
||||
= compress_then_byte_encode (v (v_VECTOR_V_COMPRESSION_FACTOR r))
|
||||
|
||||
let decode_then_decompress_v (#r:rank): t_Array u8 (v_C2_SIZE r) -> polynomial
|
||||
= byte_decode_then_decompress (v (v_VECTOR_V_COMPRESSION_FACTOR r))
|
||||
|
||||
(** IND-CPA Functions *)
|
||||
|
||||
val ind_cpa_generate_keypair_unpacked (r:rank) (randomness:t_Array u8 v_CPA_KEY_GENERATION_SEED_SIZE) :
|
||||
(((((vector r) & (t_Array u8 (sz 32))) & (matrix r)) & (vector r)) & bool)
|
||||
let ind_cpa_generate_keypair_unpacked r randomness =
|
||||
let hashed = v_G (Seq.append randomness (Seq.create 1 (cast r <: u8))) in
|
||||
let (seed_for_A, seed_for_secret_and_error) = split hashed (sz 32) in
|
||||
let (matrix_A_as_ntt, sufficient_randomness) = sample_matrix_A_ntt #r seed_for_A in
|
||||
let secret_as_ntt = sample_vector_cbd_then_ntt #r seed_for_secret_and_error (sz 0) in
|
||||
let error_as_ntt = sample_vector_cbd_then_ntt #r seed_for_secret_and_error r in
|
||||
let t_as_ntt = compute_As_plus_e_ntt #r matrix_A_as_ntt secret_as_ntt error_as_ntt in
|
||||
(((t_as_ntt,seed_for_A), matrix_A_as_ntt), secret_as_ntt), sufficient_randomness
|
||||
|
||||
/// This function implements most of <strong>Algorithm 12</strong> of the
|
||||
/// NIST FIPS 203 specification; this is the MLKEM CPA-PKE key generation algorithm.
|
||||
///
|
||||
/// We say "most of" since Algorithm 12 samples the required randomness within
|
||||
/// the function itself, whereas this implementation expects it to be provided
|
||||
/// through the `key_generation_seed` parameter.
|
||||
|
||||
val ind_cpa_generate_keypair (r:rank) (randomness:t_Array u8 v_CPA_KEY_GENERATION_SEED_SIZE) :
|
||||
(t_MLKEMCPAKeyPair r & bool)
|
||||
let ind_cpa_generate_keypair r randomness =
|
||||
let ((((t_as_ntt,seed_for_A), _), secret_as_ntt), sufficient_randomness) =
|
||||
ind_cpa_generate_keypair_unpacked r randomness in
|
||||
let public_key_serialized = Seq.append (vector_encode_12 #r t_as_ntt) seed_for_A in
|
||||
let secret_key_serialized = vector_encode_12 #r secret_as_ntt in
|
||||
((secret_key_serialized,public_key_serialized), sufficient_randomness)
|
||||
|
||||
val ind_cpa_encrypt_unpacked (r:rank)
|
||||
(message: t_Array u8 v_SHARED_SECRET_SIZE)
|
||||
(randomness:t_Array u8 v_SHARED_SECRET_SIZE)
|
||||
(t_as_ntt:vector r)
|
||||
(matrix_A_as_ntt:matrix r) :
|
||||
t_MLKEMCiphertext r
|
||||
|
||||
#push-options "--z3rlimit 500 --ext context_pruning"
|
||||
let ind_cpa_encrypt_unpacked r message randomness t_as_ntt matrix_A_as_ntt =
|
||||
let r_as_ntt = sample_vector_cbd_then_ntt #r randomness (sz 0) in
|
||||
let error_1 = sample_vector_cbd2 #r randomness r in
|
||||
let error_2 = sample_poly_cbd2 #r randomness (r +! r) in
|
||||
let u = vector_add (vector_inv_ntt (matrix_vector_mul_ntt matrix_A_as_ntt r_as_ntt)) error_1 in
|
||||
let mu = decode_then_decompress_message message in
|
||||
let v = poly_add (poly_add (vector_dot_product_ntt t_as_ntt r_as_ntt) error_2) mu in
|
||||
let c1 = compress_then_encode_u #r u in
|
||||
let c2 = compress_then_encode_v #r v in
|
||||
concat c1 c2
|
||||
#pop-options
|
||||
|
||||
/// This function implements <strong>Algorithm 13</strong> of the
|
||||
/// NIST FIPS 203 specification; this is the MLKEM CPA-PKE encryption algorithm.
|
||||
|
||||
val ind_cpa_encrypt (r:rank) (public_key: t_MLKEMPublicKey r)
|
||||
(message: t_Array u8 v_SHARED_SECRET_SIZE)
|
||||
(randomness:t_Array u8 v_SHARED_SECRET_SIZE) :
|
||||
(t_MLKEMCiphertext r & bool)
|
||||
|
||||
[@ "opaque_to_smt"]
|
||||
let ind_cpa_encrypt r public_key message randomness =
|
||||
let (t_as_ntt_bytes, seed_for_A) = split public_key (v_T_AS_NTT_ENCODED_SIZE r) in
|
||||
let t_as_ntt = vector_decode_12 #r t_as_ntt_bytes in
|
||||
let matrix_A_as_ntt, sufficient_randomness = sample_matrix_A_ntt #r seed_for_A in
|
||||
let c = ind_cpa_encrypt_unpacked r message randomness t_as_ntt (matrix_transpose matrix_A_as_ntt) in
|
||||
(c, sufficient_randomness)
|
||||
|
||||
val ind_cpa_decrypt_unpacked (r:rank)
|
||||
(ciphertext: t_MLKEMCiphertext r) (secret_as_ntt:vector r):
|
||||
t_MLKEMSharedSecret
|
||||
|
||||
let ind_cpa_decrypt_unpacked r ciphertext secret_as_ntt =
|
||||
let (c1,c2) = split ciphertext (v_C1_SIZE r) in
|
||||
let u = decode_then_decompress_u #r c1 in
|
||||
let v = decode_then_decompress_v #r c2 in
|
||||
let w = poly_sub v (poly_inv_ntt (vector_dot_product_ntt secret_as_ntt (vector_ntt u))) in
|
||||
compress_then_encode_message w
|
||||
|
||||
/// This function implements <strong>Algorithm 14</strong> of the
|
||||
/// NIST FIPS 203 specification; this is the MLKEM CPA-PKE decryption algorithm.
|
||||
|
||||
val ind_cpa_decrypt (r:rank) (secret_key: t_MLKEMCPAPrivateKey r)
|
||||
(ciphertext: t_MLKEMCiphertext r):
|
||||
t_MLKEMSharedSecret
|
||||
|
||||
[@ "opaque_to_smt"]
|
||||
let ind_cpa_decrypt r secret_key ciphertext =
|
||||
let secret_as_ntt = vector_decode_12 #r secret_key in
|
||||
ind_cpa_decrypt_unpacked r ciphertext secret_as_ntt
|
||||
|
||||
(** IND-CCA Functions *)
|
||||
|
||||
|
||||
/// This function implements most of Algorithm 15 of the
|
||||
/// NIST FIPS 203 specification; this is the MLKEM CCA-KEM key generation algorithm.
|
||||
///
|
||||
/// We say "most of" since Algorithm 15 samples the required randomness within
|
||||
/// the function itself, whereas this implementation expects it to be provided
|
||||
/// through the `randomness` parameter.
|
||||
///
|
||||
/// TODO: input validation
|
||||
|
||||
val ind_cca_generate_keypair (r:rank) (randomness:t_Array u8 v_KEY_GENERATION_SEED_SIZE) :
|
||||
t_MLKEMKeyPair r & bool
|
||||
let ind_cca_generate_keypair p randomness =
|
||||
let (ind_cpa_keypair_randomness, implicit_rejection_value) =
|
||||
split randomness v_CPA_KEY_GENERATION_SEED_SIZE in
|
||||
|
||||
let (ind_cpa_secret_key,ind_cpa_public_key), sufficient_randomness = ind_cpa_generate_keypair p ind_cpa_keypair_randomness in
|
||||
let ind_cca_secret_key = Seq.append ind_cpa_secret_key (
|
||||
Seq.append ind_cpa_public_key (
|
||||
Seq.append (v_H ind_cpa_public_key) implicit_rejection_value)) in
|
||||
(ind_cca_secret_key, ind_cpa_public_key), sufficient_randomness
|
||||
|
||||
/// This function implements most of Algorithm 16 of the
|
||||
/// NIST FIPS 203 specification; this is the MLKEM CCA-KEM encapsulation algorithm.
|
||||
///
|
||||
/// We say "most of" since Algorithm 16 samples the required randomness within
|
||||
/// the function itself, whereas this implementation expects it to be provided
|
||||
/// through the `randomness` parameter.
|
||||
///
|
||||
/// TODO: input validation
|
||||
|
||||
val ind_cca_encapsulate (r:rank) (public_key: t_MLKEMPublicKey r)
|
||||
(randomness:t_Array u8 v_SHARED_SECRET_SIZE) :
|
||||
(t_MLKEMCiphertext r & t_MLKEMSharedSecret) & bool
|
||||
let ind_cca_encapsulate p public_key randomness =
|
||||
let to_hash = concat randomness (v_H public_key) in
|
||||
let hashed = v_G to_hash in
|
||||
let (shared_secret, pseudorandomness) = split hashed v_SHARED_SECRET_SIZE in
|
||||
let ciphertext, sufficient_randomness = ind_cpa_encrypt p public_key randomness pseudorandomness in
|
||||
(ciphertext,shared_secret), sufficient_randomness
|
||||
|
||||
|
||||
/// This function implements Algorithm 17 of the
|
||||
/// NIST FIPS 203 specification; this is the MLKEM CCA-KEM encapsulation algorithm.
|
||||
|
||||
val ind_cca_decapsulate (r:rank) (secret_key: t_MLKEMPrivateKey r)
|
||||
(ciphertext: t_MLKEMCiphertext r):
|
||||
t_MLKEMSharedSecret & bool
|
||||
let ind_cca_decapsulate p secret_key ciphertext =
|
||||
let (ind_cpa_secret_key,rest) = split secret_key (v_CPA_PRIVATE_KEY_SIZE p) in
|
||||
let (ind_cpa_public_key,rest) = split rest (v_CPA_PUBLIC_KEY_SIZE p) in
|
||||
let (ind_cpa_public_key_hash,implicit_rejection_value) = split rest v_H_DIGEST_SIZE in
|
||||
|
||||
let decrypted = ind_cpa_decrypt p ind_cpa_secret_key ciphertext in
|
||||
let to_hash = concat decrypted ind_cpa_public_key_hash in
|
||||
let hashed = v_G to_hash in
|
||||
let (success_shared_secret, pseudorandomness) = split hashed v_SHARED_SECRET_SIZE in
|
||||
|
||||
assert (Seq.length implicit_rejection_value = 32);
|
||||
let to_hash = concat implicit_rejection_value ciphertext in
|
||||
let rejection_shared_secret = v_J to_hash in
|
||||
|
||||
let reencrypted, sufficient_randomness = ind_cpa_encrypt p ind_cpa_public_key decrypted pseudorandomness in
|
||||
if reencrypted = ciphertext
|
||||
then success_shared_secret, sufficient_randomness
|
||||
else rejection_shared_secret, sufficient_randomness
|
||||
|
||||
val ind_cca_unpack_public_key (r:rank) (public_key: t_MLKEMPublicKey r) :
|
||||
t_Array u8 (sz 32) & (t_Array u8 (sz 32) & (vector r & (matrix r & bool)))
|
||||
let ind_cca_unpack_public_key p public_key =
|
||||
let (ring_elements, seed) = split public_key (v_T_AS_NTT_ENCODED_SIZE p) in
|
||||
let deserialized_pk = vector_decode_12 #p ring_elements in
|
||||
let (matrix_A, sufficient_randomness) = sample_matrix_A_ntt seed in
|
||||
let matrix_A = matrix_transpose #p matrix_A in
|
||||
let public_key_hash = v_H public_key in
|
||||
public_key_hash, (seed, (deserialized_pk, (matrix_A, sufficient_randomness)))
|
||||
|
||||
let matrix_A_as_ntt_j (#r:rank) (matrix_A_as_ntt:matrix r) (i:usize{i <. r}) (j:usize{j <. r}) : polynomial =
|
||||
Seq.index (Seq.index matrix_A_as_ntt (v j)) (v i)
|
||||
|
||||
let matrix_A_as_ntt_i (#r:rank) (matrix_A_as_ntt:matrix r) (i:usize{i <. r}) : vector r =
|
||||
createi r (matrix_A_as_ntt_j matrix_A_as_ntt i)
|
||||
|
||||
val ind_cca_unpack_generate_keypair (r:rank) (randomness:t_Array u8 v_KEY_GENERATION_SEED_SIZE) :
|
||||
((matrix r & t_Array u8 (sz 32)) & t_Array u8 (sz 32)) & bool
|
||||
let ind_cca_unpack_generate_keypair p randomness =
|
||||
let (ind_cpa_keypair_randomness, implicit_rejection_value) = split randomness v_CPA_KEY_GENERATION_SEED_SIZE in
|
||||
let ((((t_as_ntt,seed_for_A), matrix_A_as_ntt), secret_as_ntt), sufficient_randomness) =
|
||||
ind_cpa_generate_keypair_unpacked p ind_cpa_keypair_randomness in
|
||||
// let m_A =
|
||||
// createi p (fun i ->
|
||||
// createi p (fun j ->
|
||||
// Seq.index (Seq.index matrix_A_as_ntt j) i
|
||||
// ))
|
||||
// in
|
||||
let m_A = createi p (matrix_A_as_ntt_i matrix_A_as_ntt) in
|
||||
let pk_serialized = Seq.append (vector_encode_12 t_as_ntt) seed_for_A in
|
||||
let public_key_hash = v_H pk_serialized in
|
||||
((m_A, public_key_hash), implicit_rejection_value), sufficient_randomness
|
||||
|
||||
val ind_cca_unpack_encapsulate (r:rank) (public_key_hash:t_Array u8 (sz 32))
|
||||
(t_as_ntt:vector r)
|
||||
(matrix_A_as_ntt:matrix r)
|
||||
(randomness:t_Array u8 v_SHARED_SECRET_SIZE) :
|
||||
(t_MLKEMCiphertext r & t_Array u8 v_SHARED_SECRET_SIZE)
|
||||
let ind_cca_unpack_encapsulate r public_key_hash t_as_ntt matrix_A_as_ntt randomness =
|
||||
let to_hash = concat randomness public_key_hash in
|
||||
let hashed = v_G to_hash in
|
||||
let (shared_secret, pseudorandomness) = split hashed v_SHARED_SECRET_SIZE in
|
||||
let ciphertext = ind_cpa_encrypt_unpacked r randomness pseudorandomness t_as_ntt matrix_A_as_ntt in
|
||||
ciphertext, shared_secret
|
||||
|
||||
val ind_cca_unpack_decapsulate (r:rank) (public_key_hash:t_Array u8 (sz 32))
|
||||
(implicit_rejection_value:t_Array u8 (sz 32))
|
||||
(ciphertext: t_MLKEMCiphertext r)
|
||||
(secret_as_ntt:vector r)
|
||||
(t_as_ntt:vector r)
|
||||
(matrix_A_as_ntt:matrix r) :
|
||||
t_Array u8 v_SHARED_SECRET_SIZE
|
||||
let ind_cca_unpack_decapsulate r public_key_hash implicit_rejection_value ciphertext secret_as_ntt t_as_ntt matrix_A_as_ntt =
|
||||
let decrypted = ind_cpa_decrypt_unpacked r ciphertext secret_as_ntt in
|
||||
let to_hash = concat decrypted public_key_hash in
|
||||
let hashed = v_G to_hash in
|
||||
let (shared_secret, pseudorandomness) = split hashed v_SHARED_SECRET_SIZE in
|
||||
let to_hash:t_Array u8 (v_IMPLICIT_REJECTION_HASH_INPUT_SIZE r) = concat implicit_rejection_value ciphertext in
|
||||
let implicit_rejection_shared_secret = v_PRF v_SHARED_SECRET_SIZE to_hash in
|
||||
let expected_ciphertext = ind_cpa_encrypt_unpacked r decrypted pseudorandomness t_as_ntt matrix_A_as_ntt in
|
||||
if ciphertext = expected_ciphertext
|
||||
then shared_secret
|
||||
else implicit_rejection_shared_secret
|
||||
@@ -0,0 +1,248 @@
|
||||
module Spec.Utils
|
||||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 100"
|
||||
open FStar.Mul
|
||||
open Core_models
|
||||
|
||||
(** Utils *)
|
||||
let map_slice #a #b
|
||||
(f:a -> b)
|
||||
(s: t_Slice a)
|
||||
= createi (length s) (fun i -> f (Seq.index s (v i)))
|
||||
|
||||
let map_array #a #b #len
|
||||
(f:a -> b)
|
||||
(s: t_Array a len)
|
||||
= createi (length s) (fun i -> f (Seq.index s (v i)))
|
||||
|
||||
let map2 #a #b #c #len
|
||||
(f:a -> b -> c)
|
||||
(x: t_Array a len) (y: t_Array b len)
|
||||
= createi (length x) (fun i -> f (Seq.index x (v i)) (Seq.index y (v i)))
|
||||
|
||||
let create len c = createi len (fun i -> c)
|
||||
|
||||
let repeati #acc (l:usize) (f:(i:usize{v i < v l}) -> acc -> acc) acc0 : acc = Lib.LoopCombinators.repeati (v l) (fun i acc -> f (sz i) acc) acc0
|
||||
|
||||
let createL len l = Rust_primitives.Hax.array_of_list len l
|
||||
|
||||
let create16 v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 v0 =
|
||||
let l = [v15; v14; v13; v12; v11; v10; v9; v8; v7; v6; v5; v4; v3; v2; v1; v0] in
|
||||
assert_norm (List.Tot.length l == 16);
|
||||
createL 16 l
|
||||
|
||||
val lemma_createL_index #a len l i :
|
||||
Lemma (Seq.index (createL #a len l) i == List.Tot.index l i)
|
||||
[SMTPat (Seq.index (createL #a len l) i)]
|
||||
|
||||
val lemma_create16_index #a v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 v0 i :
|
||||
Lemma (Seq.index (create16 #a v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 v0) i ==
|
||||
(if i = 0 then v15 else
|
||||
if i = 1 then v14 else
|
||||
if i = 2 then v13 else
|
||||
if i = 3 then v12 else
|
||||
if i = 4 then v11 else
|
||||
if i = 5 then v10 else
|
||||
if i = 6 then v9 else
|
||||
if i = 7 then v8 else
|
||||
if i = 8 then v7 else
|
||||
if i = 9 then v6 else
|
||||
if i = 10 then v5 else
|
||||
if i = 11 then v4 else
|
||||
if i = 12 then v3 else
|
||||
if i = 13 then v2 else
|
||||
if i = 14 then v1 else
|
||||
if i = 15 then v0))
|
||||
[SMTPat (Seq.index (create16 #a v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 v0) i)]
|
||||
|
||||
val lemma_createi_index #a len f i :
|
||||
Lemma (Seq.index (createi #a len f) i == f (sz i))
|
||||
[SMTPat (Seq.index (createi #a len f) i)]
|
||||
|
||||
val lemma_create_index #a len c i:
|
||||
Lemma (Seq.index (create #a len c) i == c)
|
||||
[SMTPat (Seq.index (create #a len c) i)]
|
||||
|
||||
val lemma_bitand_properties #t (x:int_t t) :
|
||||
Lemma ((x &. ones) == x /\ (x &. mk_int #t 0) == mk_int #t 0 /\ (ones #t &. x) == x /\ (mk_int #t 0 &. x) == mk_int #t 0)
|
||||
|
||||
#push-options "--z3rlimit 15"
|
||||
let flatten #t #n
|
||||
(#m: usize {range (v n * v m) usize_inttype})
|
||||
(x: t_Array (t_Array t m) n)
|
||||
: t_Array t (m *! n)
|
||||
= createi (m *! n) (fun i -> Seq.index (Seq.index x (v i / v m)) (v i % v m))
|
||||
#pop-options
|
||||
|
||||
type t_Error = | Error_RejectionSampling : t_Error
|
||||
|
||||
type t_Result a b =
|
||||
| Ok: a -> t_Result a b
|
||||
| Err: b -> t_Result a b
|
||||
|
||||
val v_G (input: t_Slice u8) : t_Array u8 (sz 64)
|
||||
val v_H (input: t_Slice u8) : t_Array u8 (sz 32)
|
||||
val v_PRF (v_LEN: usize{v v_LEN < pow2 32}) (input: t_Slice u8) : t_Array u8 v_LEN
|
||||
|
||||
val v_PRFxN (r:usize{v r == 2 \/ v r == 3 \/ v r == 4}) (v_LEN: usize{v v_LEN < pow2 32})
|
||||
(input: t_Array (t_Array u8 (sz 33)) r) : t_Array (t_Array u8 v_LEN) r
|
||||
|
||||
val v_J (input: t_Slice u8) : t_Array u8 (sz 32)
|
||||
|
||||
val v_XOF (v_LEN: usize{v v_LEN < pow2 32}) (input: t_Slice u8) : t_Array u8 v_LEN
|
||||
|
||||
val update_at_range_lemma #n
|
||||
(s: t_Slice 't)
|
||||
(i: Core_models.Ops.Range.t_Range (int_t n) {(Core_models.Ops.Range.impl_index_range_slice 't n).f_index_pre s i})
|
||||
(x: t_Slice 't)
|
||||
: Lemma
|
||||
(requires (Seq.length x == v i.f_end - v i.f_start))
|
||||
(ensures (
|
||||
let s' = Rust_primitives.Hax.Monomorphized_update_at.update_at_range s i x in
|
||||
let len = v i.f_start in
|
||||
forall (i: nat). i < len ==> Seq.index s i == Seq.index s' i
|
||||
))
|
||||
[SMTPat (Rust_primitives.Hax.Monomorphized_update_at.update_at_range s i x)]
|
||||
|
||||
/// Bounded integers
|
||||
|
||||
let is_intb (l:nat) (x:int) = (x <= l) && (x >= -l)
|
||||
let is_i16b (l:nat) (x:i16) = is_intb l (v x)
|
||||
let is_i16b_array (l:nat) (x:t_Slice i16) = forall i. i < Seq.length x ==> is_i16b l (Seq.index x i)
|
||||
let is_i16b_vector (l:nat) (r:usize) (x:t_Array (t_Array i16 (sz 256)) r) = forall i. i < v r ==> is_i16b_array l (Seq.index x i)
|
||||
let is_i16b_matrix (l:nat) (r:usize) (x:t_Array (t_Array (t_Array i16 (sz 256)) r) r) = forall i. i < v r ==> is_i16b_vector l r (Seq.index x i)
|
||||
|
||||
[@ "opaque_to_smt"]
|
||||
let is_i16b_array_opaque (l:nat) (x:t_Slice i16) = is_i16b_array l x
|
||||
|
||||
let is_i32b (l:nat) (x:i32) = is_intb l (v x)
|
||||
let is_i32b_array (l:nat) (x:t_Slice i32) = forall i. i < Seq.length x ==> is_i32b l (Seq.index x i)
|
||||
|
||||
let is_i64b (l:nat) (x:i64) = is_intb l (v x)
|
||||
|
||||
let nat_div_ceil (x:nat) (y:pos) : nat = if (x % y = 0) then x/y else (x/y)+1
|
||||
|
||||
val lemma_intb_le b b'
|
||||
: Lemma (requires (b <= b'))
|
||||
(ensures (forall n. is_intb b n ==> is_intb b' n))
|
||||
|
||||
#push-options "--z3rlimit 200"
|
||||
val lemma_mul_intb (b1 b2: nat) (n1 n2: int)
|
||||
: Lemma (requires (is_intb b1 n1 /\ is_intb b2 n2))
|
||||
(ensures (is_intb (b1 * b2) (n1 * n2)))
|
||||
#pop-options
|
||||
|
||||
#push-options "--z3rlimit 200"
|
||||
val lemma_mul_i16b (b1 b2: nat) (n1 n2: i16)
|
||||
: Lemma (requires (is_i16b b1 n1 /\ is_i16b b2 n2 /\ b1 * b2 < pow2 31))
|
||||
(ensures (range (v n1 * v n2) i32_inttype /\
|
||||
is_i32b (b1 * b2) ((cast n1 <: i32) *! (cast n2 <: i32)) /\
|
||||
v ((cast n1 <: i32) *! (cast n2 <: i32)) == v n1 * v n2))
|
||||
#pop-options
|
||||
|
||||
#push-options "--z3rlimit 200"
|
||||
val lemma_mul_i32b (b1 b2: nat) (n1 n2: i32)
|
||||
: Lemma (requires (is_i32b b1 n1 /\ is_i32b b2 n2 /\ b1 * b2 < pow2 63))
|
||||
(ensures (range (v n1 * v n2) i64_inttype /\
|
||||
is_i64b (b1 * b2) ((cast n1 <: i64) *! (cast n2 <: i64)) /\
|
||||
v ((cast n1 <: i64) *! (cast n2 <: i64)) == v n1 * v n2))
|
||||
#pop-options
|
||||
|
||||
val lemma_add_i16b (b1 b2:nat) (n1 n2:i16) :
|
||||
Lemma (requires (is_i16b b1 n1 /\ is_i16b b2 n2 /\ b1 + b2 < pow2 15))
|
||||
(ensures (range (v n1 + v n2) i16_inttype /\
|
||||
is_i16b (b1 + b2) (n1 +! n2)))
|
||||
|
||||
val lemma_range_at_percent (v:int) (p:int{p>0/\ p%2=0 /\ v < p/2 /\ v >= -p / 2}):
|
||||
Lemma (v @% p == v)
|
||||
|
||||
val lemma_sub_i16b (b1 b2:nat) (n1 n2:i16) :
|
||||
Lemma (requires (is_i16b b1 n1 /\ is_i16b b2 n2 /\ b1 + b2 < pow2 15))
|
||||
(ensures (range (v n1 - v n2) i16_inttype /\
|
||||
is_i16b (b1 + b2) (n1 -. n2) /\
|
||||
v (n1 -. n2) == v n1 - v n2))
|
||||
|
||||
let mont_mul_red_i16 (x:i16) (y:i16) : i16=
|
||||
let vlow = x *. y in
|
||||
let k = vlow *. (neg (mk_i16 3327)) in
|
||||
let k_times_modulus = cast (((cast k <: i32) *. (mk_i32 3329)) >>! (mk_i32 16)) <: i16 in
|
||||
let vhigh = cast (((cast x <: i32) *. (cast y <: i32)) >>! (mk_i32 16)) <: i16 in
|
||||
vhigh -. k_times_modulus
|
||||
|
||||
let mont_red_i32 (x:i32) : i16 =
|
||||
let vlow = cast x <: i16 in
|
||||
let k = vlow *. (neg (mk_i16 3327)) in
|
||||
let k_times_modulus = cast (((cast k <: i32) *. (mk_i32 3329)) >>! (mk_i32 16)) <: i16 in
|
||||
let vhigh = cast (x >>! (mk_i32 16)) <: i16 in
|
||||
vhigh -. k_times_modulus
|
||||
|
||||
val lemma_at_percent_mod (v:int) (p:int{p>0/\ p%2=0}):
|
||||
Lemma ((v @% p) % p == v % p)
|
||||
|
||||
val lemma_div_at_percent (v:int) (p:int{p>0/\ p%2=0 /\ (v/p) < p/2 /\ (v/p) >= -p / 2}):
|
||||
Lemma ((v / p) @% p == v / p)
|
||||
|
||||
val lemma_mont_red_i32 (x:i32): Lemma
|
||||
(requires (is_i32b (3328 * pow2 16) x))
|
||||
(ensures (
|
||||
let result:i16 = mont_red_i32 x in
|
||||
is_i16b (3328 + 1665) result /\
|
||||
(is_i32b (3328 * pow2 15) x ==> is_i16b 3328 result) /\
|
||||
v result % 3329 == (v x * 169) % 3329))
|
||||
|
||||
val lemma_mont_mul_red_i16_int (x y:i16): Lemma
|
||||
(requires (is_intb (3326 * pow2 15) (v x * v y)))
|
||||
(ensures (
|
||||
let result:i16 = mont_mul_red_i16 x y in
|
||||
is_i16b 3328 result /\
|
||||
v result % 3329 == (v x * v y * 169) % 3329))
|
||||
|
||||
val lemma_mont_mul_red_i16 (x y:i16): Lemma
|
||||
(requires (is_i16b 1664 y \/ is_intb (3326 * pow2 15) (v x * v y)))
|
||||
(ensures (
|
||||
let result:i16 = mont_mul_red_i16 x y in
|
||||
is_i16b 3328 result /\
|
||||
v result % 3329 == (v x * v y * 169) % 3329))
|
||||
[SMTPat (mont_mul_red_i16 x y)]
|
||||
|
||||
let barrett_red (x:i16) =
|
||||
let t1 = cast (((cast x <: i32) *. (cast (mk_i16 20159) <: i32)) >>! (mk_i32 16)) <: i16 in
|
||||
let t2 = t1 +. (mk_i16 512) in
|
||||
let q = t2 >>! (mk_i32 10) in
|
||||
let qm = q *. (mk_i16 3329) in
|
||||
x -. qm
|
||||
|
||||
val lemma_barrett_red (x:i16) : Lemma
|
||||
(requires (is_i16b 28296 x))
|
||||
(ensures (let result = barrett_red x in
|
||||
is_i16b 3328 result /\
|
||||
v result % 3329 == v x % 3329))
|
||||
[SMTPat (barrett_red x)]
|
||||
|
||||
let cond_sub (x:i16) =
|
||||
let xm = x -. (mk_i16 3329) in
|
||||
let mask = xm >>! (mk_i32 15) in
|
||||
let mm = mask &. (mk_i16 3329) in
|
||||
xm +. mm
|
||||
|
||||
val lemma_cond_sub x:
|
||||
Lemma (let r = cond_sub x in
|
||||
if x >=. (mk_i16 3329) then r == x -! (mk_i16 3329) else r == x)
|
||||
[SMTPat (cond_sub x)]
|
||||
|
||||
val lemma_shift_right_15_i16 (x:i16):
|
||||
Lemma (if v x >= 0 then (x >>! (mk_i32 15)) == mk_i16 0 else (x >>! (mk_i32 15)) == (mk_i16 (-1)))
|
||||
|
||||
let ntt_spec #len (vec_in: t_Array i16 len) (zeta: int) (i: nat{i < v len}) (j: nat{j < v len})
|
||||
(vec_out: t_Array i16 len) : Type0 =
|
||||
((v (Seq.index vec_out i) % 3329) ==
|
||||
((v (Seq.index vec_in i) + (v (Seq.index vec_in j) * zeta * 169)) % 3329)) /\
|
||||
((v (Seq.index vec_out j) % 3329) ==
|
||||
((v (Seq.index vec_in i) - (v (Seq.index vec_in j) * zeta * 169)) % 3329))
|
||||
|
||||
let inv_ntt_spec #len (vec_in: t_Array i16 len) (zeta: int) (i: nat{i < v len}) (j: nat{j < v len})
|
||||
(vec_out: t_Array i16 len) : Type0 =
|
||||
((v (Seq.index vec_out i) % 3329) ==
|
||||
((v (Seq.index vec_in j) + v (Seq.index vec_in i)) % 3329)) /\
|
||||
((v (Seq.index vec_out j) % 3329) ==
|
||||
(((v (Seq.index vec_in j) - v (Seq.index vec_in i)) * zeta * 169) % 3329))
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# ProVerif model for SPQR
|
||||
|
||||
This folder contains a ProVerif model for the SPQR protocol.
|
||||
@@ -0,0 +1,44 @@
|
||||
(* Minimal generic crypto library *)
|
||||
|
||||
free c: channel.
|
||||
event Reachable.
|
||||
type principal.
|
||||
|
||||
|
||||
type symkey.
|
||||
fun aead_enc(symkey,bitstring,bitstring): bitstring.
|
||||
fun aead_dec(symkey,bitstring,bitstring): bitstring
|
||||
reduc forall k:symkey, m:bitstring, ad:bitstring;
|
||||
aead_dec(k, aead_enc(k,m,ad), ad) = m.
|
||||
|
||||
type seed.
|
||||
type enckey.
|
||||
type deckey.
|
||||
type ctsecret.
|
||||
fun dk2seed(deckey): seed.
|
||||
fun dk2enckey(deckey): enckey.
|
||||
fun pkenc1(ctsecret, seed, symkey): bitstring.
|
||||
fun pkenc2(ctsecret, enckey): bitstring.
|
||||
fun pkdec(deckey, bitstring, bitstring): symkey
|
||||
reduc forall dk:deckey, sk:symkey, r: ctsecret;
|
||||
pkdec(dk, pkenc1(r, dk2seed(dk), sk), pkenc2(r, dk2enckey(dk))) = sk.
|
||||
|
||||
fun extractsecret(ctsecret, bitstring): symkey
|
||||
reduc forall sk: symkey, s: seed, r: ctsecret;
|
||||
extractsecret(r, pkenc1(r, s, sk)) = sk.
|
||||
|
||||
letfun kem_keygen() =
|
||||
new dk: deckey;
|
||||
(dk, dk2seed(dk), dk2enckey(dk)).
|
||||
|
||||
letfun kem_decap(dk: deckey, ct1: bitstring, ct2: bitstring) =
|
||||
pkdec(dk, ct1, ct2).
|
||||
|
||||
type authenticator.
|
||||
fun mac(authenticator, bitstring): bitstring.
|
||||
fun auth_update(authenticator, symkey): authenticator.
|
||||
|
||||
(* hash function *)
|
||||
fun h(bitstring): bitstring.
|
||||
|
||||
fun kdf(symkey, bitstring): symkey.
|
||||
@@ -0,0 +1,377 @@
|
||||
(* Protocol-specific crypto *)
|
||||
|
||||
free ct_label: bitstring.
|
||||
free hdr_label: bitstring.
|
||||
letfun mac_ct(auth: authenticator, ct1: bitstring, ct2: bitstring) =
|
||||
mac(auth, (ct_label, ct1, ct2)).
|
||||
letfun mac_header(auth: authenticator, ep: nat, ekseed: seed, ek_hash: bitstring) =
|
||||
mac(auth, (hdr_label, ep, ekseed, ek_hash)).
|
||||
|
||||
free cka_label: bitstring.
|
||||
|
||||
(* Protocol Data structures *)
|
||||
|
||||
type opt_symkey.
|
||||
fun SK_None(): opt_symkey [data].
|
||||
fun SK(symkey): opt_symkey [data].
|
||||
|
||||
type opt_mac.
|
||||
fun MAC_None(): opt_mac [data].
|
||||
fun MAC(bitstring): opt_mac [data].
|
||||
|
||||
type opt_keypair.
|
||||
fun KP_None(): opt_keypair [data].
|
||||
fun KP(deckey, seed, enckey): opt_keypair [data].
|
||||
|
||||
(* Requestor/EK Generator States *)
|
||||
type eksender.
|
||||
fun NeedToSample(nat): eksender [data].
|
||||
fun SentHeader(nat, deckey, seed, enckey): eksender [data].
|
||||
fun ReceivedCt1(nat, deckey, seed, enckey, bitstring): eksender [data].
|
||||
fun SentEk(nat, deckey, seed, enckey): eksender [data].
|
||||
fun SentEkReceivedCt1(nat, deckey, seed, enckey, bitstring): eksender [data].
|
||||
|
||||
(* Responder/CT Generator States *)
|
||||
type ctsender.
|
||||
fun Waiting(nat): ctsender [data].
|
||||
fun ReceivedHeader(nat, seed, bitstring): ctsender [data].
|
||||
fun SentCt1(nat, ctsecret, seed, bitstring, bitstring, symkey): ctsender [data].
|
||||
fun SentCt1ReceivedEk(nat, ctsecret, seed, enckey, bitstring, symkey): ctsender [data].
|
||||
fun SentCt2(nat, symkey): ctsender [data].
|
||||
|
||||
reduc forall ep: nat; RequestorEpoch(NeedToSample(ep)) = ep;
|
||||
forall ep: nat, dk: deckey, ekseed: seed, ek: enckey; RequestorEpoch(SentHeader(ep, dk, ekseed, ek)) = ep;
|
||||
forall ep: nat, dk: deckey, ekseed: seed, ek: enckey, ct1: bitstring; RequestorEpoch(ReceivedCt1(ep, dk, ekseed, ek, ct1)) = ep;
|
||||
forall ep: nat, dk: deckey, ekseed: seed, ek: enckey; RequestorEpoch(SentEk(ep, dk, ekseed, ek)) = ep;
|
||||
forall ep: nat, dk: deckey, ekseed: seed, ek: enckey, ct1: bitstring; RequestorEpoch(SentEkReceivedCt1(ep, dk, ekseed, ek, ct1)) = ep
|
||||
.
|
||||
|
||||
(* Requestor/EK Generator Functions *)
|
||||
|
||||
letfun sendHeader(req: eksender, auth: authenticator) =
|
||||
let NeedToSample(ep) = req in
|
||||
let (dk: deckey, ekseed: seed, ek: enckey) = kem_keygen() in
|
||||
let ek_hash = h((ekseed, ek)) in
|
||||
let header_mac = mac_header(auth, ep, ekseed, ek_hash) in
|
||||
(SentHeader(ep, dk, ekseed, ek), (ekseed, ek_hash, header_mac))
|
||||
.
|
||||
|
||||
letfun sendEK(req: eksender, auth: authenticator) =
|
||||
let SentHeader(ep, dk, ekseed, ek) = req in
|
||||
(SentEk(ep, dk, ekseed, ek), ek)
|
||||
else let ReceivedCt1(ep, dk, ekseed, ek, ct1) = req in
|
||||
(SentEkReceivedCt1(ep, dk, ekseed, ek, ct1), ek)
|
||||
.
|
||||
|
||||
letfun recvCT1(req: eksender, ct1: bitstring) =
|
||||
let SentEk(ep, dk, ekseed, ek) = req in
|
||||
SentEkReceivedCt1(ep, dk, ekseed, ek, ct1)
|
||||
else let SentHeader(ep, dk, ekseed, ek) = req in
|
||||
ReceivedCt1(ep, dk, ekseed, ek, ct1)
|
||||
.
|
||||
|
||||
letfun recvCT2(req: eksender, auth: authenticator, ct2: bitstring, ct_mac: bitstring) =
|
||||
let SentEkReceivedCt1(ep, dk, ekseed, ek, ct1) = req in
|
||||
let ss = kem_decap(dk, ct1, ct2) in
|
||||
let k = kdf(ss, (h((ekseed,ek)), ep, cka_label)) in
|
||||
let new_auth = auth_update(auth, k) in
|
||||
if mac_ct(new_auth, ct1, ct2) = ct_mac then
|
||||
(Waiting(ep+1), (new_auth, ep, k))
|
||||
.
|
||||
|
||||
reduc forall ep: nat; ResponderEpoch(Waiting(ep)) = ep;
|
||||
forall ep: nat, ekseed: seed, ek_hash: bitstring; ResponderEpoch(ReceivedHeader(ep, ekseed, ek_hash)) = ep;
|
||||
forall ep: nat, r: ctsecret, ekseed: seed, ek_hash: bitstring, ct1: bitstring, k: symkey; ResponderEpoch(SentCt1(ep, r, ekseed, ek_hash, ct1, k)) = ep;
|
||||
forall ep: nat, r: ctsecret, ekseed: seed, ek: enckey, ct1: bitstring, k: symkey; ResponderEpoch(SentCt1ReceivedEk(ep, r, ekseed, ek, ct1, k)) = ep;
|
||||
forall ep: nat, k: symkey; ResponderEpoch(SentCt2(ep, k)) = ep
|
||||
.
|
||||
|
||||
letfun recvHeader(rsp: ctsender, auth: authenticator, ekseed: seed, ek_hash: bitstring, header_mac: bitstring) =
|
||||
let Waiting(ep) = rsp in
|
||||
if mac_header(auth, ep, ekseed, ek_hash) = header_mac then
|
||||
ReceivedHeader(ep, ekseed, ek_hash)
|
||||
.
|
||||
|
||||
letfun sendCT1(rsp: ctsender, auth: authenticator) =
|
||||
let ReceivedHeader(ep, ekseed, ek_hash) = rsp in
|
||||
new r: ctsecret;
|
||||
new sk: symkey;
|
||||
let ct1 = pkenc1(r, ekseed, sk) in
|
||||
let k = kdf(sk, (ek_hash, ep, cka_label)) in
|
||||
let new_auth = auth_update(auth, k) in
|
||||
(SentCt1(ep, r, ekseed, ek_hash, ct1, k), (new_auth, ct1))
|
||||
.
|
||||
|
||||
(* we can probably get rid of SentCt1ReceivedEk and go straight to SentCt2 here *)
|
||||
letfun recvEK(rsp: ctsender, auth: authenticator, ek: enckey) =
|
||||
let SentCt1(ep, r, ekseed, ek_hash, ct1, k) = rsp in
|
||||
if ek_hash = h((ekseed, ek)) then
|
||||
SentCt1ReceivedEk(ep, r, ekseed, ek, ct1, k)
|
||||
.
|
||||
|
||||
letfun sendCT2(rsp: ctsender, auth: authenticator) =
|
||||
let SentCt1ReceivedEk(ep, r, ekseed, ek, ct1, k) = rsp in
|
||||
let ct2: bitstring = pkenc2(r, ek) in
|
||||
let ct_mac = mac_ct(auth, ct1, ct2) in
|
||||
(SentCt2(ep, k), (ct2, ct_mac))
|
||||
.
|
||||
|
||||
letfun takeResponderKey(rsp: ctsender) =
|
||||
let SentCt2(ep, k) = rsp in
|
||||
(NeedToSample(ep+1), (ep,k))
|
||||
.
|
||||
|
||||
(* Main processes *)
|
||||
|
||||
free A: principal.
|
||||
free B: principal.
|
||||
|
||||
table AStates(principal, principal, eksender, authenticator).
|
||||
table BStates(principal, principal, ctsender, authenticator).
|
||||
|
||||
event StartedA(principal, principal, nat, seed).
|
||||
event CompletedA(principal, principal, nat, symkey).
|
||||
|
||||
event StartedB(principal, principal, nat, seed).
|
||||
event CompletedB(principal, principal, nat, symkey).
|
||||
|
||||
letfun max_epoch() = 5.
|
||||
|
||||
let SendEk0() =
|
||||
get AStates(a, b, req, auth) in
|
||||
let (req': eksender, (ekseed: seed, ek_hash: bitstring, header_mac: bitstring)) = sendHeader(req, auth) in
|
||||
let ep = RequestorEpoch(req') in
|
||||
event StartedA(a, b, ep, ekseed);
|
||||
out(c, (ekseed, ek_hash, header_mac));
|
||||
insert AStates(a, b, req', auth).
|
||||
|
||||
let SendEk1a() =
|
||||
get AStates(a, b, req, auth) in
|
||||
in (c, ct1: bitstring);
|
||||
let req' = recvCT1(req, ct1) in
|
||||
insert AStates(a, b, req', auth)
|
||||
.
|
||||
|
||||
let SendEk1b() =
|
||||
get AStates(a, b, req, auth) in
|
||||
let (req': eksender, ek: enckey) = sendEK(req, auth) in
|
||||
out(c, ek);
|
||||
insert AStates(a, b, req', auth)
|
||||
.
|
||||
|
||||
let SendEk2() =
|
||||
get AStates(a, b, req, auth) in
|
||||
in (c, (ct2: bitstring, ct_mac: bitstring));
|
||||
let (req': ctsender,
|
||||
(new_auth: authenticator,
|
||||
ep: nat,
|
||||
k: symkey)) = recvCT2(req, auth, ct2, ct_mac) in
|
||||
event CompletedA(a, b, ep, k);
|
||||
if ep < max_epoch() then insert BStates(a, b, req', new_auth).
|
||||
|
||||
let SendEkProc() =
|
||||
SendEk0() | SendEk1a() | SendEk1b() | SendEk2()
|
||||
.
|
||||
|
||||
let SendCt0() =
|
||||
get BStates(b, a, rsp, auth) in
|
||||
let ep = ResponderEpoch(rsp) in
|
||||
in(c, (ekseed: seed, ek_hash: bitstring, header_mac: bitstring));
|
||||
event StartedB(b, a, ep, ekseed);
|
||||
let rsp' = recvHeader(rsp, auth, ekseed, ek_hash, header_mac) in
|
||||
insert BStates(b, a, rsp', auth)
|
||||
.
|
||||
|
||||
let SendCt1() =
|
||||
get BStates(b, a, rsp, auth) in
|
||||
let (rsp': ctsender, (new_auth: authenticator, ct1: bitstring)) = sendCT1(rsp, auth) in
|
||||
out (c, ct1);
|
||||
insert BStates(b, a, rsp', new_auth)
|
||||
.
|
||||
|
||||
let SendCt2() =
|
||||
get BStates(b, a, rsp, auth) in
|
||||
in(c, ek: enckey);
|
||||
let rsp': ctsender = recvEK(rsp, auth, ek) in
|
||||
insert BStates(b, a, rsp', auth)
|
||||
.
|
||||
|
||||
let SendCt3() =
|
||||
get BStates(b, a, rsp, auth) in
|
||||
let (rsp': ctsender, (ct2: bitstring, ct_mac: bitstring)) = sendCT2(rsp, auth) in
|
||||
out(c, (ct2, ct_mac));
|
||||
let (rsp'': eksender, (ep: nat, k: symkey)) = takeResponderKey(rsp') in
|
||||
event CompletedB(b, a, ep, k);
|
||||
if ep < max_epoch() then insert AStates(b, a, rsp'', auth)
|
||||
.
|
||||
|
||||
let SendCtProc() =
|
||||
SendCt0() | SendCt1() | SendCt2() | SendCt3()
|
||||
.
|
||||
|
||||
(* Compromise Scenarions *)
|
||||
event CompromisedKeysA(principal, principal, nat).
|
||||
let CompromiseKeysA(a: principal, b:principal, ep:nat) =
|
||||
(get AStates(=a, =b, req, auth) in
|
||||
let SentHeader(=ep, dk, ekseed, ek) = req in
|
||||
event CompromisedKeysA(a,b,ep);
|
||||
out(c,dk)
|
||||
else let ReceivedCt1(=ep, dk, ekseed, ek, ct1) = req in
|
||||
event CompromisedKeysA(a,b,ep);
|
||||
out(c,dk)
|
||||
else let SentEk(=ep, dk, ekseed, ek) = req in
|
||||
event CompromisedKeysA(a,b,ep);
|
||||
out(c,dk)
|
||||
else let SentEkReceivedCt1(=ep, dk, ekseed, ek, ct1) = req in
|
||||
event CompromisedKeysA(a,b,ep);
|
||||
out(c,dk))
|
||||
.
|
||||
|
||||
event CompromisedAuthA(principal, principal, nat).
|
||||
let CompromiseAuthA(a: principal, b:principal, ep:nat) =
|
||||
(get AStates(=a, =b, req, auth) in
|
||||
if ep = RequestorEpoch(req) then (
|
||||
event CompromisedAuthA(a,b,ep);
|
||||
out(c,auth)))
|
||||
.
|
||||
|
||||
event CompromisedKeysB(principal, principal, nat).
|
||||
let CompromiseKeysB(a: principal, b:principal, ep:nat) =
|
||||
(get BStates(=a, =b, rsp, auth) in
|
||||
let SentCt1(=ep, r, ekseed, ek_hash, ct1, k) = rsp in
|
||||
event CompromisedKeysB(a,b,ep);
|
||||
out(c,(r,k))
|
||||
else let SentCt1ReceivedEk(=ep, r, ekseed, ek, ct1, k) = rsp in
|
||||
event CompromisedKeysB(a,b,ep);
|
||||
out(c,(r,k))
|
||||
else let SentCt2(=ep, k) = rsp in
|
||||
event CompromisedKeysB(a,b,ep);
|
||||
out(c,k))
|
||||
.
|
||||
|
||||
event CompromisedAuthB(principal, principal, nat).
|
||||
let CompromiseAuthB(a: principal, b: principal, ep: nat) =
|
||||
(get BStates(=a, =b, rsp, auth) in
|
||||
if ep = ResponderEpoch(rsp) then (
|
||||
event CompromisedAuthB(a,b,ep);
|
||||
out(c,auth)))
|
||||
.
|
||||
|
||||
(* Security Queries *)
|
||||
|
||||
(* Reachability Queries *)
|
||||
|
||||
query ep:nat, ek:seed;
|
||||
event(StartedA(A,B,4,ek));
|
||||
event(StartedB(B,A,4,ek))
|
||||
.
|
||||
|
||||
query ep:nat, sk:symkey;
|
||||
event(CompletedA(A,B,4,sk));
|
||||
event(CompletedB(B,A,4,sk))
|
||||
.
|
||||
|
||||
query ep:nat, ek:seed;
|
||||
event(StartedA(B,A,3,ek));
|
||||
event(StartedB(A,B,3,ek))
|
||||
.
|
||||
|
||||
query ep:nat, sk:symkey;
|
||||
event(CompletedA(B,A,3,sk));
|
||||
event(CompletedB(A,B,3,sk))
|
||||
.
|
||||
|
||||
(* Confidentiality Queries *)
|
||||
|
||||
query i: time, j: time, ep:nat, sk:symkey, ep_:nat, x:principal, y:principal;
|
||||
event(CompletedA(A,B,0,sk)) && attacker(sk);
|
||||
event(CompletedB(B,A,0,sk)) && attacker(sk);
|
||||
event(CompletedA(B,A,1,sk)) && attacker(sk);
|
||||
event(CompletedB(A,B,1,sk)) && attacker(sk);
|
||||
event(CompletedA(A,B,2,sk)) && attacker(sk);
|
||||
event(CompletedB(B,A,2,sk)) && attacker(sk);
|
||||
event(CompletedA(B,A,3,sk)) && attacker(sk);
|
||||
event(CompletedB(A,B,3,sk)) && attacker(sk);
|
||||
|
||||
event(CompletedA(x,y,ep,sk)) && attacker(sk) ==>
|
||||
event(CompromisedKeysB(y,x,ep));
|
||||
event(CompletedA(x,y,ep,sk)) && attacker(sk) ==>
|
||||
event(CompromisedKeysA(x,y,ep));
|
||||
event(CompletedB(x,y,ep,sk)) && attacker(sk) ==>
|
||||
event(CompromisedKeysB(x,y,ep));
|
||||
event(CompletedB(x,y,ep,sk)) && attacker(sk) ==>
|
||||
event(CompromisedKeysA(y,x,ep));
|
||||
|
||||
event(CompletedA(x,y,ep,sk)) && attacker(sk) ==>
|
||||
(event(CompromisedKeysA(x,y,ep)) || event(CompromisedKeysB(y,x,ep)));
|
||||
event(CompletedB(x,y,ep,sk)) && attacker(sk) ==>
|
||||
(event(CompromisedKeysB(x,y,ep)) || event(CompromisedKeysA(y,x,ep)));
|
||||
|
||||
(* An epoch key can be known to the attacker if either the states in that
|
||||
epoch were compromised, or the MAC key or some prior epoch was compromised.
|
||||
Compromising later keys has no effect. This encodes Forward Secrecy. *)
|
||||
(* Furthermore, since we compromise all authentication keys in phase 1,
|
||||
this also encodes post-compromise security *)
|
||||
|
||||
|
||||
event(CompletedA(x,y,ep,sk))@i && attacker(sk) ==>
|
||||
(event(CompromisedKeysA(x,y,ep)) || event(CompromisedKeysB(y,x,ep)) ||
|
||||
(ep_ <= ep && event(CompromisedAuthA(y,x,ep_))@j && j < i) ||
|
||||
(ep_ <= ep && event(CompromisedAuthA(x,y,ep_))@j && j < i) ||
|
||||
(ep_ <= ep && event(CompromisedAuthB(x,y,ep_))@j && j < i) ||
|
||||
(ep_ <= ep && event(CompromisedAuthB(y,x,ep_))@j && j < i));
|
||||
event(CompletedB(x,y,ep,sk))@i && attacker(sk) ==>
|
||||
(event(CompromisedKeysB(x,y,ep)) || event(CompromisedKeysA(y,x,ep)) ||
|
||||
(ep_ <= ep && event(CompromisedAuthA(x,y,ep_))@j && j < i
|
||||
(* && event(CompletedA(A,B,ep-1,sk')) && attacker(sk') *)) ||
|
||||
(ep_ <= ep && event(CompromisedAuthA(y,x,ep_))@j && j < i
|
||||
(* && event(CompletedA(A,B,ep-1,sk')) && attacker(sk') *)) ||
|
||||
(ep_ <= ep && event(CompromisedAuthB(x,y,ep_))@j && j < i)||
|
||||
(ep_ <= ep && event(CompromisedAuthB(y,x,ep_))@j && j < i))
|
||||
|
||||
.
|
||||
|
||||
(* Authentication Queries *)
|
||||
|
||||
|
||||
query x: principal, y: principal, ep, ep_:nat, ek:seed, sk:symkey;
|
||||
event(CompletedB(y,x,ep,sk)) ==> event(StartedA(x,y,ep,ek));
|
||||
event(CompletedB(y,x,ep,sk)) ==>
|
||||
(event(StartedA(x,y,ep,ek)) ||
|
||||
(ep_ <= ep && (event(CompromisedAuthA(x,y,ep_)) || event(CompromisedAuthA(y,x,ep_))
|
||||
|| event(CompromisedAuthB(y,x,ep_)) || event(CompromisedAuthB(x,y,ep_)))));
|
||||
event(CompletedA(x,y,ep,sk)) ==> event(StartedB(y,x,ep,ek));
|
||||
event(CompletedA(x,y,ep,sk)) ==>
|
||||
(event(StartedB(y,x,ep,ek)) ||
|
||||
(ep_ <= ep && (event(CompromisedAuthA(x,y,ep_)) || event(CompromisedAuthA(y,x,ep_))
|
||||
|| event(CompromisedAuthB(y,x,ep_)) || event(CompromisedAuthB(x,y,ep_)))))
|
||||
.
|
||||
|
||||
process
|
||||
new authAB: authenticator;
|
||||
insert AStates(A, B, NeedToSample(0), authAB);
|
||||
insert BStates(B, A, Waiting(0), authAB);
|
||||
(!SendEkProc() | !SendCtProc() |
|
||||
(* Compromise Scenarios: comment out different options below to experiment *)
|
||||
|
||||
(* Compromise Private Keys *)
|
||||
|
||||
CompromiseKeysA(A,B,0) | (* CompromiseKeysB(B,A,0) |
|
||||
CompromiseKeysA(B,A,1) | CompromiseKeysB(A,B,1) |
|
||||
CompromiseKeysA(A,B,2) | *) CompromiseKeysB(B,A,2) |
|
||||
(* CompromiseKeysA(B,A,3) | CompromiseKeysB(A,B,3) |
|
||||
CompromiseKeysA(B,A,4) | CompromiseKeysB(A,B,4) | *)
|
||||
|
||||
|
||||
(* Compromise MAC Keys *)
|
||||
|
||||
(* CompromiseAuthA(A,B,0) | CompromiseAuthB(B,A,0) |
|
||||
CompromiseAuthA(B,A,1) | CompromiseAuthB(A,B,1) |
|
||||
CompromiseAuthA(A,B,2) | CompromiseAuthB(B,A,2) |
|
||||
CompromiseAuthA(B,A,3) | CompromiseAuthB(A,B,3) |
|
||||
CompromiseAuthA(B,A,4) |*) CompromiseAuthB(A,B,4) |
|
||||
|
||||
(* Post-Compromise Secrecy: Passively Compromise MAC Keys *after* all epochs are done *)
|
||||
(phase 1; (out(c,authAB) |
|
||||
(in (c,(x:principal, y:principal, ep:nat));
|
||||
(CompromiseAuthA(x,y,ep) | CompromiseAuthB(x,y,ep))))))
|
||||
@@ -0,0 +1,162 @@
|
||||
type dir.
|
||||
free a2b:dir.
|
||||
free b2a:dir.
|
||||
|
||||
table SharedKeys(principal, principal, dir, nat, symkey). (* a,b,dir,epoch,k: if dir is a2b then a as initiator esablished k at epoch ep with b using SPQR *)
|
||||
table RootKeys(principal, principal, dir, nat, symkey). (* a <-> b: dir, epoch, rk *)
|
||||
table ChainKeys(principal, principal, dir, nat, nat, symkey). (* a <-> b: dir, epoch, ctr, ck *)
|
||||
table MsgKeys(principal, principal, dir, nat, nat, symkey). (* a <-> b: dir, epoch, ctr, mk *)
|
||||
|
||||
letfun max_epoch() = 3.
|
||||
letfun max_ctr() = 3.
|
||||
|
||||
free root_key_label: bitstring.
|
||||
free send_chain_key_label: bitstring.
|
||||
free recv_chain_key_label: bitstring.
|
||||
|
||||
event CompromisedSharedKey(principal, principal, dir, nat).
|
||||
|
||||
let CKA_Key0(a:principal, b:principal) =
|
||||
(new k:symkey;
|
||||
insert SharedKeys(a, b, a2b, 0, k);
|
||||
insert SharedKeys(b, a, b2a, 0, k))
|
||||
(* We should allow attacker to choose 2 different keys *)
|
||||
| (in (c, k:symkey);
|
||||
event CompromisedSharedKey(a, b, a2b, 0);
|
||||
insert SharedKeys(a, b, a2b, 0, k);
|
||||
insert SharedKeys(b, a, b2a, 0, k)).
|
||||
|
||||
let CKA_KeyN(a:principal, b:principal) =
|
||||
get SharedKeys(=a, =b, =a2b, ep, oldk) in
|
||||
if ep+1 <= max_epoch() then (
|
||||
(new k:symkey;
|
||||
insert SharedKeys(a, b, a2b, ep+1, k);
|
||||
insert SharedKeys(b, a, b2a, ep+1, k))
|
||||
(* We should allow attacker to choose 2 different keys *)
|
||||
| (in (c, k:symkey);
|
||||
event CompromisedSharedKey(a, b, a2b, ep+1);
|
||||
insert SharedKeys(a, b, a2b, ep+1, k);
|
||||
insert SharedKeys(b, a, b2a, ep+1, k))).
|
||||
|
||||
|
||||
event RootKey(principal, principal, dir, nat, symkey).
|
||||
|
||||
letfun SR_InitState(a:principal, b:principal, d:dir) =
|
||||
get SharedKeys(=a, =b, =d, 0, k) in
|
||||
let rk = kdf(k, root_key_label) in
|
||||
let cks = kdf(k, send_chain_key_label) in
|
||||
let ckr = kdf(k, recv_chain_key_label) in
|
||||
event RootKey(a, b, d, 0, rk);
|
||||
insert RootKeys(a, b, d, 0, rk);
|
||||
if d = a2b then (
|
||||
insert ChainKeys(a, b, a2b, 0, 0, cks);
|
||||
insert ChainKeys(a, b, b2a, 0, 0, ckr);
|
||||
0)
|
||||
else (
|
||||
insert ChainKeys(a, b, a2b, 0, 0, ckr);
|
||||
insert ChainKeys(a, b, b2a, 0, 0, cks);
|
||||
0).
|
||||
|
||||
letfun SR_NextEpoch(a:principal, b:principal, ep_:nat) =
|
||||
get RootKeys(=a, =b, d, ep, rk) in
|
||||
get SharedKeys(=a, =b, =d, key_epoch, k) in
|
||||
if ep + 1 = key_epoch && key_epoch <= max_epoch() then (
|
||||
let nrk = kdf(rk, (k,root_key_label)) in
|
||||
let cks = kdf(rk, (k,send_chain_key_label)) in
|
||||
let ckr = kdf(rk, (k,recv_chain_key_label)) in
|
||||
event RootKey(a, b, d, key_epoch, nrk);
|
||||
insert RootKeys(a, b, d, key_epoch, nrk);
|
||||
if d = a2b then (
|
||||
insert ChainKeys(a, b, a2b, key_epoch, 0, cks);
|
||||
insert ChainKeys(a, b, b2a, key_epoch, 0, ckr);
|
||||
0)
|
||||
else (
|
||||
insert ChainKeys(a, b, a2b, key_epoch, 0, ckr);
|
||||
insert ChainKeys(a, b, b2a, key_epoch, 0, cks);
|
||||
0))
|
||||
else 0.
|
||||
|
||||
free chain_key_ratchet_label: bitstring.
|
||||
free msg_key_label: bitstring.
|
||||
|
||||
event MsgKey(principal, principal, dir, nat, nat, symkey).
|
||||
|
||||
letfun SR_NextCtr(a:principal, b:principal, d:dir, key_epoch:nat, ctr:nat) =
|
||||
get ChainKeys(=a, =b, =d, =key_epoch, =ctr, ck) in
|
||||
if ctr + 1 <= max_ctr() then (
|
||||
let nck = kdf(ck, chain_key_ratchet_label) in
|
||||
let mk = kdf(ck, msg_key_label) in
|
||||
insert ChainKeys(a, b, d, key_epoch, ctr+1, nck);
|
||||
event MsgKey(a, b, d, key_epoch, ctr, mk);
|
||||
insert MsgKeys(a, b, d, key_epoch, ctr, mk);
|
||||
0)
|
||||
else 0.
|
||||
|
||||
let SR_Init(a:principal, b:principal, d:dir) =
|
||||
let r = SR_InitState(a, b, d) in
|
||||
0.
|
||||
|
||||
let SR_AddEpoch(a:principal, b:principal) =
|
||||
get RootKeys(=a, =b, d, ep, rk) in
|
||||
let r = SR_NextEpoch(a, b, ep) in
|
||||
0.
|
||||
|
||||
let SR_NextKey(a:principal, b:principal) =
|
||||
get ChainKeys(=a, =b, d, ep, ctr, ck) in
|
||||
let s0 = SR_NextCtr(a, b, d, ep, ctr) in
|
||||
0.
|
||||
|
||||
event CompromisedRootKey(principal, principal, dir, nat, symkey).
|
||||
event CompromisedChainKey(principal, principal, dir, nat, nat, symkey).
|
||||
|
||||
let CompromiseState(a:principal) =
|
||||
(get RootKeys(=a, b, d, ep, rk) in
|
||||
event CompromisedRootKey(a,b,d,ep,rk);
|
||||
out (c,rk))
|
||||
| (get ChainKeys(=a, b, d, ep, ctr, ck) in
|
||||
event CompromisedChainKey(a,b,d,ep,ctr,ck);
|
||||
out (c,ck)).
|
||||
|
||||
free A:principal.
|
||||
free B:principal.
|
||||
|
||||
(* Reachability Queries *)
|
||||
|
||||
query a:principal, b:principal, ep:nat, ctr:nat, k:symkey;
|
||||
event(MsgKey(a,b,a2b,0,0,k));
|
||||
event(MsgKey(a,b,b2a,0,0,k));
|
||||
event(MsgKey(a,b,a2b,2,2,k));
|
||||
event(MsgKey(a,b,b2a,2,2,k)).
|
||||
|
||||
(* Confidentiality Queries *)
|
||||
|
||||
query a:principal, b:principal, ep:nat, ctr:nat, k:symkey, kk:symkey, ep_:nat;
|
||||
event(MsgKey(a,b,a2b,0,0,k)) && attacker(k);
|
||||
event(MsgKey(a,b,b2a,0,0,k)) && attacker(k);
|
||||
|
||||
(* Confidentiality for first epoch *)
|
||||
(* Forward secrecy: Compromising later keys makes no difference *)
|
||||
event(MsgKey(a,b,a2b,0,0,k)) && attacker(k) ==>
|
||||
(event(CompromisedSharedKey(a,b,a2b,0)) ||
|
||||
event(CompromisedSharedKey(b,a,a2b,0)));
|
||||
|
||||
(* Confidentiality for first epoch *)
|
||||
(* Forward secrecy: Compromising later keys makes no difference *)
|
||||
(* Post-Compromise Security: Compromising earlier keys makes no difference *)
|
||||
event(MsgKey(a,b,a2b,ep+1,0,k)) && attacker(k) ==>
|
||||
(event(CompromisedSharedKey(a,b,a2b,ep+1)) ||
|
||||
event(CompromisedSharedKey(b,a,a2b,ep+1))).
|
||||
|
||||
process
|
||||
CKA_Key0(A,B) |
|
||||
!CKA_KeyN(A,B) |
|
||||
!SR_Init(A,B,a2b) |
|
||||
!SR_Init(B,A,b2a) |
|
||||
!SR_AddEpoch(A,B) |
|
||||
!SR_AddEpoch(B,A) |
|
||||
!SR_NextKey(A,B) |
|
||||
!SR_NextKey(B,A) (* |
|
||||
!CompromiseState(A) |
|
||||
!CompromiseState(B) *)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user