Skip to content

Add rotate_left and rotate_right operations to machine integers#4080

Open
remix7531 wants to merge 3 commits intoFStarLang:masterfrom
remix7531:add-rotate-operations
Open

Add rotate_left and rotate_right operations to machine integers#4080
remix7531 wants to merge 3 commits intoFStarLang:masterfrom
remix7531:add-rotate-operations

Conversation

@remix7531
Copy link

This adds the left and right rotation operations on machine integers which are used in many crypto algorithms. I added the trivial identity and inverse lemma.

  • Add rotate_left_vec and rotate_right_vec to FStar.BitVector with lemmas
  • Add rotate_left and rotate_right to FStar.UInt and FStar.Int with identity and inverse lemmas
  • Add bvrol and bvror to FStar.BV (SMT bitvector theory)
  • Update templates (.scripts/.fstip/.fstp) for code generation
  • Add OCaml extraction support in FStar_Ints.ml.body and FStar_UInt8.ml
  • Add tests in tests/machine_integers/TestRotate.fst

- Add rotate_left_vec and rotate_right_vec to FStar.BitVector with lemmas
- Add rotate_left and rotate_right to FStar.UInt and FStar.Int with identity and inverse lemmas
- Add bvrol and bvror to FStar.BV (SMT bitvector theory)
- Update templates (.scripts/*.fstip/*.fstp) for code generation
- Add OCaml extraction support in FStar_Ints.ml.body and FStar_UInt8.ml
- Add tests in tests/machine_integers/TestRotate.fst
@remix7531
Copy link
Author

@microsoft-github-policy-service agree

@mtzguido
Copy link
Member

Hi @remix7531, thank you for the PR! In general this looks good to me, and thank you for going through the (tricky) integer modules and making this work. I left a few comments with questions, but this mostly looks good to me.

Out of curiosity can you say where you want to use this?

@remix7531
Copy link
Author

remix7531 commented Jan 21, 2026

Hi @mtzguido . Thanks for your feedback! I will address it soon.

I am working on proofs for RustCrypo's SHA-2 (and others) using HAX and F*. I wrote a specification for SHA-2 in F* but the rotation operation is missing.

@remix7531 remix7531 requested a review from mtzguido January 27, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants