mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-21 21:47:32 +02:00
Merge pull request #2345 from Ryooooooga/fix-goroutine-leaks
This commit is contained in:
commit
1cf24a02d3
8
go.mod
8
go.mod
@ -11,14 +11,14 @@ require (
|
|||||||
github.com/creack/pty v1.1.11
|
github.com/creack/pty v1.1.11
|
||||||
github.com/fsmiamoto/git-todo-parser v0.0.2
|
github.com/fsmiamoto/git-todo-parser v0.0.2
|
||||||
github.com/fsnotify/fsnotify v1.4.7
|
github.com/fsnotify/fsnotify v1.4.7
|
||||||
github.com/gdamore/tcell/v2 v2.5.3
|
github.com/gdamore/tcell/v2 v2.5.4
|
||||||
github.com/go-errors/errors v1.4.2
|
github.com/go-errors/errors v1.4.2
|
||||||
github.com/gookit/color v1.4.2
|
github.com/gookit/color v1.4.2
|
||||||
github.com/imdario/mergo v0.3.11
|
github.com/imdario/mergo v0.3.11
|
||||||
github.com/integrii/flaggy v1.4.0
|
github.com/integrii/flaggy v1.4.0
|
||||||
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68
|
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68
|
||||||
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d
|
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d
|
||||||
github.com/jesseduffield/gocui v0.3.1-0.20221203233251-eeb9b3fb2494
|
github.com/jesseduffield/gocui v0.3.1-0.20230105224502-214a0df08da7
|
||||||
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10
|
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10
|
||||||
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5
|
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5
|
||||||
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e
|
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e
|
||||||
@ -65,9 +65,9 @@ require (
|
|||||||
github.com/rivo/uniseg v0.4.3 // indirect
|
github.com/rivo/uniseg v0.4.3 // indirect
|
||||||
github.com/sergi/go-diff v1.1.0 // indirect
|
github.com/sergi/go-diff v1.1.0 // indirect
|
||||||
github.com/xanzy/ssh-agent v0.2.1 // indirect
|
github.com/xanzy/ssh-agent v0.2.1 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 // indirect
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
|
||||||
golang.org/x/exp v0.0.0-20220318154914-8dddf5d87bd8 // indirect
|
golang.org/x/exp v0.0.0-20220318154914-8dddf5d87bd8 // indirect
|
||||||
golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c // indirect
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
|
||||||
golang.org/x/sys v0.3.0 // indirect
|
golang.org/x/sys v0.3.0 // indirect
|
||||||
golang.org/x/term v0.3.0 // indirect
|
golang.org/x/term v0.3.0 // indirect
|
||||||
golang.org/x/text v0.5.0 // indirect
|
golang.org/x/text v0.5.0 // indirect
|
||||||
|
35
go.sum
35
go.sum
@ -35,8 +35,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
|
|||||||
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
||||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||||
github.com/gdamore/tcell/v2 v2.4.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
|
github.com/gdamore/tcell/v2 v2.4.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
|
||||||
github.com/gdamore/tcell/v2 v2.5.3 h1:b9XQrT6QGbgI7JvZOJXFNczOQeIYbo8BfeSMzt2sAV0=
|
github.com/gdamore/tcell/v2 v2.5.4 h1:TGU4tSjD3sCL788vFNeJnTdzpNKIw1H5dgLnJRQVv/k=
|
||||||
github.com/gdamore/tcell/v2 v2.5.3/go.mod h1:wSkrPaXoiIWZqW/g7Px4xc79di6FTcpB8tvaKJ6uGBo=
|
github.com/gdamore/tcell/v2 v2.5.4/go.mod h1:dZgRy5v4iMobMEcWNYBtREnDZAT9DYmfqIkrgEMxLyw=
|
||||||
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
|
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
|
||||||
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||||
github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
|
github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
|
||||||
@ -72,8 +72,8 @@ github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68 h1:EQP2Tv8T
|
|||||||
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68/go.mod h1:+LLj9/WUPAP8LqCchs7P+7X0R98HiFujVFANdNaxhGk=
|
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68/go.mod h1:+LLj9/WUPAP8LqCchs7P+7X0R98HiFujVFANdNaxhGk=
|
||||||
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d h1:bO+OmbreIv91rCe8NmscRwhFSqkDJtzWCPV4Y+SQuXE=
|
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d h1:bO+OmbreIv91rCe8NmscRwhFSqkDJtzWCPV4Y+SQuXE=
|
||||||
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o=
|
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o=
|
||||||
github.com/jesseduffield/gocui v0.3.1-0.20221203233251-eeb9b3fb2494 h1:SH16ZF/+7S8ZyzDq+sXpOLULBs6lRo6bnYvuRAbhYbk=
|
github.com/jesseduffield/gocui v0.3.1-0.20230105224502-214a0df08da7 h1:a7T87NGCrmFhzWBWvaaPQppjbY9/w0Vl4hoB7RnFaug=
|
||||||
github.com/jesseduffield/gocui v0.3.1-0.20221203233251-eeb9b3fb2494/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU=
|
github.com/jesseduffield/gocui v0.3.1-0.20230105224502-214a0df08da7/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU=
|
||||||
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 h1:jmpr7KpX2+2GRiE91zTgfq49QvgiqB0nbmlwZ8UnOx0=
|
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 h1:jmpr7KpX2+2GRiE91zTgfq49QvgiqB0nbmlwZ8UnOx0=
|
||||||
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10/go.mod h1:aA97kHeNA+sj2Hbki0pvLslmE4CbDyhBeSSTUUnOuVo=
|
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10/go.mod h1:aA97kHeNA+sj2Hbki0pvLslmE4CbDyhBeSSTUUnOuVo=
|
||||||
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 h1:CDuQmfOjAtb1Gms6a1p5L2P8RhbLUq5t8aL7PiQd2uY=
|
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 h1:CDuQmfOjAtb1Gms6a1p5L2P8RhbLUq5t8aL7PiQd2uY=
|
||||||
@ -114,7 +114,6 @@ github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOA
|
|||||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||||
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
|
||||||
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
|
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
|
||||||
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
github.com/mgutz/str v1.2.0 h1:4IzWSdIz9qPQWLfKZ0rJcV0jcUDpxvP4JVZ4GXQyvSw=
|
github.com/mgutz/str v1.2.0 h1:4IzWSdIz9qPQWLfKZ0rJcV0jcUDpxvP4JVZ4GXQyvSw=
|
||||||
@ -171,20 +170,25 @@ github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70
|
|||||||
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
|
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
|
||||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
|
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
|
||||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
|
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
|
||||||
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
|
||||||
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 h1:hb9wdF1z5waM+dSIICn1l0DkLVDT3hqhhQsDNUmHPRE=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/exp v0.0.0-20220318154914-8dddf5d87bd8 h1:s/+U+w0teGzcoH2mdIlFQ6KfVKGaYpgyGdUefZrn9TU=
|
golang.org/x/exp v0.0.0-20220318154914-8dddf5d87bd8 h1:s/+U+w0teGzcoH2mdIlFQ6KfVKGaYpgyGdUefZrn9TU=
|
||||||
golang.org/x/exp v0.0.0-20220318154914-8dddf5d87bd8/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
|
golang.org/x/exp v0.0.0-20220318154914-8dddf5d87bd8/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c h1:dk0ukUIHmGHqASjP0iue2261isepFCC6XRCSd1nHgDw=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c/go.mod h1:iQL9McJNjoIa5mjH6nYTCTZXUN6RP+XW3eib7Ya3XcI=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20170407050850-f3918c30c5c2/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20170407050850-f3918c30c5c2/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
@ -194,23 +198,30 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220318055525-2edf467146b5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
||||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI=
|
golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI=
|
||||||
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
|
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
||||||
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -16,8 +17,10 @@ import (
|
|||||||
// This file is for the rendering of confirmation panels along with setting and handling associated
|
// This file is for the rendering of confirmation panels along with setting and handling associated
|
||||||
// keybindings.
|
// keybindings.
|
||||||
|
|
||||||
func (gui *Gui) wrappedConfirmationFunction(function func() error) func() error {
|
func (gui *Gui) wrappedConfirmationFunction(cancel context.CancelFunc, function func() error) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
|
cancel()
|
||||||
|
|
||||||
if err := gui.c.PopContext(); err != nil {
|
if err := gui.c.PopContext(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -32,8 +35,10 @@ func (gui *Gui) wrappedConfirmationFunction(function func() error) func() error
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) wrappedPromptConfirmationFunction(function func(string) error, getResponse func() string) func() error {
|
func (gui *Gui) wrappedPromptConfirmationFunction(cancel context.CancelFunc, function func(string) error, getResponse func() string) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
|
cancel()
|
||||||
|
|
||||||
if err := gui.c.PopContext(); err != nil {
|
if err := gui.c.PopContext(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -111,11 +116,12 @@ func (gui *Gui) getConfirmationPanelWidth() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) prepareConfirmationPanel(
|
func (gui *Gui) prepareConfirmationPanel(
|
||||||
|
ctx context.Context,
|
||||||
opts types.ConfirmOpts,
|
opts types.ConfirmOpts,
|
||||||
) error {
|
) error {
|
||||||
gui.Views.Confirmation.HasLoader = opts.HasLoader
|
gui.Views.Confirmation.HasLoader = opts.HasLoader
|
||||||
if opts.HasLoader {
|
if opts.HasLoader {
|
||||||
gui.g.StartTicking()
|
gui.g.StartTicking(ctx)
|
||||||
}
|
}
|
||||||
gui.Views.Confirmation.Title = opts.Title
|
gui.Views.Confirmation.Title = opts.Title
|
||||||
// for now we do not support wrapping in our editor
|
// for now we do not support wrapping in our editor
|
||||||
@ -145,16 +151,19 @@ func runeForMask(mask bool) rune {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) createPopupPanel(opts types.CreatePopupPanelOpts) error {
|
func (gui *Gui) createPopupPanel(ctx context.Context, opts types.CreatePopupPanelOpts) error {
|
||||||
gui.Mutexes.PopupMutex.Lock()
|
gui.Mutexes.PopupMutex.Lock()
|
||||||
defer gui.Mutexes.PopupMutex.Unlock()
|
defer gui.Mutexes.PopupMutex.Unlock()
|
||||||
|
|
||||||
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
|
|
||||||
// we don't allow interruptions of non-loader popups in case we get stuck somehow
|
// we don't allow interruptions of non-loader popups in case we get stuck somehow
|
||||||
// e.g. a credentials popup never gets its required user input so a process hangs
|
// e.g. a credentials popup never gets its required user input so a process hangs
|
||||||
// forever.
|
// forever.
|
||||||
// The proper solution is to have a queue of popup options
|
// The proper solution is to have a queue of popup options
|
||||||
if gui.State.CurrentPopupOpts != nil && !gui.State.CurrentPopupOpts.HasLoader {
|
if gui.State.CurrentPopupOpts != nil && !gui.State.CurrentPopupOpts.HasLoader {
|
||||||
gui.Log.Error("ignoring create popup panel because a popup panel is already open")
|
gui.Log.Error("ignoring create popup panel because a popup panel is already open")
|
||||||
|
cancel()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,6 +171,7 @@ func (gui *Gui) createPopupPanel(opts types.CreatePopupPanelOpts) error {
|
|||||||
gui.clearConfirmationViewKeyBindings()
|
gui.clearConfirmationViewKeyBindings()
|
||||||
|
|
||||||
err := gui.prepareConfirmationPanel(
|
err := gui.prepareConfirmationPanel(
|
||||||
|
ctx,
|
||||||
types.ConfirmOpts{
|
types.ConfirmOpts{
|
||||||
Title: opts.Title,
|
Title: opts.Title,
|
||||||
Prompt: opts.Prompt,
|
Prompt: opts.Prompt,
|
||||||
@ -171,6 +181,7 @@ func (gui *Gui) createPopupPanel(opts types.CreatePopupPanelOpts) error {
|
|||||||
Mask: opts.Mask,
|
Mask: opts.Mask,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
cancel()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
confirmationView := gui.Views.Confirmation
|
confirmationView := gui.Views.Confirmation
|
||||||
@ -185,11 +196,13 @@ func (gui *Gui) createPopupPanel(opts types.CreatePopupPanelOpts) error {
|
|||||||
confirmationView.RenderTextArea()
|
confirmationView.RenderTextArea()
|
||||||
} else {
|
} else {
|
||||||
if err := gui.renderString(confirmationView, style.AttrBold.Sprint(opts.Prompt)); err != nil {
|
if err := gui.renderString(confirmationView, style.AttrBold.Sprint(opts.Prompt)); err != nil {
|
||||||
|
cancel()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := gui.setKeyBindings(opts); err != nil {
|
if err := gui.setKeyBindings(cancel, opts); err != nil {
|
||||||
|
cancel()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +211,7 @@ func (gui *Gui) createPopupPanel(opts types.CreatePopupPanelOpts) error {
|
|||||||
return gui.c.PushContext(gui.State.Contexts.Confirmation)
|
return gui.c.PushContext(gui.State.Contexts.Confirmation)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) setKeyBindings(opts types.CreatePopupPanelOpts) error {
|
func (gui *Gui) setKeyBindings(cancel context.CancelFunc, opts types.CreatePopupPanelOpts) error {
|
||||||
actions := utils.ResolvePlaceholderString(
|
actions := utils.ResolvePlaceholderString(
|
||||||
gui.c.Tr.CloseConfirm,
|
gui.c.Tr.CloseConfirm,
|
||||||
map[string]string{
|
map[string]string{
|
||||||
@ -210,13 +223,14 @@ func (gui *Gui) setKeyBindings(opts types.CreatePopupPanelOpts) error {
|
|||||||
_ = gui.renderString(gui.Views.Options, actions)
|
_ = gui.renderString(gui.Views.Options, actions)
|
||||||
var onConfirm func() error
|
var onConfirm func() error
|
||||||
if opts.HandleConfirmPrompt != nil {
|
if opts.HandleConfirmPrompt != nil {
|
||||||
onConfirm = gui.wrappedPromptConfirmationFunction(opts.HandleConfirmPrompt, func() string { return gui.Views.Confirmation.TextArea.GetContent() })
|
onConfirm = gui.wrappedPromptConfirmationFunction(cancel, opts.HandleConfirmPrompt, func() string { return gui.Views.Confirmation.TextArea.GetContent() })
|
||||||
} else {
|
} else {
|
||||||
onConfirm = gui.wrappedConfirmationFunction(opts.HandleConfirm)
|
onConfirm = gui.wrappedConfirmationFunction(cancel, opts.HandleConfirm)
|
||||||
}
|
}
|
||||||
|
|
||||||
keybindingConfig := gui.c.UserConfig.Keybinding
|
keybindingConfig := gui.c.UserConfig.Keybinding
|
||||||
onSuggestionConfirm := gui.wrappedPromptConfirmationFunction(
|
onSuggestionConfirm := gui.wrappedPromptConfirmationFunction(
|
||||||
|
cancel,
|
||||||
opts.HandleConfirmPrompt,
|
opts.HandleConfirmPrompt,
|
||||||
gui.getSelectedSuggestionValue,
|
gui.getSelectedSuggestionValue,
|
||||||
)
|
)
|
||||||
@ -235,7 +249,7 @@ func (gui *Gui) setKeyBindings(opts types.CreatePopupPanelOpts) error {
|
|||||||
{
|
{
|
||||||
ViewName: "confirmation",
|
ViewName: "confirmation",
|
||||||
Key: keybindings.GetKey(keybindingConfig.Universal.Return),
|
Key: keybindings.GetKey(keybindingConfig.Universal.Return),
|
||||||
Handler: gui.wrappedConfirmationFunction(opts.HandleClose),
|
Handler: gui.wrappedConfirmationFunction(cancel, opts.HandleClose),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ViewName: "confirmation",
|
ViewName: "confirmation",
|
||||||
@ -260,7 +274,7 @@ func (gui *Gui) setKeyBindings(opts types.CreatePopupPanelOpts) error {
|
|||||||
{
|
{
|
||||||
ViewName: "suggestions",
|
ViewName: "suggestions",
|
||||||
Key: keybindings.GetKey(keybindingConfig.Universal.Return),
|
Key: keybindings.GetKey(keybindingConfig.Universal.Return),
|
||||||
Handler: gui.wrappedConfirmationFunction(opts.HandleClose),
|
Handler: gui.wrappedConfirmationFunction(cancel, opts.HandleClose),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ViewName: "suggestions",
|
ViewName: "suggestions",
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package popup
|
package popup
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
"github.com/jesseduffield/lazygit/pkg/common"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
gctx "github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
@ -16,7 +17,7 @@ type PopupHandler struct {
|
|||||||
*common.Common
|
*common.Common
|
||||||
index int
|
index int
|
||||||
deadlock.Mutex
|
deadlock.Mutex
|
||||||
createPopupPanelFn func(types.CreatePopupPanelOpts) error
|
createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts) error
|
||||||
onErrorFn func() error
|
onErrorFn func() error
|
||||||
popContextFn func() error
|
popContextFn func() error
|
||||||
currentContextFn func() types.Context
|
currentContextFn func() types.Context
|
||||||
@ -30,7 +31,7 @@ var _ types.IPopupHandler = &PopupHandler{}
|
|||||||
|
|
||||||
func NewPopupHandler(
|
func NewPopupHandler(
|
||||||
common *common.Common,
|
common *common.Common,
|
||||||
createPopupPanelFn func(types.CreatePopupPanelOpts) error,
|
createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts) error,
|
||||||
onErrorFn func() error,
|
onErrorFn func() error,
|
||||||
popContextFn func() error,
|
popContextFn func() error,
|
||||||
currentContextFn func() types.Context,
|
currentContextFn func() types.Context,
|
||||||
@ -96,7 +97,7 @@ func (self *PopupHandler) Confirm(opts types.ConfirmOpts) error {
|
|||||||
self.index++
|
self.index++
|
||||||
self.Unlock()
|
self.Unlock()
|
||||||
|
|
||||||
return self.createPopupPanelFn(types.CreatePopupPanelOpts{
|
return self.createPopupPanelFn(context.Background(), types.CreatePopupPanelOpts{
|
||||||
Title: opts.Title,
|
Title: opts.Title,
|
||||||
Prompt: opts.Prompt,
|
Prompt: opts.Prompt,
|
||||||
HandleConfirm: opts.HandleConfirm,
|
HandleConfirm: opts.HandleConfirm,
|
||||||
@ -109,7 +110,7 @@ func (self *PopupHandler) Prompt(opts types.PromptOpts) error {
|
|||||||
self.index++
|
self.index++
|
||||||
self.Unlock()
|
self.Unlock()
|
||||||
|
|
||||||
return self.createPopupPanelFn(types.CreatePopupPanelOpts{
|
return self.createPopupPanelFn(context.Background(), types.CreatePopupPanelOpts{
|
||||||
Title: opts.Title,
|
Title: opts.Title,
|
||||||
Prompt: opts.InitialContent,
|
Prompt: opts.InitialContent,
|
||||||
Editable: true,
|
Editable: true,
|
||||||
@ -127,12 +128,15 @@ func (self *PopupHandler) WithLoaderPanel(message string, f func() error) error
|
|||||||
index = self.index
|
index = self.index
|
||||||
self.Unlock()
|
self.Unlock()
|
||||||
|
|
||||||
err := self.createPopupPanelFn(types.CreatePopupPanelOpts{
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
|
||||||
|
err := self.createPopupPanelFn(ctx, types.CreatePopupPanelOpts{
|
||||||
Prompt: message,
|
Prompt: message,
|
||||||
HasLoader: true,
|
HasLoader: true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
self.Log.Error(err)
|
self.Log.Error(err)
|
||||||
|
cancel()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,8 +145,10 @@ func (self *PopupHandler) WithLoaderPanel(message string, f func() error) error
|
|||||||
self.Log.Error(err)
|
self.Log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cancel()
|
||||||
|
|
||||||
self.Lock()
|
self.Lock()
|
||||||
if index == self.index && self.currentContextFn().GetKey() == context.CONFIRMATION_CONTEXT_KEY {
|
if index == self.index && self.currentContextFn().GetKey() == gctx.CONFIRMATION_CONTEXT_KEY {
|
||||||
_ = self.popContextFn()
|
_ = self.popContextFn()
|
||||||
}
|
}
|
||||||
self.Unlock()
|
self.Unlock()
|
||||||
|
151
vendor/github.com/gdamore/tcell/v2/README.md
generated
vendored
151
vendor/github.com/gdamore/tcell/v2/README.md
generated
vendored
@ -6,16 +6,17 @@ _Tcell_ is a _Go_ package that provides a cell based view for text terminals, li
|
|||||||
It was inspired by _termbox_, but includes many additional improvements.
|
It was inspired by _termbox_, but includes many additional improvements.
|
||||||
|
|
||||||
[](https://stand-with-ukraine.pp.ua)
|
[](https://stand-with-ukraine.pp.ua)
|
||||||
[](https://github.com/gdamore/tcell/actions/workflows/linux.yml)
|
[](https://github.com/gdamore/tcell/actions/workflows/linux.yml)
|
||||||
[](https://github.com/gdamore/tcell/actions/workflows/windows.yml)
|
[](https://github.com/gdamore/tcell/actions/workflows/windows.yml)
|
||||||
[](https://github.com/gdamore/tcell/blob/master/LICENSE)
|
[](https://github.com/gdamore/tcell/blob/master/LICENSE)
|
||||||
[](https://pkg.go.dev/github.com/gdamore/tcell/v2)
|
[](https://pkg.go.dev/github.com/gdamore/tcell/v2)
|
||||||
[](https://discord.gg/urTTxDN)
|
[](https://discord.gg/urTTxDN)
|
||||||
[](https://codecov.io/gh/gdamore/tcell)
|
[](https://codecov.io/gh/gdamore/tcell)
|
||||||
|
[](https://goreportcard.com/report/github.com/gdamore/tcell/v2)
|
||||||
|
|
||||||
Please see [here](UKRAINE.md) for an important message for the people of Russia.
|
Please see [here](UKRAINE.md) for an important message for the people of Russia.
|
||||||
|
|
||||||
NOTE: This is version 2 of _Tcell_. There are breaking changes relative to version 1.
|
NOTE: This is version 2 of _Tcell_. There are breaking changes relative to version 1.
|
||||||
Version 1.x remains available using the import `github.com/gdamore/tcell`.
|
Version 1.x remains available using the import `github.com/gdamore/tcell`.
|
||||||
|
|
||||||
## Tutorial
|
## Tutorial
|
||||||
@ -24,51 +25,51 @@ A brief, and still somewhat rough, [tutorial](TUTORIAL.md) is available.
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
* [proxima5](https://github.com/gdamore/proxima5) - space shooter ([video](https://youtu.be/jNxKTCmY_bQ))
|
- [proxima5](https://github.com/gdamore/proxima5) - space shooter ([video](https://youtu.be/jNxKTCmY_bQ))
|
||||||
* [govisor](https://github.com/gdamore/govisor) - service management UI ([screenshot](http://2.bp.blogspot.com/--OsvnfzSNow/Vf7aqMw3zXI/AAAAAAAAARo/uOMtOvw4Sbg/s1600/Screen%2BShot%2B2015-09-20%2Bat%2B9.08.41%2BAM.png))
|
- [govisor](https://github.com/gdamore/govisor) - service management UI ([screenshot](http://2.bp.blogspot.com/--OsvnfzSNow/Vf7aqMw3zXI/AAAAAAAAARo/uOMtOvw4Sbg/s1600/Screen%2BShot%2B2015-09-20%2Bat%2B9.08.41%2BAM.png))
|
||||||
* mouse demo - included mouse test ([screenshot](http://2.bp.blogspot.com/-fWvW5opT0es/VhIdItdKqJI/AAAAAAAAATE/7Ojc0L1SpB0/s1600/Screen%2BShot%2B2015-10-04%2Bat%2B11.47.13%2BPM.png))
|
- mouse demo - included mouse test ([screenshot](http://2.bp.blogspot.com/-fWvW5opT0es/VhIdItdKqJI/AAAAAAAAATE/7Ojc0L1SpB0/s1600/Screen%2BShot%2B2015-10-04%2Bat%2B11.47.13%2BPM.png))
|
||||||
* [gomatrix](https://github.com/gdamore/gomatrix) - converted from Termbox
|
- [gomatrix](https://github.com/gdamore/gomatrix) - converted from Termbox
|
||||||
* [micro](https://github.com/zyedidia/micro/) - lightweight text editor with syntax-highlighting and themes
|
- [micro](https://github.com/zyedidia/micro/) - lightweight text editor with syntax-highlighting and themes
|
||||||
* [godu](https://github.com/viktomas/godu) - utility to discover large files/folders
|
- [godu](https://github.com/viktomas/godu) - utility to discover large files/folders
|
||||||
* [tview](https://github.com/rivo/tview/) - rich interactive widgets
|
- [tview](https://github.com/rivo/tview/) - rich interactive widgets
|
||||||
* [cview](https://code.rocketnine.space/tslocum/cview) - user interface toolkit (fork of _tview_)
|
- [cview](https://code.rocketnine.space/tslocum/cview) - user interface toolkit (fork of _tview_)
|
||||||
* [awsome gocui](https://github.com/awesome-gocui/gocui) - Go Console User Interface
|
- [awsome gocui](https://github.com/awesome-gocui/gocui) - Go Console User Interface
|
||||||
* [gomandelbrot](https://github.com/rgm3/gomandelbrot) - Mandelbrot!
|
- [gomandelbrot](https://github.com/rgm3/gomandelbrot) - Mandelbrot!
|
||||||
* [WTF](https://github.com/senorprogrammer/wtf) - personal information dashboard
|
- [WTF](https://github.com/senorprogrammer/wtf) - personal information dashboard
|
||||||
* [browsh](https://github.com/browsh-org/browsh) - modern web browser ([video](https://www.youtube.com/watch?v=HZq86XfBoRo))
|
- [browsh](https://github.com/browsh-org/browsh) - modern web browser ([video](https://www.youtube.com/watch?v=HZq86XfBoRo))
|
||||||
* [go-life](https://github.com/sachaos/go-life) - Conway's Game of Life
|
- [go-life](https://github.com/sachaos/go-life) - Conway's Game of Life
|
||||||
* [gowid](https://github.com/gcla/gowid) - compositional widgets for terminal UIs, inspired by _urwid_
|
- [gowid](https://github.com/gcla/gowid) - compositional widgets for terminal UIs, inspired by _urwid_
|
||||||
* [termshark](https://termshark.io) - interface for _tshark_, inspired by Wireshark, built on _gowid_
|
- [termshark](https://termshark.io) - interface for _tshark_, inspired by Wireshark, built on _gowid_
|
||||||
* [go-tetris](https://github.com/MichaelS11/go-tetris) - Go Tetris with AI option
|
- [go-tetris](https://github.com/MichaelS11/go-tetris) - Go Tetris with AI option
|
||||||
* [fzf](https://github.com/junegunn/fzf) - command-line fuzzy finder
|
- [fzf](https://github.com/junegunn/fzf) - command-line fuzzy finder
|
||||||
* [ascii-fluid](https://github.com/esimov/ascii-fluid) - fluid simulation controlled by webcam
|
- [ascii-fluid](https://github.com/esimov/ascii-fluid) - fluid simulation controlled by webcam
|
||||||
* [cbind](https://code.rocketnine.space/tslocum/cbind) - key event encoding, decoding and handling
|
- [cbind](https://code.rocketnine.space/tslocum/cbind) - key event encoding, decoding and handling
|
||||||
* [tpong](https://github.com/spinzed/tpong) - old-school Pong
|
- [tpong](https://github.com/spinzed/tpong) - old-school Pong
|
||||||
* [aerc](https://git.sr.ht/~sircmpwn/aerc) - email client
|
- [aerc](https://git.sr.ht/~sircmpwn/aerc) - email client
|
||||||
* [tblogs](https://github.com/ezeoleaf/tblogs) - development blogs reader
|
- [tblogs](https://github.com/ezeoleaf/tblogs) - development blogs reader
|
||||||
* [spinc](https://github.com/lallassu/spinc) - _irssi_ inspired chat application for Cisco Spark/WebEx
|
- [spinc](https://github.com/lallassu/spinc) - _irssi_ inspired chat application for Cisco Spark/WebEx
|
||||||
* [gorss](https://github.com/lallassu/gorss) - RSS/Atom feed reader
|
- [gorss](https://github.com/lallassu/gorss) - RSS/Atom feed reader
|
||||||
* [memoryalike](https://github.com/Bios-Marcel/memoryalike) - memorization game
|
- [memoryalike](https://github.com/Bios-Marcel/memoryalike) - memorization game
|
||||||
* [lf](https://github.com/gokcehan/lf) - file manager
|
- [lf](https://github.com/gokcehan/lf) - file manager
|
||||||
* [goful](https://github.com/anmitsu/goful) - CUI file manager
|
- [goful](https://github.com/anmitsu/goful) - CUI file manager
|
||||||
* [gokeybr](https://github.com/bunyk/gokeybr) - deliberately practice your typing
|
- [gokeybr](https://github.com/bunyk/gokeybr) - deliberately practice your typing
|
||||||
* [gonano](https://github.com/jbaramidze/gonano) - editor, mimics _nano_
|
- [gonano](https://github.com/jbaramidze/gonano) - editor, mimics _nano_
|
||||||
* [uchess](https://github.com/tmountain/uchess) - UCI chess client
|
- [uchess](https://github.com/tmountain/uchess) - UCI chess client
|
||||||
* [min](https://github.com/a-h/min) - Gemini browser
|
- [min](https://github.com/a-h/min) - Gemini browser
|
||||||
* [ov](https://github.com/noborus/ov) - file pager
|
- [ov](https://github.com/noborus/ov) - file pager
|
||||||
* [tmux-wormhole](https://github.com/gcla/tmux-wormhole) - _tmux_ plugin to transfer files
|
- [tmux-wormhole](https://github.com/gcla/tmux-wormhole) - _tmux_ plugin to transfer files
|
||||||
* [gruid-tcell](https://github.com/anaseto/gruid-tcell) - driver for the grid based UI and game framework
|
- [gruid-tcell](https://github.com/anaseto/gruid-tcell) - driver for the grid based UI and game framework
|
||||||
* [aretext](https://github.com/aretext/aretext) - minimalist text editor with _vim_ key bindings
|
- [aretext](https://github.com/aretext/aretext) - minimalist text editor with _vim_ key bindings
|
||||||
* [sync](https://github.com/kyprifog/sync) - GitHub repo synchronization tool
|
- [sync](https://github.com/kyprifog/sync) - GitHub repo synchronization tool
|
||||||
* [statusbar](https://github.com/kyprifog/statusbar) - statusbar motivation tool for tracking periodic tasks/goals
|
- [statusbar](https://github.com/kyprifog/statusbar) - statusbar motivation tool for tracking periodic tasks/goals
|
||||||
* [todo](https://github.com/kyprifog/todo) - simple todo app
|
- [todo](https://github.com/kyprifog/todo) - simple todo app
|
||||||
* [gosnakego](https://github.com/liweiyi88/gosnakego) - a snake game
|
- [gosnakego](https://github.com/liweiyi88/gosnakego) - a snake game
|
||||||
|
- [gbb](https://github.com/sdemingo/gbb) - A classical bulletin board app for tildes or public unix servers
|
||||||
|
|
||||||
## Pure Go Terminfo Database
|
## Pure Go Terminfo Database
|
||||||
|
|
||||||
_Tcell_ includes a full parser and expander for terminfo capability strings,
|
_Tcell_ includes a full parser and expander for terminfo capability strings,
|
||||||
so that it can avoid hard coding escape strings for formatting. It also favors
|
so that it can avoid hard coding escape strings for formatting. It also favors
|
||||||
portability, and includes support for all POSIX systems.
|
portability, and includes support for all POSIX systems.
|
||||||
|
|
||||||
The database is also flexible & extensible, and can be modified by either running
|
The database is also flexible & extensible, and can be modified by either running
|
||||||
@ -113,7 +114,7 @@ For example attempts to emit color sequences on VT100 terminals
|
|||||||
won't result in unintended consequences.
|
won't result in unintended consequences.
|
||||||
|
|
||||||
In legacy Windows mode, _Tcell_ supports 16 colors, bold, dim, and reverse,
|
In legacy Windows mode, _Tcell_ supports 16 colors, bold, dim, and reverse,
|
||||||
instead of just termbox's 8 colors with reverse. (Note that there is some
|
instead of just termbox's 8 colors with reverse. (Note that there is some
|
||||||
conflation with bold/dim and colors.)
|
conflation with bold/dim and colors.)
|
||||||
Modern Windows 10 can benefit from much richer colors however.
|
Modern Windows 10 can benefit from much richer colors however.
|
||||||
|
|
||||||
@ -126,7 +127,7 @@ _Tcell_ supports enhanced mouse tracking mode, so your application can receive
|
|||||||
regular mouse motion events, and wheel events, if your terminal supports it.
|
regular mouse motion events, and wheel events, if your terminal supports it.
|
||||||
|
|
||||||
(Note: The Windows 10 Terminal application suffers from a flaw in this regard,
|
(Note: The Windows 10 Terminal application suffers from a flaw in this regard,
|
||||||
and does not support mouse interaction. The stock Windows 10 console host
|
and does not support mouse interaction. The stock Windows 10 console host
|
||||||
fired up with cmd.exe or PowerShell works fine however.)
|
fired up with cmd.exe or PowerShell works fine however.)
|
||||||
|
|
||||||
## _Termbox_ Compatibility
|
## _Termbox_ Compatibility
|
||||||
@ -151,7 +152,7 @@ The `SetContent()` API takes a primary rune, and an optional list of combining r
|
|||||||
If any of the runes is a wide (East Asian) rune occupying two cells,
|
If any of the runes is a wide (East Asian) rune occupying two cells,
|
||||||
then the library will skip output from the following cell. Care must be
|
then the library will skip output from the following cell. Care must be
|
||||||
taken in the application to avoid explicitly attempting to set content in the
|
taken in the application to avoid explicitly attempting to set content in the
|
||||||
next cell, otherwise the results are undefined. (Normally the wide character
|
next cell, otherwise the results are undefined. (Normally the wide character
|
||||||
is displayed, and the other character is not; do not depend on that behavior.)
|
is displayed, and the other character is not; do not depend on that behavior.)
|
||||||
|
|
||||||
Older terminal applications (especially on systems like Windows 8) lack support
|
Older terminal applications (especially on systems like Windows 8) lack support
|
||||||
@ -160,15 +161,15 @@ for advanced Unicode, and thus may not fare well.
|
|||||||
## Colors
|
## Colors
|
||||||
|
|
||||||
_Tcell_ assumes the ANSI/XTerm color model, including the 256 color map that
|
_Tcell_ assumes the ANSI/XTerm color model, including the 256 color map that
|
||||||
XTerm uses when it supports 256 colors. The terminfo guidance will be
|
XTerm uses when it supports 256 colors. The terminfo guidance will be
|
||||||
honored, with respect to the number of colors supported. Also, only
|
honored, with respect to the number of colors supported. Also, only
|
||||||
terminals which expose ANSI style `setaf` and `setab` will support color;
|
terminals which expose ANSI style `setaf` and `setab` will support color;
|
||||||
if you have a color terminal that only has `setf` and `setb`, please submit
|
if you have a color terminal that only has `setf` and `setb`, please submit
|
||||||
a ticket.
|
a ticket.
|
||||||
|
|
||||||
## 24-bit Color
|
## 24-bit Color
|
||||||
|
|
||||||
_Tcell_ _supports 24-bit color!_ (That is, if your terminal can support it.)
|
_Tcell_ _supports 24-bit color!_ (That is, if your terminal can support it.)
|
||||||
|
|
||||||
NOTE: Technically the approach of using 24-bit RGB values for color is more
|
NOTE: Technically the approach of using 24-bit RGB values for color is more
|
||||||
accurately described as "direct color", but most people use the term "true color".
|
accurately described as "direct color", but most people use the term "true color".
|
||||||
@ -176,26 +177,26 @@ We follow the (inaccurate) common convention.
|
|||||||
|
|
||||||
There are a few ways you can enable (or disable) true color.
|
There are a few ways you can enable (or disable) true color.
|
||||||
|
|
||||||
* For many terminals, we can detect it automatically if your terminal
|
- For many terminals, we can detect it automatically if your terminal
|
||||||
includes the `RGB` or `Tc` capabilities (or rather it did when the database
|
includes the `RGB` or `Tc` capabilities (or rather it did when the database
|
||||||
was updated.)
|
was updated.)
|
||||||
|
|
||||||
* You can force this one by setting the `COLORTERM` environment variable to
|
- You can force this one by setting the `COLORTERM` environment variable to
|
||||||
`24-bit`, `truecolor` or `24bit`. This is the same method used
|
`24-bit`, `truecolor` or `24bit`. This is the same method used
|
||||||
by most other terminal applications that support 24-bit color.
|
by most other terminal applications that support 24-bit color.
|
||||||
|
|
||||||
* If you set your `TERM` environment variable to a value with the suffix `-truecolor`
|
- If you set your `TERM` environment variable to a value with the suffix `-truecolor`
|
||||||
then 24-bit color compatible with XTerm and ECMA-48 will be assumed.
|
then 24-bit color compatible with XTerm and ECMA-48 will be assumed.
|
||||||
(This feature is deprecated.
|
(This feature is deprecated.
|
||||||
It is recommended to use one of other methods listed above.)
|
It is recommended to use one of other methods listed above.)
|
||||||
|
|
||||||
* You can disable 24-bit color by setting `TCELL_TRUECOLOR=disable` in your
|
- You can disable 24-bit color by setting `TCELL_TRUECOLOR=disable` in your
|
||||||
environment.
|
environment.
|
||||||
|
|
||||||
When using TrueColor, programs will display the colors that the programmer
|
When using TrueColor, programs will display the colors that the programmer
|
||||||
intended, overriding any "`themes`" you may have set in your terminal
|
intended, overriding any "`themes`" you may have set in your terminal
|
||||||
emulator. (For some cases, accurate color fidelity is more important
|
emulator. (For some cases, accurate color fidelity is more important
|
||||||
than respecting themes. For other cases, such as typical text apps that
|
than respecting themes. For other cases, such as typical text apps that
|
||||||
only use a few colors, its more desirable to respect the themes that
|
only use a few colors, its more desirable to respect the themes that
|
||||||
the user has established.)
|
the user has established.)
|
||||||
|
|
||||||
@ -209,7 +210,7 @@ avoiding repeated sequences or drawing the same cell on refresh updates.
|
|||||||
(Not relevant for Windows users.)
|
(Not relevant for Windows users.)
|
||||||
|
|
||||||
The Terminfo implementation operates with a built-in database.
|
The Terminfo implementation operates with a built-in database.
|
||||||
This should satisfy most users. However, it can also (on systems
|
This should satisfy most users. However, it can also (on systems
|
||||||
with ncurses installed), dynamically parse the output from `infocmp`
|
with ncurses installed), dynamically parse the output from `infocmp`
|
||||||
for terminals it does not already know about.
|
for terminals it does not already know about.
|
||||||
|
|
||||||
@ -226,8 +227,8 @@ since the early 1970s.
|
|||||||
|
|
||||||
Mouse support is detected via the `kmous` terminfo variable, however,
|
Mouse support is detected via the `kmous` terminfo variable, however,
|
||||||
enablement/disablement and decoding mouse events is done using hard coded
|
enablement/disablement and decoding mouse events is done using hard coded
|
||||||
sequences based on the XTerm X11 model. All popular
|
sequences based on the XTerm X11 model. All popular
|
||||||
terminals with mouse tracking support this model. (Full terminfo support
|
terminals with mouse tracking support this model. (Full terminfo support
|
||||||
is not possible as terminfo sequences are not defined.)
|
is not possible as terminfo sequences are not defined.)
|
||||||
|
|
||||||
On Windows, the mouse works normally.
|
On Windows, the mouse works normally.
|
||||||
@ -240,12 +241,12 @@ Modern _xterm_, macOS _Terminal_, and _iTerm_ all work well.
|
|||||||
## Bracketed Paste
|
## Bracketed Paste
|
||||||
|
|
||||||
Terminals that appear to support the XTerm mouse model also can support
|
Terminals that appear to support the XTerm mouse model also can support
|
||||||
bracketed paste, for applications that opt-in. See `EnablePaste()` for details.
|
bracketed paste, for applications that opt-in. See `EnablePaste()` for details.
|
||||||
|
|
||||||
## Testability
|
## Testability
|
||||||
|
|
||||||
There is a `SimulationScreen`, that can be used to simulate a real screen
|
There is a `SimulationScreen`, that can be used to simulate a real screen
|
||||||
for automated testing. The supplied tests do this. The simulation contains
|
for automated testing. The supplied tests do this. The simulation contains
|
||||||
event delivery, screen resizing support, and capabilities to inject events
|
event delivery, screen resizing support, and capabilities to inject events
|
||||||
and examine "`physical`" screen contents.
|
and examine "`physical`" screen contents.
|
||||||
|
|
||||||
@ -253,8 +254,8 @@ and examine "`physical`" screen contents.
|
|||||||
|
|
||||||
### POSIX (Linux, FreeBSD, macOS, Solaris, etc.)
|
### POSIX (Linux, FreeBSD, macOS, Solaris, etc.)
|
||||||
|
|
||||||
Everything works using pure Go on mainstream platforms. Some more esoteric
|
Everything works using pure Go on mainstream platforms. Some more esoteric
|
||||||
platforms (e.g., AIX) may need to be added. Pull requests are welcome!
|
platforms (e.g., AIX) may need to be added. Pull requests are welcome!
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
@ -267,15 +268,15 @@ support all the good features (resize, mouse tracking, etc.)
|
|||||||
|
|
||||||
These platforms won't work, but compilation stubs are supplied
|
These platforms won't work, but compilation stubs are supplied
|
||||||
for folks that want to include parts of this in software for those
|
for folks that want to include parts of this in software for those
|
||||||
platforms. The Simulation screen works, but as _Tcell_ doesn't know how to
|
platforms. The Simulation screen works, but as _Tcell_ doesn't know how to
|
||||||
allocate a real screen object on those platforms, `NewScreen()` will fail.
|
allocate a real screen object on those platforms, `NewScreen()` will fail.
|
||||||
|
|
||||||
If anyone has wisdom about how to improve support for these,
|
If anyone has wisdom about how to improve support for these,
|
||||||
please let me know. PRs are especially welcome.
|
please let me know. PRs are especially welcome.
|
||||||
|
|
||||||
### Commercial Support
|
### Commercial Support
|
||||||
|
|
||||||
_Tcell_ is absolutely free, but if you want to obtain commercial, professional support, there are options.
|
_Tcell_ is absolutely free, but if you want to obtain commercial, professional support, there are options.
|
||||||
|
|
||||||
* [TideLift](https://tidelift.com/) subscriptions include support for _Tcell_, as well as many other open source packages.
|
- [TideLift](https://tidelift.com/) subscriptions include support for _Tcell_, as well as many other open source packages.
|
||||||
* [Staysail Systems Inc.](mailto:info@staysail.tech) offers direct support, and custom development around _Tcell_ on an hourly basis.
|
- [Staysail Systems Inc.](mailto:info@staysail.tech) offers direct support, and custom development around _Tcell_ on an hourly basis.
|
||||||
|
62
vendor/github.com/gdamore/tcell/v2/TUTORIAL.md
generated
vendored
62
vendor/github.com/gdamore/tcell/v2/TUTORIAL.md
generated
vendored
@ -18,7 +18,7 @@ to the terminal capabilities.
|
|||||||
Applications receive an event of type `EventResize` when they are first initialized and each time the terminal is resized.
|
Applications receive an event of type `EventResize` when they are first initialized and each time the terminal is resized.
|
||||||
The new size is available as `Size`.
|
The new size is available as `Size`.
|
||||||
|
|
||||||
```golang
|
```go
|
||||||
switch ev := ev.(type) {
|
switch ev := ev.(type) {
|
||||||
case *tcell.EventResize:
|
case *tcell.EventResize:
|
||||||
w, h := ev.Size()
|
w, h := ev.Size()
|
||||||
@ -35,7 +35,7 @@ When a rune key is pressed, an event with its `Key` set to `KeyRune` is dispatch
|
|||||||
|
|
||||||
When a non-rune key is pressed, it is available as the `Key` of the event.
|
When a non-rune key is pressed, it is available as the `Key` of the event.
|
||||||
|
|
||||||
```golang
|
```go
|
||||||
switch ev := ev.(type) {
|
switch ev := ev.(type) {
|
||||||
case *tcell.EventKey:
|
case *tcell.EventKey:
|
||||||
mod, key, ch := ev.Mod(), ev.Key(), ev.Rune()
|
mod, key, ch := ev.Mod(), ev.Key(), ev.Rune()
|
||||||
@ -62,7 +62,7 @@ Mouse events are only delivered if
|
|||||||
|
|
||||||
The mouse buttons being pressed (if any) are available as `Buttons`, and the position of the mouse is available as `Position`.
|
The mouse buttons being pressed (if any) are available as `Buttons`, and the position of the mouse is available as `Position`.
|
||||||
|
|
||||||
```golang
|
```go
|
||||||
switch ev := ev.(type) {
|
switch ev := ev.(type) {
|
||||||
case *tcell.EventMouse:
|
case *tcell.EventMouse:
|
||||||
mod := ev.Modifiers()
|
mod := ev.Modifiers()
|
||||||
@ -81,12 +81,16 @@ Button2 | ButtonSecondary | Right button
|
|||||||
Button3 | ButtonMiddle | Middle button
|
Button3 | ButtonMiddle | Middle button
|
||||||
Button4 | | Side button (thumb/next)
|
Button4 | | Side button (thumb/next)
|
||||||
Button5 | | Side button (thumb/prev)
|
Button5 | | Side button (thumb/prev)
|
||||||
|
WheelUp | | Scroll wheel up
|
||||||
|
WheelDown | | Scroll wheel down
|
||||||
|
WheelLeft | | Horizontal wheel left
|
||||||
|
WheelRight | | Horizontal wheel right
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
To create a tcell application, first initialize a screen to hold it.
|
To create a _Tcell_ application, first initialize a screen to hold it.
|
||||||
|
|
||||||
```golang
|
```go
|
||||||
s, err := tcell.NewScreen()
|
s, err := tcell.NewScreen()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("%+v", err)
|
log.Fatalf("%+v", err)
|
||||||
@ -105,7 +109,7 @@ s.Clear()
|
|||||||
|
|
||||||
Text may be drawn on the screen using `SetContent`.
|
Text may be drawn on the screen using `SetContent`.
|
||||||
|
|
||||||
```golang
|
```go
|
||||||
s.SetContent(0, 0, 'H', nil, defStyle)
|
s.SetContent(0, 0, 'H', nil, defStyle)
|
||||||
s.SetContent(1, 0, 'i', nil, defStyle)
|
s.SetContent(1, 0, 'i', nil, defStyle)
|
||||||
s.SetContent(2, 0, '!', nil, defStyle)
|
s.SetContent(2, 0, '!', nil, defStyle)
|
||||||
@ -113,7 +117,7 @@ s.SetContent(2, 0, '!', nil, defStyle)
|
|||||||
|
|
||||||
To draw text more easily, define a render function.
|
To draw text more easily, define a render function.
|
||||||
|
|
||||||
```golang
|
```go
|
||||||
func drawText(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string) {
|
func drawText(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string) {
|
||||||
row := y1
|
row := y1
|
||||||
col := x1
|
col := x1
|
||||||
@ -133,7 +137,7 @@ func drawText(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string
|
|||||||
|
|
||||||
Lastly, define an event loop to handle user input and update application state.
|
Lastly, define an event loop to handle user input and update application state.
|
||||||
|
|
||||||
```golang
|
```go
|
||||||
quit := func() {
|
quit := func() {
|
||||||
s.Fini()
|
s.Fini()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
@ -161,13 +165,12 @@ for {
|
|||||||
|
|
||||||
The following demonstrates how to initialize a screen, draw text/graphics and handle user input.
|
The following demonstrates how to initialize a screen, draw text/graphics and handle user input.
|
||||||
|
|
||||||
```golang
|
```go
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
)
|
)
|
||||||
@ -245,12 +248,29 @@ func main() {
|
|||||||
drawBox(s, 1, 1, 42, 7, boxStyle, "Click and drag to draw a box")
|
drawBox(s, 1, 1, 42, 7, boxStyle, "Click and drag to draw a box")
|
||||||
drawBox(s, 5, 9, 32, 14, boxStyle, "Press C to reset")
|
drawBox(s, 5, 9, 32, 14, boxStyle, "Press C to reset")
|
||||||
|
|
||||||
|
quit := func() {
|
||||||
|
// You have to catch panics in a defer, clean up, and
|
||||||
|
// re-raise them - otherwise your application can
|
||||||
|
// die without leaving any diagnostic trace.
|
||||||
|
maybePanic := recover()
|
||||||
|
s.Fini()
|
||||||
|
if maybePanic != nil {
|
||||||
|
panic(maybePanic)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defer quit()
|
||||||
|
|
||||||
|
// Here's how to get the screen size when you need it.
|
||||||
|
// xmax, ymax := s.Size()
|
||||||
|
|
||||||
|
// Here's an example of how to inject a keystroke where it will
|
||||||
|
// be picked up by the next PollEvent call. Note that the
|
||||||
|
// queue is LIFO, it has a limited length, and PostEvent() can
|
||||||
|
// return an error.
|
||||||
|
// s.PostEvent(tcell.NewEventKey(tcell.KeyRune, rune('a'), 0))
|
||||||
|
|
||||||
// Event loop
|
// Event loop
|
||||||
ox, oy := -1, -1
|
ox, oy := -1, -1
|
||||||
quit := func() {
|
|
||||||
s.Fini()
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
for {
|
for {
|
||||||
// Update screen
|
// Update screen
|
||||||
s.Show()
|
s.Show()
|
||||||
@ -264,7 +284,7 @@ func main() {
|
|||||||
s.Sync()
|
s.Sync()
|
||||||
case *tcell.EventKey:
|
case *tcell.EventKey:
|
||||||
if ev.Key() == tcell.KeyEscape || ev.Key() == tcell.KeyCtrlC {
|
if ev.Key() == tcell.KeyEscape || ev.Key() == tcell.KeyCtrlC {
|
||||||
quit()
|
return
|
||||||
} else if ev.Key() == tcell.KeyCtrlL {
|
} else if ev.Key() == tcell.KeyCtrlL {
|
||||||
s.Sync()
|
s.Sync()
|
||||||
} else if ev.Rune() == 'C' || ev.Rune() == 'c' {
|
} else if ev.Rune() == 'C' || ev.Rune() == 'c' {
|
||||||
@ -272,14 +292,13 @@ func main() {
|
|||||||
}
|
}
|
||||||
case *tcell.EventMouse:
|
case *tcell.EventMouse:
|
||||||
x, y := ev.Position()
|
x, y := ev.Position()
|
||||||
button := ev.Buttons()
|
|
||||||
// Only process button events, not wheel events
|
|
||||||
button &= tcell.ButtonMask(0xff)
|
|
||||||
|
|
||||||
if button != tcell.ButtonNone && ox < 0 {
|
|
||||||
ox, oy = x, y
|
|
||||||
}
|
|
||||||
switch ev.Buttons() {
|
switch ev.Buttons() {
|
||||||
|
case tcell.Button1, tcell.Button2:
|
||||||
|
if ox < 0 {
|
||||||
|
ox, oy = x, y // record location when click started
|
||||||
|
}
|
||||||
|
|
||||||
case tcell.ButtonNone:
|
case tcell.ButtonNone:
|
||||||
if ox >= 0 {
|
if ox >= 0 {
|
||||||
label := fmt.Sprintf("%d,%d to %d,%d", ox, oy, x, y)
|
label := fmt.Sprintf("%d,%d to %d,%d", ox, oy, x, y)
|
||||||
@ -291,3 +310,4 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
21
vendor/github.com/gdamore/tcell/v2/cell.go
generated
vendored
21
vendor/github.com/gdamore/tcell/v2/cell.go
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2019 The TCell Authors
|
// Copyright 2022 The TCell Authors
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use file except in compliance with the License.
|
// you may not use file except in compliance with the License.
|
||||||
@ -15,6 +15,8 @@
|
|||||||
package tcell
|
package tcell
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
runewidth "github.com/mattn/go-runewidth"
|
runewidth "github.com/mattn/go-runewidth"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -175,3 +177,20 @@ func (cb *CellBuffer) Fill(r rune, style Style) {
|
|||||||
c.width = 1
|
c.width = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var runeConfig *runewidth.Condition;
|
||||||
|
func init() {
|
||||||
|
// The defaults for the runewidth package are poorly chosen for terminal
|
||||||
|
// applications. We however will honor the setting in the environment if
|
||||||
|
// it is set.
|
||||||
|
if os.Getenv("RUNEWIDTH_EASTASIAN") == "" {
|
||||||
|
runewidth.DefaultCondition.EastAsianWidth = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For performance reasons, we create a lookup table. However some users
|
||||||
|
// might be more memory conscious. If that's you, set the TCELL_MINIMIZE
|
||||||
|
// environment variable.
|
||||||
|
if os.Getenv("TCELL_MINIMIZE") == "" {
|
||||||
|
runewidth.CreateLUT()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1
vendor/github.com/gdamore/tcell/v2/charset_stub.go
generated
vendored
1
vendor/github.com/gdamore/tcell/v2/charset_stub.go
generated
vendored
@ -1,3 +1,4 @@
|
|||||||
|
//go:build plan9 || nacl
|
||||||
// +build plan9 nacl
|
// +build plan9 nacl
|
||||||
|
|
||||||
// Copyright 2015 The TCell Authors
|
// Copyright 2015 The TCell Authors
|
||||||
|
1
vendor/github.com/gdamore/tcell/v2/charset_unix.go
generated
vendored
1
vendor/github.com/gdamore/tcell/v2/charset_unix.go
generated
vendored
@ -1,3 +1,4 @@
|
|||||||
|
//go:build !windows && !nacl && !plan9
|
||||||
// +build !windows,!nacl,!plan9
|
// +build !windows,!nacl,!plan9
|
||||||
|
|
||||||
// Copyright 2016 The TCell Authors
|
// Copyright 2016 The TCell Authors
|
||||||
|
1
vendor/github.com/gdamore/tcell/v2/charset_windows.go
generated
vendored
1
vendor/github.com/gdamore/tcell/v2/charset_windows.go
generated
vendored
@ -1,3 +1,4 @@
|
|||||||
|
//go:build windows
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
// Copyright 2015 The TCell Authors
|
// Copyright 2015 The TCell Authors
|
||||||
|
3
vendor/github.com/gdamore/tcell/v2/colorfit.go
generated
vendored
3
vendor/github.com/gdamore/tcell/v2/colorfit.go
generated
vendored
@ -15,8 +15,9 @@
|
|||||||
package tcell
|
package tcell
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/lucasb-eyer/go-colorful"
|
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
"github.com/lucasb-eyer/go-colorful"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FindColor attempts to find a given color, or the best match possible for it,
|
// FindColor attempts to find a given color, or the best match possible for it,
|
||||||
|
1
vendor/github.com/gdamore/tcell/v2/console_stub.go
generated
vendored
1
vendor/github.com/gdamore/tcell/v2/console_stub.go
generated
vendored
@ -1,3 +1,4 @@
|
|||||||
|
//go:build !windows
|
||||||
// +build !windows
|
// +build !windows
|
||||||
|
|
||||||
// Copyright 2015 The TCell Authors
|
// Copyright 2015 The TCell Authors
|
||||||
|
5
vendor/github.com/gdamore/tcell/v2/doc.go
generated
vendored
5
vendor/github.com/gdamore/tcell/v2/doc.go
generated
vendored
@ -36,13 +36,12 @@
|
|||||||
//
|
//
|
||||||
// Note that support for non-UTF-8 locales (other than C) must be enabled
|
// Note that support for non-UTF-8 locales (other than C) must be enabled
|
||||||
// by the application using RegisterEncoding() -- we don't have them all
|
// by the application using RegisterEncoding() -- we don't have them all
|
||||||
// enabled by default to avoid bloating the application unneccessarily.
|
// enabled by default to avoid bloating the application unnecessarily.
|
||||||
// (These days UTF-8 is good enough for almost everyone, and nobody should
|
// (These days UTF-8 is good enough for almost everyone, and nobody should
|
||||||
// be using legacy locales anymore.) Also, actual glyphs for various code
|
// be using legacy locales anymore.) Also, actual glyphs for various code
|
||||||
// point will only be displayed if your terminal or emulator (or the font
|
// point will only be displayed if your terminal or emulator (or the font
|
||||||
// the emulator is using) supports them.
|
// the emulator is using) supports them.
|
||||||
//
|
//
|
||||||
// A rich set of keycodes is supported, with support for up to 65 function
|
// A rich set of key codes is supported, with support for up to 65 function
|
||||||
// keys, and various other special keys.
|
// keys, and various other special keys.
|
||||||
//
|
|
||||||
package tcell
|
package tcell
|
||||||
|
24
vendor/github.com/gdamore/tcell/v2/encoding.go
generated
vendored
24
vendor/github.com/gdamore/tcell/v2/encoding.go
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2015 The TCell Authors
|
// Copyright 2022 The TCell Authors
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use file except in compliance with the License.
|
// you may not use file except in compliance with the License.
|
||||||
@ -38,19 +38,19 @@ var encodingFallback EncodingFallback = EncodingFallbackFail
|
|||||||
// the common ones exist already as stock variables. For example, ISO8859-15
|
// the common ones exist already as stock variables. For example, ISO8859-15
|
||||||
// can be registered using the following code:
|
// can be registered using the following code:
|
||||||
//
|
//
|
||||||
// import "golang.org/x/text/encoding/charmap"
|
// import "golang.org/x/text/encoding/charmap"
|
||||||
//
|
//
|
||||||
// ...
|
// ...
|
||||||
// RegisterEncoding("ISO8859-15", charmap.ISO8859_15)
|
// RegisterEncoding("ISO8859-15", charmap.ISO8859_15)
|
||||||
//
|
//
|
||||||
// Aliases can be registered as well, for example "8859-15" could be an alias
|
// Aliases can be registered as well, for example "8859-15" could be an alias
|
||||||
// for "ISO8859-15".
|
// for "ISO8859-15".
|
||||||
//
|
//
|
||||||
// For POSIX systems, the tcell package will check the environment variables
|
// For POSIX systems, this package will check the environment variables
|
||||||
// LC_ALL, LC_CTYPE, and LANG (in that order) to determine the character set.
|
// LC_ALL, LC_CTYPE, and LANG (in that order) to determine the character set.
|
||||||
// These are expected to have the following pattern:
|
// These are expected to have the following pattern:
|
||||||
//
|
//
|
||||||
// $language[.$codeset[@$variant]
|
// $language[.$codeset[@$variant]
|
||||||
//
|
//
|
||||||
// We extract only the $codeset part, which will usually be something like
|
// We extract only the $codeset part, which will usually be something like
|
||||||
// UTF-8 or ISO8859-15 or KOI8-R. Note that if the locale is either "POSIX"
|
// UTF-8 or ISO8859-15 or KOI8-R. Note that if the locale is either "POSIX"
|
||||||
@ -64,9 +64,11 @@ var encodingFallback EncodingFallback = EncodingFallbackFail
|
|||||||
// quite a lot processing overhead.
|
// quite a lot processing overhead.
|
||||||
//
|
//
|
||||||
// Note that some encodings are quite large (for example GB18030 which is a
|
// Note that some encodings are quite large (for example GB18030 which is a
|
||||||
// superset of Unicode) and so the application size can be expected ot
|
// superset of Unicode) and so the application size can be expected to
|
||||||
// increase quite a bit as each encoding is added. The East Asian encodings
|
// increase quite a bit as each encoding is added.
|
||||||
// have been seen to add 100-200K per encoding to the application size.
|
|
||||||
|
// The East Asian encodings have been seen to add 100-200K per encoding to the
|
||||||
|
// size of the resulting binary.
|
||||||
//
|
//
|
||||||
func RegisterEncoding(charset string, enc encoding.Encoding) {
|
func RegisterEncoding(charset string, enc encoding.Encoding) {
|
||||||
encodingLk.Lock()
|
encodingLk.Lock()
|
||||||
@ -75,7 +77,7 @@ func RegisterEncoding(charset string, enc encoding.Encoding) {
|
|||||||
encodingLk.Unlock()
|
encodingLk.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodingFallback describes how the system behavees when the locale
|
// EncodingFallback describes how the system behaves when the locale
|
||||||
// requires a character set that we do not support. The system always
|
// requires a character set that we do not support. The system always
|
||||||
// supports UTF-8 and US-ASCII. On Windows consoles, UTF-16LE is also
|
// supports UTF-8 and US-ASCII. On Windows consoles, UTF-16LE is also
|
||||||
// supported automatically. Other character sets must be added using the
|
// supported automatically. Other character sets must be added using the
|
||||||
@ -88,7 +90,7 @@ const (
|
|||||||
// when it cannot find an encoding.
|
// when it cannot find an encoding.
|
||||||
EncodingFallbackFail = iota
|
EncodingFallbackFail = iota
|
||||||
|
|
||||||
// EncodingFallbackASCII behaviore causes GetEncoding to fall back
|
// EncodingFallbackASCII behavior causes GetEncoding to fall back
|
||||||
// to a 7-bit ASCII encoding, if no other encoding can be found.
|
// to a 7-bit ASCII encoding, if no other encoding can be found.
|
||||||
EncodingFallbackASCII
|
EncodingFallbackASCII
|
||||||
|
|
||||||
|
1
vendor/github.com/gdamore/tcell/v2/nonblock_bsd.go
generated
vendored
1
vendor/github.com/gdamore/tcell/v2/nonblock_bsd.go
generated
vendored
@ -12,6 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build darwin || dragonfly || freebsd || netbsd || openbsd
|
||||||
// +build darwin dragonfly freebsd netbsd openbsd
|
// +build darwin dragonfly freebsd netbsd openbsd
|
||||||
|
|
||||||
package tcell
|
package tcell
|
||||||
|
1
vendor/github.com/gdamore/tcell/v2/nonblock_unix.go
generated
vendored
1
vendor/github.com/gdamore/tcell/v2/nonblock_unix.go
generated
vendored
@ -12,6 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build linux || aix || zos || solaris
|
||||||
// +build linux aix zos solaris
|
// +build linux aix zos solaris
|
||||||
|
|
||||||
package tcell
|
package tcell
|
||||||
|
11
vendor/github.com/gdamore/tcell/v2/screen.go
generated
vendored
11
vendor/github.com/gdamore/tcell/v2/screen.go
generated
vendored
@ -24,12 +24,13 @@ type Screen interface {
|
|||||||
// Fini finalizes the screen also releasing resources.
|
// Fini finalizes the screen also releasing resources.
|
||||||
Fini()
|
Fini()
|
||||||
|
|
||||||
// Clear erases the screen. The contents of any screen buffers
|
// Clear logically erases the screen.
|
||||||
// will also be cleared. This has the logical effect of
|
// This is effectively a short-cut for Fill(' ', StyleDefault).
|
||||||
// filling the screen with spaces, using the global default style.
|
|
||||||
Clear()
|
Clear()
|
||||||
|
|
||||||
// Fill fills the screen with the given character and style.
|
// Fill fills the screen with the given character and style.
|
||||||
|
// The effect of filling the screen is not visible until Show
|
||||||
|
// is called (or Sync).
|
||||||
Fill(rune, Style)
|
Fill(rune, Style)
|
||||||
|
|
||||||
// SetCell is an older API, and will be removed. Please use
|
// SetCell is an older API, and will be removed. Please use
|
||||||
@ -42,7 +43,7 @@ type Screen interface {
|
|||||||
// and may not actually be what is displayed, but rather are what will
|
// and may not actually be what is displayed, but rather are what will
|
||||||
// be displayed if Show() or Sync() is called. The width is the width
|
// be displayed if Show() or Sync() is called. The width is the width
|
||||||
// in screen cells; most often this will be 1, but some East Asian
|
// in screen cells; most often this will be 1, but some East Asian
|
||||||
// characters require two cells.
|
// characters and emoji require two cells.
|
||||||
GetContent(x, y int) (primary rune, combining []rune, style Style, width int)
|
GetContent(x, y int) (primary rune, combining []rune, style Style, width int)
|
||||||
|
|
||||||
// SetContent sets the contents of the given cell location. If
|
// SetContent sets the contents of the given cell location. If
|
||||||
@ -54,7 +55,7 @@ type Screen interface {
|
|||||||
//
|
//
|
||||||
// The results are not displayed until Show() or Sync() is called.
|
// The results are not displayed until Show() or Sync() is called.
|
||||||
//
|
//
|
||||||
// Note that wide (East Asian full width) runes occupy two cells,
|
// Note that wide (East Asian full width and emoji) runes occupy two cells,
|
||||||
// and attempts to place character at next cell to the right will have
|
// and attempts to place character at next cell to the right will have
|
||||||
// undefined effects. Wide runes that are printed in the
|
// undefined effects. Wide runes that are printed in the
|
||||||
// last column will be replaced with a single width space on output.
|
// last column will be replaced with a single width space on output.
|
||||||
|
5
vendor/github.com/gdamore/tcell/v2/stdin_unix.go
generated
vendored
5
vendor/github.com/gdamore/tcell/v2/stdin_unix.go
generated
vendored
@ -12,6 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
|
||||||
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
|
||||||
|
|
||||||
package tcell
|
package tcell
|
||||||
@ -60,7 +61,7 @@ func (tty *stdIoTty) Start() error {
|
|||||||
defer tty.l.Unlock()
|
defer tty.l.Unlock()
|
||||||
|
|
||||||
// We open another copy of /dev/tty. This is a workaround for unusual behavior
|
// We open another copy of /dev/tty. This is a workaround for unusual behavior
|
||||||
// observed in macOS, apparently caused when a subshell (for example) closes our
|
// observed in macOS, apparently caused when a sub-shell (for example) closes our
|
||||||
// own tty device (when it exits for example). Getting a fresh new one seems to
|
// own tty device (when it exits for example). Getting a fresh new one seems to
|
||||||
// resolve the problem. (We believe this is a bug in the macOS tty driver that
|
// resolve the problem. (We believe this is a bug in the macOS tty driver that
|
||||||
// fails to account for dup() references to the same file before applying close()
|
// fails to account for dup() references to the same file before applying close()
|
||||||
@ -162,7 +163,7 @@ func (tty *stdIoTty) NotifyResize(cb func()) {
|
|||||||
func NewStdIoTty() (Tty, error) {
|
func NewStdIoTty() (Tty, error) {
|
||||||
tty := &stdIoTty{
|
tty := &stdIoTty{
|
||||||
sig: make(chan os.Signal),
|
sig: make(chan os.Signal),
|
||||||
in: os.Stdin,
|
in: os.Stdin,
|
||||||
out: os.Stdout,
|
out: os.Stdout,
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
|
21
vendor/github.com/gdamore/tcell/v2/style.go
generated
vendored
21
vendor/github.com/gdamore/tcell/v2/style.go
generated
vendored
@ -27,6 +27,7 @@ type Style struct {
|
|||||||
bg Color
|
bg Color
|
||||||
attrs AttrMask
|
attrs AttrMask
|
||||||
url string
|
url string
|
||||||
|
urlId string
|
||||||
}
|
}
|
||||||
|
|
||||||
// StyleDefault represents a default style, based upon the context.
|
// StyleDefault represents a default style, based upon the context.
|
||||||
@ -44,6 +45,7 @@ func (s Style) Foreground(c Color) Style {
|
|||||||
bg: s.bg,
|
bg: s.bg,
|
||||||
attrs: s.attrs,
|
attrs: s.attrs,
|
||||||
url: s.url,
|
url: s.url,
|
||||||
|
urlId: s.urlId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +57,7 @@ func (s Style) Background(c Color) Style {
|
|||||||
bg: c,
|
bg: c,
|
||||||
attrs: s.attrs,
|
attrs: s.attrs,
|
||||||
url: s.url,
|
url: s.url,
|
||||||
|
urlId: s.urlId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +74,7 @@ func (s Style) setAttrs(attrs AttrMask, on bool) Style {
|
|||||||
bg: s.bg,
|
bg: s.bg,
|
||||||
attrs: s.attrs | attrs,
|
attrs: s.attrs | attrs,
|
||||||
url: s.url,
|
url: s.url,
|
||||||
|
urlId: s.urlId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Style{
|
return Style{
|
||||||
@ -78,6 +82,7 @@ func (s Style) setAttrs(attrs AttrMask, on bool) Style {
|
|||||||
bg: s.bg,
|
bg: s.bg,
|
||||||
attrs: s.attrs &^ attrs,
|
attrs: s.attrs &^ attrs,
|
||||||
url: s.url,
|
url: s.url,
|
||||||
|
urlId: s.urlId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +144,7 @@ func (s Style) Attributes(attrs AttrMask) Style {
|
|||||||
bg: s.bg,
|
bg: s.bg,
|
||||||
attrs: attrs,
|
attrs: attrs,
|
||||||
url: s.url,
|
url: s.url,
|
||||||
|
urlId: s.urlId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,5 +157,20 @@ func (s Style) Url(url string) Style {
|
|||||||
bg: s.bg,
|
bg: s.bg,
|
||||||
attrs: s.attrs,
|
attrs: s.attrs,
|
||||||
url: url,
|
url: url,
|
||||||
|
urlId: s.urlId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UrlId returns a style with the UrlId set. If the provided UrlId is not empty,
|
||||||
|
// any marked up Url with this style will be given the UrlId also. If the
|
||||||
|
// terminal supports it, any text with the same UrlId will be grouped as if it
|
||||||
|
// were one Url, even if it spans multiple lines.
|
||||||
|
func (s Style) UrlId(id string) Style {
|
||||||
|
return Style{
|
||||||
|
fg: s.fg,
|
||||||
|
bg: s.bg,
|
||||||
|
attrs: s.attrs,
|
||||||
|
url: s.url,
|
||||||
|
urlId: "id=" + id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
114
vendor/github.com/gdamore/tcell/v2/terminfo/f/foot/foot.go
generated
vendored
114
vendor/github.com/gdamore/tcell/v2/terminfo/f/foot/foot.go
generated
vendored
@ -8,63 +8,63 @@ func init() {
|
|||||||
|
|
||||||
// foot terminal emulator
|
// foot terminal emulator
|
||||||
terminfo.AddTerminfo(&terminfo.Terminfo{
|
terminfo.AddTerminfo(&terminfo.Terminfo{
|
||||||
Name: "foot",
|
Name: "foot",
|
||||||
Aliases: []string{"foot-extra"},
|
Aliases: []string{"foot-extra"},
|
||||||
Columns: 80,
|
Columns: 80,
|
||||||
Lines: 24,
|
Lines: 24,
|
||||||
Colors: 256,
|
Colors: 256,
|
||||||
Bell: "\a",
|
Bell: "\a",
|
||||||
Clear: "\x1b[H\x1b[2J",
|
Clear: "\x1b[H\x1b[2J",
|
||||||
EnterCA: "\x1b[?1049h\x1b[22;0;0t",
|
EnterCA: "\x1b[?1049h\x1b[22;0;0t",
|
||||||
ExitCA: "\x1b[?1049l\x1b[23;0;0t",
|
ExitCA: "\x1b[?1049l\x1b[23;0;0t",
|
||||||
ShowCursor: "\x1b[?12l\x1b[?25h",
|
ShowCursor: "\x1b[?12l\x1b[?25h",
|
||||||
HideCursor: "\x1b[?25l",
|
HideCursor: "\x1b[?25l",
|
||||||
AttrOff: "\x1b(B\x1b[m",
|
AttrOff: "\x1b(B\x1b[m",
|
||||||
Underline: "\x1b[4m",
|
Underline: "\x1b[4m",
|
||||||
Bold: "\x1b[1m",
|
Bold: "\x1b[1m",
|
||||||
Dim: "\x1b[2m",
|
Dim: "\x1b[2m",
|
||||||
Italic: "\x1b[3m",
|
Italic: "\x1b[3m",
|
||||||
Blink: "\x1b[5m",
|
Blink: "\x1b[5m",
|
||||||
Reverse: "\x1b[7m",
|
Reverse: "\x1b[7m",
|
||||||
EnterKeypad: "\x1b[?1h\x1b=",
|
EnterKeypad: "\x1b[?1h\x1b=",
|
||||||
ExitKeypad: "\x1b[?1l\x1b>",
|
ExitKeypad: "\x1b[?1l\x1b>",
|
||||||
SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;m",
|
SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;m",
|
||||||
SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48:5:%p1%d%;m",
|
SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48:5:%p1%d%;m",
|
||||||
SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48:5:%p2%d%;m",
|
SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48:5:%p2%d%;m",
|
||||||
ResetFgBg: "\x1b[39;49m",
|
ResetFgBg: "\x1b[39;49m",
|
||||||
AltChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
AltChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
|
||||||
EnterAcs: "\x1b(0",
|
EnterAcs: "\x1b(0",
|
||||||
ExitAcs: "\x1b(B",
|
ExitAcs: "\x1b(B",
|
||||||
StrikeThrough: "\x1b[9m",
|
StrikeThrough: "\x1b[9m",
|
||||||
Mouse: "\x1b[M",
|
Mouse: "\x1b[M",
|
||||||
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
SetCursor: "\x1b[%i%p1%d;%p2%dH",
|
||||||
CursorBack1: "\b",
|
CursorBack1: "\b",
|
||||||
CursorUp1: "\x1b[A",
|
CursorUp1: "\x1b[A",
|
||||||
KeyUp: "\x1bOA",
|
KeyUp: "\x1bOA",
|
||||||
KeyDown: "\x1bOB",
|
KeyDown: "\x1bOB",
|
||||||
KeyRight: "\x1bOC",
|
KeyRight: "\x1bOC",
|
||||||
KeyLeft: "\x1bOD",
|
KeyLeft: "\x1bOD",
|
||||||
KeyInsert: "\x1b[2~",
|
KeyInsert: "\x1b[2~",
|
||||||
KeyDelete: "\x1b[3~",
|
KeyDelete: "\x1b[3~",
|
||||||
KeyBackspace: "\u007f",
|
KeyBackspace: "\u007f",
|
||||||
KeyHome: "\x1bOH",
|
KeyHome: "\x1bOH",
|
||||||
KeyEnd: "\x1bOF",
|
KeyEnd: "\x1bOF",
|
||||||
KeyPgUp: "\x1b[5~",
|
KeyPgUp: "\x1b[5~",
|
||||||
KeyPgDn: "\x1b[6~",
|
KeyPgDn: "\x1b[6~",
|
||||||
KeyF1: "\x1bOP",
|
KeyF1: "\x1bOP",
|
||||||
KeyF2: "\x1bOQ",
|
KeyF2: "\x1bOQ",
|
||||||
KeyF3: "\x1bOR",
|
KeyF3: "\x1bOR",
|
||||||
KeyF4: "\x1bOS",
|
KeyF4: "\x1bOS",
|
||||||
KeyF5: "\x1b[15~",
|
KeyF5: "\x1b[15~",
|
||||||
KeyF6: "\x1b[17~",
|
KeyF6: "\x1b[17~",
|
||||||
KeyF7: "\x1b[18~",
|
KeyF7: "\x1b[18~",
|
||||||
KeyF8: "\x1b[19~",
|
KeyF8: "\x1b[19~",
|
||||||
KeyF9: "\x1b[20~",
|
KeyF9: "\x1b[20~",
|
||||||
KeyF10: "\x1b[21~",
|
KeyF10: "\x1b[21~",
|
||||||
KeyF11: "\x1b[23~",
|
KeyF11: "\x1b[23~",
|
||||||
KeyF12: "\x1b[24~",
|
KeyF12: "\x1b[24~",
|
||||||
KeyBacktab: "\x1b[Z",
|
KeyBacktab: "\x1b[Z",
|
||||||
Modifiers: 1,
|
Modifiers: 1,
|
||||||
AutoMargin: true,
|
AutoMargin: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
173
vendor/github.com/gdamore/tcell/v2/terminfo/terminfo.go
generated
vendored
173
vendor/github.com/gdamore/tcell/v2/terminfo/terminfo.go
generated
vendored
@ -240,15 +240,14 @@ const (
|
|||||||
type stack []interface{}
|
type stack []interface{}
|
||||||
|
|
||||||
func (st stack) Push(v interface{}) stack {
|
func (st stack) Push(v interface{}) stack {
|
||||||
return append(st, v)
|
if b, ok := v.(bool); ok {
|
||||||
}
|
if b {
|
||||||
|
return append(st, 1)
|
||||||
func (st stack) Pop() (interface{}, stack) {
|
} else {
|
||||||
if len(st) > 0 {
|
return append(st, 0)
|
||||||
e := st[len(st)-1]
|
}
|
||||||
return e, st[:len(st)-1]
|
|
||||||
}
|
}
|
||||||
return 0, st
|
return append(st, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st stack) PopString() (string, stack) {
|
func (st stack) PopString() (string, stack) {
|
||||||
@ -258,8 +257,6 @@ func (st stack) PopString() (string, stack) {
|
|||||||
switch v := e.(type) {
|
switch v := e.(type) {
|
||||||
case int:
|
case int:
|
||||||
s = strconv.Itoa(v)
|
s = strconv.Itoa(v)
|
||||||
case bool:
|
|
||||||
s = strconv.FormatBool(v)
|
|
||||||
case string:
|
case string:
|
||||||
s = v
|
s = v
|
||||||
}
|
}
|
||||||
@ -275,12 +272,6 @@ func (st stack) PopInt() (int, stack) {
|
|||||||
switch v := e.(type) {
|
switch v := e.(type) {
|
||||||
case int:
|
case int:
|
||||||
i = v
|
i = v
|
||||||
case bool:
|
|
||||||
if v {
|
|
||||||
i = 1
|
|
||||||
} else {
|
|
||||||
i = 0
|
|
||||||
}
|
|
||||||
case string:
|
case string:
|
||||||
i, _ = strconv.Atoi(v)
|
i, _ = strconv.Atoi(v)
|
||||||
}
|
}
|
||||||
@ -289,42 +280,18 @@ func (st stack) PopInt() (int, stack) {
|
|||||||
return 0, st
|
return 0, st
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st stack) PopBool() (bool, stack) {
|
|
||||||
var b bool
|
|
||||||
if len(st) > 0 {
|
|
||||||
e := st[len(st)-1]
|
|
||||||
switch v := e.(type) {
|
|
||||||
case int:
|
|
||||||
b = v != 0
|
|
||||||
case bool:
|
|
||||||
b = v
|
|
||||||
case string:
|
|
||||||
b = v != "" && v != "false"
|
|
||||||
}
|
|
||||||
return b, st[:len(st)-1]
|
|
||||||
}
|
|
||||||
return false, st
|
|
||||||
}
|
|
||||||
|
|
||||||
// static vars
|
// static vars
|
||||||
var svars [26]string
|
var svars [26]string
|
||||||
|
|
||||||
// paramsBuffer handles some persistent state for TParam. Technically we
|
|
||||||
// could probably dispense with this, but caching buffer arrays gives us
|
|
||||||
// a nice little performance boost. Furthermore, we know that TParam is
|
|
||||||
// rarely (never?) called re-entrantly, so we can just reuse the same
|
|
||||||
// buffers, making it thread-safe by stashing a lock.
|
|
||||||
type paramsBuffer struct {
|
type paramsBuffer struct {
|
||||||
out bytes.Buffer
|
out bytes.Buffer
|
||||||
buf bytes.Buffer
|
buf bytes.Buffer
|
||||||
lk sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start initializes the params buffer with the initial string data.
|
// Start initializes the params buffer with the initial string data.
|
||||||
// It also locks the paramsBuffer. The caller must call End() when
|
// It also locks the paramsBuffer. The caller must call End() when
|
||||||
// finished.
|
// finished.
|
||||||
func (pb *paramsBuffer) Start(s string) {
|
func (pb *paramsBuffer) Start(s string) {
|
||||||
pb.lk.Lock()
|
|
||||||
pb.out.Reset()
|
pb.out.Reset()
|
||||||
pb.buf.Reset()
|
pb.buf.Reset()
|
||||||
pb.buf.WriteString(s)
|
pb.buf.WriteString(s)
|
||||||
@ -333,7 +300,6 @@ func (pb *paramsBuffer) Start(s string) {
|
|||||||
// End returns the final output from TParam, but it also releases the lock.
|
// End returns the final output from TParam, but it also releases the lock.
|
||||||
func (pb *paramsBuffer) End() string {
|
func (pb *paramsBuffer) End() string {
|
||||||
s := pb.out.String()
|
s := pb.out.String()
|
||||||
pb.lk.Unlock()
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,18 +318,16 @@ func (pb *paramsBuffer) PutString(s string) {
|
|||||||
pb.out.WriteString(s)
|
pb.out.WriteString(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
var pb = ¶msBuffer{}
|
|
||||||
|
|
||||||
// TParm takes a terminfo parameterized string, such as setaf or cup, and
|
// TParm takes a terminfo parameterized string, such as setaf or cup, and
|
||||||
// evaluates the string, and returns the result with the parameter
|
// evaluates the string, and returns the result with the parameter
|
||||||
// applied.
|
// applied.
|
||||||
func (t *Terminfo) TParm(s string, p ...interface{}) string {
|
func (t *Terminfo) TParm(s string, p ...interface{}) string {
|
||||||
var stk stack
|
var stk stack
|
||||||
var a, b string
|
var a string
|
||||||
var ai, bi int
|
var ai, bi int
|
||||||
var ab bool
|
|
||||||
var dvars [26]string
|
var dvars [26]string
|
||||||
var params [9]interface{}
|
var params [9]interface{}
|
||||||
|
var pb = ¶msBuffer{}
|
||||||
|
|
||||||
pb.Start(s)
|
pb.Start(s)
|
||||||
|
|
||||||
@ -373,7 +337,13 @@ func (t *Terminfo) TParm(s string, p ...interface{}) string {
|
|||||||
params[i] = p[i]
|
params[i] = p[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
nest := 0
|
const (
|
||||||
|
emit = iota
|
||||||
|
toEnd
|
||||||
|
toElse
|
||||||
|
)
|
||||||
|
|
||||||
|
skip := emit
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
||||||
@ -383,7 +353,9 @@ func (t *Terminfo) TParm(s string, p ...interface{}) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ch != '%' {
|
if ch != '%' {
|
||||||
pb.PutCh(ch)
|
if skip == emit {
|
||||||
|
pb.PutCh(ch)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,6 +364,17 @@ func (t *Terminfo) TParm(s string, p ...interface{}) string {
|
|||||||
// XXX Error
|
// XXX Error
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if skip == toEnd {
|
||||||
|
if ch == ';' {
|
||||||
|
skip = emit
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
} else if skip == toElse {
|
||||||
|
if ch == 'e' || ch == ';' {
|
||||||
|
skip = emit
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
switch ch {
|
switch ch {
|
||||||
case '%': // quoted %
|
case '%': // quoted %
|
||||||
@ -405,18 +388,23 @@ func (t *Terminfo) TParm(s string, p ...interface{}) string {
|
|||||||
params[1] = i + 1
|
params[1] = i + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'c', 's':
|
case 's':
|
||||||
// NB: these, and 'd' below are special cased for
|
// NB: 's', 'c', and 'd' below are special cased for
|
||||||
// efficiency. They could be handled by the richer
|
// efficiency. They could be handled by the richer
|
||||||
// format support below, less efficiently.
|
// format support below, less efficiently.
|
||||||
a, stk = stk.PopString()
|
a, stk = stk.PopString()
|
||||||
pb.PutString(a)
|
pb.PutString(a)
|
||||||
|
|
||||||
|
case 'c':
|
||||||
|
// Integer as special character.
|
||||||
|
ai, stk = stk.PopInt()
|
||||||
|
pb.PutCh(byte(ai))
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
ai, stk = stk.PopInt()
|
ai, stk = stk.PopInt()
|
||||||
pb.PutString(strconv.Itoa(ai))
|
pb.PutString(strconv.Itoa(ai))
|
||||||
|
|
||||||
case '0', '1', '2', '3', '4', 'x', 'X', 'o', ':':
|
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'x', 'X', 'o', ':':
|
||||||
// This is pretty suboptimal, but this is rarely used.
|
// This is pretty suboptimal, but this is rarely used.
|
||||||
// None of the mainstream terminals use any of this,
|
// None of the mainstream terminals use any of this,
|
||||||
// and it would surprise me if this code is ever
|
// and it would surprise me if this code is ever
|
||||||
@ -438,9 +426,12 @@ func (t *Terminfo) TParm(s string, p ...interface{}) string {
|
|||||||
case 'd', 'x', 'X', 'o':
|
case 'd', 'x', 'X', 'o':
|
||||||
ai, stk = stk.PopInt()
|
ai, stk = stk.PopInt()
|
||||||
pb.PutString(fmt.Sprintf(f, ai))
|
pb.PutString(fmt.Sprintf(f, ai))
|
||||||
case 'c', 's':
|
case 's':
|
||||||
a, stk = stk.PopString()
|
a, stk = stk.PopString()
|
||||||
pb.PutString(fmt.Sprintf(f, a))
|
pb.PutString(fmt.Sprintf(f, a))
|
||||||
|
case 'c':
|
||||||
|
ai, stk = stk.PopInt()
|
||||||
|
pb.PutString(fmt.Sprintf(f, ai))
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'p': // push parameter
|
case 'p': // push parameter
|
||||||
@ -468,10 +459,10 @@ func (t *Terminfo) TParm(s string, p ...interface{}) string {
|
|||||||
stk = stk.Push(dvars[int(ch-'a')])
|
stk = stk.Push(dvars[int(ch-'a')])
|
||||||
}
|
}
|
||||||
|
|
||||||
case '\'': // push(char)
|
case '\'': // push(char) - the integer value of it
|
||||||
ch, _ = pb.NextCh()
|
ch, _ = pb.NextCh()
|
||||||
_, _ = pb.NextCh() // must be ' but we don't check
|
_, _ = pb.NextCh() // must be ' but we don't check
|
||||||
stk = stk.Push(string(ch))
|
stk = stk.Push(int(ch))
|
||||||
|
|
||||||
case '{': // push(int)
|
case '{': // push(int)
|
||||||
ai = 0
|
ai = 0
|
||||||
@ -542,12 +533,12 @@ func (t *Terminfo) TParm(s string, p ...interface{}) string {
|
|||||||
|
|
||||||
case '!': // logical NOT
|
case '!': // logical NOT
|
||||||
ai, stk = stk.PopInt()
|
ai, stk = stk.PopInt()
|
||||||
stk = stk.Push(ai != 0)
|
stk = stk.Push(ai == 0)
|
||||||
|
|
||||||
case '=': // numeric compare or string compare
|
case '=': // numeric compare
|
||||||
b, stk = stk.PopString()
|
bi, stk = stk.PopInt()
|
||||||
a, stk = stk.PopString()
|
ai, stk = stk.PopInt()
|
||||||
stk = stk.Push(a == b)
|
stk = stk.Push(ai == bi)
|
||||||
|
|
||||||
case '>': // greater than, numeric
|
case '>': // greater than, numeric
|
||||||
bi, stk = stk.PopInt()
|
bi, stk = stk.PopInt()
|
||||||
@ -561,68 +552,20 @@ func (t *Terminfo) TParm(s string, p ...interface{}) string {
|
|||||||
|
|
||||||
case '?': // start conditional
|
case '?': // start conditional
|
||||||
|
|
||||||
|
case ';':
|
||||||
|
skip = emit
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
ab, stk = stk.PopBool()
|
ai, stk = stk.PopInt()
|
||||||
if ab {
|
if ai == 0 {
|
||||||
// just keep going
|
skip = toElse
|
||||||
break
|
|
||||||
}
|
|
||||||
nest = 0
|
|
||||||
ifloop:
|
|
||||||
// this loop consumes everything until we hit our else,
|
|
||||||
// or the end of the conditional
|
|
||||||
for {
|
|
||||||
ch, err = pb.NextCh()
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if ch != '%' {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
ch, _ = pb.NextCh()
|
|
||||||
switch ch {
|
|
||||||
case ';':
|
|
||||||
if nest == 0 {
|
|
||||||
break ifloop
|
|
||||||
}
|
|
||||||
nest--
|
|
||||||
case '?':
|
|
||||||
nest++
|
|
||||||
case 'e':
|
|
||||||
if nest == 0 {
|
|
||||||
break ifloop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'e':
|
case 'e':
|
||||||
// if we got here, it means we didn't use the else
|
skip = toEnd
|
||||||
// in the 't' case above, and we should skip until
|
|
||||||
// the end of the conditional
|
|
||||||
nest = 0
|
|
||||||
elloop:
|
|
||||||
for {
|
|
||||||
ch, err = pb.NextCh()
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if ch != '%' {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
ch, _ = pb.NextCh()
|
|
||||||
switch ch {
|
|
||||||
case ';':
|
|
||||||
if nest == 0 {
|
|
||||||
break elloop
|
|
||||||
}
|
|
||||||
nest--
|
|
||||||
case '?':
|
|
||||||
nest++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case ';': // endif
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
pb.PutString("%" + string(ch))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
vendor/github.com/gdamore/tcell/v2/terms_default.go
generated
vendored
1
vendor/github.com/gdamore/tcell/v2/terms_default.go
generated
vendored
@ -1,3 +1,4 @@
|
|||||||
|
//go:build !tcell_minimal
|
||||||
// +build !tcell_minimal
|
// +build !tcell_minimal
|
||||||
|
|
||||||
// Copyright 2019 The TCell Authors
|
// Copyright 2019 The TCell Authors
|
||||||
|
1
vendor/github.com/gdamore/tcell/v2/terms_dynamic.go
generated
vendored
1
vendor/github.com/gdamore/tcell/v2/terms_dynamic.go
generated
vendored
@ -1,3 +1,4 @@
|
|||||||
|
//go:build !tcell_minimal && !nacl && !js && !zos && !plan9 && !windows && !android
|
||||||
// +build !tcell_minimal,!nacl,!js,!zos,!plan9,!windows,!android
|
// +build !tcell_minimal,!nacl,!js,!zos,!plan9,!windows,!android
|
||||||
|
|
||||||
// Copyright 2019 The TCell Authors
|
// Copyright 2019 The TCell Authors
|
||||||
|
1
vendor/github.com/gdamore/tcell/v2/terms_static.go
generated
vendored
1
vendor/github.com/gdamore/tcell/v2/terms_static.go
generated
vendored
@ -1,3 +1,4 @@
|
|||||||
|
//go:build tcell_minimal || nacl || js || zos || plan9 || windows || android
|
||||||
// +build tcell_minimal nacl js zos plan9 windows android
|
// +build tcell_minimal nacl js zos plan9 windows android
|
||||||
|
|
||||||
// Copyright 2019 The TCell Authors
|
// Copyright 2019 The TCell Authors
|
||||||
|
43
vendor/github.com/gdamore/tcell/v2/tscreen.go
generated
vendored
43
vendor/github.com/gdamore/tcell/v2/tscreen.go
generated
vendored
@ -134,7 +134,6 @@ type tScreen struct {
|
|||||||
clear bool
|
clear bool
|
||||||
cursorx int
|
cursorx int
|
||||||
cursory int
|
cursory int
|
||||||
wasbtn bool
|
|
||||||
acs map[rune]string
|
acs map[rune]string
|
||||||
charset string
|
charset string
|
||||||
encoder transform.Transformer
|
encoder transform.Transformer
|
||||||
@ -199,9 +198,13 @@ func (t *tScreen) Init() error {
|
|||||||
if os.Getenv("TCELL_TRUECOLOR") == "disable" {
|
if os.Getenv("TCELL_TRUECOLOR") == "disable" {
|
||||||
t.truecolor = false
|
t.truecolor = false
|
||||||
}
|
}
|
||||||
t.colors = make(map[Color]Color)
|
nColors := t.nColors()
|
||||||
t.palette = make([]Color, t.nColors())
|
if nColors > 256 {
|
||||||
for i := 0; i < t.nColors(); i++ {
|
nColors = 256 // clip to reasonable limits
|
||||||
|
}
|
||||||
|
t.colors = make(map[Color]Color, nColors)
|
||||||
|
t.palette = make([]Color, nColors)
|
||||||
|
for i := 0; i < nColors; i++ {
|
||||||
t.palette[i] = Color(i) | ColorValid
|
t.palette[i] = Color(i) | ColorValid
|
||||||
// identity map for our builtin colors
|
// identity map for our builtin colors
|
||||||
t.colors[Color(i)|ColorValid] = Color(i) | ColorValid
|
t.colors[Color(i)|ColorValid] = Color(i) | ColorValid
|
||||||
@ -346,7 +349,7 @@ func (t *tScreen) prepareExtendedOSC() {
|
|||||||
t.enterUrl = t.ti.EnterUrl
|
t.enterUrl = t.ti.EnterUrl
|
||||||
t.exitUrl = t.ti.ExitUrl
|
t.exitUrl = t.ti.ExitUrl
|
||||||
} else if t.ti.Mouse != "" {
|
} else if t.ti.Mouse != "" {
|
||||||
t.enterUrl = "\x1b]8;;%p1%s\x1b\\"
|
t.enterUrl = "\x1b]8;%p2%s;%p1%s\x1b\\"
|
||||||
t.exitUrl = "\x1b]8;;\x1b\\"
|
t.exitUrl = "\x1b]8;;\x1b\\"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,18 +575,6 @@ func (t *tScreen) SetStyle(style Style) {
|
|||||||
|
|
||||||
func (t *tScreen) Clear() {
|
func (t *tScreen) Clear() {
|
||||||
t.Fill(' ', t.style)
|
t.Fill(' ', t.style)
|
||||||
t.Lock()
|
|
||||||
t.clear = true
|
|
||||||
w, h := t.cells.Size()
|
|
||||||
// because we are going to clear (see t.clear) in the next cycle,
|
|
||||||
// let's also unmark the dirty bit so that we don't waste cycles
|
|
||||||
// drawing things that are already dealt with via the clear escape sequence.
|
|
||||||
for row := 0; row < h; row++ {
|
|
||||||
for col := 0; col < w; col++ {
|
|
||||||
t.cells.SetDirty(col, row, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tScreen) Fill(r rune, style Style) {
|
func (t *tScreen) Fill(r rune, style Style) {
|
||||||
@ -794,7 +785,7 @@ func (t *tScreen) drawCell(x, y int) int {
|
|||||||
// URL string can be long, so don't send it unless we really need to
|
// URL string can be long, so don't send it unless we really need to
|
||||||
if t.enterUrl != "" && t.curstyle != style {
|
if t.enterUrl != "" && t.curstyle != style {
|
||||||
if style.url != "" {
|
if style.url != "" {
|
||||||
t.TPuts(ti.TParm(t.enterUrl, style.url))
|
t.TPuts(ti.TParm(t.enterUrl, style.url, style.urlId))
|
||||||
} else {
|
} else {
|
||||||
t.TPuts(t.exitUrl)
|
t.TPuts(t.exitUrl)
|
||||||
}
|
}
|
||||||
@ -1229,28 +1220,16 @@ func (t *tScreen) buildMouseEvent(x, y, btn int) *EventMouse {
|
|||||||
switch btn & 0x43 {
|
switch btn & 0x43 {
|
||||||
case 0:
|
case 0:
|
||||||
button = Button1
|
button = Button1
|
||||||
t.wasbtn = true
|
|
||||||
case 1:
|
case 1:
|
||||||
button = Button3 // Note we prefer to treat right as button 2
|
button = Button3 // Note we prefer to treat right as button 2
|
||||||
t.wasbtn = true
|
|
||||||
case 2:
|
case 2:
|
||||||
button = Button2 // And the middle button as button 3
|
button = Button2 // And the middle button as button 3
|
||||||
t.wasbtn = true
|
|
||||||
case 3:
|
case 3:
|
||||||
button = ButtonNone
|
button = ButtonNone
|
||||||
t.wasbtn = false
|
|
||||||
case 0x40:
|
case 0x40:
|
||||||
if !t.wasbtn {
|
button = WheelUp
|
||||||
button = WheelUp
|
|
||||||
} else {
|
|
||||||
button = Button1
|
|
||||||
}
|
|
||||||
case 0x41:
|
case 0x41:
|
||||||
if !t.wasbtn {
|
button = WheelDown
|
||||||
button = WheelDown
|
|
||||||
} else {
|
|
||||||
button = Button2
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if btn&0x4 != 0 {
|
if btn&0x4 != 0 {
|
||||||
|
11
vendor/github.com/gdamore/tcell/v2/tscreen_stub.go
generated
vendored
11
vendor/github.com/gdamore/tcell/v2/tscreen_stub.go
generated
vendored
@ -1,6 +1,7 @@
|
|||||||
|
//go:build js || plan9 || windows
|
||||||
// +build js plan9 windows
|
// +build js plan9 windows
|
||||||
|
|
||||||
// Copyright 2021 The TCell Authors
|
// Copyright 2022 The TCell Authors
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use file except in compliance with the License.
|
// you may not use file except in compliance with the License.
|
||||||
@ -21,5 +22,11 @@ package tcell
|
|||||||
// that we can obtain with the console API present on Windows.
|
// that we can obtain with the console API present on Windows.
|
||||||
|
|
||||||
func (t *tScreen) initialize() error {
|
func (t *tScreen) initialize() error {
|
||||||
return ErrNoScreen
|
if t.tty == nil {
|
||||||
|
return ErrNoScreen
|
||||||
|
}
|
||||||
|
// If a tty was supplied (custom), it should work.
|
||||||
|
// Custom screen implementations will need to provide a TTY
|
||||||
|
// implementation that we can use.
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
1
vendor/github.com/gdamore/tcell/v2/tscreen_unix.go
generated
vendored
1
vendor/github.com/gdamore/tcell/v2/tscreen_unix.go
generated
vendored
@ -12,6 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
|
||||||
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
|
||||||
|
|
||||||
package tcell
|
package tcell
|
||||||
|
2
vendor/github.com/gdamore/tcell/v2/tty.go
generated
vendored
2
vendor/github.com/gdamore/tcell/v2/tty.go
generated
vendored
@ -53,4 +53,4 @@ type Tty interface {
|
|||||||
WindowSize() (width int, height int, err error)
|
WindowSize() (width int, height int, err error)
|
||||||
|
|
||||||
io.ReadWriteCloser
|
io.ReadWriteCloser
|
||||||
}
|
}
|
||||||
|
1
vendor/github.com/gdamore/tcell/v2/tty_unix.go
generated
vendored
1
vendor/github.com/gdamore/tcell/v2/tty_unix.go
generated
vendored
@ -12,6 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
|
||||||
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
|
||||||
|
|
||||||
package tcell
|
package tcell
|
||||||
|
5
vendor/github.com/jesseduffield/gocui/gui.go
generated
vendored
5
vendor/github.com/jesseduffield/gocui/gui.go
generated
vendored
@ -5,6 +5,7 @@
|
|||||||
package gocui
|
package gocui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
standardErrors "errors"
|
standardErrors "errors"
|
||||||
"log"
|
"log"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -1357,7 +1358,7 @@ func (g *Gui) execKeybinding(v *View, kb *keybinding) (bool, error) {
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Gui) StartTicking() {
|
func (g *Gui) StartTicking(ctx context.Context) {
|
||||||
go func() {
|
go func() {
|
||||||
g.Mutexes.tickingMutex.Lock()
|
g.Mutexes.tickingMutex.Lock()
|
||||||
defer g.Mutexes.tickingMutex.Unlock()
|
defer g.Mutexes.tickingMutex.Unlock()
|
||||||
@ -1379,6 +1380,8 @@ func (g *Gui) StartTicking() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
case <-g.stop:
|
case <-g.stop:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
3
vendor/golang.org/x/crypto/chacha20/chacha_arm64.go
generated
vendored
3
vendor/golang.org/x/crypto/chacha20/chacha_arm64.go
generated
vendored
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build go1.11,!gccgo,!purego
|
//go:build go1.11 && gc && !purego
|
||||||
|
// +build go1.11,gc,!purego
|
||||||
|
|
||||||
package chacha20
|
package chacha20
|
||||||
|
|
||||||
|
3
vendor/golang.org/x/crypto/chacha20/chacha_arm64.s
generated
vendored
3
vendor/golang.org/x/crypto/chacha20/chacha_arm64.s
generated
vendored
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build go1.11,!gccgo,!purego
|
//go:build go1.11 && gc && !purego
|
||||||
|
// +build go1.11,gc,!purego
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
3
vendor/golang.org/x/crypto/chacha20/chacha_noasm.go
generated
vendored
3
vendor/golang.org/x/crypto/chacha20/chacha_noasm.go
generated
vendored
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !arm64,!s390x,!ppc64le arm64,!go1.11 gccgo purego
|
//go:build (!arm64 && !s390x && !ppc64le) || (arm64 && !go1.11) || !gc || purego
|
||||||
|
// +build !arm64,!s390x,!ppc64le arm64,!go1.11 !gc purego
|
||||||
|
|
||||||
package chacha20
|
package chacha20
|
||||||
|
|
||||||
|
3
vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go
generated
vendored
3
vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go
generated
vendored
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo,!purego
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
package chacha20
|
package chacha20
|
||||||
|
|
||||||
|
3
vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.s
generated
vendored
3
vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.s
generated
vendored
@ -19,7 +19,8 @@
|
|||||||
// The differences in this and the original implementation are
|
// The differences in this and the original implementation are
|
||||||
// due to the calling conventions and initialization of constants.
|
// due to the calling conventions and initialization of constants.
|
||||||
|
|
||||||
// +build !gccgo,!purego
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
3
vendor/golang.org/x/crypto/chacha20/chacha_s390x.go
generated
vendored
3
vendor/golang.org/x/crypto/chacha20/chacha_s390x.go
generated
vendored
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo,!purego
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
package chacha20
|
package chacha20
|
||||||
|
|
||||||
|
3
vendor/golang.org/x/crypto/chacha20/chacha_s390x.s
generated
vendored
3
vendor/golang.org/x/crypto/chacha20/chacha_s390x.s
generated
vendored
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo,!purego
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
#include "go_asm.h"
|
#include "go_asm.h"
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
52
vendor/golang.org/x/crypto/curve25519/curve25519.go
generated
vendored
52
vendor/golang.org/x/crypto/curve25519/curve25519.go
generated
vendored
@ -10,6 +10,8 @@ package curve25519 // import "golang.org/x/crypto/curve25519"
|
|||||||
import (
|
import (
|
||||||
"crypto/subtle"
|
"crypto/subtle"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/curve25519/internal/field"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ScalarMult sets dst to the product scalar * point.
|
// ScalarMult sets dst to the product scalar * point.
|
||||||
@ -18,7 +20,55 @@ import (
|
|||||||
// zeroes, irrespective of the scalar. Instead, use the X25519 function, which
|
// zeroes, irrespective of the scalar. Instead, use the X25519 function, which
|
||||||
// will return an error.
|
// will return an error.
|
||||||
func ScalarMult(dst, scalar, point *[32]byte) {
|
func ScalarMult(dst, scalar, point *[32]byte) {
|
||||||
scalarMult(dst, scalar, point)
|
var e [32]byte
|
||||||
|
|
||||||
|
copy(e[:], scalar[:])
|
||||||
|
e[0] &= 248
|
||||||
|
e[31] &= 127
|
||||||
|
e[31] |= 64
|
||||||
|
|
||||||
|
var x1, x2, z2, x3, z3, tmp0, tmp1 field.Element
|
||||||
|
x1.SetBytes(point[:])
|
||||||
|
x2.One()
|
||||||
|
x3.Set(&x1)
|
||||||
|
z3.One()
|
||||||
|
|
||||||
|
swap := 0
|
||||||
|
for pos := 254; pos >= 0; pos-- {
|
||||||
|
b := e[pos/8] >> uint(pos&7)
|
||||||
|
b &= 1
|
||||||
|
swap ^= int(b)
|
||||||
|
x2.Swap(&x3, swap)
|
||||||
|
z2.Swap(&z3, swap)
|
||||||
|
swap = int(b)
|
||||||
|
|
||||||
|
tmp0.Subtract(&x3, &z3)
|
||||||
|
tmp1.Subtract(&x2, &z2)
|
||||||
|
x2.Add(&x2, &z2)
|
||||||
|
z2.Add(&x3, &z3)
|
||||||
|
z3.Multiply(&tmp0, &x2)
|
||||||
|
z2.Multiply(&z2, &tmp1)
|
||||||
|
tmp0.Square(&tmp1)
|
||||||
|
tmp1.Square(&x2)
|
||||||
|
x3.Add(&z3, &z2)
|
||||||
|
z2.Subtract(&z3, &z2)
|
||||||
|
x2.Multiply(&tmp1, &tmp0)
|
||||||
|
tmp1.Subtract(&tmp1, &tmp0)
|
||||||
|
z2.Square(&z2)
|
||||||
|
|
||||||
|
z3.Mult32(&tmp1, 121666)
|
||||||
|
x3.Square(&x3)
|
||||||
|
tmp0.Add(&tmp0, &z3)
|
||||||
|
z3.Multiply(&x1, &z2)
|
||||||
|
z2.Multiply(&tmp1, &tmp0)
|
||||||
|
}
|
||||||
|
|
||||||
|
x2.Swap(&x3, swap)
|
||||||
|
z2.Swap(&z3, swap)
|
||||||
|
|
||||||
|
z2.Invert(&z2)
|
||||||
|
x2.Multiply(&x2, &z2)
|
||||||
|
copy(dst[:], x2.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScalarBaseMult sets dst to the product scalar * base where base is the
|
// ScalarBaseMult sets dst to the product scalar * base where base is the
|
||||||
|
240
vendor/golang.org/x/crypto/curve25519/curve25519_amd64.go
generated
vendored
240
vendor/golang.org/x/crypto/curve25519/curve25519_amd64.go
generated
vendored
@ -1,240 +0,0 @@
|
|||||||
// Copyright 2012 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build amd64,!gccgo,!appengine,!purego
|
|
||||||
|
|
||||||
package curve25519
|
|
||||||
|
|
||||||
// These functions are implemented in the .s files. The names of the functions
|
|
||||||
// in the rest of the file are also taken from the SUPERCOP sources to help
|
|
||||||
// people following along.
|
|
||||||
|
|
||||||
//go:noescape
|
|
||||||
|
|
||||||
func cswap(inout *[5]uint64, v uint64)
|
|
||||||
|
|
||||||
//go:noescape
|
|
||||||
|
|
||||||
func ladderstep(inout *[5][5]uint64)
|
|
||||||
|
|
||||||
//go:noescape
|
|
||||||
|
|
||||||
func freeze(inout *[5]uint64)
|
|
||||||
|
|
||||||
//go:noescape
|
|
||||||
|
|
||||||
func mul(dest, a, b *[5]uint64)
|
|
||||||
|
|
||||||
//go:noescape
|
|
||||||
|
|
||||||
func square(out, in *[5]uint64)
|
|
||||||
|
|
||||||
// mladder uses a Montgomery ladder to calculate (xr/zr) *= s.
|
|
||||||
func mladder(xr, zr *[5]uint64, s *[32]byte) {
|
|
||||||
var work [5][5]uint64
|
|
||||||
|
|
||||||
work[0] = *xr
|
|
||||||
setint(&work[1], 1)
|
|
||||||
setint(&work[2], 0)
|
|
||||||
work[3] = *xr
|
|
||||||
setint(&work[4], 1)
|
|
||||||
|
|
||||||
j := uint(6)
|
|
||||||
var prevbit byte
|
|
||||||
|
|
||||||
for i := 31; i >= 0; i-- {
|
|
||||||
for j < 8 {
|
|
||||||
bit := ((*s)[i] >> j) & 1
|
|
||||||
swap := bit ^ prevbit
|
|
||||||
prevbit = bit
|
|
||||||
cswap(&work[1], uint64(swap))
|
|
||||||
ladderstep(&work)
|
|
||||||
j--
|
|
||||||
}
|
|
||||||
j = 7
|
|
||||||
}
|
|
||||||
|
|
||||||
*xr = work[1]
|
|
||||||
*zr = work[2]
|
|
||||||
}
|
|
||||||
|
|
||||||
func scalarMult(out, in, base *[32]byte) {
|
|
||||||
var e [32]byte
|
|
||||||
copy(e[:], (*in)[:])
|
|
||||||
e[0] &= 248
|
|
||||||
e[31] &= 127
|
|
||||||
e[31] |= 64
|
|
||||||
|
|
||||||
var t, z [5]uint64
|
|
||||||
unpack(&t, base)
|
|
||||||
mladder(&t, &z, &e)
|
|
||||||
invert(&z, &z)
|
|
||||||
mul(&t, &t, &z)
|
|
||||||
pack(out, &t)
|
|
||||||
}
|
|
||||||
|
|
||||||
func setint(r *[5]uint64, v uint64) {
|
|
||||||
r[0] = v
|
|
||||||
r[1] = 0
|
|
||||||
r[2] = 0
|
|
||||||
r[3] = 0
|
|
||||||
r[4] = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// unpack sets r = x where r consists of 5, 51-bit limbs in little-endian
|
|
||||||
// order.
|
|
||||||
func unpack(r *[5]uint64, x *[32]byte) {
|
|
||||||
r[0] = uint64(x[0]) |
|
|
||||||
uint64(x[1])<<8 |
|
|
||||||
uint64(x[2])<<16 |
|
|
||||||
uint64(x[3])<<24 |
|
|
||||||
uint64(x[4])<<32 |
|
|
||||||
uint64(x[5])<<40 |
|
|
||||||
uint64(x[6]&7)<<48
|
|
||||||
|
|
||||||
r[1] = uint64(x[6])>>3 |
|
|
||||||
uint64(x[7])<<5 |
|
|
||||||
uint64(x[8])<<13 |
|
|
||||||
uint64(x[9])<<21 |
|
|
||||||
uint64(x[10])<<29 |
|
|
||||||
uint64(x[11])<<37 |
|
|
||||||
uint64(x[12]&63)<<45
|
|
||||||
|
|
||||||
r[2] = uint64(x[12])>>6 |
|
|
||||||
uint64(x[13])<<2 |
|
|
||||||
uint64(x[14])<<10 |
|
|
||||||
uint64(x[15])<<18 |
|
|
||||||
uint64(x[16])<<26 |
|
|
||||||
uint64(x[17])<<34 |
|
|
||||||
uint64(x[18])<<42 |
|
|
||||||
uint64(x[19]&1)<<50
|
|
||||||
|
|
||||||
r[3] = uint64(x[19])>>1 |
|
|
||||||
uint64(x[20])<<7 |
|
|
||||||
uint64(x[21])<<15 |
|
|
||||||
uint64(x[22])<<23 |
|
|
||||||
uint64(x[23])<<31 |
|
|
||||||
uint64(x[24])<<39 |
|
|
||||||
uint64(x[25]&15)<<47
|
|
||||||
|
|
||||||
r[4] = uint64(x[25])>>4 |
|
|
||||||
uint64(x[26])<<4 |
|
|
||||||
uint64(x[27])<<12 |
|
|
||||||
uint64(x[28])<<20 |
|
|
||||||
uint64(x[29])<<28 |
|
|
||||||
uint64(x[30])<<36 |
|
|
||||||
uint64(x[31]&127)<<44
|
|
||||||
}
|
|
||||||
|
|
||||||
// pack sets out = x where out is the usual, little-endian form of the 5,
|
|
||||||
// 51-bit limbs in x.
|
|
||||||
func pack(out *[32]byte, x *[5]uint64) {
|
|
||||||
t := *x
|
|
||||||
freeze(&t)
|
|
||||||
|
|
||||||
out[0] = byte(t[0])
|
|
||||||
out[1] = byte(t[0] >> 8)
|
|
||||||
out[2] = byte(t[0] >> 16)
|
|
||||||
out[3] = byte(t[0] >> 24)
|
|
||||||
out[4] = byte(t[0] >> 32)
|
|
||||||
out[5] = byte(t[0] >> 40)
|
|
||||||
out[6] = byte(t[0] >> 48)
|
|
||||||
|
|
||||||
out[6] ^= byte(t[1]<<3) & 0xf8
|
|
||||||
out[7] = byte(t[1] >> 5)
|
|
||||||
out[8] = byte(t[1] >> 13)
|
|
||||||
out[9] = byte(t[1] >> 21)
|
|
||||||
out[10] = byte(t[1] >> 29)
|
|
||||||
out[11] = byte(t[1] >> 37)
|
|
||||||
out[12] = byte(t[1] >> 45)
|
|
||||||
|
|
||||||
out[12] ^= byte(t[2]<<6) & 0xc0
|
|
||||||
out[13] = byte(t[2] >> 2)
|
|
||||||
out[14] = byte(t[2] >> 10)
|
|
||||||
out[15] = byte(t[2] >> 18)
|
|
||||||
out[16] = byte(t[2] >> 26)
|
|
||||||
out[17] = byte(t[2] >> 34)
|
|
||||||
out[18] = byte(t[2] >> 42)
|
|
||||||
out[19] = byte(t[2] >> 50)
|
|
||||||
|
|
||||||
out[19] ^= byte(t[3]<<1) & 0xfe
|
|
||||||
out[20] = byte(t[3] >> 7)
|
|
||||||
out[21] = byte(t[3] >> 15)
|
|
||||||
out[22] = byte(t[3] >> 23)
|
|
||||||
out[23] = byte(t[3] >> 31)
|
|
||||||
out[24] = byte(t[3] >> 39)
|
|
||||||
out[25] = byte(t[3] >> 47)
|
|
||||||
|
|
||||||
out[25] ^= byte(t[4]<<4) & 0xf0
|
|
||||||
out[26] = byte(t[4] >> 4)
|
|
||||||
out[27] = byte(t[4] >> 12)
|
|
||||||
out[28] = byte(t[4] >> 20)
|
|
||||||
out[29] = byte(t[4] >> 28)
|
|
||||||
out[30] = byte(t[4] >> 36)
|
|
||||||
out[31] = byte(t[4] >> 44)
|
|
||||||
}
|
|
||||||
|
|
||||||
// invert calculates r = x^-1 mod p using Fermat's little theorem.
|
|
||||||
func invert(r *[5]uint64, x *[5]uint64) {
|
|
||||||
var z2, z9, z11, z2_5_0, z2_10_0, z2_20_0, z2_50_0, z2_100_0, t [5]uint64
|
|
||||||
|
|
||||||
square(&z2, x) /* 2 */
|
|
||||||
square(&t, &z2) /* 4 */
|
|
||||||
square(&t, &t) /* 8 */
|
|
||||||
mul(&z9, &t, x) /* 9 */
|
|
||||||
mul(&z11, &z9, &z2) /* 11 */
|
|
||||||
square(&t, &z11) /* 22 */
|
|
||||||
mul(&z2_5_0, &t, &z9) /* 2^5 - 2^0 = 31 */
|
|
||||||
|
|
||||||
square(&t, &z2_5_0) /* 2^6 - 2^1 */
|
|
||||||
for i := 1; i < 5; i++ { /* 2^20 - 2^10 */
|
|
||||||
square(&t, &t)
|
|
||||||
}
|
|
||||||
mul(&z2_10_0, &t, &z2_5_0) /* 2^10 - 2^0 */
|
|
||||||
|
|
||||||
square(&t, &z2_10_0) /* 2^11 - 2^1 */
|
|
||||||
for i := 1; i < 10; i++ { /* 2^20 - 2^10 */
|
|
||||||
square(&t, &t)
|
|
||||||
}
|
|
||||||
mul(&z2_20_0, &t, &z2_10_0) /* 2^20 - 2^0 */
|
|
||||||
|
|
||||||
square(&t, &z2_20_0) /* 2^21 - 2^1 */
|
|
||||||
for i := 1; i < 20; i++ { /* 2^40 - 2^20 */
|
|
||||||
square(&t, &t)
|
|
||||||
}
|
|
||||||
mul(&t, &t, &z2_20_0) /* 2^40 - 2^0 */
|
|
||||||
|
|
||||||
square(&t, &t) /* 2^41 - 2^1 */
|
|
||||||
for i := 1; i < 10; i++ { /* 2^50 - 2^10 */
|
|
||||||
square(&t, &t)
|
|
||||||
}
|
|
||||||
mul(&z2_50_0, &t, &z2_10_0) /* 2^50 - 2^0 */
|
|
||||||
|
|
||||||
square(&t, &z2_50_0) /* 2^51 - 2^1 */
|
|
||||||
for i := 1; i < 50; i++ { /* 2^100 - 2^50 */
|
|
||||||
square(&t, &t)
|
|
||||||
}
|
|
||||||
mul(&z2_100_0, &t, &z2_50_0) /* 2^100 - 2^0 */
|
|
||||||
|
|
||||||
square(&t, &z2_100_0) /* 2^101 - 2^1 */
|
|
||||||
for i := 1; i < 100; i++ { /* 2^200 - 2^100 */
|
|
||||||
square(&t, &t)
|
|
||||||
}
|
|
||||||
mul(&t, &t, &z2_100_0) /* 2^200 - 2^0 */
|
|
||||||
|
|
||||||
square(&t, &t) /* 2^201 - 2^1 */
|
|
||||||
for i := 1; i < 50; i++ { /* 2^250 - 2^50 */
|
|
||||||
square(&t, &t)
|
|
||||||
}
|
|
||||||
mul(&t, &t, &z2_50_0) /* 2^250 - 2^0 */
|
|
||||||
|
|
||||||
square(&t, &t) /* 2^251 - 2^1 */
|
|
||||||
square(&t, &t) /* 2^252 - 2^2 */
|
|
||||||
square(&t, &t) /* 2^253 - 2^3 */
|
|
||||||
|
|
||||||
square(&t, &t) /* 2^254 - 2^4 */
|
|
||||||
|
|
||||||
square(&t, &t) /* 2^255 - 2^5 */
|
|
||||||
mul(r, &t, &z11) /* 2^255 - 21 */
|
|
||||||
}
|
|
1793
vendor/golang.org/x/crypto/curve25519/curve25519_amd64.s
generated
vendored
1793
vendor/golang.org/x/crypto/curve25519/curve25519_amd64.s
generated
vendored
File diff suppressed because it is too large
Load Diff
828
vendor/golang.org/x/crypto/curve25519/curve25519_generic.go
generated
vendored
828
vendor/golang.org/x/crypto/curve25519/curve25519_generic.go
generated
vendored
@ -1,828 +0,0 @@
|
|||||||
// Copyright 2013 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package curve25519
|
|
||||||
|
|
||||||
import "encoding/binary"
|
|
||||||
|
|
||||||
// This code is a port of the public domain, "ref10" implementation of
|
|
||||||
// curve25519 from SUPERCOP 20130419 by D. J. Bernstein.
|
|
||||||
|
|
||||||
// fieldElement represents an element of the field GF(2^255 - 19). An element
|
|
||||||
// t, entries t[0]...t[9], represents the integer t[0]+2^26 t[1]+2^51 t[2]+2^77
|
|
||||||
// t[3]+2^102 t[4]+...+2^230 t[9]. Bounds on each t[i] vary depending on
|
|
||||||
// context.
|
|
||||||
type fieldElement [10]int32
|
|
||||||
|
|
||||||
func feZero(fe *fieldElement) {
|
|
||||||
for i := range fe {
|
|
||||||
fe[i] = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func feOne(fe *fieldElement) {
|
|
||||||
feZero(fe)
|
|
||||||
fe[0] = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
func feAdd(dst, a, b *fieldElement) {
|
|
||||||
for i := range dst {
|
|
||||||
dst[i] = a[i] + b[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func feSub(dst, a, b *fieldElement) {
|
|
||||||
for i := range dst {
|
|
||||||
dst[i] = a[i] - b[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func feCopy(dst, src *fieldElement) {
|
|
||||||
for i := range dst {
|
|
||||||
dst[i] = src[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// feCSwap replaces (f,g) with (g,f) if b == 1; replaces (f,g) with (f,g) if b == 0.
|
|
||||||
//
|
|
||||||
// Preconditions: b in {0,1}.
|
|
||||||
func feCSwap(f, g *fieldElement, b int32) {
|
|
||||||
b = -b
|
|
||||||
for i := range f {
|
|
||||||
t := b & (f[i] ^ g[i])
|
|
||||||
f[i] ^= t
|
|
||||||
g[i] ^= t
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// load3 reads a 24-bit, little-endian value from in.
|
|
||||||
func load3(in []byte) int64 {
|
|
||||||
var r int64
|
|
||||||
r = int64(in[0])
|
|
||||||
r |= int64(in[1]) << 8
|
|
||||||
r |= int64(in[2]) << 16
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
// load4 reads a 32-bit, little-endian value from in.
|
|
||||||
func load4(in []byte) int64 {
|
|
||||||
return int64(binary.LittleEndian.Uint32(in))
|
|
||||||
}
|
|
||||||
|
|
||||||
func feFromBytes(dst *fieldElement, src *[32]byte) {
|
|
||||||
h0 := load4(src[:])
|
|
||||||
h1 := load3(src[4:]) << 6
|
|
||||||
h2 := load3(src[7:]) << 5
|
|
||||||
h3 := load3(src[10:]) << 3
|
|
||||||
h4 := load3(src[13:]) << 2
|
|
||||||
h5 := load4(src[16:])
|
|
||||||
h6 := load3(src[20:]) << 7
|
|
||||||
h7 := load3(src[23:]) << 5
|
|
||||||
h8 := load3(src[26:]) << 4
|
|
||||||
h9 := (load3(src[29:]) & 0x7fffff) << 2
|
|
||||||
|
|
||||||
var carry [10]int64
|
|
||||||
carry[9] = (h9 + 1<<24) >> 25
|
|
||||||
h0 += carry[9] * 19
|
|
||||||
h9 -= carry[9] << 25
|
|
||||||
carry[1] = (h1 + 1<<24) >> 25
|
|
||||||
h2 += carry[1]
|
|
||||||
h1 -= carry[1] << 25
|
|
||||||
carry[3] = (h3 + 1<<24) >> 25
|
|
||||||
h4 += carry[3]
|
|
||||||
h3 -= carry[3] << 25
|
|
||||||
carry[5] = (h5 + 1<<24) >> 25
|
|
||||||
h6 += carry[5]
|
|
||||||
h5 -= carry[5] << 25
|
|
||||||
carry[7] = (h7 + 1<<24) >> 25
|
|
||||||
h8 += carry[7]
|
|
||||||
h7 -= carry[7] << 25
|
|
||||||
|
|
||||||
carry[0] = (h0 + 1<<25) >> 26
|
|
||||||
h1 += carry[0]
|
|
||||||
h0 -= carry[0] << 26
|
|
||||||
carry[2] = (h2 + 1<<25) >> 26
|
|
||||||
h3 += carry[2]
|
|
||||||
h2 -= carry[2] << 26
|
|
||||||
carry[4] = (h4 + 1<<25) >> 26
|
|
||||||
h5 += carry[4]
|
|
||||||
h4 -= carry[4] << 26
|
|
||||||
carry[6] = (h6 + 1<<25) >> 26
|
|
||||||
h7 += carry[6]
|
|
||||||
h6 -= carry[6] << 26
|
|
||||||
carry[8] = (h8 + 1<<25) >> 26
|
|
||||||
h9 += carry[8]
|
|
||||||
h8 -= carry[8] << 26
|
|
||||||
|
|
||||||
dst[0] = int32(h0)
|
|
||||||
dst[1] = int32(h1)
|
|
||||||
dst[2] = int32(h2)
|
|
||||||
dst[3] = int32(h3)
|
|
||||||
dst[4] = int32(h4)
|
|
||||||
dst[5] = int32(h5)
|
|
||||||
dst[6] = int32(h6)
|
|
||||||
dst[7] = int32(h7)
|
|
||||||
dst[8] = int32(h8)
|
|
||||||
dst[9] = int32(h9)
|
|
||||||
}
|
|
||||||
|
|
||||||
// feToBytes marshals h to s.
|
|
||||||
// Preconditions:
|
|
||||||
// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
|
|
||||||
//
|
|
||||||
// Write p=2^255-19; q=floor(h/p).
|
|
||||||
// Basic claim: q = floor(2^(-255)(h + 19 2^(-25)h9 + 2^(-1))).
|
|
||||||
//
|
|
||||||
// Proof:
|
|
||||||
// Have |h|<=p so |q|<=1 so |19^2 2^(-255) q|<1/4.
|
|
||||||
// Also have |h-2^230 h9|<2^230 so |19 2^(-255)(h-2^230 h9)|<1/4.
|
|
||||||
//
|
|
||||||
// Write y=2^(-1)-19^2 2^(-255)q-19 2^(-255)(h-2^230 h9).
|
|
||||||
// Then 0<y<1.
|
|
||||||
//
|
|
||||||
// Write r=h-pq.
|
|
||||||
// Have 0<=r<=p-1=2^255-20.
|
|
||||||
// Thus 0<=r+19(2^-255)r<r+19(2^-255)2^255<=2^255-1.
|
|
||||||
//
|
|
||||||
// Write x=r+19(2^-255)r+y.
|
|
||||||
// Then 0<x<2^255 so floor(2^(-255)x) = 0 so floor(q+2^(-255)x) = q.
|
|
||||||
//
|
|
||||||
// Have q+2^(-255)x = 2^(-255)(h + 19 2^(-25) h9 + 2^(-1))
|
|
||||||
// so floor(2^(-255)(h + 19 2^(-25) h9 + 2^(-1))) = q.
|
|
||||||
func feToBytes(s *[32]byte, h *fieldElement) {
|
|
||||||
var carry [10]int32
|
|
||||||
|
|
||||||
q := (19*h[9] + (1 << 24)) >> 25
|
|
||||||
q = (h[0] + q) >> 26
|
|
||||||
q = (h[1] + q) >> 25
|
|
||||||
q = (h[2] + q) >> 26
|
|
||||||
q = (h[3] + q) >> 25
|
|
||||||
q = (h[4] + q) >> 26
|
|
||||||
q = (h[5] + q) >> 25
|
|
||||||
q = (h[6] + q) >> 26
|
|
||||||
q = (h[7] + q) >> 25
|
|
||||||
q = (h[8] + q) >> 26
|
|
||||||
q = (h[9] + q) >> 25
|
|
||||||
|
|
||||||
// Goal: Output h-(2^255-19)q, which is between 0 and 2^255-20.
|
|
||||||
h[0] += 19 * q
|
|
||||||
// Goal: Output h-2^255 q, which is between 0 and 2^255-20.
|
|
||||||
|
|
||||||
carry[0] = h[0] >> 26
|
|
||||||
h[1] += carry[0]
|
|
||||||
h[0] -= carry[0] << 26
|
|
||||||
carry[1] = h[1] >> 25
|
|
||||||
h[2] += carry[1]
|
|
||||||
h[1] -= carry[1] << 25
|
|
||||||
carry[2] = h[2] >> 26
|
|
||||||
h[3] += carry[2]
|
|
||||||
h[2] -= carry[2] << 26
|
|
||||||
carry[3] = h[3] >> 25
|
|
||||||
h[4] += carry[3]
|
|
||||||
h[3] -= carry[3] << 25
|
|
||||||
carry[4] = h[4] >> 26
|
|
||||||
h[5] += carry[4]
|
|
||||||
h[4] -= carry[4] << 26
|
|
||||||
carry[5] = h[5] >> 25
|
|
||||||
h[6] += carry[5]
|
|
||||||
h[5] -= carry[5] << 25
|
|
||||||
carry[6] = h[6] >> 26
|
|
||||||
h[7] += carry[6]
|
|
||||||
h[6] -= carry[6] << 26
|
|
||||||
carry[7] = h[7] >> 25
|
|
||||||
h[8] += carry[7]
|
|
||||||
h[7] -= carry[7] << 25
|
|
||||||
carry[8] = h[8] >> 26
|
|
||||||
h[9] += carry[8]
|
|
||||||
h[8] -= carry[8] << 26
|
|
||||||
carry[9] = h[9] >> 25
|
|
||||||
h[9] -= carry[9] << 25
|
|
||||||
// h10 = carry9
|
|
||||||
|
|
||||||
// Goal: Output h[0]+...+2^255 h10-2^255 q, which is between 0 and 2^255-20.
|
|
||||||
// Have h[0]+...+2^230 h[9] between 0 and 2^255-1;
|
|
||||||
// evidently 2^255 h10-2^255 q = 0.
|
|
||||||
// Goal: Output h[0]+...+2^230 h[9].
|
|
||||||
|
|
||||||
s[0] = byte(h[0] >> 0)
|
|
||||||
s[1] = byte(h[0] >> 8)
|
|
||||||
s[2] = byte(h[0] >> 16)
|
|
||||||
s[3] = byte((h[0] >> 24) | (h[1] << 2))
|
|
||||||
s[4] = byte(h[1] >> 6)
|
|
||||||
s[5] = byte(h[1] >> 14)
|
|
||||||
s[6] = byte((h[1] >> 22) | (h[2] << 3))
|
|
||||||
s[7] = byte(h[2] >> 5)
|
|
||||||
s[8] = byte(h[2] >> 13)
|
|
||||||
s[9] = byte((h[2] >> 21) | (h[3] << 5))
|
|
||||||
s[10] = byte(h[3] >> 3)
|
|
||||||
s[11] = byte(h[3] >> 11)
|
|
||||||
s[12] = byte((h[3] >> 19) | (h[4] << 6))
|
|
||||||
s[13] = byte(h[4] >> 2)
|
|
||||||
s[14] = byte(h[4] >> 10)
|
|
||||||
s[15] = byte(h[4] >> 18)
|
|
||||||
s[16] = byte(h[5] >> 0)
|
|
||||||
s[17] = byte(h[5] >> 8)
|
|
||||||
s[18] = byte(h[5] >> 16)
|
|
||||||
s[19] = byte((h[5] >> 24) | (h[6] << 1))
|
|
||||||
s[20] = byte(h[6] >> 7)
|
|
||||||
s[21] = byte(h[6] >> 15)
|
|
||||||
s[22] = byte((h[6] >> 23) | (h[7] << 3))
|
|
||||||
s[23] = byte(h[7] >> 5)
|
|
||||||
s[24] = byte(h[7] >> 13)
|
|
||||||
s[25] = byte((h[7] >> 21) | (h[8] << 4))
|
|
||||||
s[26] = byte(h[8] >> 4)
|
|
||||||
s[27] = byte(h[8] >> 12)
|
|
||||||
s[28] = byte((h[8] >> 20) | (h[9] << 6))
|
|
||||||
s[29] = byte(h[9] >> 2)
|
|
||||||
s[30] = byte(h[9] >> 10)
|
|
||||||
s[31] = byte(h[9] >> 18)
|
|
||||||
}
|
|
||||||
|
|
||||||
// feMul calculates h = f * g
|
|
||||||
// Can overlap h with f or g.
|
|
||||||
//
|
|
||||||
// Preconditions:
|
|
||||||
// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
|
|
||||||
// |g| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
|
|
||||||
//
|
|
||||||
// Postconditions:
|
|
||||||
// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
|
|
||||||
//
|
|
||||||
// Notes on implementation strategy:
|
|
||||||
//
|
|
||||||
// Using schoolbook multiplication.
|
|
||||||
// Karatsuba would save a little in some cost models.
|
|
||||||
//
|
|
||||||
// Most multiplications by 2 and 19 are 32-bit precomputations;
|
|
||||||
// cheaper than 64-bit postcomputations.
|
|
||||||
//
|
|
||||||
// There is one remaining multiplication by 19 in the carry chain;
|
|
||||||
// one *19 precomputation can be merged into this,
|
|
||||||
// but the resulting data flow is considerably less clean.
|
|
||||||
//
|
|
||||||
// There are 12 carries below.
|
|
||||||
// 10 of them are 2-way parallelizable and vectorizable.
|
|
||||||
// Can get away with 11 carries, but then data flow is much deeper.
|
|
||||||
//
|
|
||||||
// With tighter constraints on inputs can squeeze carries into int32.
|
|
||||||
func feMul(h, f, g *fieldElement) {
|
|
||||||
f0 := f[0]
|
|
||||||
f1 := f[1]
|
|
||||||
f2 := f[2]
|
|
||||||
f3 := f[3]
|
|
||||||
f4 := f[4]
|
|
||||||
f5 := f[5]
|
|
||||||
f6 := f[6]
|
|
||||||
f7 := f[7]
|
|
||||||
f8 := f[8]
|
|
||||||
f9 := f[9]
|
|
||||||
g0 := g[0]
|
|
||||||
g1 := g[1]
|
|
||||||
g2 := g[2]
|
|
||||||
g3 := g[3]
|
|
||||||
g4 := g[4]
|
|
||||||
g5 := g[5]
|
|
||||||
g6 := g[6]
|
|
||||||
g7 := g[7]
|
|
||||||
g8 := g[8]
|
|
||||||
g9 := g[9]
|
|
||||||
g1_19 := 19 * g1 // 1.4*2^29
|
|
||||||
g2_19 := 19 * g2 // 1.4*2^30; still ok
|
|
||||||
g3_19 := 19 * g3
|
|
||||||
g4_19 := 19 * g4
|
|
||||||
g5_19 := 19 * g5
|
|
||||||
g6_19 := 19 * g6
|
|
||||||
g7_19 := 19 * g7
|
|
||||||
g8_19 := 19 * g8
|
|
||||||
g9_19 := 19 * g9
|
|
||||||
f1_2 := 2 * f1
|
|
||||||
f3_2 := 2 * f3
|
|
||||||
f5_2 := 2 * f5
|
|
||||||
f7_2 := 2 * f7
|
|
||||||
f9_2 := 2 * f9
|
|
||||||
f0g0 := int64(f0) * int64(g0)
|
|
||||||
f0g1 := int64(f0) * int64(g1)
|
|
||||||
f0g2 := int64(f0) * int64(g2)
|
|
||||||
f0g3 := int64(f0) * int64(g3)
|
|
||||||
f0g4 := int64(f0) * int64(g4)
|
|
||||||
f0g5 := int64(f0) * int64(g5)
|
|
||||||
f0g6 := int64(f0) * int64(g6)
|
|
||||||
f0g7 := int64(f0) * int64(g7)
|
|
||||||
f0g8 := int64(f0) * int64(g8)
|
|
||||||
f0g9 := int64(f0) * int64(g9)
|
|
||||||
f1g0 := int64(f1) * int64(g0)
|
|
||||||
f1g1_2 := int64(f1_2) * int64(g1)
|
|
||||||
f1g2 := int64(f1) * int64(g2)
|
|
||||||
f1g3_2 := int64(f1_2) * int64(g3)
|
|
||||||
f1g4 := int64(f1) * int64(g4)
|
|
||||||
f1g5_2 := int64(f1_2) * int64(g5)
|
|
||||||
f1g6 := int64(f1) * int64(g6)
|
|
||||||
f1g7_2 := int64(f1_2) * int64(g7)
|
|
||||||
f1g8 := int64(f1) * int64(g8)
|
|
||||||
f1g9_38 := int64(f1_2) * int64(g9_19)
|
|
||||||
f2g0 := int64(f2) * int64(g0)
|
|
||||||
f2g1 := int64(f2) * int64(g1)
|
|
||||||
f2g2 := int64(f2) * int64(g2)
|
|
||||||
f2g3 := int64(f2) * int64(g3)
|
|
||||||
f2g4 := int64(f2) * int64(g4)
|
|
||||||
f2g5 := int64(f2) * int64(g5)
|
|
||||||
f2g6 := int64(f2) * int64(g6)
|
|
||||||
f2g7 := int64(f2) * int64(g7)
|
|
||||||
f2g8_19 := int64(f2) * int64(g8_19)
|
|
||||||
f2g9_19 := int64(f2) * int64(g9_19)
|
|
||||||
f3g0 := int64(f3) * int64(g0)
|
|
||||||
f3g1_2 := int64(f3_2) * int64(g1)
|
|
||||||
f3g2 := int64(f3) * int64(g2)
|
|
||||||
f3g3_2 := int64(f3_2) * int64(g3)
|
|
||||||
f3g4 := int64(f3) * int64(g4)
|
|
||||||
f3g5_2 := int64(f3_2) * int64(g5)
|
|
||||||
f3g6 := int64(f3) * int64(g6)
|
|
||||||
f3g7_38 := int64(f3_2) * int64(g7_19)
|
|
||||||
f3g8_19 := int64(f3) * int64(g8_19)
|
|
||||||
f3g9_38 := int64(f3_2) * int64(g9_19)
|
|
||||||
f4g0 := int64(f4) * int64(g0)
|
|
||||||
f4g1 := int64(f4) * int64(g1)
|
|
||||||
f4g2 := int64(f4) * int64(g2)
|
|
||||||
f4g3 := int64(f4) * int64(g3)
|
|
||||||
f4g4 := int64(f4) * int64(g4)
|
|
||||||
f4g5 := int64(f4) * int64(g5)
|
|
||||||
f4g6_19 := int64(f4) * int64(g6_19)
|
|
||||||
f4g7_19 := int64(f4) * int64(g7_19)
|
|
||||||
f4g8_19 := int64(f4) * int64(g8_19)
|
|
||||||
f4g9_19 := int64(f4) * int64(g9_19)
|
|
||||||
f5g0 := int64(f5) * int64(g0)
|
|
||||||
f5g1_2 := int64(f5_2) * int64(g1)
|
|
||||||
f5g2 := int64(f5) * int64(g2)
|
|
||||||
f5g3_2 := int64(f5_2) * int64(g3)
|
|
||||||
f5g4 := int64(f5) * int64(g4)
|
|
||||||
f5g5_38 := int64(f5_2) * int64(g5_19)
|
|
||||||
f5g6_19 := int64(f5) * int64(g6_19)
|
|
||||||
f5g7_38 := int64(f5_2) * int64(g7_19)
|
|
||||||
f5g8_19 := int64(f5) * int64(g8_19)
|
|
||||||
f5g9_38 := int64(f5_2) * int64(g9_19)
|
|
||||||
f6g0 := int64(f6) * int64(g0)
|
|
||||||
f6g1 := int64(f6) * int64(g1)
|
|
||||||
f6g2 := int64(f6) * int64(g2)
|
|
||||||
f6g3 := int64(f6) * int64(g3)
|
|
||||||
f6g4_19 := int64(f6) * int64(g4_19)
|
|
||||||
f6g5_19 := int64(f6) * int64(g5_19)
|
|
||||||
f6g6_19 := int64(f6) * int64(g6_19)
|
|
||||||
f6g7_19 := int64(f6) * int64(g7_19)
|
|
||||||
f6g8_19 := int64(f6) * int64(g8_19)
|
|
||||||
f6g9_19 := int64(f6) * int64(g9_19)
|
|
||||||
f7g0 := int64(f7) * int64(g0)
|
|
||||||
f7g1_2 := int64(f7_2) * int64(g1)
|
|
||||||
f7g2 := int64(f7) * int64(g2)
|
|
||||||
f7g3_38 := int64(f7_2) * int64(g3_19)
|
|
||||||
f7g4_19 := int64(f7) * int64(g4_19)
|
|
||||||
f7g5_38 := int64(f7_2) * int64(g5_19)
|
|
||||||
f7g6_19 := int64(f7) * int64(g6_19)
|
|
||||||
f7g7_38 := int64(f7_2) * int64(g7_19)
|
|
||||||
f7g8_19 := int64(f7) * int64(g8_19)
|
|
||||||
f7g9_38 := int64(f7_2) * int64(g9_19)
|
|
||||||
f8g0 := int64(f8) * int64(g0)
|
|
||||||
f8g1 := int64(f8) * int64(g1)
|
|
||||||
f8g2_19 := int64(f8) * int64(g2_19)
|
|
||||||
f8g3_19 := int64(f8) * int64(g3_19)
|
|
||||||
f8g4_19 := int64(f8) * int64(g4_19)
|
|
||||||
f8g5_19 := int64(f8) * int64(g5_19)
|
|
||||||
f8g6_19 := int64(f8) * int64(g6_19)
|
|
||||||
f8g7_19 := int64(f8) * int64(g7_19)
|
|
||||||
f8g8_19 := int64(f8) * int64(g8_19)
|
|
||||||
f8g9_19 := int64(f8) * int64(g9_19)
|
|
||||||
f9g0 := int64(f9) * int64(g0)
|
|
||||||
f9g1_38 := int64(f9_2) * int64(g1_19)
|
|
||||||
f9g2_19 := int64(f9) * int64(g2_19)
|
|
||||||
f9g3_38 := int64(f9_2) * int64(g3_19)
|
|
||||||
f9g4_19 := int64(f9) * int64(g4_19)
|
|
||||||
f9g5_38 := int64(f9_2) * int64(g5_19)
|
|
||||||
f9g6_19 := int64(f9) * int64(g6_19)
|
|
||||||
f9g7_38 := int64(f9_2) * int64(g7_19)
|
|
||||||
f9g8_19 := int64(f9) * int64(g8_19)
|
|
||||||
f9g9_38 := int64(f9_2) * int64(g9_19)
|
|
||||||
h0 := f0g0 + f1g9_38 + f2g8_19 + f3g7_38 + f4g6_19 + f5g5_38 + f6g4_19 + f7g3_38 + f8g2_19 + f9g1_38
|
|
||||||
h1 := f0g1 + f1g0 + f2g9_19 + f3g8_19 + f4g7_19 + f5g6_19 + f6g5_19 + f7g4_19 + f8g3_19 + f9g2_19
|
|
||||||
h2 := f0g2 + f1g1_2 + f2g0 + f3g9_38 + f4g8_19 + f5g7_38 + f6g6_19 + f7g5_38 + f8g4_19 + f9g3_38
|
|
||||||
h3 := f0g3 + f1g2 + f2g1 + f3g0 + f4g9_19 + f5g8_19 + f6g7_19 + f7g6_19 + f8g5_19 + f9g4_19
|
|
||||||
h4 := f0g4 + f1g3_2 + f2g2 + f3g1_2 + f4g0 + f5g9_38 + f6g8_19 + f7g7_38 + f8g6_19 + f9g5_38
|
|
||||||
h5 := f0g5 + f1g4 + f2g3 + f3g2 + f4g1 + f5g0 + f6g9_19 + f7g8_19 + f8g7_19 + f9g6_19
|
|
||||||
h6 := f0g6 + f1g5_2 + f2g4 + f3g3_2 + f4g2 + f5g1_2 + f6g0 + f7g9_38 + f8g8_19 + f9g7_38
|
|
||||||
h7 := f0g7 + f1g6 + f2g5 + f3g4 + f4g3 + f5g2 + f6g1 + f7g0 + f8g9_19 + f9g8_19
|
|
||||||
h8 := f0g8 + f1g7_2 + f2g6 + f3g5_2 + f4g4 + f5g3_2 + f6g2 + f7g1_2 + f8g0 + f9g9_38
|
|
||||||
h9 := f0g9 + f1g8 + f2g7 + f3g6 + f4g5 + f5g4 + f6g3 + f7g2 + f8g1 + f9g0
|
|
||||||
var carry [10]int64
|
|
||||||
|
|
||||||
// |h0| <= (1.1*1.1*2^52*(1+19+19+19+19)+1.1*1.1*2^50*(38+38+38+38+38))
|
|
||||||
// i.e. |h0| <= 1.2*2^59; narrower ranges for h2, h4, h6, h8
|
|
||||||
// |h1| <= (1.1*1.1*2^51*(1+1+19+19+19+19+19+19+19+19))
|
|
||||||
// i.e. |h1| <= 1.5*2^58; narrower ranges for h3, h5, h7, h9
|
|
||||||
|
|
||||||
carry[0] = (h0 + (1 << 25)) >> 26
|
|
||||||
h1 += carry[0]
|
|
||||||
h0 -= carry[0] << 26
|
|
||||||
carry[4] = (h4 + (1 << 25)) >> 26
|
|
||||||
h5 += carry[4]
|
|
||||||
h4 -= carry[4] << 26
|
|
||||||
// |h0| <= 2^25
|
|
||||||
// |h4| <= 2^25
|
|
||||||
// |h1| <= 1.51*2^58
|
|
||||||
// |h5| <= 1.51*2^58
|
|
||||||
|
|
||||||
carry[1] = (h1 + (1 << 24)) >> 25
|
|
||||||
h2 += carry[1]
|
|
||||||
h1 -= carry[1] << 25
|
|
||||||
carry[5] = (h5 + (1 << 24)) >> 25
|
|
||||||
h6 += carry[5]
|
|
||||||
h5 -= carry[5] << 25
|
|
||||||
// |h1| <= 2^24; from now on fits into int32
|
|
||||||
// |h5| <= 2^24; from now on fits into int32
|
|
||||||
// |h2| <= 1.21*2^59
|
|
||||||
// |h6| <= 1.21*2^59
|
|
||||||
|
|
||||||
carry[2] = (h2 + (1 << 25)) >> 26
|
|
||||||
h3 += carry[2]
|
|
||||||
h2 -= carry[2] << 26
|
|
||||||
carry[6] = (h6 + (1 << 25)) >> 26
|
|
||||||
h7 += carry[6]
|
|
||||||
h6 -= carry[6] << 26
|
|
||||||
// |h2| <= 2^25; from now on fits into int32 unchanged
|
|
||||||
// |h6| <= 2^25; from now on fits into int32 unchanged
|
|
||||||
// |h3| <= 1.51*2^58
|
|
||||||
// |h7| <= 1.51*2^58
|
|
||||||
|
|
||||||
carry[3] = (h3 + (1 << 24)) >> 25
|
|
||||||
h4 += carry[3]
|
|
||||||
h3 -= carry[3] << 25
|
|
||||||
carry[7] = (h7 + (1 << 24)) >> 25
|
|
||||||
h8 += carry[7]
|
|
||||||
h7 -= carry[7] << 25
|
|
||||||
// |h3| <= 2^24; from now on fits into int32 unchanged
|
|
||||||
// |h7| <= 2^24; from now on fits into int32 unchanged
|
|
||||||
// |h4| <= 1.52*2^33
|
|
||||||
// |h8| <= 1.52*2^33
|
|
||||||
|
|
||||||
carry[4] = (h4 + (1 << 25)) >> 26
|
|
||||||
h5 += carry[4]
|
|
||||||
h4 -= carry[4] << 26
|
|
||||||
carry[8] = (h8 + (1 << 25)) >> 26
|
|
||||||
h9 += carry[8]
|
|
||||||
h8 -= carry[8] << 26
|
|
||||||
// |h4| <= 2^25; from now on fits into int32 unchanged
|
|
||||||
// |h8| <= 2^25; from now on fits into int32 unchanged
|
|
||||||
// |h5| <= 1.01*2^24
|
|
||||||
// |h9| <= 1.51*2^58
|
|
||||||
|
|
||||||
carry[9] = (h9 + (1 << 24)) >> 25
|
|
||||||
h0 += carry[9] * 19
|
|
||||||
h9 -= carry[9] << 25
|
|
||||||
// |h9| <= 2^24; from now on fits into int32 unchanged
|
|
||||||
// |h0| <= 1.8*2^37
|
|
||||||
|
|
||||||
carry[0] = (h0 + (1 << 25)) >> 26
|
|
||||||
h1 += carry[0]
|
|
||||||
h0 -= carry[0] << 26
|
|
||||||
// |h0| <= 2^25; from now on fits into int32 unchanged
|
|
||||||
// |h1| <= 1.01*2^24
|
|
||||||
|
|
||||||
h[0] = int32(h0)
|
|
||||||
h[1] = int32(h1)
|
|
||||||
h[2] = int32(h2)
|
|
||||||
h[3] = int32(h3)
|
|
||||||
h[4] = int32(h4)
|
|
||||||
h[5] = int32(h5)
|
|
||||||
h[6] = int32(h6)
|
|
||||||
h[7] = int32(h7)
|
|
||||||
h[8] = int32(h8)
|
|
||||||
h[9] = int32(h9)
|
|
||||||
}
|
|
||||||
|
|
||||||
// feSquare calculates h = f*f. Can overlap h with f.
|
|
||||||
//
|
|
||||||
// Preconditions:
|
|
||||||
// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
|
|
||||||
//
|
|
||||||
// Postconditions:
|
|
||||||
// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
|
|
||||||
func feSquare(h, f *fieldElement) {
|
|
||||||
f0 := f[0]
|
|
||||||
f1 := f[1]
|
|
||||||
f2 := f[2]
|
|
||||||
f3 := f[3]
|
|
||||||
f4 := f[4]
|
|
||||||
f5 := f[5]
|
|
||||||
f6 := f[6]
|
|
||||||
f7 := f[7]
|
|
||||||
f8 := f[8]
|
|
||||||
f9 := f[9]
|
|
||||||
f0_2 := 2 * f0
|
|
||||||
f1_2 := 2 * f1
|
|
||||||
f2_2 := 2 * f2
|
|
||||||
f3_2 := 2 * f3
|
|
||||||
f4_2 := 2 * f4
|
|
||||||
f5_2 := 2 * f5
|
|
||||||
f6_2 := 2 * f6
|
|
||||||
f7_2 := 2 * f7
|
|
||||||
f5_38 := 38 * f5 // 1.31*2^30
|
|
||||||
f6_19 := 19 * f6 // 1.31*2^30
|
|
||||||
f7_38 := 38 * f7 // 1.31*2^30
|
|
||||||
f8_19 := 19 * f8 // 1.31*2^30
|
|
||||||
f9_38 := 38 * f9 // 1.31*2^30
|
|
||||||
f0f0 := int64(f0) * int64(f0)
|
|
||||||
f0f1_2 := int64(f0_2) * int64(f1)
|
|
||||||
f0f2_2 := int64(f0_2) * int64(f2)
|
|
||||||
f0f3_2 := int64(f0_2) * int64(f3)
|
|
||||||
f0f4_2 := int64(f0_2) * int64(f4)
|
|
||||||
f0f5_2 := int64(f0_2) * int64(f5)
|
|
||||||
f0f6_2 := int64(f0_2) * int64(f6)
|
|
||||||
f0f7_2 := int64(f0_2) * int64(f7)
|
|
||||||
f0f8_2 := int64(f0_2) * int64(f8)
|
|
||||||
f0f9_2 := int64(f0_2) * int64(f9)
|
|
||||||
f1f1_2 := int64(f1_2) * int64(f1)
|
|
||||||
f1f2_2 := int64(f1_2) * int64(f2)
|
|
||||||
f1f3_4 := int64(f1_2) * int64(f3_2)
|
|
||||||
f1f4_2 := int64(f1_2) * int64(f4)
|
|
||||||
f1f5_4 := int64(f1_2) * int64(f5_2)
|
|
||||||
f1f6_2 := int64(f1_2) * int64(f6)
|
|
||||||
f1f7_4 := int64(f1_2) * int64(f7_2)
|
|
||||||
f1f8_2 := int64(f1_2) * int64(f8)
|
|
||||||
f1f9_76 := int64(f1_2) * int64(f9_38)
|
|
||||||
f2f2 := int64(f2) * int64(f2)
|
|
||||||
f2f3_2 := int64(f2_2) * int64(f3)
|
|
||||||
f2f4_2 := int64(f2_2) * int64(f4)
|
|
||||||
f2f5_2 := int64(f2_2) * int64(f5)
|
|
||||||
f2f6_2 := int64(f2_2) * int64(f6)
|
|
||||||
f2f7_2 := int64(f2_2) * int64(f7)
|
|
||||||
f2f8_38 := int64(f2_2) * int64(f8_19)
|
|
||||||
f2f9_38 := int64(f2) * int64(f9_38)
|
|
||||||
f3f3_2 := int64(f3_2) * int64(f3)
|
|
||||||
f3f4_2 := int64(f3_2) * int64(f4)
|
|
||||||
f3f5_4 := int64(f3_2) * int64(f5_2)
|
|
||||||
f3f6_2 := int64(f3_2) * int64(f6)
|
|
||||||
f3f7_76 := int64(f3_2) * int64(f7_38)
|
|
||||||
f3f8_38 := int64(f3_2) * int64(f8_19)
|
|
||||||
f3f9_76 := int64(f3_2) * int64(f9_38)
|
|
||||||
f4f4 := int64(f4) * int64(f4)
|
|
||||||
f4f5_2 := int64(f4_2) * int64(f5)
|
|
||||||
f4f6_38 := int64(f4_2) * int64(f6_19)
|
|
||||||
f4f7_38 := int64(f4) * int64(f7_38)
|
|
||||||
f4f8_38 := int64(f4_2) * int64(f8_19)
|
|
||||||
f4f9_38 := int64(f4) * int64(f9_38)
|
|
||||||
f5f5_38 := int64(f5) * int64(f5_38)
|
|
||||||
f5f6_38 := int64(f5_2) * int64(f6_19)
|
|
||||||
f5f7_76 := int64(f5_2) * int64(f7_38)
|
|
||||||
f5f8_38 := int64(f5_2) * int64(f8_19)
|
|
||||||
f5f9_76 := int64(f5_2) * int64(f9_38)
|
|
||||||
f6f6_19 := int64(f6) * int64(f6_19)
|
|
||||||
f6f7_38 := int64(f6) * int64(f7_38)
|
|
||||||
f6f8_38 := int64(f6_2) * int64(f8_19)
|
|
||||||
f6f9_38 := int64(f6) * int64(f9_38)
|
|
||||||
f7f7_38 := int64(f7) * int64(f7_38)
|
|
||||||
f7f8_38 := int64(f7_2) * int64(f8_19)
|
|
||||||
f7f9_76 := int64(f7_2) * int64(f9_38)
|
|
||||||
f8f8_19 := int64(f8) * int64(f8_19)
|
|
||||||
f8f9_38 := int64(f8) * int64(f9_38)
|
|
||||||
f9f9_38 := int64(f9) * int64(f9_38)
|
|
||||||
h0 := f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38
|
|
||||||
h1 := f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38
|
|
||||||
h2 := f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19
|
|
||||||
h3 := f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38
|
|
||||||
h4 := f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38
|
|
||||||
h5 := f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38
|
|
||||||
h6 := f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19
|
|
||||||
h7 := f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38
|
|
||||||
h8 := f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38
|
|
||||||
h9 := f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2
|
|
||||||
var carry [10]int64
|
|
||||||
|
|
||||||
carry[0] = (h0 + (1 << 25)) >> 26
|
|
||||||
h1 += carry[0]
|
|
||||||
h0 -= carry[0] << 26
|
|
||||||
carry[4] = (h4 + (1 << 25)) >> 26
|
|
||||||
h5 += carry[4]
|
|
||||||
h4 -= carry[4] << 26
|
|
||||||
|
|
||||||
carry[1] = (h1 + (1 << 24)) >> 25
|
|
||||||
h2 += carry[1]
|
|
||||||
h1 -= carry[1] << 25
|
|
||||||
carry[5] = (h5 + (1 << 24)) >> 25
|
|
||||||
h6 += carry[5]
|
|
||||||
h5 -= carry[5] << 25
|
|
||||||
|
|
||||||
carry[2] = (h2 + (1 << 25)) >> 26
|
|
||||||
h3 += carry[2]
|
|
||||||
h2 -= carry[2] << 26
|
|
||||||
carry[6] = (h6 + (1 << 25)) >> 26
|
|
||||||
h7 += carry[6]
|
|
||||||
h6 -= carry[6] << 26
|
|
||||||
|
|
||||||
carry[3] = (h3 + (1 << 24)) >> 25
|
|
||||||
h4 += carry[3]
|
|
||||||
h3 -= carry[3] << 25
|
|
||||||
carry[7] = (h7 + (1 << 24)) >> 25
|
|
||||||
h8 += carry[7]
|
|
||||||
h7 -= carry[7] << 25
|
|
||||||
|
|
||||||
carry[4] = (h4 + (1 << 25)) >> 26
|
|
||||||
h5 += carry[4]
|
|
||||||
h4 -= carry[4] << 26
|
|
||||||
carry[8] = (h8 + (1 << 25)) >> 26
|
|
||||||
h9 += carry[8]
|
|
||||||
h8 -= carry[8] << 26
|
|
||||||
|
|
||||||
carry[9] = (h9 + (1 << 24)) >> 25
|
|
||||||
h0 += carry[9] * 19
|
|
||||||
h9 -= carry[9] << 25
|
|
||||||
|
|
||||||
carry[0] = (h0 + (1 << 25)) >> 26
|
|
||||||
h1 += carry[0]
|
|
||||||
h0 -= carry[0] << 26
|
|
||||||
|
|
||||||
h[0] = int32(h0)
|
|
||||||
h[1] = int32(h1)
|
|
||||||
h[2] = int32(h2)
|
|
||||||
h[3] = int32(h3)
|
|
||||||
h[4] = int32(h4)
|
|
||||||
h[5] = int32(h5)
|
|
||||||
h[6] = int32(h6)
|
|
||||||
h[7] = int32(h7)
|
|
||||||
h[8] = int32(h8)
|
|
||||||
h[9] = int32(h9)
|
|
||||||
}
|
|
||||||
|
|
||||||
// feMul121666 calculates h = f * 121666. Can overlap h with f.
|
|
||||||
//
|
|
||||||
// Preconditions:
|
|
||||||
// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
|
|
||||||
//
|
|
||||||
// Postconditions:
|
|
||||||
// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
|
|
||||||
func feMul121666(h, f *fieldElement) {
|
|
||||||
h0 := int64(f[0]) * 121666
|
|
||||||
h1 := int64(f[1]) * 121666
|
|
||||||
h2 := int64(f[2]) * 121666
|
|
||||||
h3 := int64(f[3]) * 121666
|
|
||||||
h4 := int64(f[4]) * 121666
|
|
||||||
h5 := int64(f[5]) * 121666
|
|
||||||
h6 := int64(f[6]) * 121666
|
|
||||||
h7 := int64(f[7]) * 121666
|
|
||||||
h8 := int64(f[8]) * 121666
|
|
||||||
h9 := int64(f[9]) * 121666
|
|
||||||
var carry [10]int64
|
|
||||||
|
|
||||||
carry[9] = (h9 + (1 << 24)) >> 25
|
|
||||||
h0 += carry[9] * 19
|
|
||||||
h9 -= carry[9] << 25
|
|
||||||
carry[1] = (h1 + (1 << 24)) >> 25
|
|
||||||
h2 += carry[1]
|
|
||||||
h1 -= carry[1] << 25
|
|
||||||
carry[3] = (h3 + (1 << 24)) >> 25
|
|
||||||
h4 += carry[3]
|
|
||||||
h3 -= carry[3] << 25
|
|
||||||
carry[5] = (h5 + (1 << 24)) >> 25
|
|
||||||
h6 += carry[5]
|
|
||||||
h5 -= carry[5] << 25
|
|
||||||
carry[7] = (h7 + (1 << 24)) >> 25
|
|
||||||
h8 += carry[7]
|
|
||||||
h7 -= carry[7] << 25
|
|
||||||
|
|
||||||
carry[0] = (h0 + (1 << 25)) >> 26
|
|
||||||
h1 += carry[0]
|
|
||||||
h0 -= carry[0] << 26
|
|
||||||
carry[2] = (h2 + (1 << 25)) >> 26
|
|
||||||
h3 += carry[2]
|
|
||||||
h2 -= carry[2] << 26
|
|
||||||
carry[4] = (h4 + (1 << 25)) >> 26
|
|
||||||
h5 += carry[4]
|
|
||||||
h4 -= carry[4] << 26
|
|
||||||
carry[6] = (h6 + (1 << 25)) >> 26
|
|
||||||
h7 += carry[6]
|
|
||||||
h6 -= carry[6] << 26
|
|
||||||
carry[8] = (h8 + (1 << 25)) >> 26
|
|
||||||
h9 += carry[8]
|
|
||||||
h8 -= carry[8] << 26
|
|
||||||
|
|
||||||
h[0] = int32(h0)
|
|
||||||
h[1] = int32(h1)
|
|
||||||
h[2] = int32(h2)
|
|
||||||
h[3] = int32(h3)
|
|
||||||
h[4] = int32(h4)
|
|
||||||
h[5] = int32(h5)
|
|
||||||
h[6] = int32(h6)
|
|
||||||
h[7] = int32(h7)
|
|
||||||
h[8] = int32(h8)
|
|
||||||
h[9] = int32(h9)
|
|
||||||
}
|
|
||||||
|
|
||||||
// feInvert sets out = z^-1.
|
|
||||||
func feInvert(out, z *fieldElement) {
|
|
||||||
var t0, t1, t2, t3 fieldElement
|
|
||||||
var i int
|
|
||||||
|
|
||||||
feSquare(&t0, z)
|
|
||||||
for i = 1; i < 1; i++ {
|
|
||||||
feSquare(&t0, &t0)
|
|
||||||
}
|
|
||||||
feSquare(&t1, &t0)
|
|
||||||
for i = 1; i < 2; i++ {
|
|
||||||
feSquare(&t1, &t1)
|
|
||||||
}
|
|
||||||
feMul(&t1, z, &t1)
|
|
||||||
feMul(&t0, &t0, &t1)
|
|
||||||
feSquare(&t2, &t0)
|
|
||||||
for i = 1; i < 1; i++ {
|
|
||||||
feSquare(&t2, &t2)
|
|
||||||
}
|
|
||||||
feMul(&t1, &t1, &t2)
|
|
||||||
feSquare(&t2, &t1)
|
|
||||||
for i = 1; i < 5; i++ {
|
|
||||||
feSquare(&t2, &t2)
|
|
||||||
}
|
|
||||||
feMul(&t1, &t2, &t1)
|
|
||||||
feSquare(&t2, &t1)
|
|
||||||
for i = 1; i < 10; i++ {
|
|
||||||
feSquare(&t2, &t2)
|
|
||||||
}
|
|
||||||
feMul(&t2, &t2, &t1)
|
|
||||||
feSquare(&t3, &t2)
|
|
||||||
for i = 1; i < 20; i++ {
|
|
||||||
feSquare(&t3, &t3)
|
|
||||||
}
|
|
||||||
feMul(&t2, &t3, &t2)
|
|
||||||
feSquare(&t2, &t2)
|
|
||||||
for i = 1; i < 10; i++ {
|
|
||||||
feSquare(&t2, &t2)
|
|
||||||
}
|
|
||||||
feMul(&t1, &t2, &t1)
|
|
||||||
feSquare(&t2, &t1)
|
|
||||||
for i = 1; i < 50; i++ {
|
|
||||||
feSquare(&t2, &t2)
|
|
||||||
}
|
|
||||||
feMul(&t2, &t2, &t1)
|
|
||||||
feSquare(&t3, &t2)
|
|
||||||
for i = 1; i < 100; i++ {
|
|
||||||
feSquare(&t3, &t3)
|
|
||||||
}
|
|
||||||
feMul(&t2, &t3, &t2)
|
|
||||||
feSquare(&t2, &t2)
|
|
||||||
for i = 1; i < 50; i++ {
|
|
||||||
feSquare(&t2, &t2)
|
|
||||||
}
|
|
||||||
feMul(&t1, &t2, &t1)
|
|
||||||
feSquare(&t1, &t1)
|
|
||||||
for i = 1; i < 5; i++ {
|
|
||||||
feSquare(&t1, &t1)
|
|
||||||
}
|
|
||||||
feMul(out, &t1, &t0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func scalarMultGeneric(out, in, base *[32]byte) {
|
|
||||||
var e [32]byte
|
|
||||||
|
|
||||||
copy(e[:], in[:])
|
|
||||||
e[0] &= 248
|
|
||||||
e[31] &= 127
|
|
||||||
e[31] |= 64
|
|
||||||
|
|
||||||
var x1, x2, z2, x3, z3, tmp0, tmp1 fieldElement
|
|
||||||
feFromBytes(&x1, base)
|
|
||||||
feOne(&x2)
|
|
||||||
feCopy(&x3, &x1)
|
|
||||||
feOne(&z3)
|
|
||||||
|
|
||||||
swap := int32(0)
|
|
||||||
for pos := 254; pos >= 0; pos-- {
|
|
||||||
b := e[pos/8] >> uint(pos&7)
|
|
||||||
b &= 1
|
|
||||||
swap ^= int32(b)
|
|
||||||
feCSwap(&x2, &x3, swap)
|
|
||||||
feCSwap(&z2, &z3, swap)
|
|
||||||
swap = int32(b)
|
|
||||||
|
|
||||||
feSub(&tmp0, &x3, &z3)
|
|
||||||
feSub(&tmp1, &x2, &z2)
|
|
||||||
feAdd(&x2, &x2, &z2)
|
|
||||||
feAdd(&z2, &x3, &z3)
|
|
||||||
feMul(&z3, &tmp0, &x2)
|
|
||||||
feMul(&z2, &z2, &tmp1)
|
|
||||||
feSquare(&tmp0, &tmp1)
|
|
||||||
feSquare(&tmp1, &x2)
|
|
||||||
feAdd(&x3, &z3, &z2)
|
|
||||||
feSub(&z2, &z3, &z2)
|
|
||||||
feMul(&x2, &tmp1, &tmp0)
|
|
||||||
feSub(&tmp1, &tmp1, &tmp0)
|
|
||||||
feSquare(&z2, &z2)
|
|
||||||
feMul121666(&z3, &tmp1)
|
|
||||||
feSquare(&x3, &x3)
|
|
||||||
feAdd(&tmp0, &tmp0, &z3)
|
|
||||||
feMul(&z3, &x1, &z2)
|
|
||||||
feMul(&z2, &tmp1, &tmp0)
|
|
||||||
}
|
|
||||||
|
|
||||||
feCSwap(&x2, &x3, swap)
|
|
||||||
feCSwap(&z2, &z3, swap)
|
|
||||||
|
|
||||||
feInvert(&z2, &z2)
|
|
||||||
feMul(&x2, &x2, &z2)
|
|
||||||
feToBytes(out, &x2)
|
|
||||||
}
|
|
11
vendor/golang.org/x/crypto/curve25519/curve25519_noasm.go
generated
vendored
11
vendor/golang.org/x/crypto/curve25519/curve25519_noasm.go
generated
vendored
@ -1,11 +0,0 @@
|
|||||||
// Copyright 2019 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !amd64 gccgo appengine purego
|
|
||||||
|
|
||||||
package curve25519
|
|
||||||
|
|
||||||
func scalarMult(out, in, base *[32]byte) {
|
|
||||||
scalarMultGeneric(out, in, base)
|
|
||||||
}
|
|
7
vendor/golang.org/x/crypto/curve25519/internal/field/README
generated
vendored
Normal file
7
vendor/golang.org/x/crypto/curve25519/internal/field/README
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
This package is kept in sync with crypto/ed25519/internal/edwards25519/field in
|
||||||
|
the standard library.
|
||||||
|
|
||||||
|
If there are any changes in the standard library that need to be synced to this
|
||||||
|
package, run sync.sh. It will not overwrite any local changes made since the
|
||||||
|
previous sync, so it's ok to land changes in this package first, and then sync
|
||||||
|
to the standard library later.
|
416
vendor/golang.org/x/crypto/curve25519/internal/field/fe.go
generated
vendored
Normal file
416
vendor/golang.org/x/crypto/curve25519/internal/field/fe.go
generated
vendored
Normal file
@ -0,0 +1,416 @@
|
|||||||
|
// Copyright (c) 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Package field implements fast arithmetic modulo 2^255-19.
|
||||||
|
package field
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/subtle"
|
||||||
|
"encoding/binary"
|
||||||
|
"math/bits"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Element represents an element of the field GF(2^255-19). Note that this
|
||||||
|
// is not a cryptographically secure group, and should only be used to interact
|
||||||
|
// with edwards25519.Point coordinates.
|
||||||
|
//
|
||||||
|
// This type works similarly to math/big.Int, and all arguments and receivers
|
||||||
|
// are allowed to alias.
|
||||||
|
//
|
||||||
|
// The zero value is a valid zero element.
|
||||||
|
type Element struct {
|
||||||
|
// An element t represents the integer
|
||||||
|
// t.l0 + t.l1*2^51 + t.l2*2^102 + t.l3*2^153 + t.l4*2^204
|
||||||
|
//
|
||||||
|
// Between operations, all limbs are expected to be lower than 2^52.
|
||||||
|
l0 uint64
|
||||||
|
l1 uint64
|
||||||
|
l2 uint64
|
||||||
|
l3 uint64
|
||||||
|
l4 uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
const maskLow51Bits uint64 = (1 << 51) - 1
|
||||||
|
|
||||||
|
var feZero = &Element{0, 0, 0, 0, 0}
|
||||||
|
|
||||||
|
// Zero sets v = 0, and returns v.
|
||||||
|
func (v *Element) Zero() *Element {
|
||||||
|
*v = *feZero
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
var feOne = &Element{1, 0, 0, 0, 0}
|
||||||
|
|
||||||
|
// One sets v = 1, and returns v.
|
||||||
|
func (v *Element) One() *Element {
|
||||||
|
*v = *feOne
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// reduce reduces v modulo 2^255 - 19 and returns it.
|
||||||
|
func (v *Element) reduce() *Element {
|
||||||
|
v.carryPropagate()
|
||||||
|
|
||||||
|
// After the light reduction we now have a field element representation
|
||||||
|
// v < 2^255 + 2^13 * 19, but need v < 2^255 - 19.
|
||||||
|
|
||||||
|
// If v >= 2^255 - 19, then v + 19 >= 2^255, which would overflow 2^255 - 1,
|
||||||
|
// generating a carry. That is, c will be 0 if v < 2^255 - 19, and 1 otherwise.
|
||||||
|
c := (v.l0 + 19) >> 51
|
||||||
|
c = (v.l1 + c) >> 51
|
||||||
|
c = (v.l2 + c) >> 51
|
||||||
|
c = (v.l3 + c) >> 51
|
||||||
|
c = (v.l4 + c) >> 51
|
||||||
|
|
||||||
|
// If v < 2^255 - 19 and c = 0, this will be a no-op. Otherwise, it's
|
||||||
|
// effectively applying the reduction identity to the carry.
|
||||||
|
v.l0 += 19 * c
|
||||||
|
|
||||||
|
v.l1 += v.l0 >> 51
|
||||||
|
v.l0 = v.l0 & maskLow51Bits
|
||||||
|
v.l2 += v.l1 >> 51
|
||||||
|
v.l1 = v.l1 & maskLow51Bits
|
||||||
|
v.l3 += v.l2 >> 51
|
||||||
|
v.l2 = v.l2 & maskLow51Bits
|
||||||
|
v.l4 += v.l3 >> 51
|
||||||
|
v.l3 = v.l3 & maskLow51Bits
|
||||||
|
// no additional carry
|
||||||
|
v.l4 = v.l4 & maskLow51Bits
|
||||||
|
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add sets v = a + b, and returns v.
|
||||||
|
func (v *Element) Add(a, b *Element) *Element {
|
||||||
|
v.l0 = a.l0 + b.l0
|
||||||
|
v.l1 = a.l1 + b.l1
|
||||||
|
v.l2 = a.l2 + b.l2
|
||||||
|
v.l3 = a.l3 + b.l3
|
||||||
|
v.l4 = a.l4 + b.l4
|
||||||
|
// Using the generic implementation here is actually faster than the
|
||||||
|
// assembly. Probably because the body of this function is so simple that
|
||||||
|
// the compiler can figure out better optimizations by inlining the carry
|
||||||
|
// propagation. TODO
|
||||||
|
return v.carryPropagateGeneric()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subtract sets v = a - b, and returns v.
|
||||||
|
func (v *Element) Subtract(a, b *Element) *Element {
|
||||||
|
// We first add 2 * p, to guarantee the subtraction won't underflow, and
|
||||||
|
// then subtract b (which can be up to 2^255 + 2^13 * 19).
|
||||||
|
v.l0 = (a.l0 + 0xFFFFFFFFFFFDA) - b.l0
|
||||||
|
v.l1 = (a.l1 + 0xFFFFFFFFFFFFE) - b.l1
|
||||||
|
v.l2 = (a.l2 + 0xFFFFFFFFFFFFE) - b.l2
|
||||||
|
v.l3 = (a.l3 + 0xFFFFFFFFFFFFE) - b.l3
|
||||||
|
v.l4 = (a.l4 + 0xFFFFFFFFFFFFE) - b.l4
|
||||||
|
return v.carryPropagate()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Negate sets v = -a, and returns v.
|
||||||
|
func (v *Element) Negate(a *Element) *Element {
|
||||||
|
return v.Subtract(feZero, a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invert sets v = 1/z mod p, and returns v.
|
||||||
|
//
|
||||||
|
// If z == 0, Invert returns v = 0.
|
||||||
|
func (v *Element) Invert(z *Element) *Element {
|
||||||
|
// Inversion is implemented as exponentiation with exponent p − 2. It uses the
|
||||||
|
// same sequence of 255 squarings and 11 multiplications as [Curve25519].
|
||||||
|
var z2, z9, z11, z2_5_0, z2_10_0, z2_20_0, z2_50_0, z2_100_0, t Element
|
||||||
|
|
||||||
|
z2.Square(z) // 2
|
||||||
|
t.Square(&z2) // 4
|
||||||
|
t.Square(&t) // 8
|
||||||
|
z9.Multiply(&t, z) // 9
|
||||||
|
z11.Multiply(&z9, &z2) // 11
|
||||||
|
t.Square(&z11) // 22
|
||||||
|
z2_5_0.Multiply(&t, &z9) // 31 = 2^5 - 2^0
|
||||||
|
|
||||||
|
t.Square(&z2_5_0) // 2^6 - 2^1
|
||||||
|
for i := 0; i < 4; i++ {
|
||||||
|
t.Square(&t) // 2^10 - 2^5
|
||||||
|
}
|
||||||
|
z2_10_0.Multiply(&t, &z2_5_0) // 2^10 - 2^0
|
||||||
|
|
||||||
|
t.Square(&z2_10_0) // 2^11 - 2^1
|
||||||
|
for i := 0; i < 9; i++ {
|
||||||
|
t.Square(&t) // 2^20 - 2^10
|
||||||
|
}
|
||||||
|
z2_20_0.Multiply(&t, &z2_10_0) // 2^20 - 2^0
|
||||||
|
|
||||||
|
t.Square(&z2_20_0) // 2^21 - 2^1
|
||||||
|
for i := 0; i < 19; i++ {
|
||||||
|
t.Square(&t) // 2^40 - 2^20
|
||||||
|
}
|
||||||
|
t.Multiply(&t, &z2_20_0) // 2^40 - 2^0
|
||||||
|
|
||||||
|
t.Square(&t) // 2^41 - 2^1
|
||||||
|
for i := 0; i < 9; i++ {
|
||||||
|
t.Square(&t) // 2^50 - 2^10
|
||||||
|
}
|
||||||
|
z2_50_0.Multiply(&t, &z2_10_0) // 2^50 - 2^0
|
||||||
|
|
||||||
|
t.Square(&z2_50_0) // 2^51 - 2^1
|
||||||
|
for i := 0; i < 49; i++ {
|
||||||
|
t.Square(&t) // 2^100 - 2^50
|
||||||
|
}
|
||||||
|
z2_100_0.Multiply(&t, &z2_50_0) // 2^100 - 2^0
|
||||||
|
|
||||||
|
t.Square(&z2_100_0) // 2^101 - 2^1
|
||||||
|
for i := 0; i < 99; i++ {
|
||||||
|
t.Square(&t) // 2^200 - 2^100
|
||||||
|
}
|
||||||
|
t.Multiply(&t, &z2_100_0) // 2^200 - 2^0
|
||||||
|
|
||||||
|
t.Square(&t) // 2^201 - 2^1
|
||||||
|
for i := 0; i < 49; i++ {
|
||||||
|
t.Square(&t) // 2^250 - 2^50
|
||||||
|
}
|
||||||
|
t.Multiply(&t, &z2_50_0) // 2^250 - 2^0
|
||||||
|
|
||||||
|
t.Square(&t) // 2^251 - 2^1
|
||||||
|
t.Square(&t) // 2^252 - 2^2
|
||||||
|
t.Square(&t) // 2^253 - 2^3
|
||||||
|
t.Square(&t) // 2^254 - 2^4
|
||||||
|
t.Square(&t) // 2^255 - 2^5
|
||||||
|
|
||||||
|
return v.Multiply(&t, &z11) // 2^255 - 21
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set sets v = a, and returns v.
|
||||||
|
func (v *Element) Set(a *Element) *Element {
|
||||||
|
*v = *a
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetBytes sets v to x, which must be a 32-byte little-endian encoding.
|
||||||
|
//
|
||||||
|
// Consistent with RFC 7748, the most significant bit (the high bit of the
|
||||||
|
// last byte) is ignored, and non-canonical values (2^255-19 through 2^255-1)
|
||||||
|
// are accepted. Note that this is laxer than specified by RFC 8032.
|
||||||
|
func (v *Element) SetBytes(x []byte) *Element {
|
||||||
|
if len(x) != 32 {
|
||||||
|
panic("edwards25519: invalid field element input size")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bits 0:51 (bytes 0:8, bits 0:64, shift 0, mask 51).
|
||||||
|
v.l0 = binary.LittleEndian.Uint64(x[0:8])
|
||||||
|
v.l0 &= maskLow51Bits
|
||||||
|
// Bits 51:102 (bytes 6:14, bits 48:112, shift 3, mask 51).
|
||||||
|
v.l1 = binary.LittleEndian.Uint64(x[6:14]) >> 3
|
||||||
|
v.l1 &= maskLow51Bits
|
||||||
|
// Bits 102:153 (bytes 12:20, bits 96:160, shift 6, mask 51).
|
||||||
|
v.l2 = binary.LittleEndian.Uint64(x[12:20]) >> 6
|
||||||
|
v.l2 &= maskLow51Bits
|
||||||
|
// Bits 153:204 (bytes 19:27, bits 152:216, shift 1, mask 51).
|
||||||
|
v.l3 = binary.LittleEndian.Uint64(x[19:27]) >> 1
|
||||||
|
v.l3 &= maskLow51Bits
|
||||||
|
// Bits 204:251 (bytes 24:32, bits 192:256, shift 12, mask 51).
|
||||||
|
// Note: not bytes 25:33, shift 4, to avoid overread.
|
||||||
|
v.l4 = binary.LittleEndian.Uint64(x[24:32]) >> 12
|
||||||
|
v.l4 &= maskLow51Bits
|
||||||
|
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bytes returns the canonical 32-byte little-endian encoding of v.
|
||||||
|
func (v *Element) Bytes() []byte {
|
||||||
|
// This function is outlined to make the allocations inline in the caller
|
||||||
|
// rather than happen on the heap.
|
||||||
|
var out [32]byte
|
||||||
|
return v.bytes(&out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *Element) bytes(out *[32]byte) []byte {
|
||||||
|
t := *v
|
||||||
|
t.reduce()
|
||||||
|
|
||||||
|
var buf [8]byte
|
||||||
|
for i, l := range [5]uint64{t.l0, t.l1, t.l2, t.l3, t.l4} {
|
||||||
|
bitsOffset := i * 51
|
||||||
|
binary.LittleEndian.PutUint64(buf[:], l<<uint(bitsOffset%8))
|
||||||
|
for i, bb := range buf {
|
||||||
|
off := bitsOffset/8 + i
|
||||||
|
if off >= len(out) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
out[off] |= bb
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return out[:]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equal returns 1 if v and u are equal, and 0 otherwise.
|
||||||
|
func (v *Element) Equal(u *Element) int {
|
||||||
|
sa, sv := u.Bytes(), v.Bytes()
|
||||||
|
return subtle.ConstantTimeCompare(sa, sv)
|
||||||
|
}
|
||||||
|
|
||||||
|
// mask64Bits returns 0xffffffff if cond is 1, and 0 otherwise.
|
||||||
|
func mask64Bits(cond int) uint64 { return ^(uint64(cond) - 1) }
|
||||||
|
|
||||||
|
// Select sets v to a if cond == 1, and to b if cond == 0.
|
||||||
|
func (v *Element) Select(a, b *Element, cond int) *Element {
|
||||||
|
m := mask64Bits(cond)
|
||||||
|
v.l0 = (m & a.l0) | (^m & b.l0)
|
||||||
|
v.l1 = (m & a.l1) | (^m & b.l1)
|
||||||
|
v.l2 = (m & a.l2) | (^m & b.l2)
|
||||||
|
v.l3 = (m & a.l3) | (^m & b.l3)
|
||||||
|
v.l4 = (m & a.l4) | (^m & b.l4)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap swaps v and u if cond == 1 or leaves them unchanged if cond == 0, and returns v.
|
||||||
|
func (v *Element) Swap(u *Element, cond int) {
|
||||||
|
m := mask64Bits(cond)
|
||||||
|
t := m & (v.l0 ^ u.l0)
|
||||||
|
v.l0 ^= t
|
||||||
|
u.l0 ^= t
|
||||||
|
t = m & (v.l1 ^ u.l1)
|
||||||
|
v.l1 ^= t
|
||||||
|
u.l1 ^= t
|
||||||
|
t = m & (v.l2 ^ u.l2)
|
||||||
|
v.l2 ^= t
|
||||||
|
u.l2 ^= t
|
||||||
|
t = m & (v.l3 ^ u.l3)
|
||||||
|
v.l3 ^= t
|
||||||
|
u.l3 ^= t
|
||||||
|
t = m & (v.l4 ^ u.l4)
|
||||||
|
v.l4 ^= t
|
||||||
|
u.l4 ^= t
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsNegative returns 1 if v is negative, and 0 otherwise.
|
||||||
|
func (v *Element) IsNegative() int {
|
||||||
|
return int(v.Bytes()[0] & 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Absolute sets v to |u|, and returns v.
|
||||||
|
func (v *Element) Absolute(u *Element) *Element {
|
||||||
|
return v.Select(new(Element).Negate(u), u, u.IsNegative())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiply sets v = x * y, and returns v.
|
||||||
|
func (v *Element) Multiply(x, y *Element) *Element {
|
||||||
|
feMul(v, x, y)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Square sets v = x * x, and returns v.
|
||||||
|
func (v *Element) Square(x *Element) *Element {
|
||||||
|
feSquare(v, x)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mult32 sets v = x * y, and returns v.
|
||||||
|
func (v *Element) Mult32(x *Element, y uint32) *Element {
|
||||||
|
x0lo, x0hi := mul51(x.l0, y)
|
||||||
|
x1lo, x1hi := mul51(x.l1, y)
|
||||||
|
x2lo, x2hi := mul51(x.l2, y)
|
||||||
|
x3lo, x3hi := mul51(x.l3, y)
|
||||||
|
x4lo, x4hi := mul51(x.l4, y)
|
||||||
|
v.l0 = x0lo + 19*x4hi // carried over per the reduction identity
|
||||||
|
v.l1 = x1lo + x0hi
|
||||||
|
v.l2 = x2lo + x1hi
|
||||||
|
v.l3 = x3lo + x2hi
|
||||||
|
v.l4 = x4lo + x3hi
|
||||||
|
// The hi portions are going to be only 32 bits, plus any previous excess,
|
||||||
|
// so we can skip the carry propagation.
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// mul51 returns lo + hi * 2⁵¹ = a * b.
|
||||||
|
func mul51(a uint64, b uint32) (lo uint64, hi uint64) {
|
||||||
|
mh, ml := bits.Mul64(a, uint64(b))
|
||||||
|
lo = ml & maskLow51Bits
|
||||||
|
hi = (mh << 13) | (ml >> 51)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pow22523 set v = x^((p-5)/8), and returns v. (p-5)/8 is 2^252-3.
|
||||||
|
func (v *Element) Pow22523(x *Element) *Element {
|
||||||
|
var t0, t1, t2 Element
|
||||||
|
|
||||||
|
t0.Square(x) // x^2
|
||||||
|
t1.Square(&t0) // x^4
|
||||||
|
t1.Square(&t1) // x^8
|
||||||
|
t1.Multiply(x, &t1) // x^9
|
||||||
|
t0.Multiply(&t0, &t1) // x^11
|
||||||
|
t0.Square(&t0) // x^22
|
||||||
|
t0.Multiply(&t1, &t0) // x^31
|
||||||
|
t1.Square(&t0) // x^62
|
||||||
|
for i := 1; i < 5; i++ { // x^992
|
||||||
|
t1.Square(&t1)
|
||||||
|
}
|
||||||
|
t0.Multiply(&t1, &t0) // x^1023 -> 1023 = 2^10 - 1
|
||||||
|
t1.Square(&t0) // 2^11 - 2
|
||||||
|
for i := 1; i < 10; i++ { // 2^20 - 2^10
|
||||||
|
t1.Square(&t1)
|
||||||
|
}
|
||||||
|
t1.Multiply(&t1, &t0) // 2^20 - 1
|
||||||
|
t2.Square(&t1) // 2^21 - 2
|
||||||
|
for i := 1; i < 20; i++ { // 2^40 - 2^20
|
||||||
|
t2.Square(&t2)
|
||||||
|
}
|
||||||
|
t1.Multiply(&t2, &t1) // 2^40 - 1
|
||||||
|
t1.Square(&t1) // 2^41 - 2
|
||||||
|
for i := 1; i < 10; i++ { // 2^50 - 2^10
|
||||||
|
t1.Square(&t1)
|
||||||
|
}
|
||||||
|
t0.Multiply(&t1, &t0) // 2^50 - 1
|
||||||
|
t1.Square(&t0) // 2^51 - 2
|
||||||
|
for i := 1; i < 50; i++ { // 2^100 - 2^50
|
||||||
|
t1.Square(&t1)
|
||||||
|
}
|
||||||
|
t1.Multiply(&t1, &t0) // 2^100 - 1
|
||||||
|
t2.Square(&t1) // 2^101 - 2
|
||||||
|
for i := 1; i < 100; i++ { // 2^200 - 2^100
|
||||||
|
t2.Square(&t2)
|
||||||
|
}
|
||||||
|
t1.Multiply(&t2, &t1) // 2^200 - 1
|
||||||
|
t1.Square(&t1) // 2^201 - 2
|
||||||
|
for i := 1; i < 50; i++ { // 2^250 - 2^50
|
||||||
|
t1.Square(&t1)
|
||||||
|
}
|
||||||
|
t0.Multiply(&t1, &t0) // 2^250 - 1
|
||||||
|
t0.Square(&t0) // 2^251 - 2
|
||||||
|
t0.Square(&t0) // 2^252 - 4
|
||||||
|
return v.Multiply(&t0, x) // 2^252 - 3 -> x^(2^252-3)
|
||||||
|
}
|
||||||
|
|
||||||
|
// sqrtM1 is 2^((p-1)/4), which squared is equal to -1 by Euler's Criterion.
|
||||||
|
var sqrtM1 = &Element{1718705420411056, 234908883556509,
|
||||||
|
2233514472574048, 2117202627021982, 765476049583133}
|
||||||
|
|
||||||
|
// SqrtRatio sets r to the non-negative square root of the ratio of u and v.
|
||||||
|
//
|
||||||
|
// If u/v is square, SqrtRatio returns r and 1. If u/v is not square, SqrtRatio
|
||||||
|
// sets r according to Section 4.3 of draft-irtf-cfrg-ristretto255-decaf448-00,
|
||||||
|
// and returns r and 0.
|
||||||
|
func (r *Element) SqrtRatio(u, v *Element) (rr *Element, wasSquare int) {
|
||||||
|
var a, b Element
|
||||||
|
|
||||||
|
// r = (u * v3) * (u * v7)^((p-5)/8)
|
||||||
|
v2 := a.Square(v)
|
||||||
|
uv3 := b.Multiply(u, b.Multiply(v2, v))
|
||||||
|
uv7 := a.Multiply(uv3, a.Square(v2))
|
||||||
|
r.Multiply(uv3, r.Pow22523(uv7))
|
||||||
|
|
||||||
|
check := a.Multiply(v, a.Square(r)) // check = v * r^2
|
||||||
|
|
||||||
|
uNeg := b.Negate(u)
|
||||||
|
correctSignSqrt := check.Equal(u)
|
||||||
|
flippedSignSqrt := check.Equal(uNeg)
|
||||||
|
flippedSignSqrtI := check.Equal(uNeg.Multiply(uNeg, sqrtM1))
|
||||||
|
|
||||||
|
rPrime := b.Multiply(r, sqrtM1) // r_prime = SQRT_M1 * r
|
||||||
|
// r = CT_SELECT(r_prime IF flipped_sign_sqrt | flipped_sign_sqrt_i ELSE r)
|
||||||
|
r.Select(rPrime, r, flippedSignSqrt|flippedSignSqrtI)
|
||||||
|
|
||||||
|
r.Absolute(r) // Choose the nonnegative square root.
|
||||||
|
return r, correctSignSqrt | flippedSignSqrt
|
||||||
|
}
|
13
vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.go
generated
vendored
Normal file
13
vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.go
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Code generated by command: go run fe_amd64_asm.go -out ../fe_amd64.s -stubs ../fe_amd64.go -pkg field. DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build amd64,gc,!purego
|
||||||
|
|
||||||
|
package field
|
||||||
|
|
||||||
|
// feMul sets out = a * b. It works like feMulGeneric.
|
||||||
|
//go:noescape
|
||||||
|
func feMul(out *Element, a *Element, b *Element)
|
||||||
|
|
||||||
|
// feSquare sets out = a * a. It works like feSquareGeneric.
|
||||||
|
//go:noescape
|
||||||
|
func feSquare(out *Element, a *Element)
|
379
vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.s
generated
vendored
Normal file
379
vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.s
generated
vendored
Normal file
@ -0,0 +1,379 @@
|
|||||||
|
// Code generated by command: go run fe_amd64_asm.go -out ../fe_amd64.s -stubs ../fe_amd64.go -pkg field. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build amd64 && gc && !purego
|
||||||
|
// +build amd64,gc,!purego
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// func feMul(out *Element, a *Element, b *Element)
|
||||||
|
TEXT ·feMul(SB), NOSPLIT, $0-24
|
||||||
|
MOVQ a+8(FP), CX
|
||||||
|
MOVQ b+16(FP), BX
|
||||||
|
|
||||||
|
// r0 = a0×b0
|
||||||
|
MOVQ (CX), AX
|
||||||
|
MULQ (BX)
|
||||||
|
MOVQ AX, DI
|
||||||
|
MOVQ DX, SI
|
||||||
|
|
||||||
|
// r0 += 19×a1×b4
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 32(BX)
|
||||||
|
ADDQ AX, DI
|
||||||
|
ADCQ DX, SI
|
||||||
|
|
||||||
|
// r0 += 19×a2×b3
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 24(BX)
|
||||||
|
ADDQ AX, DI
|
||||||
|
ADCQ DX, SI
|
||||||
|
|
||||||
|
// r0 += 19×a3×b2
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 16(BX)
|
||||||
|
ADDQ AX, DI
|
||||||
|
ADCQ DX, SI
|
||||||
|
|
||||||
|
// r0 += 19×a4×b1
|
||||||
|
MOVQ 32(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 8(BX)
|
||||||
|
ADDQ AX, DI
|
||||||
|
ADCQ DX, SI
|
||||||
|
|
||||||
|
// r1 = a0×b1
|
||||||
|
MOVQ (CX), AX
|
||||||
|
MULQ 8(BX)
|
||||||
|
MOVQ AX, R9
|
||||||
|
MOVQ DX, R8
|
||||||
|
|
||||||
|
// r1 += a1×b0
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
MULQ (BX)
|
||||||
|
ADDQ AX, R9
|
||||||
|
ADCQ DX, R8
|
||||||
|
|
||||||
|
// r1 += 19×a2×b4
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 32(BX)
|
||||||
|
ADDQ AX, R9
|
||||||
|
ADCQ DX, R8
|
||||||
|
|
||||||
|
// r1 += 19×a3×b3
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 24(BX)
|
||||||
|
ADDQ AX, R9
|
||||||
|
ADCQ DX, R8
|
||||||
|
|
||||||
|
// r1 += 19×a4×b2
|
||||||
|
MOVQ 32(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 16(BX)
|
||||||
|
ADDQ AX, R9
|
||||||
|
ADCQ DX, R8
|
||||||
|
|
||||||
|
// r2 = a0×b2
|
||||||
|
MOVQ (CX), AX
|
||||||
|
MULQ 16(BX)
|
||||||
|
MOVQ AX, R11
|
||||||
|
MOVQ DX, R10
|
||||||
|
|
||||||
|
// r2 += a1×b1
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
MULQ 8(BX)
|
||||||
|
ADDQ AX, R11
|
||||||
|
ADCQ DX, R10
|
||||||
|
|
||||||
|
// r2 += a2×b0
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
MULQ (BX)
|
||||||
|
ADDQ AX, R11
|
||||||
|
ADCQ DX, R10
|
||||||
|
|
||||||
|
// r2 += 19×a3×b4
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 32(BX)
|
||||||
|
ADDQ AX, R11
|
||||||
|
ADCQ DX, R10
|
||||||
|
|
||||||
|
// r2 += 19×a4×b3
|
||||||
|
MOVQ 32(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 24(BX)
|
||||||
|
ADDQ AX, R11
|
||||||
|
ADCQ DX, R10
|
||||||
|
|
||||||
|
// r3 = a0×b3
|
||||||
|
MOVQ (CX), AX
|
||||||
|
MULQ 24(BX)
|
||||||
|
MOVQ AX, R13
|
||||||
|
MOVQ DX, R12
|
||||||
|
|
||||||
|
// r3 += a1×b2
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
MULQ 16(BX)
|
||||||
|
ADDQ AX, R13
|
||||||
|
ADCQ DX, R12
|
||||||
|
|
||||||
|
// r3 += a2×b1
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
MULQ 8(BX)
|
||||||
|
ADDQ AX, R13
|
||||||
|
ADCQ DX, R12
|
||||||
|
|
||||||
|
// r3 += a3×b0
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
MULQ (BX)
|
||||||
|
ADDQ AX, R13
|
||||||
|
ADCQ DX, R12
|
||||||
|
|
||||||
|
// r3 += 19×a4×b4
|
||||||
|
MOVQ 32(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 32(BX)
|
||||||
|
ADDQ AX, R13
|
||||||
|
ADCQ DX, R12
|
||||||
|
|
||||||
|
// r4 = a0×b4
|
||||||
|
MOVQ (CX), AX
|
||||||
|
MULQ 32(BX)
|
||||||
|
MOVQ AX, R15
|
||||||
|
MOVQ DX, R14
|
||||||
|
|
||||||
|
// r4 += a1×b3
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
MULQ 24(BX)
|
||||||
|
ADDQ AX, R15
|
||||||
|
ADCQ DX, R14
|
||||||
|
|
||||||
|
// r4 += a2×b2
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
MULQ 16(BX)
|
||||||
|
ADDQ AX, R15
|
||||||
|
ADCQ DX, R14
|
||||||
|
|
||||||
|
// r4 += a3×b1
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
MULQ 8(BX)
|
||||||
|
ADDQ AX, R15
|
||||||
|
ADCQ DX, R14
|
||||||
|
|
||||||
|
// r4 += a4×b0
|
||||||
|
MOVQ 32(CX), AX
|
||||||
|
MULQ (BX)
|
||||||
|
ADDQ AX, R15
|
||||||
|
ADCQ DX, R14
|
||||||
|
|
||||||
|
// First reduction chain
|
||||||
|
MOVQ $0x0007ffffffffffff, AX
|
||||||
|
SHLQ $0x0d, DI, SI
|
||||||
|
SHLQ $0x0d, R9, R8
|
||||||
|
SHLQ $0x0d, R11, R10
|
||||||
|
SHLQ $0x0d, R13, R12
|
||||||
|
SHLQ $0x0d, R15, R14
|
||||||
|
ANDQ AX, DI
|
||||||
|
IMUL3Q $0x13, R14, R14
|
||||||
|
ADDQ R14, DI
|
||||||
|
ANDQ AX, R9
|
||||||
|
ADDQ SI, R9
|
||||||
|
ANDQ AX, R11
|
||||||
|
ADDQ R8, R11
|
||||||
|
ANDQ AX, R13
|
||||||
|
ADDQ R10, R13
|
||||||
|
ANDQ AX, R15
|
||||||
|
ADDQ R12, R15
|
||||||
|
|
||||||
|
// Second reduction chain (carryPropagate)
|
||||||
|
MOVQ DI, SI
|
||||||
|
SHRQ $0x33, SI
|
||||||
|
MOVQ R9, R8
|
||||||
|
SHRQ $0x33, R8
|
||||||
|
MOVQ R11, R10
|
||||||
|
SHRQ $0x33, R10
|
||||||
|
MOVQ R13, R12
|
||||||
|
SHRQ $0x33, R12
|
||||||
|
MOVQ R15, R14
|
||||||
|
SHRQ $0x33, R14
|
||||||
|
ANDQ AX, DI
|
||||||
|
IMUL3Q $0x13, R14, R14
|
||||||
|
ADDQ R14, DI
|
||||||
|
ANDQ AX, R9
|
||||||
|
ADDQ SI, R9
|
||||||
|
ANDQ AX, R11
|
||||||
|
ADDQ R8, R11
|
||||||
|
ANDQ AX, R13
|
||||||
|
ADDQ R10, R13
|
||||||
|
ANDQ AX, R15
|
||||||
|
ADDQ R12, R15
|
||||||
|
|
||||||
|
// Store output
|
||||||
|
MOVQ out+0(FP), AX
|
||||||
|
MOVQ DI, (AX)
|
||||||
|
MOVQ R9, 8(AX)
|
||||||
|
MOVQ R11, 16(AX)
|
||||||
|
MOVQ R13, 24(AX)
|
||||||
|
MOVQ R15, 32(AX)
|
||||||
|
RET
|
||||||
|
|
||||||
|
// func feSquare(out *Element, a *Element)
|
||||||
|
TEXT ·feSquare(SB), NOSPLIT, $0-16
|
||||||
|
MOVQ a+8(FP), CX
|
||||||
|
|
||||||
|
// r0 = l0×l0
|
||||||
|
MOVQ (CX), AX
|
||||||
|
MULQ (CX)
|
||||||
|
MOVQ AX, SI
|
||||||
|
MOVQ DX, BX
|
||||||
|
|
||||||
|
// r0 += 38×l1×l4
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
IMUL3Q $0x26, AX, AX
|
||||||
|
MULQ 32(CX)
|
||||||
|
ADDQ AX, SI
|
||||||
|
ADCQ DX, BX
|
||||||
|
|
||||||
|
// r0 += 38×l2×l3
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
IMUL3Q $0x26, AX, AX
|
||||||
|
MULQ 24(CX)
|
||||||
|
ADDQ AX, SI
|
||||||
|
ADCQ DX, BX
|
||||||
|
|
||||||
|
// r1 = 2×l0×l1
|
||||||
|
MOVQ (CX), AX
|
||||||
|
SHLQ $0x01, AX
|
||||||
|
MULQ 8(CX)
|
||||||
|
MOVQ AX, R8
|
||||||
|
MOVQ DX, DI
|
||||||
|
|
||||||
|
// r1 += 38×l2×l4
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
IMUL3Q $0x26, AX, AX
|
||||||
|
MULQ 32(CX)
|
||||||
|
ADDQ AX, R8
|
||||||
|
ADCQ DX, DI
|
||||||
|
|
||||||
|
// r1 += 19×l3×l3
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 24(CX)
|
||||||
|
ADDQ AX, R8
|
||||||
|
ADCQ DX, DI
|
||||||
|
|
||||||
|
// r2 = 2×l0×l2
|
||||||
|
MOVQ (CX), AX
|
||||||
|
SHLQ $0x01, AX
|
||||||
|
MULQ 16(CX)
|
||||||
|
MOVQ AX, R10
|
||||||
|
MOVQ DX, R9
|
||||||
|
|
||||||
|
// r2 += l1×l1
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
MULQ 8(CX)
|
||||||
|
ADDQ AX, R10
|
||||||
|
ADCQ DX, R9
|
||||||
|
|
||||||
|
// r2 += 38×l3×l4
|
||||||
|
MOVQ 24(CX), AX
|
||||||
|
IMUL3Q $0x26, AX, AX
|
||||||
|
MULQ 32(CX)
|
||||||
|
ADDQ AX, R10
|
||||||
|
ADCQ DX, R9
|
||||||
|
|
||||||
|
// r3 = 2×l0×l3
|
||||||
|
MOVQ (CX), AX
|
||||||
|
SHLQ $0x01, AX
|
||||||
|
MULQ 24(CX)
|
||||||
|
MOVQ AX, R12
|
||||||
|
MOVQ DX, R11
|
||||||
|
|
||||||
|
// r3 += 2×l1×l2
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
IMUL3Q $0x02, AX, AX
|
||||||
|
MULQ 16(CX)
|
||||||
|
ADDQ AX, R12
|
||||||
|
ADCQ DX, R11
|
||||||
|
|
||||||
|
// r3 += 19×l4×l4
|
||||||
|
MOVQ 32(CX), AX
|
||||||
|
IMUL3Q $0x13, AX, AX
|
||||||
|
MULQ 32(CX)
|
||||||
|
ADDQ AX, R12
|
||||||
|
ADCQ DX, R11
|
||||||
|
|
||||||
|
// r4 = 2×l0×l4
|
||||||
|
MOVQ (CX), AX
|
||||||
|
SHLQ $0x01, AX
|
||||||
|
MULQ 32(CX)
|
||||||
|
MOVQ AX, R14
|
||||||
|
MOVQ DX, R13
|
||||||
|
|
||||||
|
// r4 += 2×l1×l3
|
||||||
|
MOVQ 8(CX), AX
|
||||||
|
IMUL3Q $0x02, AX, AX
|
||||||
|
MULQ 24(CX)
|
||||||
|
ADDQ AX, R14
|
||||||
|
ADCQ DX, R13
|
||||||
|
|
||||||
|
// r4 += l2×l2
|
||||||
|
MOVQ 16(CX), AX
|
||||||
|
MULQ 16(CX)
|
||||||
|
ADDQ AX, R14
|
||||||
|
ADCQ DX, R13
|
||||||
|
|
||||||
|
// First reduction chain
|
||||||
|
MOVQ $0x0007ffffffffffff, AX
|
||||||
|
SHLQ $0x0d, SI, BX
|
||||||
|
SHLQ $0x0d, R8, DI
|
||||||
|
SHLQ $0x0d, R10, R9
|
||||||
|
SHLQ $0x0d, R12, R11
|
||||||
|
SHLQ $0x0d, R14, R13
|
||||||
|
ANDQ AX, SI
|
||||||
|
IMUL3Q $0x13, R13, R13
|
||||||
|
ADDQ R13, SI
|
||||||
|
ANDQ AX, R8
|
||||||
|
ADDQ BX, R8
|
||||||
|
ANDQ AX, R10
|
||||||
|
ADDQ DI, R10
|
||||||
|
ANDQ AX, R12
|
||||||
|
ADDQ R9, R12
|
||||||
|
ANDQ AX, R14
|
||||||
|
ADDQ R11, R14
|
||||||
|
|
||||||
|
// Second reduction chain (carryPropagate)
|
||||||
|
MOVQ SI, BX
|
||||||
|
SHRQ $0x33, BX
|
||||||
|
MOVQ R8, DI
|
||||||
|
SHRQ $0x33, DI
|
||||||
|
MOVQ R10, R9
|
||||||
|
SHRQ $0x33, R9
|
||||||
|
MOVQ R12, R11
|
||||||
|
SHRQ $0x33, R11
|
||||||
|
MOVQ R14, R13
|
||||||
|
SHRQ $0x33, R13
|
||||||
|
ANDQ AX, SI
|
||||||
|
IMUL3Q $0x13, R13, R13
|
||||||
|
ADDQ R13, SI
|
||||||
|
ANDQ AX, R8
|
||||||
|
ADDQ BX, R8
|
||||||
|
ANDQ AX, R10
|
||||||
|
ADDQ DI, R10
|
||||||
|
ANDQ AX, R12
|
||||||
|
ADDQ R9, R12
|
||||||
|
ANDQ AX, R14
|
||||||
|
ADDQ R11, R14
|
||||||
|
|
||||||
|
// Store output
|
||||||
|
MOVQ out+0(FP), AX
|
||||||
|
MOVQ SI, (AX)
|
||||||
|
MOVQ R8, 8(AX)
|
||||||
|
MOVQ R10, 16(AX)
|
||||||
|
MOVQ R12, 24(AX)
|
||||||
|
MOVQ R14, 32(AX)
|
||||||
|
RET
|
12
vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64_noasm.go
generated
vendored
Normal file
12
vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64_noasm.go
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright (c) 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !amd64 || !gc || purego
|
||||||
|
// +build !amd64 !gc purego
|
||||||
|
|
||||||
|
package field
|
||||||
|
|
||||||
|
func feMul(v, x, y *Element) { feMulGeneric(v, x, y) }
|
||||||
|
|
||||||
|
func feSquare(v, x *Element) { feSquareGeneric(v, x) }
|
16
vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.go
generated
vendored
Normal file
16
vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.go
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) 2020 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build arm64 && gc && !purego
|
||||||
|
// +build arm64,gc,!purego
|
||||||
|
|
||||||
|
package field
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
func carryPropagate(v *Element)
|
||||||
|
|
||||||
|
func (v *Element) carryPropagate() *Element {
|
||||||
|
carryPropagate(v)
|
||||||
|
return v
|
||||||
|
}
|
43
vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.s
generated
vendored
Normal file
43
vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.s
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (c) 2020 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build arm64 && gc && !purego
|
||||||
|
// +build arm64,gc,!purego
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// carryPropagate works exactly like carryPropagateGeneric and uses the
|
||||||
|
// same AND, ADD, and LSR+MADD instructions emitted by the compiler, but
|
||||||
|
// avoids loading R0-R4 twice and uses LDP and STP.
|
||||||
|
//
|
||||||
|
// See https://golang.org/issues/43145 for the main compiler issue.
|
||||||
|
//
|
||||||
|
// func carryPropagate(v *Element)
|
||||||
|
TEXT ·carryPropagate(SB),NOFRAME|NOSPLIT,$0-8
|
||||||
|
MOVD v+0(FP), R20
|
||||||
|
|
||||||
|
LDP 0(R20), (R0, R1)
|
||||||
|
LDP 16(R20), (R2, R3)
|
||||||
|
MOVD 32(R20), R4
|
||||||
|
|
||||||
|
AND $0x7ffffffffffff, R0, R10
|
||||||
|
AND $0x7ffffffffffff, R1, R11
|
||||||
|
AND $0x7ffffffffffff, R2, R12
|
||||||
|
AND $0x7ffffffffffff, R3, R13
|
||||||
|
AND $0x7ffffffffffff, R4, R14
|
||||||
|
|
||||||
|
ADD R0>>51, R11, R11
|
||||||
|
ADD R1>>51, R12, R12
|
||||||
|
ADD R2>>51, R13, R13
|
||||||
|
ADD R3>>51, R14, R14
|
||||||
|
// R4>>51 * 19 + R10 -> R10
|
||||||
|
LSR $51, R4, R21
|
||||||
|
MOVD $19, R22
|
||||||
|
MADD R22, R10, R21, R10
|
||||||
|
|
||||||
|
STP (R10, R11), 0(R20)
|
||||||
|
STP (R12, R13), 16(R20)
|
||||||
|
MOVD R14, 32(R20)
|
||||||
|
|
||||||
|
RET
|
12
vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64_noasm.go
generated
vendored
Normal file
12
vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64_noasm.go
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright (c) 2021 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !arm64 || !gc || purego
|
||||||
|
// +build !arm64 !gc purego
|
||||||
|
|
||||||
|
package field
|
||||||
|
|
||||||
|
func (v *Element) carryPropagate() *Element {
|
||||||
|
return v.carryPropagateGeneric()
|
||||||
|
}
|
264
vendor/golang.org/x/crypto/curve25519/internal/field/fe_generic.go
generated
vendored
Normal file
264
vendor/golang.org/x/crypto/curve25519/internal/field/fe_generic.go
generated
vendored
Normal file
@ -0,0 +1,264 @@
|
|||||||
|
// Copyright (c) 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package field
|
||||||
|
|
||||||
|
import "math/bits"
|
||||||
|
|
||||||
|
// uint128 holds a 128-bit number as two 64-bit limbs, for use with the
|
||||||
|
// bits.Mul64 and bits.Add64 intrinsics.
|
||||||
|
type uint128 struct {
|
||||||
|
lo, hi uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
// mul64 returns a * b.
|
||||||
|
func mul64(a, b uint64) uint128 {
|
||||||
|
hi, lo := bits.Mul64(a, b)
|
||||||
|
return uint128{lo, hi}
|
||||||
|
}
|
||||||
|
|
||||||
|
// addMul64 returns v + a * b.
|
||||||
|
func addMul64(v uint128, a, b uint64) uint128 {
|
||||||
|
hi, lo := bits.Mul64(a, b)
|
||||||
|
lo, c := bits.Add64(lo, v.lo, 0)
|
||||||
|
hi, _ = bits.Add64(hi, v.hi, c)
|
||||||
|
return uint128{lo, hi}
|
||||||
|
}
|
||||||
|
|
||||||
|
// shiftRightBy51 returns a >> 51. a is assumed to be at most 115 bits.
|
||||||
|
func shiftRightBy51(a uint128) uint64 {
|
||||||
|
return (a.hi << (64 - 51)) | (a.lo >> 51)
|
||||||
|
}
|
||||||
|
|
||||||
|
func feMulGeneric(v, a, b *Element) {
|
||||||
|
a0 := a.l0
|
||||||
|
a1 := a.l1
|
||||||
|
a2 := a.l2
|
||||||
|
a3 := a.l3
|
||||||
|
a4 := a.l4
|
||||||
|
|
||||||
|
b0 := b.l0
|
||||||
|
b1 := b.l1
|
||||||
|
b2 := b.l2
|
||||||
|
b3 := b.l3
|
||||||
|
b4 := b.l4
|
||||||
|
|
||||||
|
// Limb multiplication works like pen-and-paper columnar multiplication, but
|
||||||
|
// with 51-bit limbs instead of digits.
|
||||||
|
//
|
||||||
|
// a4 a3 a2 a1 a0 x
|
||||||
|
// b4 b3 b2 b1 b0 =
|
||||||
|
// ------------------------
|
||||||
|
// a4b0 a3b0 a2b0 a1b0 a0b0 +
|
||||||
|
// a4b1 a3b1 a2b1 a1b1 a0b1 +
|
||||||
|
// a4b2 a3b2 a2b2 a1b2 a0b2 +
|
||||||
|
// a4b3 a3b3 a2b3 a1b3 a0b3 +
|
||||||
|
// a4b4 a3b4 a2b4 a1b4 a0b4 =
|
||||||
|
// ----------------------------------------------
|
||||||
|
// r8 r7 r6 r5 r4 r3 r2 r1 r0
|
||||||
|
//
|
||||||
|
// We can then use the reduction identity (a * 2²⁵⁵ + b = a * 19 + b) to
|
||||||
|
// reduce the limbs that would overflow 255 bits. r5 * 2²⁵⁵ becomes 19 * r5,
|
||||||
|
// r6 * 2³⁰⁶ becomes 19 * r6 * 2⁵¹, etc.
|
||||||
|
//
|
||||||
|
// Reduction can be carried out simultaneously to multiplication. For
|
||||||
|
// example, we do not compute r5: whenever the result of a multiplication
|
||||||
|
// belongs to r5, like a1b4, we multiply it by 19 and add the result to r0.
|
||||||
|
//
|
||||||
|
// a4b0 a3b0 a2b0 a1b0 a0b0 +
|
||||||
|
// a3b1 a2b1 a1b1 a0b1 19×a4b1 +
|
||||||
|
// a2b2 a1b2 a0b2 19×a4b2 19×a3b2 +
|
||||||
|
// a1b3 a0b3 19×a4b3 19×a3b3 19×a2b3 +
|
||||||
|
// a0b4 19×a4b4 19×a3b4 19×a2b4 19×a1b4 =
|
||||||
|
// --------------------------------------
|
||||||
|
// r4 r3 r2 r1 r0
|
||||||
|
//
|
||||||
|
// Finally we add up the columns into wide, overlapping limbs.
|
||||||
|
|
||||||
|
a1_19 := a1 * 19
|
||||||
|
a2_19 := a2 * 19
|
||||||
|
a3_19 := a3 * 19
|
||||||
|
a4_19 := a4 * 19
|
||||||
|
|
||||||
|
// r0 = a0×b0 + 19×(a1×b4 + a2×b3 + a3×b2 + a4×b1)
|
||||||
|
r0 := mul64(a0, b0)
|
||||||
|
r0 = addMul64(r0, a1_19, b4)
|
||||||
|
r0 = addMul64(r0, a2_19, b3)
|
||||||
|
r0 = addMul64(r0, a3_19, b2)
|
||||||
|
r0 = addMul64(r0, a4_19, b1)
|
||||||
|
|
||||||
|
// r1 = a0×b1 + a1×b0 + 19×(a2×b4 + a3×b3 + a4×b2)
|
||||||
|
r1 := mul64(a0, b1)
|
||||||
|
r1 = addMul64(r1, a1, b0)
|
||||||
|
r1 = addMul64(r1, a2_19, b4)
|
||||||
|
r1 = addMul64(r1, a3_19, b3)
|
||||||
|
r1 = addMul64(r1, a4_19, b2)
|
||||||
|
|
||||||
|
// r2 = a0×b2 + a1×b1 + a2×b0 + 19×(a3×b4 + a4×b3)
|
||||||
|
r2 := mul64(a0, b2)
|
||||||
|
r2 = addMul64(r2, a1, b1)
|
||||||
|
r2 = addMul64(r2, a2, b0)
|
||||||
|
r2 = addMul64(r2, a3_19, b4)
|
||||||
|
r2 = addMul64(r2, a4_19, b3)
|
||||||
|
|
||||||
|
// r3 = a0×b3 + a1×b2 + a2×b1 + a3×b0 + 19×a4×b4
|
||||||
|
r3 := mul64(a0, b3)
|
||||||
|
r3 = addMul64(r3, a1, b2)
|
||||||
|
r3 = addMul64(r3, a2, b1)
|
||||||
|
r3 = addMul64(r3, a3, b0)
|
||||||
|
r3 = addMul64(r3, a4_19, b4)
|
||||||
|
|
||||||
|
// r4 = a0×b4 + a1×b3 + a2×b2 + a3×b1 + a4×b0
|
||||||
|
r4 := mul64(a0, b4)
|
||||||
|
r4 = addMul64(r4, a1, b3)
|
||||||
|
r4 = addMul64(r4, a2, b2)
|
||||||
|
r4 = addMul64(r4, a3, b1)
|
||||||
|
r4 = addMul64(r4, a4, b0)
|
||||||
|
|
||||||
|
// After the multiplication, we need to reduce (carry) the five coefficients
|
||||||
|
// to obtain a result with limbs that are at most slightly larger than 2⁵¹,
|
||||||
|
// to respect the Element invariant.
|
||||||
|
//
|
||||||
|
// Overall, the reduction works the same as carryPropagate, except with
|
||||||
|
// wider inputs: we take the carry for each coefficient by shifting it right
|
||||||
|
// by 51, and add it to the limb above it. The top carry is multiplied by 19
|
||||||
|
// according to the reduction identity and added to the lowest limb.
|
||||||
|
//
|
||||||
|
// The largest coefficient (r0) will be at most 111 bits, which guarantees
|
||||||
|
// that all carries are at most 111 - 51 = 60 bits, which fits in a uint64.
|
||||||
|
//
|
||||||
|
// r0 = a0×b0 + 19×(a1×b4 + a2×b3 + a3×b2 + a4×b1)
|
||||||
|
// r0 < 2⁵²×2⁵² + 19×(2⁵²×2⁵² + 2⁵²×2⁵² + 2⁵²×2⁵² + 2⁵²×2⁵²)
|
||||||
|
// r0 < (1 + 19 × 4) × 2⁵² × 2⁵²
|
||||||
|
// r0 < 2⁷ × 2⁵² × 2⁵²
|
||||||
|
// r0 < 2¹¹¹
|
||||||
|
//
|
||||||
|
// Moreover, the top coefficient (r4) is at most 107 bits, so c4 is at most
|
||||||
|
// 56 bits, and c4 * 19 is at most 61 bits, which again fits in a uint64 and
|
||||||
|
// allows us to easily apply the reduction identity.
|
||||||
|
//
|
||||||
|
// r4 = a0×b4 + a1×b3 + a2×b2 + a3×b1 + a4×b0
|
||||||
|
// r4 < 5 × 2⁵² × 2⁵²
|
||||||
|
// r4 < 2¹⁰⁷
|
||||||
|
//
|
||||||
|
|
||||||
|
c0 := shiftRightBy51(r0)
|
||||||
|
c1 := shiftRightBy51(r1)
|
||||||
|
c2 := shiftRightBy51(r2)
|
||||||
|
c3 := shiftRightBy51(r3)
|
||||||
|
c4 := shiftRightBy51(r4)
|
||||||
|
|
||||||
|
rr0 := r0.lo&maskLow51Bits + c4*19
|
||||||
|
rr1 := r1.lo&maskLow51Bits + c0
|
||||||
|
rr2 := r2.lo&maskLow51Bits + c1
|
||||||
|
rr3 := r3.lo&maskLow51Bits + c2
|
||||||
|
rr4 := r4.lo&maskLow51Bits + c3
|
||||||
|
|
||||||
|
// Now all coefficients fit into 64-bit registers but are still too large to
|
||||||
|
// be passed around as a Element. We therefore do one last carry chain,
|
||||||
|
// where the carries will be small enough to fit in the wiggle room above 2⁵¹.
|
||||||
|
*v = Element{rr0, rr1, rr2, rr3, rr4}
|
||||||
|
v.carryPropagate()
|
||||||
|
}
|
||||||
|
|
||||||
|
func feSquareGeneric(v, a *Element) {
|
||||||
|
l0 := a.l0
|
||||||
|
l1 := a.l1
|
||||||
|
l2 := a.l2
|
||||||
|
l3 := a.l3
|
||||||
|
l4 := a.l4
|
||||||
|
|
||||||
|
// Squaring works precisely like multiplication above, but thanks to its
|
||||||
|
// symmetry we get to group a few terms together.
|
||||||
|
//
|
||||||
|
// l4 l3 l2 l1 l0 x
|
||||||
|
// l4 l3 l2 l1 l0 =
|
||||||
|
// ------------------------
|
||||||
|
// l4l0 l3l0 l2l0 l1l0 l0l0 +
|
||||||
|
// l4l1 l3l1 l2l1 l1l1 l0l1 +
|
||||||
|
// l4l2 l3l2 l2l2 l1l2 l0l2 +
|
||||||
|
// l4l3 l3l3 l2l3 l1l3 l0l3 +
|
||||||
|
// l4l4 l3l4 l2l4 l1l4 l0l4 =
|
||||||
|
// ----------------------------------------------
|
||||||
|
// r8 r7 r6 r5 r4 r3 r2 r1 r0
|
||||||
|
//
|
||||||
|
// l4l0 l3l0 l2l0 l1l0 l0l0 +
|
||||||
|
// l3l1 l2l1 l1l1 l0l1 19×l4l1 +
|
||||||
|
// l2l2 l1l2 l0l2 19×l4l2 19×l3l2 +
|
||||||
|
// l1l3 l0l3 19×l4l3 19×l3l3 19×l2l3 +
|
||||||
|
// l0l4 19×l4l4 19×l3l4 19×l2l4 19×l1l4 =
|
||||||
|
// --------------------------------------
|
||||||
|
// r4 r3 r2 r1 r0
|
||||||
|
//
|
||||||
|
// With precomputed 2×, 19×, and 2×19× terms, we can compute each limb with
|
||||||
|
// only three Mul64 and four Add64, instead of five and eight.
|
||||||
|
|
||||||
|
l0_2 := l0 * 2
|
||||||
|
l1_2 := l1 * 2
|
||||||
|
|
||||||
|
l1_38 := l1 * 38
|
||||||
|
l2_38 := l2 * 38
|
||||||
|
l3_38 := l3 * 38
|
||||||
|
|
||||||
|
l3_19 := l3 * 19
|
||||||
|
l4_19 := l4 * 19
|
||||||
|
|
||||||
|
// r0 = l0×l0 + 19×(l1×l4 + l2×l3 + l3×l2 + l4×l1) = l0×l0 + 19×2×(l1×l4 + l2×l3)
|
||||||
|
r0 := mul64(l0, l0)
|
||||||
|
r0 = addMul64(r0, l1_38, l4)
|
||||||
|
r0 = addMul64(r0, l2_38, l3)
|
||||||
|
|
||||||
|
// r1 = l0×l1 + l1×l0 + 19×(l2×l4 + l3×l3 + l4×l2) = 2×l0×l1 + 19×2×l2×l4 + 19×l3×l3
|
||||||
|
r1 := mul64(l0_2, l1)
|
||||||
|
r1 = addMul64(r1, l2_38, l4)
|
||||||
|
r1 = addMul64(r1, l3_19, l3)
|
||||||
|
|
||||||
|
// r2 = l0×l2 + l1×l1 + l2×l0 + 19×(l3×l4 + l4×l3) = 2×l0×l2 + l1×l1 + 19×2×l3×l4
|
||||||
|
r2 := mul64(l0_2, l2)
|
||||||
|
r2 = addMul64(r2, l1, l1)
|
||||||
|
r2 = addMul64(r2, l3_38, l4)
|
||||||
|
|
||||||
|
// r3 = l0×l3 + l1×l2 + l2×l1 + l3×l0 + 19×l4×l4 = 2×l0×l3 + 2×l1×l2 + 19×l4×l4
|
||||||
|
r3 := mul64(l0_2, l3)
|
||||||
|
r3 = addMul64(r3, l1_2, l2)
|
||||||
|
r3 = addMul64(r3, l4_19, l4)
|
||||||
|
|
||||||
|
// r4 = l0×l4 + l1×l3 + l2×l2 + l3×l1 + l4×l0 = 2×l0×l4 + 2×l1×l3 + l2×l2
|
||||||
|
r4 := mul64(l0_2, l4)
|
||||||
|
r4 = addMul64(r4, l1_2, l3)
|
||||||
|
r4 = addMul64(r4, l2, l2)
|
||||||
|
|
||||||
|
c0 := shiftRightBy51(r0)
|
||||||
|
c1 := shiftRightBy51(r1)
|
||||||
|
c2 := shiftRightBy51(r2)
|
||||||
|
c3 := shiftRightBy51(r3)
|
||||||
|
c4 := shiftRightBy51(r4)
|
||||||
|
|
||||||
|
rr0 := r0.lo&maskLow51Bits + c4*19
|
||||||
|
rr1 := r1.lo&maskLow51Bits + c0
|
||||||
|
rr2 := r2.lo&maskLow51Bits + c1
|
||||||
|
rr3 := r3.lo&maskLow51Bits + c2
|
||||||
|
rr4 := r4.lo&maskLow51Bits + c3
|
||||||
|
|
||||||
|
*v = Element{rr0, rr1, rr2, rr3, rr4}
|
||||||
|
v.carryPropagate()
|
||||||
|
}
|
||||||
|
|
||||||
|
// carryPropagate brings the limbs below 52 bits by applying the reduction
|
||||||
|
// identity (a * 2²⁵⁵ + b = a * 19 + b) to the l4 carry. TODO inline
|
||||||
|
func (v *Element) carryPropagateGeneric() *Element {
|
||||||
|
c0 := v.l0 >> 51
|
||||||
|
c1 := v.l1 >> 51
|
||||||
|
c2 := v.l2 >> 51
|
||||||
|
c3 := v.l3 >> 51
|
||||||
|
c4 := v.l4 >> 51
|
||||||
|
|
||||||
|
v.l0 = v.l0&maskLow51Bits + c4*19
|
||||||
|
v.l1 = v.l1&maskLow51Bits + c0
|
||||||
|
v.l2 = v.l2&maskLow51Bits + c1
|
||||||
|
v.l3 = v.l3&maskLow51Bits + c2
|
||||||
|
v.l4 = v.l4&maskLow51Bits + c3
|
||||||
|
|
||||||
|
return v
|
||||||
|
}
|
1
vendor/golang.org/x/crypto/curve25519/internal/field/sync.checkpoint
generated
vendored
Normal file
1
vendor/golang.org/x/crypto/curve25519/internal/field/sync.checkpoint
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
b0c49ae9f59d233526f8934262c5bbbe14d4358d
|
19
vendor/golang.org/x/crypto/curve25519/internal/field/sync.sh
generated
vendored
Normal file
19
vendor/golang.org/x/crypto/curve25519/internal/field/sync.sh
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cd "$(git rev-parse --show-toplevel)"
|
||||||
|
|
||||||
|
STD_PATH=src/crypto/ed25519/internal/edwards25519/field
|
||||||
|
LOCAL_PATH=curve25519/internal/field
|
||||||
|
LAST_SYNC_REF=$(cat $LOCAL_PATH/sync.checkpoint)
|
||||||
|
|
||||||
|
git fetch https://go.googlesource.com/go master
|
||||||
|
|
||||||
|
if git diff --quiet $LAST_SYNC_REF:$STD_PATH FETCH_HEAD:$STD_PATH; then
|
||||||
|
echo "No changes."
|
||||||
|
else
|
||||||
|
NEW_REF=$(git rev-parse FETCH_HEAD | tee $LOCAL_PATH/sync.checkpoint)
|
||||||
|
echo "Applying changes from $LAST_SYNC_REF to $NEW_REF..."
|
||||||
|
git diff $LAST_SYNC_REF:$STD_PATH FETCH_HEAD:$STD_PATH | \
|
||||||
|
git apply -3 --directory=$LOCAL_PATH
|
||||||
|
fi
|
1
vendor/golang.org/x/crypto/ed25519/ed25519.go
generated
vendored
1
vendor/golang.org/x/crypto/ed25519/ed25519.go
generated
vendored
@ -5,6 +5,7 @@
|
|||||||
// In Go 1.13, the ed25519 package was promoted to the standard library as
|
// In Go 1.13, the ed25519 package was promoted to the standard library as
|
||||||
// crypto/ed25519, and this package became a wrapper for the standard library one.
|
// crypto/ed25519, and this package became a wrapper for the standard library one.
|
||||||
//
|
//
|
||||||
|
//go:build !go1.13
|
||||||
// +build !go1.13
|
// +build !go1.13
|
||||||
|
|
||||||
// Package ed25519 implements the Ed25519 signature algorithm. See
|
// Package ed25519 implements the Ed25519 signature algorithm. See
|
||||||
|
1
vendor/golang.org/x/crypto/ed25519/ed25519_go113.go
generated
vendored
1
vendor/golang.org/x/crypto/ed25519/ed25519_go113.go
generated
vendored
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build go1.13
|
||||||
// +build go1.13
|
// +build go1.13
|
||||||
|
|
||||||
// Package ed25519 implements the Ed25519 signature algorithm. See
|
// Package ed25519 implements the Ed25519 signature algorithm. See
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !go1.13
|
||||||
// +build !go1.13
|
// +build !go1.13
|
||||||
|
|
||||||
package poly1305
|
package poly1305
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build go1.13
|
||||||
// +build go1.13
|
// +build go1.13
|
||||||
|
|
||||||
package poly1305
|
package poly1305
|
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !amd64,!ppc64le,!s390x gccgo purego
|
//go:build (!amd64 && !ppc64le && !s390x) || !gc || purego
|
||||||
|
// +build !amd64,!ppc64le,!s390x !gc purego
|
||||||
|
|
||||||
package poly1305
|
package poly1305
|
||||||
|
|
@ -15,7 +15,7 @@
|
|||||||
// used with a fixed key in order to generate one-time keys from an nonce.
|
// used with a fixed key in order to generate one-time keys from an nonce.
|
||||||
// However, in this package AES isn't used and the one-time key is specified
|
// However, in this package AES isn't used and the one-time key is specified
|
||||||
// directly.
|
// directly.
|
||||||
package poly1305 // import "golang.org/x/crypto/poly1305"
|
package poly1305
|
||||||
|
|
||||||
import "crypto/subtle"
|
import "crypto/subtle"
|
||||||
|
|
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo,!purego
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
package poly1305
|
package poly1305
|
||||||
|
|
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo,!purego
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo,!purego
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
package poly1305
|
package poly1305
|
||||||
|
|
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo,!purego
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ multiply:
|
|||||||
BGE loop
|
BGE loop
|
||||||
|
|
||||||
bytes_between_0_and_15:
|
bytes_between_0_and_15:
|
||||||
CMP $0, R5
|
CMP R5, $0
|
||||||
BEQ done
|
BEQ done
|
||||||
MOVD $0, R16 // h0
|
MOVD $0, R16 // h0
|
||||||
MOVD $0, R17 // h1
|
MOVD $0, R17 // h1
|
||||||
@ -122,7 +123,7 @@ just1:
|
|||||||
// Exactly 8
|
// Exactly 8
|
||||||
MOVD (R4), R16
|
MOVD (R4), R16
|
||||||
|
|
||||||
CMP $0, R17
|
CMP R17, $0
|
||||||
|
|
||||||
// Check if we've already set R17; if not
|
// Check if we've already set R17; if not
|
||||||
// set 1 to indicate end of msg.
|
// set 1 to indicate end of msg.
|
||||||
@ -151,7 +152,7 @@ less4:
|
|||||||
ADD $2, R4
|
ADD $2, R4
|
||||||
|
|
||||||
less2:
|
less2:
|
||||||
CMP $0, R5
|
CMP R5, $0
|
||||||
BEQ insert1
|
BEQ insert1
|
||||||
MOVBZ (R4), R21
|
MOVBZ (R4), R21
|
||||||
SLD R22, R21, R21
|
SLD R22, R21, R21
|
||||||
@ -166,12 +167,12 @@ insert1:
|
|||||||
|
|
||||||
carry:
|
carry:
|
||||||
// Add new values to h0, h1, h2
|
// Add new values to h0, h1, h2
|
||||||
ADDC R16, R8
|
ADDC R16, R8
|
||||||
ADDE R17, R9
|
ADDE R17, R9
|
||||||
ADDE $0, R10
|
ADDZE R10, R10
|
||||||
MOVD $16, R5
|
MOVD $16, R5
|
||||||
ADD R5, R4
|
ADD R5, R4
|
||||||
BR multiply
|
BR multiply
|
||||||
|
|
||||||
done:
|
done:
|
||||||
// Save h0, h1, h2 in state
|
// Save h0, h1, h2 in state
|
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo,!purego
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
package poly1305
|
package poly1305
|
||||||
|
|
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo,!purego
|
//go:build gc && !purego
|
||||||
|
// +build gc,!purego
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
@ -17,7 +18,7 @@
|
|||||||
// value. These limbs are, for the most part, zero extended and
|
// value. These limbs are, for the most part, zero extended and
|
||||||
// placed into 64-bit vector register elements. Each vector
|
// placed into 64-bit vector register elements. Each vector
|
||||||
// register is 128-bits wide and so holds 2 of these elements.
|
// register is 128-bits wide and so holds 2 of these elements.
|
||||||
// Using 26-bit limbs allows us plenty of headroom to accomodate
|
// Using 26-bit limbs allows us plenty of headroom to accommodate
|
||||||
// accumulations before and after multiplication without
|
// accumulations before and after multiplication without
|
||||||
// overflowing either 32-bits (before multiplication) or 64-bits
|
// overflowing either 32-bits (before multiplication) or 64-bits
|
||||||
// (after multiplication).
|
// (after multiplication).
|
3
vendor/golang.org/x/crypto/internal/subtle/aliasing.go
generated
vendored
3
vendor/golang.org/x/crypto/internal/subtle/aliasing.go
generated
vendored
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !appengine
|
//go:build !purego
|
||||||
|
// +build !purego
|
||||||
|
|
||||||
// Package subtle implements functions that are often useful in cryptographic
|
// Package subtle implements functions that are often useful in cryptographic
|
||||||
// code but require careful thought to use correctly.
|
// code but require careful thought to use correctly.
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build appengine
|
//go:build purego
|
||||||
|
// +build purego
|
||||||
|
|
||||||
// Package subtle implements functions that are often useful in cryptographic
|
// Package subtle implements functions that are often useful in cryptographic
|
||||||
// code but require careful thought to use correctly.
|
// code but require careful thought to use correctly.
|
6
vendor/golang.org/x/crypto/openpgp/armor/armor.go
generated
vendored
6
vendor/golang.org/x/crypto/openpgp/armor/armor.go
generated
vendored
@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
// Package armor implements OpenPGP ASCII Armor, see RFC 4880. OpenPGP Armor is
|
// Package armor implements OpenPGP ASCII Armor, see RFC 4880. OpenPGP Armor is
|
||||||
// very similar to PEM except that it has an additional CRC checksum.
|
// very similar to PEM except that it has an additional CRC checksum.
|
||||||
|
//
|
||||||
|
// Deprecated: this package is unmaintained except for security fixes. New
|
||||||
|
// applications should consider a more focused, modern alternative to OpenPGP
|
||||||
|
// for their specific task. If you are required to interoperate with OpenPGP
|
||||||
|
// systems and need a maintained package, consider a community fork.
|
||||||
|
// See https://golang.org/issue/44226.
|
||||||
package armor // import "golang.org/x/crypto/openpgp/armor"
|
package armor // import "golang.org/x/crypto/openpgp/armor"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
6
vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go
generated
vendored
6
vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go
generated
vendored
@ -10,6 +10,12 @@
|
|||||||
// This form of ElGamal embeds PKCS#1 v1.5 padding, which may make it
|
// This form of ElGamal embeds PKCS#1 v1.5 padding, which may make it
|
||||||
// unsuitable for other protocols. RSA should be used in preference in any
|
// unsuitable for other protocols. RSA should be used in preference in any
|
||||||
// case.
|
// case.
|
||||||
|
//
|
||||||
|
// Deprecated: this package was only provided to support ElGamal encryption in
|
||||||
|
// OpenPGP. The golang.org/x/crypto/openpgp package is now deprecated (see
|
||||||
|
// https://golang.org/issue/44226), and ElGamal in the OpenPGP ecosystem has
|
||||||
|
// compatibility and security issues (see https://eprint.iacr.org/2021/923).
|
||||||
|
// Moreover, this package doesn't protect against side-channel attacks.
|
||||||
package elgamal // import "golang.org/x/crypto/openpgp/elgamal"
|
package elgamal // import "golang.org/x/crypto/openpgp/elgamal"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
6
vendor/golang.org/x/crypto/openpgp/errors/errors.go
generated
vendored
6
vendor/golang.org/x/crypto/openpgp/errors/errors.go
generated
vendored
@ -3,6 +3,12 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package errors contains common error types for the OpenPGP packages.
|
// Package errors contains common error types for the OpenPGP packages.
|
||||||
|
//
|
||||||
|
// Deprecated: this package is unmaintained except for security fixes. New
|
||||||
|
// applications should consider a more focused, modern alternative to OpenPGP
|
||||||
|
// for their specific task. If you are required to interoperate with OpenPGP
|
||||||
|
// systems and need a maintained package, consider a community fork.
|
||||||
|
// See https://golang.org/issue/44226.
|
||||||
package errors // import "golang.org/x/crypto/openpgp/errors"
|
package errors // import "golang.org/x/crypto/openpgp/errors"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
6
vendor/golang.org/x/crypto/openpgp/packet/packet.go
generated
vendored
6
vendor/golang.org/x/crypto/openpgp/packet/packet.go
generated
vendored
@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
// Package packet implements parsing and serialization of OpenPGP packets, as
|
// Package packet implements parsing and serialization of OpenPGP packets, as
|
||||||
// specified in RFC 4880.
|
// specified in RFC 4880.
|
||||||
|
//
|
||||||
|
// Deprecated: this package is unmaintained except for security fixes. New
|
||||||
|
// applications should consider a more focused, modern alternative to OpenPGP
|
||||||
|
// for their specific task. If you are required to interoperate with OpenPGP
|
||||||
|
// systems and need a maintained package, consider a community fork.
|
||||||
|
// See https://golang.org/issue/44226.
|
||||||
package packet // import "golang.org/x/crypto/openpgp/packet"
|
package packet // import "golang.org/x/crypto/openpgp/packet"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
6
vendor/golang.org/x/crypto/openpgp/read.go
generated
vendored
6
vendor/golang.org/x/crypto/openpgp/read.go
generated
vendored
@ -3,6 +3,12 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package openpgp implements high level operations on OpenPGP messages.
|
// Package openpgp implements high level operations on OpenPGP messages.
|
||||||
|
//
|
||||||
|
// Deprecated: this package is unmaintained except for security fixes. New
|
||||||
|
// applications should consider a more focused, modern alternative to OpenPGP
|
||||||
|
// for their specific task. If you are required to interoperate with OpenPGP
|
||||||
|
// systems and need a maintained package, consider a community fork.
|
||||||
|
// See https://golang.org/issue/44226.
|
||||||
package openpgp // import "golang.org/x/crypto/openpgp"
|
package openpgp // import "golang.org/x/crypto/openpgp"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
6
vendor/golang.org/x/crypto/openpgp/s2k/s2k.go
generated
vendored
6
vendor/golang.org/x/crypto/openpgp/s2k/s2k.go
generated
vendored
@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
// Package s2k implements the various OpenPGP string-to-key transforms as
|
// Package s2k implements the various OpenPGP string-to-key transforms as
|
||||||
// specified in RFC 4800 section 3.7.1.
|
// specified in RFC 4800 section 3.7.1.
|
||||||
|
//
|
||||||
|
// Deprecated: this package is unmaintained except for security fixes. New
|
||||||
|
// applications should consider a more focused, modern alternative to OpenPGP
|
||||||
|
// for their specific task. If you are required to interoperate with OpenPGP
|
||||||
|
// systems and need a maintained package, consider a community fork.
|
||||||
|
// See https://golang.org/issue/44226.
|
||||||
package s2k // import "golang.org/x/crypto/openpgp/s2k"
|
package s2k // import "golang.org/x/crypto/openpgp/s2k"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
2
vendor/golang.org/x/crypto/ssh/cipher.go
generated
vendored
2
vendor/golang.org/x/crypto/ssh/cipher.go
generated
vendored
@ -18,7 +18,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"golang.org/x/crypto/chacha20"
|
"golang.org/x/crypto/chacha20"
|
||||||
"golang.org/x/crypto/poly1305"
|
"golang.org/x/crypto/internal/poly1305"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
2
vendor/golang.org/x/crypto/ssh/client.go
generated
vendored
2
vendor/golang.org/x/crypto/ssh/client.go
generated
vendored
@ -77,7 +77,7 @@ func NewClientConn(c net.Conn, addr string, config *ClientConfig) (Conn, <-chan
|
|||||||
}
|
}
|
||||||
|
|
||||||
conn := &connection{
|
conn := &connection{
|
||||||
sshConn: sshConn{conn: c},
|
sshConn: sshConn{conn: c, user: fullConf.User},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := conn.clientHandshake(addr, &fullConf); err != nil {
|
if err := conn.clientHandshake(addr, &fullConf); err != nil {
|
||||||
|
2
vendor/golang.org/x/crypto/ssh/client_auth.go
generated
vendored
2
vendor/golang.org/x/crypto/ssh/client_auth.go
generated
vendored
@ -471,7 +471,7 @@ func (cb KeyboardInteractiveChallenge) auth(session []byte, user string, c packe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(answers) != len(prompts) {
|
if len(answers) != len(prompts) {
|
||||||
return authFailure, nil, errors.New("ssh: not enough answers from keyboard-interactive callback")
|
return authFailure, nil, fmt.Errorf("ssh: incorrect number of answers from keyboard-interactive callback %d (expected %d)", len(answers), len(prompts))
|
||||||
}
|
}
|
||||||
responseLength := 1 + 4
|
responseLength := 1 + 4
|
||||||
for _, a := range answers {
|
for _, a := range answers {
|
||||||
|
4
vendor/golang.org/x/crypto/ssh/server.go
generated
vendored
4
vendor/golang.org/x/crypto/ssh/server.go
generated
vendored
@ -572,6 +572,10 @@ userAuthLoop:
|
|||||||
perms = candidate.perms
|
perms = candidate.perms
|
||||||
}
|
}
|
||||||
case "gssapi-with-mic":
|
case "gssapi-with-mic":
|
||||||
|
if config.GSSAPIWithMICConfig == nil {
|
||||||
|
authErr = errors.New("ssh: gssapi-with-mic auth not configured")
|
||||||
|
break
|
||||||
|
}
|
||||||
gssapiConfig := config.GSSAPIWithMICConfig
|
gssapiConfig := config.GSSAPIWithMICConfig
|
||||||
userAuthRequestGSSAPI, err := parseGSSAPIPayload(userAuthReq.Payload)
|
userAuthRequestGSSAPI, err := parseGSSAPIPayload(userAuthReq.Payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
3
vendor/golang.org/x/net/AUTHORS
generated
vendored
3
vendor/golang.org/x/net/AUTHORS
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
# This source code refers to The Go Authors for copyright purposes.
|
|
||||||
# The master list of authors is in the main Go distribution,
|
|
||||||
# visible at http://tip.golang.org/AUTHORS.
|
|
3
vendor/golang.org/x/net/CONTRIBUTORS
generated
vendored
3
vendor/golang.org/x/net/CONTRIBUTORS
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
# This source code was written by the Go contributors.
|
|
||||||
# The master list of contributors is in the main Go distribution,
|
|
||||||
# visible at http://tip.golang.org/CONTRIBUTORS.
|
|
6
vendor/golang.org/x/net/context/context.go
generated
vendored
6
vendor/golang.org/x/net/context/context.go
generated
vendored
@ -21,9 +21,9 @@
|
|||||||
// explicitly to each function that needs it. The Context should be the first
|
// explicitly to each function that needs it. The Context should be the first
|
||||||
// parameter, typically named ctx:
|
// parameter, typically named ctx:
|
||||||
//
|
//
|
||||||
// func DoSomething(ctx context.Context, arg Arg) error {
|
// func DoSomething(ctx context.Context, arg Arg) error {
|
||||||
// // ... use ctx ...
|
// // ... use ctx ...
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Do not pass a nil Context, even if a function permits it. Pass context.TODO
|
// Do not pass a nil Context, even if a function permits it. Pass context.TODO
|
||||||
// if you are unsure about which Context to use.
|
// if you are unsure about which Context to use.
|
||||||
|
11
vendor/golang.org/x/net/context/go17.go
generated
vendored
11
vendor/golang.org/x/net/context/go17.go
generated
vendored
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build go1.7
|
||||||
// +build go1.7
|
// +build go1.7
|
||||||
|
|
||||||
package context
|
package context
|
||||||
@ -53,11 +54,11 @@ func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) {
|
|||||||
// Canceling this context releases resources associated with it, so code should
|
// Canceling this context releases resources associated with it, so code should
|
||||||
// call cancel as soon as the operations running in this Context complete:
|
// call cancel as soon as the operations running in this Context complete:
|
||||||
//
|
//
|
||||||
// func slowOperationWithTimeout(ctx context.Context) (Result, error) {
|
// func slowOperationWithTimeout(ctx context.Context) (Result, error) {
|
||||||
// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
|
// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
|
||||||
// defer cancel() // releases resources if slowOperation completes before timeout elapses
|
// defer cancel() // releases resources if slowOperation completes before timeout elapses
|
||||||
// return slowOperation(ctx)
|
// return slowOperation(ctx)
|
||||||
// }
|
// }
|
||||||
func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) {
|
func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) {
|
||||||
return WithDeadline(parent, time.Now().Add(timeout))
|
return WithDeadline(parent, time.Now().Add(timeout))
|
||||||
}
|
}
|
||||||
|
1
vendor/golang.org/x/net/context/go19.go
generated
vendored
1
vendor/golang.org/x/net/context/go19.go
generated
vendored
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build go1.9
|
||||||
// +build go1.9
|
// +build go1.9
|
||||||
|
|
||||||
package context
|
package context
|
||||||
|
11
vendor/golang.org/x/net/context/pre_go17.go
generated
vendored
11
vendor/golang.org/x/net/context/pre_go17.go
generated
vendored
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !go1.7
|
||||||
// +build !go1.7
|
// +build !go1.7
|
||||||
|
|
||||||
package context
|
package context
|
||||||
@ -263,11 +264,11 @@ func (c *timerCtx) cancel(removeFromParent bool, err error) {
|
|||||||
// Canceling this context releases resources associated with it, so code should
|
// Canceling this context releases resources associated with it, so code should
|
||||||
// call cancel as soon as the operations running in this Context complete:
|
// call cancel as soon as the operations running in this Context complete:
|
||||||
//
|
//
|
||||||
// func slowOperationWithTimeout(ctx context.Context) (Result, error) {
|
// func slowOperationWithTimeout(ctx context.Context) (Result, error) {
|
||||||
// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
|
// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
|
||||||
// defer cancel() // releases resources if slowOperation completes before timeout elapses
|
// defer cancel() // releases resources if slowOperation completes before timeout elapses
|
||||||
// return slowOperation(ctx)
|
// return slowOperation(ctx)
|
||||||
// }
|
// }
|
||||||
func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) {
|
func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) {
|
||||||
return WithDeadline(parent, time.Now().Add(timeout))
|
return WithDeadline(parent, time.Now().Add(timeout))
|
||||||
}
|
}
|
||||||
|
1
vendor/golang.org/x/net/context/pre_go19.go
generated
vendored
1
vendor/golang.org/x/net/context/pre_go19.go
generated
vendored
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !go1.9
|
||||||
// +build !go1.9
|
// +build !go1.9
|
||||||
|
|
||||||
package context
|
package context
|
||||||
|
15
vendor/modules.txt
vendored
15
vendor/modules.txt
vendored
@ -39,7 +39,7 @@ github.com/fsnotify/fsnotify
|
|||||||
# github.com/gdamore/encoding v1.0.0
|
# github.com/gdamore/encoding v1.0.0
|
||||||
## explicit; go 1.9
|
## explicit; go 1.9
|
||||||
github.com/gdamore/encoding
|
github.com/gdamore/encoding
|
||||||
# github.com/gdamore/tcell/v2 v2.5.3
|
# github.com/gdamore/tcell/v2 v2.5.4
|
||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
github.com/gdamore/tcell/v2
|
github.com/gdamore/tcell/v2
|
||||||
github.com/gdamore/tcell/v2/terminfo
|
github.com/gdamore/tcell/v2/terminfo
|
||||||
@ -172,7 +172,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem
|
|||||||
github.com/jesseduffield/go-git/v5/utils/merkletrie/index
|
github.com/jesseduffield/go-git/v5/utils/merkletrie/index
|
||||||
github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame
|
github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame
|
||||||
github.com/jesseduffield/go-git/v5/utils/merkletrie/noder
|
github.com/jesseduffield/go-git/v5/utils/merkletrie/noder
|
||||||
# github.com/jesseduffield/gocui v0.3.1-0.20221203233251-eeb9b3fb2494
|
# github.com/jesseduffield/gocui v0.3.1-0.20230105224502-214a0df08da7
|
||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
github.com/jesseduffield/gocui
|
github.com/jesseduffield/gocui
|
||||||
# github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10
|
# github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10
|
||||||
@ -266,14 +266,16 @@ github.com/xanzy/ssh-agent
|
|||||||
# github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778
|
# github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778
|
||||||
## explicit; go 1.15
|
## explicit; go 1.15
|
||||||
github.com/xo/terminfo
|
github.com/xo/terminfo
|
||||||
# golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
|
# golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
|
||||||
## explicit; go 1.11
|
## explicit; go 1.17
|
||||||
golang.org/x/crypto/blowfish
|
golang.org/x/crypto/blowfish
|
||||||
golang.org/x/crypto/cast5
|
golang.org/x/crypto/cast5
|
||||||
golang.org/x/crypto/chacha20
|
golang.org/x/crypto/chacha20
|
||||||
golang.org/x/crypto/curve25519
|
golang.org/x/crypto/curve25519
|
||||||
|
golang.org/x/crypto/curve25519/internal/field
|
||||||
golang.org/x/crypto/ed25519
|
golang.org/x/crypto/ed25519
|
||||||
golang.org/x/crypto/ed25519/internal/edwards25519
|
golang.org/x/crypto/ed25519/internal/edwards25519
|
||||||
|
golang.org/x/crypto/internal/poly1305
|
||||||
golang.org/x/crypto/internal/subtle
|
golang.org/x/crypto/internal/subtle
|
||||||
golang.org/x/crypto/openpgp
|
golang.org/x/crypto/openpgp
|
||||||
golang.org/x/crypto/openpgp/armor
|
golang.org/x/crypto/openpgp/armor
|
||||||
@ -281,7 +283,6 @@ golang.org/x/crypto/openpgp/elgamal
|
|||||||
golang.org/x/crypto/openpgp/errors
|
golang.org/x/crypto/openpgp/errors
|
||||||
golang.org/x/crypto/openpgp/packet
|
golang.org/x/crypto/openpgp/packet
|
||||||
golang.org/x/crypto/openpgp/s2k
|
golang.org/x/crypto/openpgp/s2k
|
||||||
golang.org/x/crypto/poly1305
|
|
||||||
golang.org/x/crypto/ssh
|
golang.org/x/crypto/ssh
|
||||||
golang.org/x/crypto/ssh/agent
|
golang.org/x/crypto/ssh/agent
|
||||||
golang.org/x/crypto/ssh/internal/bcrypt_pbkdf
|
golang.org/x/crypto/ssh/internal/bcrypt_pbkdf
|
||||||
@ -290,8 +291,8 @@ golang.org/x/crypto/ssh/knownhosts
|
|||||||
## explicit; go 1.18
|
## explicit; go 1.18
|
||||||
golang.org/x/exp/constraints
|
golang.org/x/exp/constraints
|
||||||
golang.org/x/exp/slices
|
golang.org/x/exp/slices
|
||||||
# golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c
|
# golang.org/x/net v0.0.0-20220722155237-a158d28d115b
|
||||||
## explicit; go 1.11
|
## explicit; go 1.17
|
||||||
golang.org/x/net/context
|
golang.org/x/net/context
|
||||||
golang.org/x/net/internal/socks
|
golang.org/x/net/internal/socks
|
||||||
golang.org/x/net/proxy
|
golang.org/x/net/proxy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user