Skip to content

Commit

Permalink
[go] Widen the carry type to 64 bits artifically
Browse files Browse the repository at this point in the history
For performance reasons.  Note that this is unsound, but having the
carry type be 8 bits rather than 1 bit was already unsound, and this is
no more unsound.  The narrowness of the carry type is not used in
practice in the code, though we should still someday include it in the
proofs.
  • Loading branch information
JasonGross committed Aug 7, 2021
1 parent 26735f9 commit 464ebb0
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 33 deletions.
4 changes: 2 additions & 2 deletions fiat-go/32/curve25519/curve25519.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/32/p224/p224.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/32/p256/p256.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/32/p384/p384.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/32/poly1305/poly1305.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/32/secp256k1/secp256k1.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/64/curve25519/curve25519.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/64/p224/p224.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/64/p256/p256.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/64/p384/p384.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/64/p434/p434.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/64/p448solinas/p448solinas.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/64/p521/p521.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/64/poly1305/poly1305.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fiat-go/64/secp256k1/secp256k1.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/Stringification/Go.v
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ Module Go.
""]%string)
++ (if needs_bits_import then ["import ""math/bits"""; ""]%string else [])
++ (let typedefs
:= List.flat_map
:= let carry_bitwidth := 64 (* c.f. https://github.com/mit-plv/fiat-crypto/pull/1006#issuecomment-892625927 *) in
let carry_typedef_comment := (" // We use uint" ++ Decimal.Z.to_string carry_bitwidth ++ " instead of a more narrow type for performance reasons; see https://github.com/mit-plv/fiat-crypto/pull/1006#issuecomment-892625927")%string in
List.flat_map
(fun bw
=> (if IntSet.mem (int.of_bitwidth false bw) bitwidths_used || IntSet.mem (int.of_bitwidth true bw) bitwidths_used
then [type_prefix ++ int_type_to_string internal_private prefix (int.of_bitwidth false bw) ++ " uint8";
type_prefix ++ int_type_to_string internal_private prefix (int.of_bitwidth true bw) ++ " int8"]%string (* C: typedef signed challr prefix_int1 *)
then [type_prefix ++ int_type_to_string internal_private prefix (int.of_bitwidth false bw) ++ " uint" ++ Decimal.Z.to_string carry_bitwidth ++ carry_typedef_comment;
type_prefix ++ int_type_to_string internal_private prefix (int.of_bitwidth true bw) ++ " int" ++ Decimal.Z.to_string carry_bitwidth ++ carry_typedef_comment]%string
else []))
[1; 2] in
let typedefs :=
Expand Down

0 comments on commit 464ebb0

Please sign in to comment.