repo
stringlengths
6
47
file_url
stringlengths
77
269
file_path
stringlengths
5
186
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-07 08:35:43
2026-01-07 08:55:24
truncated
bool
2 classes
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/ztypes_386.go
vendor/github.com/creack/pty/ztypes_386.go
// Created by cgo -godefs - DO NOT EDIT // cgo -godefs types.go package pty type ( _C_int int32 _C_uint uint32 )
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/util_solaris.go
vendor/github.com/creack/pty/util_solaris.go
// package pty import ( "os" "golang.org/x/sys/unix" ) const ( TIOCGWINSZ = 21608 // 'T' << 8 | 104 TIOCSWINSZ = 21607 // 'T' << 8 | 103 ) // Winsize describes the terminal size. type Winsize struct { Rows uint16 // ws_row: Number of rows (in cells) Cols uint16 // ws_col: Number of columns (in cells) X uint16 // ws_xpixel: Width in pixels Y uint16 // ws_ypixel: Height in pixels } // GetsizeFull returns the full terminal size description. func GetsizeFull(t *os.File) (size *Winsize, err error) { var wsz *unix.Winsize wsz, err = unix.IoctlGetWinsize(int(t.Fd()), TIOCGWINSZ) if err != nil { return nil, err } else { return &Winsize{wsz.Row, wsz.Col, wsz.Xpixel, wsz.Ypixel}, nil } } // Get Windows Size func Getsize(t *os.File) (rows, cols int, err error) { var wsz *unix.Winsize wsz, err = unix.IoctlGetWinsize(int(t.Fd()), TIOCGWINSZ) if err != nil { return 80, 25, err } else { return int(wsz.Row), int(wsz.Col), nil } } // Setsize resizes t to s. func Setsize(t *os.File, ws *Winsize) error { wsz := unix.Winsize{ws.Rows, ws.Cols, ws.X, ws.Y} return unix.IoctlSetWinsize(int(t.Fd()), TIOCSWINSZ, &wsz) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/pty_solaris.go
vendor/github.com/creack/pty/pty_solaris.go
package pty /* based on: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/port/gen/pt.c */ import ( "errors" "golang.org/x/sys/unix" "os" "strconv" "syscall" "unsafe" ) const NODEV = ^uint64(0) func open() (pty, tty *os.File, err error) { masterfd, err := syscall.Open("/dev/ptmx", syscall.O_RDWR|unix.O_NOCTTY, 0) //masterfd, err := syscall.Open("/dev/ptmx", syscall.O_RDWR|syscall.O_CLOEXEC|unix.O_NOCTTY, 0) if err != nil { return nil, nil, err } p := os.NewFile(uintptr(masterfd), "/dev/ptmx") sname, err := ptsname(p) if err != nil { return nil, nil, err } err = grantpt(p) if err != nil { return nil, nil, err } err = unlockpt(p) if err != nil { return nil, nil, err } slavefd, err := syscall.Open(sname, os.O_RDWR|unix.O_NOCTTY, 0) if err != nil { return nil, nil, err } t := os.NewFile(uintptr(slavefd), sname) // pushing terminal driver STREAMS modules as per pts(7) for _, mod := range([]string{"ptem", "ldterm", "ttcompat"}) { err = streams_push(t, mod) if err != nil { return nil, nil, err } } return p, t, nil } func minor(x uint64) uint64 { return x & 0377 } func ptsdev(fd uintptr) uint64 { istr := strioctl{ISPTM, 0, 0, nil} err := ioctl(fd, I_STR, uintptr(unsafe.Pointer(&istr))) if err != nil { return NODEV } var status unix.Stat_t err = unix.Fstat(int(fd), &status) if err != nil { return NODEV } return uint64(minor(status.Rdev)) } func ptsname(f *os.File) (string, error) { dev := ptsdev(f.Fd()) if dev == NODEV { return "", errors.New("not a master pty") } fn := "/dev/pts/" + strconv.FormatInt(int64(dev), 10) // access(2) creates the slave device (if the pty exists) // F_OK == 0 (unistd.h) err := unix.Access(fn, 0) if err != nil { return "", err } return fn, nil } type pt_own struct { pto_ruid int32 pto_rgid int32 } func grantpt(f *os.File) error { if ptsdev(f.Fd()) == NODEV { return errors.New("not a master pty") } var pto pt_own pto.pto_ruid = int32(os.Getuid()) // XXX should first attempt to get gid of DEFAULT_TTY_GROUP="tty" pto.pto_rgid = int32(os.Getgid()) var istr strioctl istr.ic_cmd = OWNERPT istr.ic_timout = 0 istr.ic_len = int32(unsafe.Sizeof(istr)) istr.ic_dp = unsafe.Pointer(&pto) err := ioctl(f.Fd(), I_STR, uintptr(unsafe.Pointer(&istr))) if err != nil { return errors.New("access denied") } return nil } func unlockpt(f *os.File) error { istr := strioctl{UNLKPT, 0, 0, nil} return ioctl(f.Fd(), I_STR, uintptr(unsafe.Pointer(&istr))) } // push STREAMS modules if not already done so func streams_push(f *os.File, mod string) error { var err error buf := []byte(mod) // XXX I_FIND is not returning an error when the module // is already pushed even though truss reports a return // value of 1. A bug in the Go Solaris syscall interface? // XXX without this we are at risk of the issue // https://www.illumos.org/issues/9042 // but since we are not using libc or XPG4.2, we should not be // double-pushing modules err = ioctl(f.Fd(), I_FIND, uintptr(unsafe.Pointer(&buf[0]))) if err != nil { return nil } err = ioctl(f.Fd(), I_PUSH, uintptr(unsafe.Pointer(&buf[0]))) return err }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/ioctl_solaris.go
vendor/github.com/creack/pty/ioctl_solaris.go
package pty import ( "golang.org/x/sys/unix" "unsafe" ) const ( // see /usr/include/sys/stropts.h I_PUSH = uintptr((int32('S')<<8 | 002)) I_STR = uintptr((int32('S')<<8 | 010)) I_FIND = uintptr((int32('S')<<8 | 013)) // see /usr/include/sys/ptms.h ISPTM = (int32('P') << 8) | 1 UNLKPT = (int32('P') << 8) | 2 PTSSTTY = (int32('P') << 8) | 3 ZONEPT = (int32('P') << 8) | 4 OWNERPT = (int32('P') << 8) | 5 ) type strioctl struct { ic_cmd int32 ic_timout int32 ic_len int32 ic_dp unsafe.Pointer } func ioctl(fd, cmd, ptr uintptr) error { return unix.IoctlSetInt(int(fd), uint(cmd), int(ptr)) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/ztypes_dragonfly_amd64.go
vendor/github.com/creack/pty/ztypes_dragonfly_amd64.go
// Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_dragonfly.go package pty const ( _C_SPECNAMELEN = 0x3f ) type fiodgnameArg struct { Name *byte Len uint32 Pad_cgo_0 [4]byte }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/ioctl.go
vendor/github.com/creack/pty/ioctl.go
// +build !windows,!solaris package pty import "syscall" func ioctl(fd, cmd, ptr uintptr) error { _, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr) if e != 0 { return e } return nil }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/run.go
vendor/github.com/creack/pty/run.go
// +build !windows package pty import ( "os" "os/exec" "syscall" ) // Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, // and c.Stderr, calls c.Start, and returns the File of the tty's // corresponding pty. // // Starts the process in a new session and sets the controlling terminal. func Start(c *exec.Cmd) (pty *os.File, err error) { return StartWithSize(c, nil) } // StartWithSize assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, // and c.Stderr, calls c.Start, and returns the File of the tty's // corresponding pty. // // This will resize the pty to the specified size before starting the command. // Starts the process in a new session and sets the controlling terminal. func StartWithSize(c *exec.Cmd, sz *Winsize) (pty *os.File, err error) { if c.SysProcAttr == nil { c.SysProcAttr = &syscall.SysProcAttr{} } c.SysProcAttr.Setsid = true c.SysProcAttr.Setctty = true return StartWithAttrs(c, sz, c.SysProcAttr) } // StartWithAttrs assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, // and c.Stderr, calls c.Start, and returns the File of the tty's // corresponding pty. // // This will resize the pty to the specified size before starting the command if a size is provided. // The `attrs` parameter overrides the one set in c.SysProcAttr. // // This should generally not be needed. Used in some edge cases where it is needed to create a pty // without a controlling terminal. func StartWithAttrs(c *exec.Cmd, sz *Winsize, attrs *syscall.SysProcAttr) (pty *os.File, err error) { pty, tty, err := Open() if err != nil { return nil, err } defer tty.Close() if sz != nil { if err := Setsize(pty, sz); err != nil { pty.Close() return nil, err } } if c.Stdout == nil { c.Stdout = tty } if c.Stderr == nil { c.Stderr = tty } if c.Stdin == nil { c.Stdin = tty } c.SysProcAttr = attrs if err := c.Start(); err != nil { _ = pty.Close() return nil, err } return pty, err }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/pty_linux.go
vendor/github.com/creack/pty/pty_linux.go
package pty import ( "os" "strconv" "syscall" "unsafe" ) func open() (pty, tty *os.File, err error) { p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) if err != nil { return nil, nil, err } // In case of error after this point, make sure we close the ptmx fd. defer func() { if err != nil { _ = p.Close() // Best effort. } }() sname, err := ptsname(p) if err != nil { return nil, nil, err } if err := unlockpt(p); err != nil { return nil, nil, err } t, err := os.OpenFile(sname, os.O_RDWR|syscall.O_NOCTTY, 0) if err != nil { return nil, nil, err } return p, t, nil } func ptsname(f *os.File) (string, error) { var n _C_uint err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))) if err != nil { return "", err } return "/dev/pts/" + strconv.Itoa(int(n)), nil } func unlockpt(f *os.File) error { var u _C_int // use TIOCSPTLCK with a pointer to zero to clear the lock return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/ztypes_mipsx.go
vendor/github.com/creack/pty/ztypes_mipsx.go
// Created by cgo -godefs - DO NOT EDIT // cgo -godefs types.go // +build linux // +build mips mipsle mips64 mips64le package pty type ( _C_int int32 _C_uint uint32 )
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/doc.go
vendor/github.com/creack/pty/doc.go
// Package pty provides functions for working with Unix terminals. package pty import ( "errors" "os" ) // ErrUnsupported is returned if a function is not // available on the current platform. var ErrUnsupported = errors.New("unsupported") // Opens a pty and its corresponding tty. func Open() (pty, tty *os.File, err error) { return open() }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/ztypes_amd64.go
vendor/github.com/creack/pty/ztypes_amd64.go
// Created by cgo -godefs - DO NOT EDIT // cgo -godefs types.go package pty type ( _C_int int32 _C_uint uint32 )
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/pty_dragonfly.go
vendor/github.com/creack/pty/pty_dragonfly.go
package pty import ( "errors" "os" "strings" "syscall" "unsafe" ) // same code as pty_darwin.go func open() (pty, tty *os.File, err error) { p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) if err != nil { return nil, nil, err } // In case of error after this point, make sure we close the ptmx fd. defer func() { if err != nil { _ = p.Close() // Best effort. } }() sname, err := ptsname(p) if err != nil { return nil, nil, err } if err := grantpt(p); err != nil { return nil, nil, err } if err := unlockpt(p); err != nil { return nil, nil, err } t, err := os.OpenFile(sname, os.O_RDWR, 0) if err != nil { return nil, nil, err } return p, t, nil } func grantpt(f *os.File) error { _, err := isptmaster(f.Fd()) return err } func unlockpt(f *os.File) error { _, err := isptmaster(f.Fd()) return err } func isptmaster(fd uintptr) (bool, error) { err := ioctl(fd, syscall.TIOCISPTMASTER, 0) return err == nil, err } var ( emptyFiodgnameArg fiodgnameArg ioctl_FIODNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg)) ) func ptsname(f *os.File) (string, error) { name := make([]byte, _C_SPECNAMELEN) fa := fiodgnameArg{Name: (*byte)(unsafe.Pointer(&name[0])), Len: _C_SPECNAMELEN, Pad_cgo_0: [4]byte{0, 0, 0, 0}} err := ioctl(f.Fd(), ioctl_FIODNAME, uintptr(unsafe.Pointer(&fa))) if err != nil { return "", err } for i, c := range name { if c == 0 { s := "/dev/" + string(name[:i]) return strings.Replace(s, "ptm", "pts", -1), nil } } return "", errors.New("TIOCPTYGNAME string not NUL-terminated") }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/creack/pty/pty_unsupported.go
vendor/github.com/creack/pty/pty_unsupported.go
// +build !linux,!darwin,!freebsd,!dragonfly,!openbsd,!solaris package pty import ( "os" ) func open() (pty, tty *os.File, err error) { return nil, nil, ErrUnsupported }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/gocompat_generics_go121.go
vendor/github.com/cyphar/filepath-securejoin/gocompat_generics_go121.go
//go:build linux && go1.21 // Copyright (C) 2024 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package securejoin import ( "slices" "sync" ) func slices_DeleteFunc[S ~[]E, E any](slice S, delFn func(E) bool) S { return slices.DeleteFunc(slice, delFn) } func slices_Contains[S ~[]E, E comparable](slice S, val E) bool { return slices.Contains(slice, val) } func slices_Clone[S ~[]E, E any](slice S) S { return slices.Clone(slice) } func sync_OnceValue[T any](f func() T) func() T { return sync.OnceValue(f) } func sync_OnceValues[T1, T2 any](f func() (T1, T2)) func() (T1, T2) { return sync.OnceValues(f) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/open_linux.go
vendor/github.com/cyphar/filepath-securejoin/open_linux.go
//go:build linux // Copyright (C) 2024 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package securejoin import ( "fmt" "os" "strconv" "golang.org/x/sys/unix" ) // OpenatInRoot is equivalent to [OpenInRoot], except that the root is provided // using an *[os.File] handle, to ensure that the correct root directory is used. func OpenatInRoot(root *os.File, unsafePath string) (*os.File, error) { handle, err := completeLookupInRoot(root, unsafePath) if err != nil { return nil, &os.PathError{Op: "securejoin.OpenInRoot", Path: unsafePath, Err: err} } return handle, nil } // OpenInRoot safely opens the provided unsafePath within the root. // Effectively, OpenInRoot(root, unsafePath) is equivalent to // // path, _ := securejoin.SecureJoin(root, unsafePath) // handle, err := os.OpenFile(path, unix.O_PATH|unix.O_CLOEXEC) // // But is much safer. The above implementation is unsafe because if an attacker // can modify the filesystem tree between [SecureJoin] and [os.OpenFile], it is // possible for the returned file to be outside of the root. // // Note that the returned handle is an O_PATH handle, meaning that only a very // limited set of operations will work on the handle. This is done to avoid // accidentally opening an untrusted file that could cause issues (such as a // disconnected TTY that could cause a DoS, or some other issue). In order to // use the returned handle, you can "upgrade" it to a proper handle using // [Reopen]. func OpenInRoot(root, unsafePath string) (*os.File, error) { rootDir, err := os.OpenFile(root, unix.O_PATH|unix.O_DIRECTORY|unix.O_CLOEXEC, 0) if err != nil { return nil, err } defer rootDir.Close() return OpenatInRoot(rootDir, unsafePath) } // Reopen takes an *[os.File] handle and re-opens it through /proc/self/fd. // Reopen(file, flags) is effectively equivalent to // // fdPath := fmt.Sprintf("/proc/self/fd/%d", file.Fd()) // os.OpenFile(fdPath, flags|unix.O_CLOEXEC) // // But with some extra hardenings to ensure that we are not tricked by a // maliciously-configured /proc mount. While this attack scenario is not // common, in container runtimes it is possible for higher-level runtimes to be // tricked into configuring an unsafe /proc that can be used to attack file // operations. See [CVE-2019-19921] for more details. // // [CVE-2019-19921]: https://github.com/advisories/GHSA-fh74-hm69-rqjw func Reopen(handle *os.File, flags int) (*os.File, error) { procRoot, err := getProcRoot() if err != nil { return nil, err } // We can't operate on /proc/thread-self/fd/$n directly when doing a // re-open, so we need to open /proc/thread-self/fd and then open a single // final component. procFdDir, closer, err := procThreadSelf(procRoot, "fd/") if err != nil { return nil, fmt.Errorf("get safe /proc/thread-self/fd handle: %w", err) } defer procFdDir.Close() defer closer() // Try to detect if there is a mount on top of the magic-link we are about // to open. If we are using unsafeHostProcRoot(), this could change after // we check it (and there's nothing we can do about that) but for // privateProcRoot() this should be guaranteed to be safe (at least since // Linux 5.12[1], when anonymous mount namespaces were completely isolated // from external mounts including mount propagation events). // // [1]: Linux commit ee2e3f50629f ("mount: fix mounting of detached mounts // onto targets that reside on shared mounts"). fdStr := strconv.Itoa(int(handle.Fd())) if err := checkSymlinkOvermount(procRoot, procFdDir, fdStr); err != nil { return nil, fmt.Errorf("check safety of /proc/thread-self/fd/%s magiclink: %w", fdStr, err) } flags |= unix.O_CLOEXEC // Rather than just wrapping openatFile, open-code it so we can copy // handle.Name(). reopenFd, err := unix.Openat(int(procFdDir.Fd()), fdStr, flags, 0) if err != nil { return nil, fmt.Errorf("reopen fd %d: %w", handle.Fd(), err) } return os.NewFile(uintptr(reopenFd), handle.Name()), nil }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/openat_linux.go
vendor/github.com/cyphar/filepath-securejoin/openat_linux.go
//go:build linux // Copyright (C) 2024 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package securejoin import ( "os" "path/filepath" "golang.org/x/sys/unix" ) func dupFile(f *os.File) (*os.File, error) { fd, err := unix.FcntlInt(f.Fd(), unix.F_DUPFD_CLOEXEC, 0) if err != nil { return nil, os.NewSyscallError("fcntl(F_DUPFD_CLOEXEC)", err) } return os.NewFile(uintptr(fd), f.Name()), nil } func openatFile(dir *os.File, path string, flags int, mode int) (*os.File, error) { // Make sure we always set O_CLOEXEC. flags |= unix.O_CLOEXEC fd, err := unix.Openat(int(dir.Fd()), path, flags, uint32(mode)) if err != nil { return nil, &os.PathError{Op: "openat", Path: dir.Name() + "/" + path, Err: err} } // All of the paths we use with openatFile(2) are guaranteed to be // lexically safe, so we can use path.Join here. fullPath := filepath.Join(dir.Name(), path) return os.NewFile(uintptr(fd), fullPath), nil } func fstatatFile(dir *os.File, path string, flags int) (unix.Stat_t, error) { var stat unix.Stat_t if err := unix.Fstatat(int(dir.Fd()), path, &stat, flags); err != nil { return stat, &os.PathError{Op: "fstatat", Path: dir.Name() + "/" + path, Err: err} } return stat, nil } func readlinkatFile(dir *os.File, path string) (string, error) { size := 4096 for { linkBuf := make([]byte, size) n, err := unix.Readlinkat(int(dir.Fd()), path, linkBuf) if err != nil { return "", &os.PathError{Op: "readlinkat", Path: dir.Name() + "/" + path, Err: err} } if n != size { return string(linkBuf[:n]), nil } // Possible truncation, resize the buffer. size *= 2 } }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/join.go
vendor/github.com/cyphar/filepath-securejoin/join.go
// Copyright (C) 2014-2015 Docker Inc & Go Authors. All rights reserved. // Copyright (C) 2017-2025 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package securejoin import ( "errors" "os" "path/filepath" "strings" "syscall" ) const maxSymlinkLimit = 255 // IsNotExist tells you if err is an error that implies that either the path // accessed does not exist (or path components don't exist). This is // effectively a more broad version of [os.IsNotExist]. func IsNotExist(err error) bool { // Check that it's not actually an ENOTDIR, which in some cases is a more // convoluted case of ENOENT (usually involving weird paths). return errors.Is(err, os.ErrNotExist) || errors.Is(err, syscall.ENOTDIR) || errors.Is(err, syscall.ENOENT) } // errUnsafeRoot is returned if the user provides SecureJoinVFS with a path // that contains ".." components. var errUnsafeRoot = errors.New("root path provided to SecureJoin contains '..' components") // stripVolume just gets rid of the Windows volume included in a path. Based on // some godbolt tests, the Go compiler is smart enough to make this a no-op on // Linux. func stripVolume(path string) string { return path[len(filepath.VolumeName(path)):] } // hasDotDot checks if the path contains ".." components in a platform-agnostic // way. func hasDotDot(path string) bool { // If we are on Windows, strip any volume letters. It turns out that // C:..\foo may (or may not) be a valid pathname and we need to handle that // leading "..". path = stripVolume(path) // Look for "/../" in the path, but we need to handle leading and trailing // ".."s by adding separators. Doing this with filepath.Separator is ugly // so just convert to Unix-style "/" first. path = filepath.ToSlash(path) return strings.Contains("/"+path+"/", "/../") } // SecureJoinVFS joins the two given path components (similar to [filepath.Join]) except // that the returned path is guaranteed to be scoped inside the provided root // path (when evaluated). Any symbolic links in the path are evaluated with the // given root treated as the root of the filesystem, similar to a chroot. The // filesystem state is evaluated through the given [VFS] interface (if nil, the // standard [os].* family of functions are used). // // Note that the guarantees provided by this function only apply if the path // components in the returned string are not modified (in other words are not // replaced with symlinks on the filesystem) after this function has returned. // Such a symlink race is necessarily out-of-scope of SecureJoinVFS. // // NOTE: Due to the above limitation, Linux users are strongly encouraged to // use [OpenInRoot] instead, which does safely protect against these kinds of // attacks. There is no way to solve this problem with SecureJoinVFS because // the API is fundamentally wrong (you cannot return a "safe" path string and // guarantee it won't be modified afterwards). // // Volume names in unsafePath are always discarded, regardless if they are // provided via direct input or when evaluating symlinks. Therefore: // // "C:\Temp" + "D:\path\to\file.txt" results in "C:\Temp\path\to\file.txt" // // If the provided root is not [filepath.Clean] then an error will be returned, // as such root paths are bordering on somewhat unsafe and using such paths is // not best practice. We also strongly suggest that any root path is first // fully resolved using [filepath.EvalSymlinks] or otherwise constructed to // avoid containing symlink components. Of course, the root also *must not* be // attacker-controlled. func SecureJoinVFS(root, unsafePath string, vfs VFS) (string, error) { // The root path must not contain ".." components, otherwise when we join // the subpath we will end up with a weird path. We could work around this // in other ways but users shouldn't be giving us non-lexical root paths in // the first place. if hasDotDot(root) { return "", errUnsafeRoot } // Use the os.* VFS implementation if none was specified. if vfs == nil { vfs = osVFS{} } unsafePath = filepath.FromSlash(unsafePath) var ( currentPath string remainingPath = unsafePath linksWalked int ) for remainingPath != "" { // On Windows, if we managed to end up at a path referencing a volume, // drop the volume to make sure we don't end up with broken paths or // escaping the root volume. remainingPath = stripVolume(remainingPath) // Get the next path component. var part string if i := strings.IndexRune(remainingPath, filepath.Separator); i == -1 { part, remainingPath = remainingPath, "" } else { part, remainingPath = remainingPath[:i], remainingPath[i+1:] } // Apply the component lexically to the path we are building. // currentPath does not contain any symlinks, and we are lexically // dealing with a single component, so it's okay to do a filepath.Clean // here. nextPath := filepath.Join(string(filepath.Separator), currentPath, part) if nextPath == string(filepath.Separator) { currentPath = "" continue } fullPath := root + string(filepath.Separator) + nextPath // Figure out whether the path is a symlink. fi, err := vfs.Lstat(fullPath) if err != nil && !IsNotExist(err) { return "", err } // Treat non-existent path components the same as non-symlinks (we // can't do any better here). if IsNotExist(err) || fi.Mode()&os.ModeSymlink == 0 { currentPath = nextPath continue } // It's a symlink, so get its contents and expand it by prepending it // to the yet-unparsed path. linksWalked++ if linksWalked > maxSymlinkLimit { return "", &os.PathError{Op: "SecureJoin", Path: root + string(filepath.Separator) + unsafePath, Err: syscall.ELOOP} } dest, err := vfs.Readlink(fullPath) if err != nil { return "", err } remainingPath = dest + string(filepath.Separator) + remainingPath // Absolute symlinks reset any work we've already done. if filepath.IsAbs(dest) { currentPath = "" } } // There should be no lexical components like ".." left in the path here, // but for safety clean up the path before joining it to the root. finalPath := filepath.Join(string(filepath.Separator), currentPath) return filepath.Join(root, finalPath), nil } // SecureJoin is a wrapper around [SecureJoinVFS] that just uses the [os].* library // of functions as the [VFS]. If in doubt, use this function over [SecureJoinVFS]. func SecureJoin(root, unsafePath string) (string, error) { return SecureJoinVFS(root, unsafePath, nil) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/vfs.go
vendor/github.com/cyphar/filepath-securejoin/vfs.go
// Copyright (C) 2017-2024 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package securejoin import "os" // In future this should be moved into a separate package, because now there // are several projects (umoci and go-mtree) that are using this sort of // interface. // VFS is the minimal interface necessary to use [SecureJoinVFS]. A nil VFS is // equivalent to using the standard [os].* family of functions. This is mainly // used for the purposes of mock testing, but also can be used to otherwise use // [SecureJoinVFS] with VFS-like system. type VFS interface { // Lstat returns an [os.FileInfo] describing the named file. If the // file is a symbolic link, the returned [os.FileInfo] describes the // symbolic link. Lstat makes no attempt to follow the link. // The semantics are identical to [os.Lstat]. Lstat(name string) (os.FileInfo, error) // Readlink returns the destination of the named symbolic link. // The semantics are identical to [os.Readlink]. Readlink(name string) (string, error) } // osVFS is the "nil" VFS, in that it just passes everything through to the os // module. type osVFS struct{} func (o osVFS) Lstat(name string) (os.FileInfo, error) { return os.Lstat(name) } func (o osVFS) Readlink(name string) (string, error) { return os.Readlink(name) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/gocompat_generics_unsupported.go
vendor/github.com/cyphar/filepath-securejoin/gocompat_generics_unsupported.go
//go:build linux && !go1.21 // Copyright (C) 2024 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package securejoin import ( "sync" ) // These are very minimal implementations of functions that appear in Go 1.21's // stdlib, included so that we can build on older Go versions. Most are // borrowed directly from the stdlib, and a few are modified to be "obviously // correct" without needing to copy too many other helpers. // clearSlice is equivalent to the builtin clear from Go 1.21. // Copied from the Go 1.24 stdlib implementation. func clearSlice[S ~[]E, E any](slice S) { var zero E for i := range slice { slice[i] = zero } } // Copied from the Go 1.24 stdlib implementation. func slices_IndexFunc[S ~[]E, E any](s S, f func(E) bool) int { for i := range s { if f(s[i]) { return i } } return -1 } // Copied from the Go 1.24 stdlib implementation. func slices_DeleteFunc[S ~[]E, E any](s S, del func(E) bool) S { i := slices_IndexFunc(s, del) if i == -1 { return s } // Don't start copying elements until we find one to delete. for j := i + 1; j < len(s); j++ { if v := s[j]; !del(v) { s[i] = v i++ } } clearSlice(s[i:]) // zero/nil out the obsolete elements, for GC return s[:i] } // Similar to the stdlib slices.Contains, except that we don't have // slices.Index so we need to use slices.IndexFunc for this non-Func helper. func slices_Contains[S ~[]E, E comparable](s S, v E) bool { return slices_IndexFunc(s, func(e E) bool { return e == v }) >= 0 } // Copied from the Go 1.24 stdlib implementation. func slices_Clone[S ~[]E, E any](s S) S { // Preserve nil in case it matters. if s == nil { return nil } return append(S([]E{}), s...) } // Copied from the Go 1.24 stdlib implementation. func sync_OnceValue[T any](f func() T) func() T { var ( once sync.Once valid bool p any result T ) g := func() { defer func() { p = recover() if !valid { panic(p) } }() result = f() f = nil valid = true } return func() T { once.Do(g) if !valid { panic(p) } return result } } // Copied from the Go 1.24 stdlib implementation. func sync_OnceValues[T1, T2 any](f func() (T1, T2)) func() (T1, T2) { var ( once sync.Once valid bool p any r1 T1 r2 T2 ) g := func() { defer func() { p = recover() if !valid { panic(p) } }() r1, r2 = f() f = nil valid = true } return func() (T1, T2) { once.Do(g) if !valid { panic(p) } return r1, r2 } }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/mkdir_linux.go
vendor/github.com/cyphar/filepath-securejoin/mkdir_linux.go
//go:build linux // Copyright (C) 2024 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package securejoin import ( "errors" "fmt" "os" "path/filepath" "strings" "golang.org/x/sys/unix" ) var ( errInvalidMode = errors.New("invalid permission mode") errPossibleAttack = errors.New("possible attack detected") ) // modePermExt is like os.ModePerm except that it also includes the set[ug]id // and sticky bits. const modePermExt = os.ModePerm | os.ModeSetuid | os.ModeSetgid | os.ModeSticky //nolint:cyclop // this function needs to handle a lot of cases func toUnixMode(mode os.FileMode) (uint32, error) { sysMode := uint32(mode.Perm()) if mode&os.ModeSetuid != 0 { sysMode |= unix.S_ISUID } if mode&os.ModeSetgid != 0 { sysMode |= unix.S_ISGID } if mode&os.ModeSticky != 0 { sysMode |= unix.S_ISVTX } // We don't allow file type bits. if mode&os.ModeType != 0 { return 0, fmt.Errorf("%w %+.3o (%s): type bits not permitted", errInvalidMode, mode, mode) } // We don't allow other unknown modes. if mode&^modePermExt != 0 || sysMode&unix.S_IFMT != 0 { return 0, fmt.Errorf("%w %+.3o (%s): unknown mode bits", errInvalidMode, mode, mode) } return sysMode, nil } // MkdirAllHandle is equivalent to [MkdirAll], except that it is safer to use // in two respects: // // - The caller provides the root directory as an *[os.File] (preferably O_PATH) // handle. This means that the caller can be sure which root directory is // being used. Note that this can be emulated by using /proc/self/fd/... as // the root path with [os.MkdirAll]. // // - Once all of the directories have been created, an *[os.File] O_PATH handle // to the directory at unsafePath is returned to the caller. This is done in // an effectively-race-free way (an attacker would only be able to swap the // final directory component), which is not possible to emulate with // [MkdirAll]. // // In addition, the returned handle is obtained far more efficiently than doing // a brand new lookup of unsafePath (such as with [SecureJoin] or openat2) after // doing [MkdirAll]. If you intend to open the directory after creating it, you // should use MkdirAllHandle. func MkdirAllHandle(root *os.File, unsafePath string, mode os.FileMode) (_ *os.File, Err error) { unixMode, err := toUnixMode(mode) if err != nil { return nil, err } // On Linux, mkdirat(2) (and os.Mkdir) silently ignore the suid and sgid // bits. We could also silently ignore them but since we have very few // users it seems more prudent to return an error so users notice that // these bits will not be set. if unixMode&^0o1777 != 0 { return nil, fmt.Errorf("%w for mkdir %+.3o: suid and sgid are ignored by mkdir", errInvalidMode, mode) } // Try to open as much of the path as possible. currentDir, remainingPath, err := partialLookupInRoot(root, unsafePath) defer func() { if Err != nil { _ = currentDir.Close() } }() if err != nil && !errors.Is(err, unix.ENOENT) { return nil, fmt.Errorf("find existing subpath of %q: %w", unsafePath, err) } // If there is an attacker deleting directories as we walk into them, // detect this proactively. Note this is guaranteed to detect if the // attacker deleted any part of the tree up to currentDir. // // Once we walk into a dead directory, partialLookupInRoot would not be // able to walk further down the tree (directories must be empty before // they are deleted), and if the attacker has removed the entire tree we // can be sure that anything that was originally inside a dead directory // must also be deleted and thus is a dead directory in its own right. // // This is mostly a quality-of-life check, because mkdir will simply fail // later if the attacker deletes the tree after this check. if err := isDeadInode(currentDir); err != nil { return nil, fmt.Errorf("finding existing subpath of %q: %w", unsafePath, err) } // Re-open the path to match the O_DIRECTORY reopen loop later (so that we // always return a non-O_PATH handle). We also check that we actually got a // directory. if reopenDir, err := Reopen(currentDir, unix.O_DIRECTORY|unix.O_CLOEXEC); errors.Is(err, unix.ENOTDIR) { return nil, fmt.Errorf("cannot create subdirectories in %q: %w", currentDir.Name(), unix.ENOTDIR) } else if err != nil { return nil, fmt.Errorf("re-opening handle to %q: %w", currentDir.Name(), err) } else { _ = currentDir.Close() currentDir = reopenDir } remainingParts := strings.Split(remainingPath, string(filepath.Separator)) if slices_Contains(remainingParts, "..") { // The path contained ".." components after the end of the "real" // components. We could try to safely resolve ".." here but that would // add a bunch of extra logic for something that it's not clear even // needs to be supported. So just return an error. // // If we do filepath.Clean(remainingPath) then we end up with the // problem that ".." can erase a trailing dangling symlink and produce // a path that doesn't quite match what the user asked for. return nil, fmt.Errorf("%w: yet-to-be-created path %q contains '..' components", unix.ENOENT, remainingPath) } // Create the remaining components. for _, part := range remainingParts { switch part { case "", ".": // Skip over no-op paths. continue } // NOTE: mkdir(2) will not follow trailing symlinks, so we can safely // create the final component without worrying about symlink-exchange // attacks. // // If we get -EEXIST, it's possible that another program created the // directory at the same time as us. In that case, just continue on as // if we created it (if the created inode is not a directory, the // following open call will fail). if err := unix.Mkdirat(int(currentDir.Fd()), part, unixMode); err != nil && !errors.Is(err, unix.EEXIST) { err = &os.PathError{Op: "mkdirat", Path: currentDir.Name() + "/" + part, Err: err} // Make the error a bit nicer if the directory is dead. if deadErr := isDeadInode(currentDir); deadErr != nil { // TODO: Once we bump the minimum Go version to 1.20, we can use // multiple %w verbs for this wrapping. For now we need to use a // compatibility shim for older Go versions. //err = fmt.Errorf("%w (%w)", err, deadErr) err = wrapBaseError(err, deadErr) } return nil, err } // Get a handle to the next component. O_DIRECTORY means we don't need // to use O_PATH. var nextDir *os.File if hasOpenat2() { nextDir, err = openat2File(currentDir, part, &unix.OpenHow{ Flags: unix.O_NOFOLLOW | unix.O_DIRECTORY | unix.O_CLOEXEC, Resolve: unix.RESOLVE_BENEATH | unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_NO_XDEV, }) } else { nextDir, err = openatFile(currentDir, part, unix.O_NOFOLLOW|unix.O_DIRECTORY|unix.O_CLOEXEC, 0) } if err != nil { return nil, err } _ = currentDir.Close() currentDir = nextDir // It's possible that the directory we just opened was swapped by an // attacker. Unfortunately there isn't much we can do to protect // against this, and MkdirAll's behaviour is that we will reuse // existing directories anyway so the need to protect against this is // incredibly limited (and arguably doesn't even deserve mention here). // // Ideally we might want to check that the owner and mode match what we // would've created -- unfortunately, it is non-trivial to verify that // the owner and mode of the created directory match. While plain Unix // DAC rules seem simple enough to emulate, there are a bunch of other // factors that can change the mode or owner of created directories // (default POSIX ACLs, mount options like uid=1,gid=2,umask=0 on // filesystems like vfat, etc etc). We used to try to verify this but // it just lead to a series of spurious errors. // // We could also check that the directory is non-empty, but // unfortunately some pseduofilesystems (like cgroupfs) create // non-empty directories, which would result in different spurious // errors. } return currentDir, nil } // MkdirAll is a race-safe alternative to the [os.MkdirAll] function, // where the new directory is guaranteed to be within the root directory (if an // attacker can move directories from inside the root to outside the root, the // created directory tree might be outside of the root but the key constraint // is that at no point will we walk outside of the directory tree we are // creating). // // Effectively, MkdirAll(root, unsafePath, mode) is equivalent to // // path, _ := securejoin.SecureJoin(root, unsafePath) // err := os.MkdirAll(path, mode) // // But is much safer. The above implementation is unsafe because if an attacker // can modify the filesystem tree between [SecureJoin] and [os.MkdirAll], it is // possible for MkdirAll to resolve unsafe symlink components and create // directories outside of the root. // // If you plan to open the directory after you have created it or want to use // an open directory handle as the root, you should use [MkdirAllHandle] instead. // This function is a wrapper around [MkdirAllHandle]. func MkdirAll(root, unsafePath string, mode os.FileMode) error { rootDir, err := os.OpenFile(root, unix.O_PATH|unix.O_DIRECTORY|unix.O_CLOEXEC, 0) if err != nil { return err } defer rootDir.Close() f, err := MkdirAllHandle(rootDir, unsafePath, mode) if err != nil { return err } _ = f.Close() return nil }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/gocompat_errors_unsupported.go
vendor/github.com/cyphar/filepath-securejoin/gocompat_errors_unsupported.go
//go:build linux && !go1.20 // Copyright (C) 2024 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package securejoin import ( "fmt" ) type wrappedError struct { inner error isError error } func (err wrappedError) Is(target error) bool { return err.isError == target } func (err wrappedError) Unwrap() error { return err.inner } func (err wrappedError) Error() string { return fmt.Sprintf("%v: %v", err.isError, err.inner) } // wrapBaseError is a helper that is equivalent to fmt.Errorf("%w: %w"), except // that on pre-1.20 Go versions only errors.Is() works properly (errors.Unwrap) // is only guaranteed to give you baseErr. func wrapBaseError(baseErr, extraErr error) error { return wrappedError{ inner: baseErr, isError: extraErr, } }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/procfs_linux.go
vendor/github.com/cyphar/filepath-securejoin/procfs_linux.go
//go:build linux // Copyright (C) 2024 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package securejoin import ( "errors" "fmt" "os" "runtime" "strconv" "golang.org/x/sys/unix" ) func fstat(f *os.File) (unix.Stat_t, error) { var stat unix.Stat_t if err := unix.Fstat(int(f.Fd()), &stat); err != nil { return stat, &os.PathError{Op: "fstat", Path: f.Name(), Err: err} } return stat, nil } func fstatfs(f *os.File) (unix.Statfs_t, error) { var statfs unix.Statfs_t if err := unix.Fstatfs(int(f.Fd()), &statfs); err != nil { return statfs, &os.PathError{Op: "fstatfs", Path: f.Name(), Err: err} } return statfs, nil } // The kernel guarantees that the root inode of a procfs mount has an // f_type of PROC_SUPER_MAGIC and st_ino of PROC_ROOT_INO. const ( procSuperMagic = 0x9fa0 // PROC_SUPER_MAGIC procRootIno = 1 // PROC_ROOT_INO ) func verifyProcRoot(procRoot *os.File) error { if statfs, err := fstatfs(procRoot); err != nil { return err } else if statfs.Type != procSuperMagic { return fmt.Errorf("%w: incorrect procfs root filesystem type 0x%x", errUnsafeProcfs, statfs.Type) } if stat, err := fstat(procRoot); err != nil { return err } else if stat.Ino != procRootIno { return fmt.Errorf("%w: incorrect procfs root inode number %d", errUnsafeProcfs, stat.Ino) } return nil } var hasNewMountApi = sync_OnceValue(func() bool { // All of the pieces of the new mount API we use (fsopen, fsconfig, // fsmount, open_tree) were added together in Linux 5.1[1,2], so we can // just check for one of the syscalls and the others should also be // available. // // Just try to use open_tree(2) to open a file without OPEN_TREE_CLONE. // This is equivalent to openat(2), but tells us if open_tree is // available (and thus all of the other basic new mount API syscalls). // open_tree(2) is most light-weight syscall to test here. // // [1]: merge commit 400913252d09 // [2]: <https://lore.kernel.org/lkml/153754740781.17872.7869536526927736855.stgit@warthog.procyon.org.uk/> fd, err := unix.OpenTree(-int(unix.EBADF), "/", unix.OPEN_TREE_CLOEXEC) if err != nil { return false } _ = unix.Close(fd) return true }) func fsopen(fsName string, flags int) (*os.File, error) { // Make sure we always set O_CLOEXEC. flags |= unix.FSOPEN_CLOEXEC fd, err := unix.Fsopen(fsName, flags) if err != nil { return nil, os.NewSyscallError("fsopen "+fsName, err) } return os.NewFile(uintptr(fd), "fscontext:"+fsName), nil } func fsmount(ctx *os.File, flags, mountAttrs int) (*os.File, error) { // Make sure we always set O_CLOEXEC. flags |= unix.FSMOUNT_CLOEXEC fd, err := unix.Fsmount(int(ctx.Fd()), flags, mountAttrs) if err != nil { return nil, os.NewSyscallError("fsmount "+ctx.Name(), err) } return os.NewFile(uintptr(fd), "fsmount:"+ctx.Name()), nil } func newPrivateProcMount() (*os.File, error) { procfsCtx, err := fsopen("proc", unix.FSOPEN_CLOEXEC) if err != nil { return nil, err } defer procfsCtx.Close() // Try to configure hidepid=ptraceable,subset=pid if possible, but ignore errors. _ = unix.FsconfigSetString(int(procfsCtx.Fd()), "hidepid", "ptraceable") _ = unix.FsconfigSetString(int(procfsCtx.Fd()), "subset", "pid") // Get an actual handle. if err := unix.FsconfigCreate(int(procfsCtx.Fd())); err != nil { return nil, os.NewSyscallError("fsconfig create procfs", err) } return fsmount(procfsCtx, unix.FSMOUNT_CLOEXEC, unix.MS_RDONLY|unix.MS_NODEV|unix.MS_NOEXEC|unix.MS_NOSUID) } func openTree(dir *os.File, path string, flags uint) (*os.File, error) { dirFd := -int(unix.EBADF) dirName := "." if dir != nil { dirFd = int(dir.Fd()) dirName = dir.Name() } // Make sure we always set O_CLOEXEC. flags |= unix.OPEN_TREE_CLOEXEC fd, err := unix.OpenTree(dirFd, path, flags) if err != nil { return nil, &os.PathError{Op: "open_tree", Path: path, Err: err} } return os.NewFile(uintptr(fd), dirName+"/"+path), nil } func clonePrivateProcMount() (_ *os.File, Err error) { // Try to make a clone without using AT_RECURSIVE if we can. If this works, // we can be sure there are no over-mounts and so if the root is valid then // we're golden. Otherwise, we have to deal with over-mounts. procfsHandle, err := openTree(nil, "/proc", unix.OPEN_TREE_CLONE) if err != nil || hookForcePrivateProcRootOpenTreeAtRecursive(procfsHandle) { procfsHandle, err = openTree(nil, "/proc", unix.OPEN_TREE_CLONE|unix.AT_RECURSIVE) } if err != nil { return nil, fmt.Errorf("creating a detached procfs clone: %w", err) } defer func() { if Err != nil { _ = procfsHandle.Close() } }() if err := verifyProcRoot(procfsHandle); err != nil { return nil, err } return procfsHandle, nil } func privateProcRoot() (*os.File, error) { if !hasNewMountApi() || hookForceGetProcRootUnsafe() { return nil, fmt.Errorf("new mount api: %w", unix.ENOTSUP) } // Try to create a new procfs mount from scratch if we can. This ensures we // can get a procfs mount even if /proc is fake (for whatever reason). procRoot, err := newPrivateProcMount() if err != nil || hookForcePrivateProcRootOpenTree(procRoot) { // Try to clone /proc then... procRoot, err = clonePrivateProcMount() } return procRoot, err } func unsafeHostProcRoot() (_ *os.File, Err error) { procRoot, err := os.OpenFile("/proc", unix.O_PATH|unix.O_NOFOLLOW|unix.O_DIRECTORY|unix.O_CLOEXEC, 0) if err != nil { return nil, err } defer func() { if Err != nil { _ = procRoot.Close() } }() if err := verifyProcRoot(procRoot); err != nil { return nil, err } return procRoot, nil } func doGetProcRoot() (*os.File, error) { procRoot, err := privateProcRoot() if err != nil { // Fall back to using a /proc handle if making a private mount failed. // If we have openat2, at least we can avoid some kinds of over-mount // attacks, but without openat2 there's not much we can do. procRoot, err = unsafeHostProcRoot() } return procRoot, err } var getProcRoot = sync_OnceValues(func() (*os.File, error) { return doGetProcRoot() }) var hasProcThreadSelf = sync_OnceValue(func() bool { return unix.Access("/proc/thread-self/", unix.F_OK) == nil }) var errUnsafeProcfs = errors.New("unsafe procfs detected") type procThreadSelfCloser func() // procThreadSelf returns a handle to /proc/thread-self/<subpath> (or an // equivalent handle on older kernels where /proc/thread-self doesn't exist). // Once finished with the handle, you must call the returned closer function // (runtime.UnlockOSThread). You must not pass the returned *os.File to other // Go threads or use the handle after calling the closer. // // This is similar to ProcThreadSelf from runc, but with extra hardening // applied and using *os.File. func procThreadSelf(procRoot *os.File, subpath string) (_ *os.File, _ procThreadSelfCloser, Err error) { // We need to lock our thread until the caller is done with the handle // because between getting the handle and using it we could get interrupted // by the Go runtime and hit the case where the underlying thread is // swapped out and the original thread is killed, resulting in // pull-your-hair-out-hard-to-debug issues in the caller. runtime.LockOSThread() defer func() { if Err != nil { runtime.UnlockOSThread() } }() // Figure out what prefix we want to use. threadSelf := "thread-self/" if !hasProcThreadSelf() || hookForceProcSelfTask() { /// Pre-3.17 kernels don't have /proc/thread-self, so do it manually. threadSelf = "self/task/" + strconv.Itoa(unix.Gettid()) + "/" if _, err := fstatatFile(procRoot, threadSelf, unix.AT_SYMLINK_NOFOLLOW); err != nil || hookForceProcSelf() { // In this case, we running in a pid namespace that doesn't match // the /proc mount we have. This can happen inside runc. // // Unfortunately, there is no nice way to get the correct TID to // use here because of the age of the kernel, so we have to just // use /proc/self and hope that it works. threadSelf = "self/" } } // Grab the handle. var ( handle *os.File err error ) if hasOpenat2() { // We prefer being able to use RESOLVE_NO_XDEV if we can, to be // absolutely sure we are operating on a clean /proc handle that // doesn't have any cheeky overmounts that could trick us (including // symlink mounts on top of /proc/thread-self). RESOLVE_BENEATH isn't // strictly needed, but just use it since we have it. // // NOTE: /proc/self is technically a magic-link (the contents of the // symlink are generated dynamically), but it doesn't use // nd_jump_link() so RESOLVE_NO_MAGICLINKS allows it. // // NOTE: We MUST NOT use RESOLVE_IN_ROOT here, as openat2File uses // procSelfFdReadlink to clean up the returned f.Name() if we use // RESOLVE_IN_ROOT (which would lead to an infinite recursion). handle, err = openat2File(procRoot, threadSelf+subpath, &unix.OpenHow{ Flags: unix.O_PATH | unix.O_NOFOLLOW | unix.O_CLOEXEC, Resolve: unix.RESOLVE_BENEATH | unix.RESOLVE_NO_XDEV | unix.RESOLVE_NO_MAGICLINKS, }) if err != nil { // TODO: Once we bump the minimum Go version to 1.20, we can use // multiple %w verbs for this wrapping. For now we need to use a // compatibility shim for older Go versions. //err = fmt.Errorf("%w: %w", errUnsafeProcfs, err) return nil, nil, wrapBaseError(err, errUnsafeProcfs) } } else { handle, err = openatFile(procRoot, threadSelf+subpath, unix.O_PATH|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0) if err != nil { // TODO: Once we bump the minimum Go version to 1.20, we can use // multiple %w verbs for this wrapping. For now we need to use a // compatibility shim for older Go versions. //err = fmt.Errorf("%w: %w", errUnsafeProcfs, err) return nil, nil, wrapBaseError(err, errUnsafeProcfs) } defer func() { if Err != nil { _ = handle.Close() } }() // We can't detect bind-mounts of different parts of procfs on top of // /proc (a-la RESOLVE_NO_XDEV), but we can at least be sure that we // aren't on the wrong filesystem here. if statfs, err := fstatfs(handle); err != nil { return nil, nil, err } else if statfs.Type != procSuperMagic { return nil, nil, fmt.Errorf("%w: incorrect /proc/self/fd filesystem type 0x%x", errUnsafeProcfs, statfs.Type) } } return handle, runtime.UnlockOSThread, nil } // STATX_MNT_ID_UNIQUE is provided in golang.org/x/sys@v0.20.0, but in order to // avoid bumping the requirement for a single constant we can just define it // ourselves. const STATX_MNT_ID_UNIQUE = 0x4000 var hasStatxMountId = sync_OnceValue(func() bool { var ( stx unix.Statx_t // We don't care which mount ID we get. The kernel will give us the // unique one if it is supported. wantStxMask uint32 = STATX_MNT_ID_UNIQUE | unix.STATX_MNT_ID ) err := unix.Statx(-int(unix.EBADF), "/", 0, int(wantStxMask), &stx) return err == nil && stx.Mask&wantStxMask != 0 }) func getMountId(dir *os.File, path string) (uint64, error) { // If we don't have statx(STATX_MNT_ID*) support, we can't do anything. if !hasStatxMountId() { return 0, nil } var ( stx unix.Statx_t // We don't care which mount ID we get. The kernel will give us the // unique one if it is supported. wantStxMask uint32 = STATX_MNT_ID_UNIQUE | unix.STATX_MNT_ID ) err := unix.Statx(int(dir.Fd()), path, unix.AT_EMPTY_PATH|unix.AT_SYMLINK_NOFOLLOW, int(wantStxMask), &stx) if stx.Mask&wantStxMask == 0 { // It's not a kernel limitation, for some reason we couldn't get a // mount ID. Assume it's some kind of attack. err = fmt.Errorf("%w: could not get mount id", errUnsafeProcfs) } if err != nil { return 0, &os.PathError{Op: "statx(STATX_MNT_ID_...)", Path: dir.Name() + "/" + path, Err: err} } return stx.Mnt_id, nil } func checkSymlinkOvermount(procRoot *os.File, dir *os.File, path string) error { // Get the mntId of our procfs handle. expectedMountId, err := getMountId(procRoot, "") if err != nil { return err } // Get the mntId of the target magic-link. gotMountId, err := getMountId(dir, path) if err != nil { return err } // As long as the directory mount is alive, even with wrapping mount IDs, // we would expect to see a different mount ID here. (Of course, if we're // using unsafeHostProcRoot() then an attaker could change this after we // did this check.) if expectedMountId != gotMountId { return fmt.Errorf("%w: symlink %s/%s has an overmount obscuring the real link (mount ids do not match %d != %d)", errUnsafeProcfs, dir.Name(), path, expectedMountId, gotMountId) } return nil } func doRawProcSelfFdReadlink(procRoot *os.File, fd int) (string, error) { fdPath := fmt.Sprintf("fd/%d", fd) procFdLink, closer, err := procThreadSelf(procRoot, fdPath) if err != nil { return "", fmt.Errorf("get safe /proc/thread-self/%s handle: %w", fdPath, err) } defer procFdLink.Close() defer closer() // Try to detect if there is a mount on top of the magic-link. Since we use the handle directly // provide to the closure. If the closure uses the handle directly, this // should be safe in general (a mount on top of the path afterwards would // not affect the handle itself) and will definitely be safe if we are // using privateProcRoot() (at least since Linux 5.12[1], when anonymous // mount namespaces were completely isolated from external mounts including // mount propagation events). // // [1]: Linux commit ee2e3f50629f ("mount: fix mounting of detached mounts // onto targets that reside on shared mounts"). if err := checkSymlinkOvermount(procRoot, procFdLink, ""); err != nil { return "", fmt.Errorf("check safety of /proc/thread-self/fd/%d magiclink: %w", fd, err) } // readlinkat implies AT_EMPTY_PATH since Linux 2.6.39. See Linux commit // 65cfc6722361 ("readlinkat(), fchownat() and fstatat() with empty // relative pathnames"). return readlinkatFile(procFdLink, "") } func rawProcSelfFdReadlink(fd int) (string, error) { procRoot, err := getProcRoot() if err != nil { return "", err } return doRawProcSelfFdReadlink(procRoot, fd) } func procSelfFdReadlink(f *os.File) (string, error) { return rawProcSelfFdReadlink(int(f.Fd())) } var ( errPossibleBreakout = errors.New("possible breakout detected") errInvalidDirectory = errors.New("wandered into deleted directory") errDeletedInode = errors.New("cannot verify path of deleted inode") ) func isDeadInode(file *os.File) error { // If the nlink of a file drops to 0, there is an attacker deleting // directories during our walk, which could result in weird /proc values. // It's better to error out in this case. stat, err := fstat(file) if err != nil { return fmt.Errorf("check for dead inode: %w", err) } if stat.Nlink == 0 { err := errDeletedInode if stat.Mode&unix.S_IFMT == unix.S_IFDIR { err = errInvalidDirectory } return fmt.Errorf("%w %q", err, file.Name()) } return nil } func checkProcSelfFdPath(path string, file *os.File) error { if err := isDeadInode(file); err != nil { return err } actualPath, err := procSelfFdReadlink(file) if err != nil { return fmt.Errorf("get path of handle: %w", err) } if actualPath != path { return fmt.Errorf("%w: handle path %q doesn't match expected path %q", errPossibleBreakout, actualPath, path) } return nil } // Test hooks used in the procfs tests to verify that the fallback logic works. // See testing_mocks_linux_test.go and procfs_linux_test.go for more details. var ( hookForcePrivateProcRootOpenTree = hookDummyFile hookForcePrivateProcRootOpenTreeAtRecursive = hookDummyFile hookForceGetProcRootUnsafe = hookDummy hookForceProcSelfTask = hookDummy hookForceProcSelf = hookDummy ) func hookDummy() bool { return false } func hookDummyFile(_ *os.File) bool { return false }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/openat2_linux.go
vendor/github.com/cyphar/filepath-securejoin/openat2_linux.go
//go:build linux // Copyright (C) 2024 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package securejoin import ( "errors" "fmt" "os" "path/filepath" "strings" "golang.org/x/sys/unix" ) var hasOpenat2 = sync_OnceValue(func() bool { fd, err := unix.Openat2(unix.AT_FDCWD, ".", &unix.OpenHow{ Flags: unix.O_PATH | unix.O_CLOEXEC, Resolve: unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_IN_ROOT, }) if err != nil { return false } _ = unix.Close(fd) return true }) func scopedLookupShouldRetry(how *unix.OpenHow, err error) bool { // RESOLVE_IN_ROOT (and RESOLVE_BENEATH) can return -EAGAIN if we resolve // ".." while a mount or rename occurs anywhere on the system. This could // happen spuriously, or as the result of an attacker trying to mess with // us during lookup. // // In addition, scoped lookups have a "safety check" at the end of // complete_walk which will return -EXDEV if the final path is not in the // root. return how.Resolve&(unix.RESOLVE_IN_ROOT|unix.RESOLVE_BENEATH) != 0 && (errors.Is(err, unix.EAGAIN) || errors.Is(err, unix.EXDEV)) } const scopedLookupMaxRetries = 10 func openat2File(dir *os.File, path string, how *unix.OpenHow) (*os.File, error) { fullPath := dir.Name() + "/" + path // Make sure we always set O_CLOEXEC. how.Flags |= unix.O_CLOEXEC var tries int for tries < scopedLookupMaxRetries { fd, err := unix.Openat2(int(dir.Fd()), path, how) if err != nil { if scopedLookupShouldRetry(how, err) { // We retry a couple of times to avoid the spurious errors, and // if we are being attacked then returning -EAGAIN is the best // we can do. tries++ continue } return nil, &os.PathError{Op: "openat2", Path: fullPath, Err: err} } // If we are using RESOLVE_IN_ROOT, the name we generated may be wrong. // NOTE: The procRoot code MUST NOT use RESOLVE_IN_ROOT, otherwise // you'll get infinite recursion here. if how.Resolve&unix.RESOLVE_IN_ROOT == unix.RESOLVE_IN_ROOT { if actualPath, err := rawProcSelfFdReadlink(fd); err == nil { fullPath = actualPath } } return os.NewFile(uintptr(fd), fullPath), nil } return nil, &os.PathError{Op: "openat2", Path: fullPath, Err: errPossibleAttack} } func lookupOpenat2(root *os.File, unsafePath string, partial bool) (*os.File, string, error) { if !partial { file, err := openat2File(root, unsafePath, &unix.OpenHow{ Flags: unix.O_PATH | unix.O_CLOEXEC, Resolve: unix.RESOLVE_IN_ROOT | unix.RESOLVE_NO_MAGICLINKS, }) return file, "", err } return partialLookupOpenat2(root, unsafePath) } // partialLookupOpenat2 is an alternative implementation of // partialLookupInRoot, using openat2(RESOLVE_IN_ROOT) to more safely get a // handle to the deepest existing child of the requested path within the root. func partialLookupOpenat2(root *os.File, unsafePath string) (*os.File, string, error) { // TODO: Implement this as a git-bisect-like binary search. unsafePath = filepath.ToSlash(unsafePath) // noop endIdx := len(unsafePath) var lastError error for endIdx > 0 { subpath := unsafePath[:endIdx] handle, err := openat2File(root, subpath, &unix.OpenHow{ Flags: unix.O_PATH | unix.O_CLOEXEC, Resolve: unix.RESOLVE_IN_ROOT | unix.RESOLVE_NO_MAGICLINKS, }) if err == nil { // Jump over the slash if we have a non-"" remainingPath. if endIdx < len(unsafePath) { endIdx += 1 } // We found a subpath! return handle, unsafePath[endIdx:], lastError } if errors.Is(err, unix.ENOENT) || errors.Is(err, unix.ENOTDIR) { // That path doesn't exist, let's try the next directory up. endIdx = strings.LastIndexByte(subpath, '/') lastError = err continue } return nil, "", fmt.Errorf("open subpath: %w", err) } // If we couldn't open anything, the whole subpath is missing. Return a // copy of the root fd so that the caller doesn't close this one by // accident. rootClone, err := dupFile(root) if err != nil { return nil, "", err } return rootClone, unsafePath, lastError }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/doc.go
vendor/github.com/cyphar/filepath-securejoin/doc.go
// Copyright (C) 2014-2015 Docker Inc & Go Authors. All rights reserved. // Copyright (C) 2017-2024 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package securejoin implements a set of helpers to make it easier to write Go // code that is safe against symlink-related escape attacks. The primary idea // is to let you resolve a path within a rootfs directory as if the rootfs was // a chroot. // // securejoin has two APIs, a "legacy" API and a "modern" API. // // The legacy API is [SecureJoin] and [SecureJoinVFS]. These methods are // **not** safe against race conditions where an attacker changes the // filesystem after (or during) the [SecureJoin] operation. // // The new API is made up of [OpenInRoot] and [MkdirAll] (and derived // functions). These are safe against racing attackers and have several other // protections that are not provided by the legacy API. There are many more // operations that most programs expect to be able to do safely, but we do not // provide explicit support for them because we want to encourage users to // switch to [libpathrs](https://github.com/openSUSE/libpathrs) which is a // cross-language next-generation library that is entirely designed around // operating on paths safely. // // securejoin has been used by several container runtimes (Docker, runc, // Kubernetes, etc) for quite a few years as a de-facto standard for operating // on container filesystem paths "safely". However, most users still use the // legacy API which is unsafe against various attacks (there is a fairly long // history of CVEs in dependent as a result). Users should switch to the modern // API as soon as possible (or even better, switch to libpathrs). // // This project was initially intended to be included in the Go standard // library, but [it was rejected](https://go.dev/issue/20126). There is now a // [new Go proposal](https://go.dev/issue/67002) for a safe path resolution API // that shares some of the goals of filepath-securejoin. However, that design // is intended to work like `openat2(RESOLVE_BENEATH)` which does not fit the // usecase of container runtimes and most system tools. package securejoin
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/gocompat_errors_go120.go
vendor/github.com/cyphar/filepath-securejoin/gocompat_errors_go120.go
//go:build linux && go1.20 // Copyright (C) 2024 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package securejoin import ( "fmt" ) // wrapBaseError is a helper that is equivalent to fmt.Errorf("%w: %w"), except // that on pre-1.20 Go versions only errors.Is() works properly (errors.Unwrap) // is only guaranteed to give you baseErr. func wrapBaseError(baseErr, extraErr error) error { return fmt.Errorf("%w: %w", extraErr, baseErr) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cyphar/filepath-securejoin/lookup_linux.go
vendor/github.com/cyphar/filepath-securejoin/lookup_linux.go
//go:build linux // Copyright (C) 2024 SUSE LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package securejoin import ( "errors" "fmt" "os" "path" "path/filepath" "strings" "golang.org/x/sys/unix" ) type symlinkStackEntry struct { // (dir, remainingPath) is what we would've returned if the link didn't // exist. This matches what openat2(RESOLVE_IN_ROOT) would return in // this case. dir *os.File remainingPath string // linkUnwalked is the remaining path components from the original // Readlink which we have yet to walk. When this slice is empty, we // drop the link from the stack. linkUnwalked []string } func (se symlinkStackEntry) String() string { return fmt.Sprintf("<%s>/%s [->%s]", se.dir.Name(), se.remainingPath, strings.Join(se.linkUnwalked, "/")) } func (se symlinkStackEntry) Close() { _ = se.dir.Close() } type symlinkStack []*symlinkStackEntry func (s *symlinkStack) IsEmpty() bool { return s == nil || len(*s) == 0 } func (s *symlinkStack) Close() { if s != nil { for _, link := range *s { link.Close() } // TODO: Switch to clear once we switch to Go 1.21. *s = nil } } var ( errEmptyStack = errors.New("[internal] stack is empty") errBrokenSymlinkStack = errors.New("[internal error] broken symlink stack") ) func (s *symlinkStack) popPart(part string) error { if s == nil || s.IsEmpty() { // If there is nothing in the symlink stack, then the part was from the // real path provided by the user, and this is a no-op. return errEmptyStack } if part == "." { // "." components are no-ops -- we drop them when doing SwapLink. return nil } tailEntry := (*s)[len(*s)-1] // Double-check that we are popping the component we expect. if len(tailEntry.linkUnwalked) == 0 { return fmt.Errorf("%w: trying to pop component %q of empty stack entry %s", errBrokenSymlinkStack, part, tailEntry) } headPart := tailEntry.linkUnwalked[0] if headPart != part { return fmt.Errorf("%w: trying to pop component %q but the last stack entry is %s (%q)", errBrokenSymlinkStack, part, tailEntry, headPart) } // Drop the component, but keep the entry around in case we are dealing // with a "tail-chained" symlink. tailEntry.linkUnwalked = tailEntry.linkUnwalked[1:] return nil } func (s *symlinkStack) PopPart(part string) error { if err := s.popPart(part); err != nil { if errors.Is(err, errEmptyStack) { // Skip empty stacks. err = nil } return err } // Clean up any of the trailing stack entries that are empty. for lastGood := len(*s) - 1; lastGood >= 0; lastGood-- { entry := (*s)[lastGood] if len(entry.linkUnwalked) > 0 { break } entry.Close() (*s) = (*s)[:lastGood] } return nil } func (s *symlinkStack) push(dir *os.File, remainingPath, linkTarget string) error { if s == nil { return nil } // Split the link target and clean up any "" parts. linkTargetParts := slices_DeleteFunc( strings.Split(linkTarget, "/"), func(part string) bool { return part == "" || part == "." }) // Copy the directory so the caller doesn't close our copy. dirCopy, err := dupFile(dir) if err != nil { return err } // Add to the stack. *s = append(*s, &symlinkStackEntry{ dir: dirCopy, remainingPath: remainingPath, linkUnwalked: linkTargetParts, }) return nil } func (s *symlinkStack) SwapLink(linkPart string, dir *os.File, remainingPath, linkTarget string) error { // If we are currently inside a symlink resolution, remove the symlink // component from the last symlink entry, but don't remove the entry even // if it's empty. If we are a "tail-chained" symlink (a trailing symlink we // hit during a symlink resolution) we need to keep the old symlink until // we finish the resolution. if err := s.popPart(linkPart); err != nil { if !errors.Is(err, errEmptyStack) { return err } // Push the component regardless of whether the stack was empty. } return s.push(dir, remainingPath, linkTarget) } func (s *symlinkStack) PopTopSymlink() (*os.File, string, bool) { if s == nil || s.IsEmpty() { return nil, "", false } tailEntry := (*s)[0] *s = (*s)[1:] return tailEntry.dir, tailEntry.remainingPath, true } // partialLookupInRoot tries to lookup as much of the request path as possible // within the provided root (a-la RESOLVE_IN_ROOT) and opens the final existing // component of the requested path, returning a file handle to the final // existing component and a string containing the remaining path components. func partialLookupInRoot(root *os.File, unsafePath string) (*os.File, string, error) { return lookupInRoot(root, unsafePath, true) } func completeLookupInRoot(root *os.File, unsafePath string) (*os.File, error) { handle, remainingPath, err := lookupInRoot(root, unsafePath, false) if remainingPath != "" && err == nil { // should never happen err = fmt.Errorf("[bug] non-empty remaining path when doing a non-partial lookup: %q", remainingPath) } // lookupInRoot(partial=false) will always close the handle if an error is // returned, so no need to double-check here. return handle, err } func lookupInRoot(root *os.File, unsafePath string, partial bool) (Handle *os.File, _ string, _ error) { unsafePath = filepath.ToSlash(unsafePath) // noop // This is very similar to SecureJoin, except that we operate on the // components using file descriptors. We then return the last component we // managed open, along with the remaining path components not opened. // Try to use openat2 if possible. if hasOpenat2() { return lookupOpenat2(root, unsafePath, partial) } // Get the "actual" root path from /proc/self/fd. This is necessary if the // root is some magic-link like /proc/$pid/root, in which case we want to // make sure when we do checkProcSelfFdPath that we are using the correct // root path. logicalRootPath, err := procSelfFdReadlink(root) if err != nil { return nil, "", fmt.Errorf("get real root path: %w", err) } currentDir, err := dupFile(root) if err != nil { return nil, "", fmt.Errorf("clone root fd: %w", err) } defer func() { // If a handle is not returned, close the internal handle. if Handle == nil { _ = currentDir.Close() } }() // symlinkStack is used to emulate how openat2(RESOLVE_IN_ROOT) treats // dangling symlinks. If we hit a non-existent path while resolving a // symlink, we need to return the (dir, remainingPath) that we had when we // hit the symlink (treating the symlink as though it were a regular file). // The set of (dir, remainingPath) sets is stored within the symlinkStack // and we add and remove parts when we hit symlink and non-symlink // components respectively. We need a stack because of recursive symlinks // (symlinks that contain symlink components in their target). // // Note that the stack is ONLY used for book-keeping. All of the actual // path walking logic is still based on currentPath/remainingPath and // currentDir (as in SecureJoin). var symStack *symlinkStack if partial { symStack = new(symlinkStack) defer symStack.Close() } var ( linksWalked int currentPath string remainingPath = unsafePath ) for remainingPath != "" { // Save the current remaining path so if the part is not real we can // return the path including the component. oldRemainingPath := remainingPath // Get the next path component. var part string if i := strings.IndexByte(remainingPath, '/'); i == -1 { part, remainingPath = remainingPath, "" } else { part, remainingPath = remainingPath[:i], remainingPath[i+1:] } // If we hit an empty component, we need to treat it as though it is // "." so that trailing "/" and "//" components on a non-directory // correctly return the right error code. if part == "" { part = "." } // Apply the component lexically to the path we are building. // currentPath does not contain any symlinks, and we are lexically // dealing with a single component, so it's okay to do a filepath.Clean // here. nextPath := path.Join("/", currentPath, part) // If we logically hit the root, just clone the root rather than // opening the part and doing all of the other checks. if nextPath == "/" { if err := symStack.PopPart(part); err != nil { return nil, "", fmt.Errorf("walking into root with part %q failed: %w", part, err) } // Jump to root. rootClone, err := dupFile(root) if err != nil { return nil, "", fmt.Errorf("clone root fd: %w", err) } _ = currentDir.Close() currentDir = rootClone currentPath = nextPath continue } // Try to open the next component. nextDir, err := openatFile(currentDir, part, unix.O_PATH|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0) switch { case err == nil: st, err := nextDir.Stat() if err != nil { _ = nextDir.Close() return nil, "", fmt.Errorf("stat component %q: %w", part, err) } switch st.Mode() & os.ModeType { case os.ModeSymlink: // readlinkat implies AT_EMPTY_PATH since Linux 2.6.39. See // Linux commit 65cfc6722361 ("readlinkat(), fchownat() and // fstatat() with empty relative pathnames"). linkDest, err := readlinkatFile(nextDir, "") // We don't need the handle anymore. _ = nextDir.Close() if err != nil { return nil, "", err } linksWalked++ if linksWalked > maxSymlinkLimit { return nil, "", &os.PathError{Op: "securejoin.lookupInRoot", Path: logicalRootPath + "/" + unsafePath, Err: unix.ELOOP} } // Swap out the symlink's component for the link entry itself. if err := symStack.SwapLink(part, currentDir, oldRemainingPath, linkDest); err != nil { return nil, "", fmt.Errorf("walking into symlink %q failed: push symlink: %w", part, err) } // Update our logical remaining path. remainingPath = linkDest + "/" + remainingPath // Absolute symlinks reset any work we've already done. if path.IsAbs(linkDest) { // Jump to root. rootClone, err := dupFile(root) if err != nil { return nil, "", fmt.Errorf("clone root fd: %w", err) } _ = currentDir.Close() currentDir = rootClone currentPath = "/" } default: // If we are dealing with a directory, simply walk into it. _ = currentDir.Close() currentDir = nextDir currentPath = nextPath // The part was real, so drop it from the symlink stack. if err := symStack.PopPart(part); err != nil { return nil, "", fmt.Errorf("walking into directory %q failed: %w", part, err) } // If we are operating on a .., make sure we haven't escaped. // We only have to check for ".." here because walking down // into a regular component component cannot cause you to // escape. This mirrors the logic in RESOLVE_IN_ROOT, except we // have to check every ".." rather than only checking after a // rename or mount on the system. if part == ".." { // Make sure the root hasn't moved. if err := checkProcSelfFdPath(logicalRootPath, root); err != nil { return nil, "", fmt.Errorf("root path moved during lookup: %w", err) } // Make sure the path is what we expect. fullPath := logicalRootPath + nextPath if err := checkProcSelfFdPath(fullPath, currentDir); err != nil { return nil, "", fmt.Errorf("walking into %q had unexpected result: %w", part, err) } } } default: if !partial { return nil, "", err } // If there are any remaining components in the symlink stack, we // are still within a symlink resolution and thus we hit a dangling // symlink. So pretend that the first symlink in the stack we hit // was an ENOENT (to match openat2). if oldDir, remainingPath, ok := symStack.PopTopSymlink(); ok { _ = currentDir.Close() return oldDir, remainingPath, err } // We have hit a final component that doesn't exist, so we have our // partial open result. Note that we have to use the OLD remaining // path, since the lookup failed. return currentDir, oldRemainingPath, err } } // If the unsafePath had a trailing slash, we need to make sure we try to // do a relative "." open so that we will correctly return an error when // the final component is a non-directory (to match openat2). In the // context of openat2, a trailing slash and a trailing "/." are completely // equivalent. if strings.HasSuffix(unsafePath, "/") { nextDir, err := openatFile(currentDir, ".", unix.O_PATH|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0) if err != nil { if !partial { _ = currentDir.Close() currentDir = nil } return currentDir, "", err } _ = currentDir.Close() currentDir = nextDir } // All of the components existed! return currentDir, "", nil }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/ecc/goldilocks/curve.go
vendor/github.com/cloudflare/circl/ecc/goldilocks/curve.go
// Package goldilocks provides elliptic curve operations over the goldilocks curve. package goldilocks import fp "github.com/cloudflare/circl/math/fp448" // Curve is the Goldilocks curve x^2+y^2=z^2-39081x^2y^2. type Curve struct{} // Identity returns the identity point. func (Curve) Identity() *Point { return &Point{ y: fp.One(), z: fp.One(), } } // IsOnCurve returns true if the point lies on the curve. func (Curve) IsOnCurve(P *Point) bool { x2, y2, t, t2, z2 := &fp.Elt{}, &fp.Elt{}, &fp.Elt{}, &fp.Elt{}, &fp.Elt{} rhs, lhs := &fp.Elt{}, &fp.Elt{} // Check z != 0 eq0 := !fp.IsZero(&P.z) fp.Mul(t, &P.ta, &P.tb) // t = ta*tb fp.Sqr(x2, &P.x) // x^2 fp.Sqr(y2, &P.y) // y^2 fp.Sqr(z2, &P.z) // z^2 fp.Sqr(t2, t) // t^2 fp.Add(lhs, x2, y2) // x^2 + y^2 fp.Mul(rhs, t2, &paramD) // dt^2 fp.Add(rhs, rhs, z2) // z^2 + dt^2 fp.Sub(lhs, lhs, rhs) // x^2 + y^2 - (z^2 + dt^2) eq1 := fp.IsZero(lhs) fp.Mul(lhs, &P.x, &P.y) // xy fp.Mul(rhs, t, &P.z) // tz fp.Sub(lhs, lhs, rhs) // xy - tz eq2 := fp.IsZero(lhs) return eq0 && eq1 && eq2 } // Generator returns the generator point. func (Curve) Generator() *Point { return &Point{ x: genX, y: genY, z: fp.One(), ta: genX, tb: genY, } } // Order returns the number of points in the prime subgroup. func (Curve) Order() Scalar { return order } // Double returns 2P. func (Curve) Double(P *Point) *Point { R := *P; R.Double(); return &R } // Add returns P+Q. func (Curve) Add(P, Q *Point) *Point { R := *P; R.Add(Q); return &R } // ScalarMult returns kP. This function runs in constant time. func (e Curve) ScalarMult(k *Scalar, P *Point) *Point { k4 := &Scalar{} k4.divBy4(k) return e.pull(twistCurve{}.ScalarMult(k4, e.push(P))) } // ScalarBaseMult returns kG where G is the generator point. This function runs in constant time. func (e Curve) ScalarBaseMult(k *Scalar) *Point { k4 := &Scalar{} k4.divBy4(k) return e.pull(twistCurve{}.ScalarBaseMult(k4)) } // CombinedMult returns mG+nP, where G is the generator point. This function is non-constant time. func (e Curve) CombinedMult(m, n *Scalar, P *Point) *Point { m4 := &Scalar{} n4 := &Scalar{} m4.divBy4(m) n4.divBy4(n) return e.pull(twistCurve{}.CombinedMult(m4, n4, twistCurve{}.pull(P))) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/ecc/goldilocks/twist.go
vendor/github.com/cloudflare/circl/ecc/goldilocks/twist.go
package goldilocks import ( "crypto/subtle" "math/bits" "github.com/cloudflare/circl/internal/conv" "github.com/cloudflare/circl/math" fp "github.com/cloudflare/circl/math/fp448" ) // twistCurve is -x^2+y^2=1-39082x^2y^2 and is 4-isogenous to Goldilocks. type twistCurve struct{} // Identity returns the identity point. func (twistCurve) Identity() *twistPoint { return &twistPoint{ y: fp.One(), z: fp.One(), } } // subYDiv16 update x = (x - y) / 16. func subYDiv16(x *scalar64, y int64) { s := uint64(y >> 63) x0, b0 := bits.Sub64((*x)[0], uint64(y), 0) x1, b1 := bits.Sub64((*x)[1], s, b0) x2, b2 := bits.Sub64((*x)[2], s, b1) x3, b3 := bits.Sub64((*x)[3], s, b2) x4, b4 := bits.Sub64((*x)[4], s, b3) x5, b5 := bits.Sub64((*x)[5], s, b4) x6, _ := bits.Sub64((*x)[6], s, b5) x[0] = (x0 >> 4) | (x1 << 60) x[1] = (x1 >> 4) | (x2 << 60) x[2] = (x2 >> 4) | (x3 << 60) x[3] = (x3 >> 4) | (x4 << 60) x[4] = (x4 >> 4) | (x5 << 60) x[5] = (x5 >> 4) | (x6 << 60) x[6] = (x6 >> 4) } func recodeScalar(d *[113]int8, k *Scalar) { var k64 scalar64 k64.fromScalar(k) for i := 0; i < 112; i++ { d[i] = int8((k64[0] & 0x1f) - 16) subYDiv16(&k64, int64(d[i])) } d[112] = int8(k64[0]) } // ScalarMult returns kP. func (e twistCurve) ScalarMult(k *Scalar, P *twistPoint) *twistPoint { var TabP [8]preTwistPointProy var S preTwistPointProy var d [113]int8 var isZero int if k.IsZero() { isZero = 1 } subtle.ConstantTimeCopy(isZero, k[:], order[:]) minusK := *k isEven := 1 - int(k[0]&0x1) minusK.Neg() subtle.ConstantTimeCopy(isEven, k[:], minusK[:]) recodeScalar(&d, k) P.oddMultiples(TabP[:]) Q := e.Identity() for i := 112; i >= 0; i-- { Q.Double() Q.Double() Q.Double() Q.Double() mask := d[i] >> 7 absDi := (d[i] + mask) ^ mask inx := int32((absDi - 1) >> 1) sig := int((d[i] >> 7) & 0x1) for j := range TabP { S.cmov(&TabP[j], uint(subtle.ConstantTimeEq(inx, int32(j)))) } S.cneg(sig) Q.mixAdd(&S) } Q.cneg(uint(isEven)) return Q } const ( omegaFix = 7 omegaVar = 5 ) // CombinedMult returns mG+nP. func (e twistCurve) CombinedMult(m, n *Scalar, P *twistPoint) *twistPoint { nafFix := math.OmegaNAF(conv.BytesLe2BigInt(m[:]), omegaFix) nafVar := math.OmegaNAF(conv.BytesLe2BigInt(n[:]), omegaVar) if len(nafFix) > len(nafVar) { nafVar = append(nafVar, make([]int32, len(nafFix)-len(nafVar))...) } else if len(nafFix) < len(nafVar) { nafFix = append(nafFix, make([]int32, len(nafVar)-len(nafFix))...) } var TabQ [1 << (omegaVar - 2)]preTwistPointProy P.oddMultiples(TabQ[:]) Q := e.Identity() for i := len(nafFix) - 1; i >= 0; i-- { Q.Double() // Generator point if nafFix[i] != 0 { idxM := absolute(nafFix[i]) >> 1 R := tabVerif[idxM] if nafFix[i] < 0 { R.neg() } Q.mixAddZ1(&R) } // Variable input point if nafVar[i] != 0 { idxN := absolute(nafVar[i]) >> 1 S := TabQ[idxN] if nafVar[i] < 0 { S.neg() } Q.mixAdd(&S) } } return Q } // absolute returns always a positive value. func absolute(x int32) int32 { mask := x >> 31 return (x + mask) ^ mask }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/ecc/goldilocks/constants.go
vendor/github.com/cloudflare/circl/ecc/goldilocks/constants.go
package goldilocks import fp "github.com/cloudflare/circl/math/fp448" var ( // genX is the x-coordinate of the generator of Goldilocks curve. genX = fp.Elt{ 0x5e, 0xc0, 0x0c, 0xc7, 0x2b, 0xa8, 0x26, 0x26, 0x8e, 0x93, 0x00, 0x8b, 0xe1, 0x80, 0x3b, 0x43, 0x11, 0x65, 0xb6, 0x2a, 0xf7, 0x1a, 0xae, 0x12, 0x64, 0xa4, 0xd3, 0xa3, 0x24, 0xe3, 0x6d, 0xea, 0x67, 0x17, 0x0f, 0x47, 0x70, 0x65, 0x14, 0x9e, 0xda, 0x36, 0xbf, 0x22, 0xa6, 0x15, 0x1d, 0x22, 0xed, 0x0d, 0xed, 0x6b, 0xc6, 0x70, 0x19, 0x4f, } // genY is the y-coordinate of the generator of Goldilocks curve. genY = fp.Elt{ 0x14, 0xfa, 0x30, 0xf2, 0x5b, 0x79, 0x08, 0x98, 0xad, 0xc8, 0xd7, 0x4e, 0x2c, 0x13, 0xbd, 0xfd, 0xc4, 0x39, 0x7c, 0xe6, 0x1c, 0xff, 0xd3, 0x3a, 0xd7, 0xc2, 0xa0, 0x05, 0x1e, 0x9c, 0x78, 0x87, 0x40, 0x98, 0xa3, 0x6c, 0x73, 0x73, 0xea, 0x4b, 0x62, 0xc7, 0xc9, 0x56, 0x37, 0x20, 0x76, 0x88, 0x24, 0xbc, 0xb6, 0x6e, 0x71, 0x46, 0x3f, 0x69, } // paramD is -39081 in Fp. paramD = fp.Elt{ 0x56, 0x67, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, } // order is 2^446-0x8335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d, // which is the number of points in the prime subgroup. order = Scalar{ 0xf3, 0x44, 0x58, 0xab, 0x92, 0xc2, 0x78, 0x23, 0x55, 0x8f, 0xc5, 0x8d, 0x72, 0xc2, 0x6c, 0x21, 0x90, 0x36, 0xd6, 0xae, 0x49, 0xdb, 0x4e, 0xc4, 0xe9, 0x23, 0xca, 0x7c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, } // residue448 is 2^448 mod order. residue448 = [4]uint64{ 0x721cf5b5529eec34, 0x7a4cf635c8e9c2ab, 0xeec492d944a725bf, 0x20cd77058, } // invFour is 1/4 mod order. invFour = Scalar{ 0x3d, 0x11, 0xd6, 0xaa, 0xa4, 0x30, 0xde, 0x48, 0xd5, 0x63, 0x71, 0xa3, 0x9c, 0x30, 0x5b, 0x08, 0xa4, 0x8d, 0xb5, 0x6b, 0xd2, 0xb6, 0x13, 0x71, 0xfa, 0x88, 0x32, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, } // paramDTwist is -39082 in Fp. The D parameter of the twist curve. paramDTwist = fp.Elt{ 0x55, 0x67, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, } )
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/ecc/goldilocks/twistTables.go
vendor/github.com/cloudflare/circl/ecc/goldilocks/twistTables.go
package goldilocks import fp "github.com/cloudflare/circl/math/fp448" var tabFixMult = [fxV][fx2w1]preTwistPointAffine{ { { addYX: fp.Elt{0x65, 0x4a, 0xdd, 0xdf, 0xb4, 0x79, 0x60, 0xc8, 0xa1, 0x70, 0xb4, 0x3a, 0x1e, 0x0c, 0x9b, 0x19, 0xe5, 0x48, 0x3f, 0xd7, 0x44, 0x18, 0x18, 0x14, 0x14, 0x27, 0x45, 0xd0, 0x2b, 0x24, 0xd5, 0x93, 0xc3, 0x74, 0x4c, 0x50, 0x70, 0x43, 0x26, 0x05, 0x08, 0x24, 0xca, 0x78, 0x30, 0xc1, 0x06, 0x8d, 0xd4, 0x86, 0x42, 0xf0, 0x14, 0xde, 0x08, 0x05}, subYX: fp.Elt{0x64, 0x4a, 0xdd, 0xdf, 0xb4, 0x79, 0x60, 0xc8, 0xa1, 0x70, 0xb4, 0x3a, 0x1e, 0x0c, 0x9b, 0x19, 0xe5, 0x48, 0x3f, 0xd7, 0x44, 0x18, 0x18, 0x14, 0x14, 0x27, 0x45, 0xd0, 0x2d, 0x24, 0xd5, 0x93, 0xc3, 0x74, 0x4c, 0x50, 0x70, 0x43, 0x26, 0x05, 0x08, 0x24, 0xca, 0x78, 0x30, 0xc1, 0x06, 0x8d, 0xd4, 0x86, 0x42, 0xf0, 0x14, 0xde, 0x08, 0x05}, dt2: fp.Elt{0x1a, 0x33, 0xea, 0x64, 0x45, 0x1c, 0xdf, 0x17, 0x1d, 0x16, 0x34, 0x28, 0xd6, 0x61, 0x19, 0x67, 0x79, 0xb4, 0x13, 0xcf, 0x3e, 0x7c, 0x0e, 0x72, 0xda, 0xf1, 0x5f, 0xda, 0xe6, 0xcf, 0x42, 0xd3, 0xb6, 0x17, 0xc2, 0x68, 0x13, 0x2d, 0xd9, 0x60, 0x3e, 0xae, 0xf0, 0x5b, 0x96, 0xf0, 0xcd, 0xaf, 0xea, 0xb7, 0x0d, 0x59, 0x16, 0xa7, 0xff, 0x55}, }, { addYX: fp.Elt{0xca, 0xd8, 0x7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 0x41, 0x56, 0x9b, 0xdf, 0x15, 0xd8, 0x43, 0x28, 0x17, 0x5b, 0x96, 0xc9, 0xcf, 0x39, 0x1f, 0x13, 0xf7, 0x4d, 0x1d, 0x1f, 0xda, 0x51, 0x56, 0xe7, 0x0a, 0x5a, 0x65, 0xb6, 0x2a, 0x87, 0x49, 0x86, 0xc2, 0x2b, 0xcd, 0xfe, 0x07, 0xf6, 0x4c, 0xe2, 0x1d, 0x9b, 0xd8, 0x82, 0x09, 0x5b, 0x11, 0x10, 0x62, 0x56, 0x89, 0xbd}, dt2: fp.Elt{0xd9, 0x15, 0x73, 0xf2, 0x96, 0x35, 0x53, 0xb0, 0xe7, 0xa8, 0x0b, 0x93, 0x35, 0x0b, 0x3a, 0x00, 0xf5, 0x18, 0xb1, 0xc3, 0x12, 0x3f, 0x91, 0x17, 0xc1, 0x4c, 0x15, 0x5a, 0x86, 0x92, 0x11, 0xbd, 0x44, 0x40, 0x5a, 0x7b, 0x15, 0x89, 0xba, 0xc1, 0xc1, 0xbc, 0x43, 0x45, 0xe6, 0x52, 0x02, 0x73, 0x0a, 0xd0, 0x2a, 0x19, 0xda, 0x47, 0xa8, 0xff}, }, }, } // tabVerif contains the odd multiples of P. The entry T[i] = (2i+1)P, where // P = phi(G) and G is the generator of the Goldilocks curve, and phi is a // 4-degree isogeny. var tabVerif = [1 << (omegaFix - 2)]preTwistPointAffine{ { /* 1P*/ addYX: fp.Elt{0x65, 0x4a, 0xdd, 0xdf, 0xb4, 0x79, 0x60, 0xc8, 0xa1, 0x70, 0xb4, 0x3a, 0x1e, 0x0c, 0x9b, 0x19, 0xe5, 0x48, 0x3f, 0xd7, 0x44, 0x18, 0x18, 0x14, 0x14, 0x27, 0x45, 0xd0, 0x2b, 0x24, 0xd5, 0x93, 0xc3, 0x74, 0x4c, 0x50, 0x70, 0x43, 0x26, 0x05, 0x08, 0x24, 0xca, 0x78, 0x30, 0xc1, 0x06, 0x8d, 0xd4, 0x86, 0x42, 0xf0, 0x14, 0xde, 0x08, 0x05}, subYX: fp.Elt{0x64, 0x4a, 0xdd, 0xdf, 0xb4, 0x79, 0x60, 0xc8, 0xa1, 0x70, 0xb4, 0x3a, 0x1e, 0x0c, 0x9b, 0x19, 0xe5, 0x48, 0x3f, 0xd7, 0x44, 0x18, 0x18, 0x14, 0x14, 0x27, 0x45, 0xd0, 0x2d, 0x24, 0xd5, 0x93, 0xc3, 0x74, 0x4c, 0x50, 0x70, 0x43, 0x26, 0x05, 0x08, 0x24, 0xca, 0x78, 0x30, 0xc1, 0x06, 0x8d, 0xd4, 0x86, 0x42, 0xf0, 0x14, 0xde, 0x08, 0x05}, dt2: fp.Elt{0x1a, 0x33, 0xea, 0x64, 0x45, 0x1c, 0xdf, 0x17, 0x1d, 0x16, 0x34, 0x28, 0xd6, 0x61, 0x19, 0x67, 0x79, 0xb4, 0x13, 0xcf, 0x3e, 0x7c, 0x0e, 0x72, 0xda, 0xf1, 0x5f, 0xda, 0xe6, 0xcf, 0x42, 0xd3, 0xb6, 0x17, 0xc2, 0x68, 0x13, 0x2d, 0xd9, 0x60, 0x3e, 0xae, 0xf0, 0x5b, 0x96, 0xf0, 0xcd, 0xaf, 0xea, 0xb7, 0x0d, 0x59, 0x16, 0xa7, 0xff, 0x55}, }, { /* 3P*/ addYX: fp.Elt{0xd1, 0xe9, 0xa8, 0x33, 0x20, 0x76, 0x18, 0x08, 0x45, 0x2a, 0xc9, 0x67, 0x2a, 0xc3, 0x15, 0x24, 0xf9, 0x74, 0x21, 0x30, 0x99, 0x59, 0x8b, 0xb2, 0xf0, 0xa4, 0x07, 0xe2, 0x6a, 0x36, 0x8d, 0xd9, 0xd2, 0x4a, 0x7f, 0x73, 0x50, 0x39, 0x3d, 0xaa, 0xa7, 0x51, 0x73, 0x0d, 0x2b, 0x8b, 0x96, 0x47, 0xac, 0x3c, 0x5d, 0xaa, 0x39, 0x9c, 0xcf, 0xd5}, subYX: fp.Elt{0x6b, 0x11, 0x5d, 0x1a, 0xf9, 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f, 0x2a, 0x32, 0x40, 0xf0, 0x2c, 0x3f, 0x5d, 0xe4, 0xfc, 0x89, 0x11, 0x24, 0xb4, 0x2f, 0x97, 0xad, 0xac, 0x8f, 0x19, 0xab, 0xfa, 0x12, 0xe5, 0xf9, 0x50, 0x4e, 0x50, 0x6f, 0x32, 0x30, 0x88, 0xa6, 0xe5, 0x48, 0x28, 0xa2, 0x1b, 0x9f, 0xcd, 0xe2, 0x43, 0x38}, dt2: fp.Elt{0xa9, 0xcc, 0x53, 0x39, 0x86, 0x02, 0x60, 0x75, 0x34, 0x99, 0x57, 0xbd, 0xfc, 0x5a, 0x8e, 0xce, 0x5e, 0x98, 0x22, 0xd0, 0xa5, 0x24, 0xff, 0x90, 0x28, 0x9f, 0x58, 0xf3, 0x39, 0xe9, 0xba, 0x36, 0x23, 0xfb, 0x7f, 0x41, 0xcc, 0x2b, 0x5a, 0x25, 0x3f, 0x4c, 0x2a, 0xf1, 0x52, 0x6f, 0x2f, 0x07, 0xe3, 0x88, 0x81, 0x77, 0xdd, 0x7c, 0x88, 0x82}, }, { /* 7P*/ addYX: fp.Elt{0xf7, 0xee, 0x88, 0xfd, 0x3a, 0xbf, 0x7e, 0x28, 0x39, 0x23, 0x79, 0xe6, 0x5c, 0x56, 0xcb, 0xb5, 0x48, 0x6a, 0x80, 0x6d, 0x37, 0x60, 0x6c, 0x10, 0x35, 0x49, 0x4b, 0x46, 0x60, 0xd4, 0x79, 0xd4, 0x53, 0xd3, 0x67, 0x88, 0xd0, 0x41, 0xd5, 0x43, 0x85, 0xc8, 0x71, 0xe3, 0x1c, 0xb6, 0xda, 0x22, 0x64, 0x8f, 0x80, 0xac, 0xad, 0x7d, 0xd5, 0x82}, subYX: fp.Elt{0x92, 0x40, 0xc1, 0x83, 0x21, 0x9b, 0xd5, 0x7d, 0x3f, 0x29, 0xb6, 0x26, 0xef, 0x12, 0xb9, 0x27, 0x39, 0x42, 0x37, 0x97, 0x09, 0x9a, 0x08, 0xe1, 0x68, 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xf1, 0x0a, 0x75, 0xe2, 0xda, 0xf4, 0x6b, 0xca, 0x14, 0xe4, 0x9f, 0x0f, 0xb5, 0x3c, 0xa6, 0xa5, 0xa2, 0x63, 0x94, 0xd1, 0x1c, 0x39, 0x58, 0x57, 0x02, 0x27, 0x98, 0xb6, 0x47, 0xc6, 0x61, 0x4b, 0x5c, 0xab, 0x6f, 0x2d, 0xab, 0xe3, 0xc1, 0x69, 0xf9, 0x12, 0xb0, 0xc8, 0xd5}, }, { /* 19P*/ addYX: fp.Elt{0x19, 0x7d, 0xd5, 0xac, 0x79, 0xa2, 0x82, 0x9b, 0x28, 0x31, 0x22, 0xc0, 0x73, 0x02, 0x76, 0x17, 0x10, 0x70, 0x79, 0x57, 0xc9, 0x84, 0x62, 0x8e, 0x04, 0x04, 0x61, 0x67, 0x08, 0x48, 0xb4, 0x4b, 0xde, 0x53, 0x8c, 0xff, 0x36, 0x1b, 0x62, 0x86, 0x5d, 0xe1, 0x9b, 0xb1, 0xe5, 0xe8, 0x44, 0x64, 0xa1, 0x68, 0x3f, 0xa8, 0x45, 0x52, 0x91, 0xed}, subYX: fp.Elt{0x42, 0x1a, 0x36, 0x1f, 0x90, 0x15, 0x24, 0x8d, 0x24, 0x80, 0xe6, 0xfe, 0x1e, 0xf0, 0xad, 0xaf, 0x6a, 0x93, 0xf0, 0xa6, 0x0d, 0x5d, 0xea, 0xf6, 0x62, 0x96, 0x7a, 0x05, 0x76, 0x85, 0x74, 0x32, 0xc7, 0xc8, 0x64, 0x53, 0x62, 0xe7, 0x54, 0x84, 0xe0, 0x40, 0x66, 0x19, 0x70, 0x40, 0x95, 0x35, 0x68, 0x64, 0x43, 0xcd, 0xba, 0x29, 0x32, 0xa8}, dt2: fp.Elt{0x3e, 0xf6, 0xd6, 0xe4, 0x99, 0xeb, 0x20, 0x66, 0x08, 0x2e, 0x26, 0x64, 0xd7, 0x76, 0xf3, 0xb4, 0xc5, 0xa4, 0x35, 0x92, 0xd2, 0x99, 0x70, 0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61, 0xde, 0xf3, 0x6d, 0xd4, 0xae, 0x8e, 0xb1, 0x72, 0xe0, 0xcd, 0x37, 0x01, 0x28, 0x52, 0xd7, 0x39, 0x46, 0x0c, 0x55, 0xcf, 0x47, 0x70, 0xef, 0xa1, 0x17}, subYX: fp.Elt{0x8d, 0x58, 0xde, 0x83, 0x88, 0x16, 0x0e, 0x12, 0x42, 0x03, 0x50, 0x60, 0x4b, 0xdf, 0xbf, 0x95, 0xcc, 0x7d, 0x18, 0x17, 0x7e, 0x31, 0x5d, 0x8a, 0x66, 0xc1, 0xcf, 0x14, 0xea, 0xf4, 0xf4, 0xe5, 0x63, 0x2d, 0x32, 0x86, 0x9b, 0xed, 0x1f, 0x4f, 0x03, 0xaf, 0x33, 0x92, 0xcb, 0xaf, 0x9c, 0x05, 0x0d, 0x47, 0x1b, 0x42, 0xba, 0x13, 0x22, 0x98}, dt2: fp.Elt{0xb5, 0x48, 0xeb, 0x7d, 0x3d, 0x10, 0x9f, 0x59, 0xde, 0xf8, 0x1c, 0x4f, 0x7d, 0x9d, 0x40, 0x4d, 0x9e, 0x13, 0x24, 0xb5, 0x21, 0x09, 0xb7, 0xee, 0x98, 0x5c, 0x56, 0xbc, 0x5e, 0x2b, 0x78, 0x38, 0x06, 0xac, 0xe3, 0xe0, 0xfa, 0x2e, 0xde, 0x4f, 0xd2, 0xb3, 0xfb, 0x2d, 0x71, 0x84, 0xd1, 0x9d, 0x12, 0x5b, 0x35, 0xc8, 0x03, 0x68, 0x67, 0xc7}, }, { /* 39P*/ addYX: fp.Elt{0xb6, 0x65, 0xfb, 0xa7, 0x06, 0x35, 0xbb, 0xe0, 0x31, 0x8d, 0x91, 0x40, 0x98, 0xab, 0x30, 0xe4, 0xca, 0x12, 0x59, 0x89, 0xed, 0x65, 0x5d, 0x7f, 0xae, 0x69, 0xa0, 0xa4, 0xfa, 0x78, 0xb4, 0xf7, 0xed, 0xae, 0x86, 0x78, 0x79, 0x64, 0x24, 0xa6, 0xd4, 0xe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aa}, subYX: fp.Elt{0xf4, 0x3e, 0x85, 0x1c, 0x1a, 0xef, 0x50, 0xd1, 0xb4, 0x20, 0xb2, 0x60, 0x05, 0x98, 0xfe, 0x47, 0x3b, 0xc1, 0x76, 0xca, 0x2c, 0x4e, 0x5a, 0x42, 0xa3, 0xf7, 0x20, 0xaa, 0x57, 0x39, 0xee, 0x34, 0x1f, 0xe1, 0x68, 0xd3, 0x7e, 0x06, 0xc4, 0x6c, 0xc7, 0x76, 0x2b, 0xe4, 0x1c, 0x48, 0x44, 0xe6, 0xe5, 0x44, 0x24, 0x8d, 0xb3, 0xb6, 0x88, 0x32}, dt2: fp.Elt{0x18, 0xa7, 0xba, 0xd0, 0x44, 0x6f, 0x33, 0x31, 0x00, 0xf8, 0xf6, 0x12, 0xe3, 0xc5, 0xc7, 0xb5, 0x91, 0x9c, 0x91, 0xb5, 0x75, 0x18, 0x18, 0x8a, 0xab, 0xed, 0x24, 0x11, 0x2e, 0xce, 0x5a, 0x0f, 0x94, 0x5f, 0x2e, 0xca, 0xd3, 0x80, 0xea, 0xe5, 0x34, 0x96, 0x67, 0x8b, 0x6a, 0x26, 0x5e, 0xc8, 0x9d, 0x2c, 0x5e, 0x6c, 0xa2, 0x0c, 0xbf, 0xf0}, }, { /* 45P*/
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
true
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/ecc/goldilocks/point.go
vendor/github.com/cloudflare/circl/ecc/goldilocks/point.go
package goldilocks import ( "errors" "fmt" fp "github.com/cloudflare/circl/math/fp448" ) // Point is a point on the Goldilocks Curve. type Point struct{ x, y, z, ta, tb fp.Elt } func (P Point) String() string { return fmt.Sprintf("x: %v\ny: %v\nz: %v\nta: %v\ntb: %v", P.x, P.y, P.z, P.ta, P.tb) } // FromAffine creates a point from affine coordinates. func FromAffine(x, y *fp.Elt) (*Point, error) { P := &Point{ x: *x, y: *y, z: fp.One(), ta: *x, tb: *y, } if !(Curve{}).IsOnCurve(P) { return P, errors.New("point not on curve") } return P, nil } // isLessThan returns true if 0 <= x < y, and assumes that slices are of the // same length and are interpreted in little-endian order. func isLessThan(x, y []byte) bool { i := len(x) - 1 for i > 0 && x[i] == y[i] { i-- } return x[i] < y[i] } // FromBytes returns a point from the input buffer. func FromBytes(in []byte) (*Point, error) { if len(in) < fp.Size+1 { return nil, errors.New("wrong input length") } err := errors.New("invalid decoding") P := &Point{} signX := in[fp.Size] >> 7 copy(P.y[:], in[:fp.Size]) p := fp.P() if !isLessThan(P.y[:], p[:]) { return nil, err } u, v := &fp.Elt{}, &fp.Elt{} one := fp.One() fp.Sqr(u, &P.y) // u = y^2 fp.Mul(v, u, &paramD) // v = dy^2 fp.Sub(u, u, &one) // u = y^2-1 fp.Sub(v, v, &one) // v = dy^2-1 isQR := fp.InvSqrt(&P.x, u, v) // x = sqrt(u/v) if !isQR { return nil, err } fp.Modp(&P.x) // x = x mod p if fp.IsZero(&P.x) && signX == 1 { return nil, err } if signX != (P.x[0] & 1) { fp.Neg(&P.x, &P.x) } P.ta = P.x P.tb = P.y P.z = fp.One() return P, nil } // IsIdentity returns true is P is the identity Point. func (P *Point) IsIdentity() bool { return fp.IsZero(&P.x) && !fp.IsZero(&P.y) && !fp.IsZero(&P.z) && P.y == P.z } // IsEqual returns true if P is equivalent to Q. func (P *Point) IsEqual(Q *Point) bool { l, r := &fp.Elt{}, &fp.Elt{} fp.Mul(l, &P.x, &Q.z) fp.Mul(r, &Q.x, &P.z) fp.Sub(l, l, r) b := fp.IsZero(l) fp.Mul(l, &P.y, &Q.z) fp.Mul(r, &Q.y, &P.z) fp.Sub(l, l, r) b = b && fp.IsZero(l) fp.Mul(l, &P.ta, &P.tb) fp.Mul(l, l, &Q.z) fp.Mul(r, &Q.ta, &Q.tb) fp.Mul(r, r, &P.z) fp.Sub(l, l, r) b = b && fp.IsZero(l) return b } // Neg obtains the inverse of the Point. func (P *Point) Neg() { fp.Neg(&P.x, &P.x); fp.Neg(&P.ta, &P.ta) } // ToAffine returns the x,y affine coordinates of P. func (P *Point) ToAffine() (x, y fp.Elt) { fp.Inv(&P.z, &P.z) // 1/z fp.Mul(&P.x, &P.x, &P.z) // x/z fp.Mul(&P.y, &P.y, &P.z) // y/z fp.Modp(&P.x) fp.Modp(&P.y) fp.SetOne(&P.z) P.ta = P.x P.tb = P.y return P.x, P.y } // ToBytes stores P into a slice of bytes. func (P *Point) ToBytes(out []byte) error { if len(out) < fp.Size+1 { return errors.New("invalid decoding") } x, y := P.ToAffine() out[fp.Size] = (x[0] & 1) << 7 return fp.ToBytes(out[:fp.Size], &y) } // MarshalBinary encodes the receiver into a binary form and returns the result. func (P *Point) MarshalBinary() (data []byte, err error) { data = make([]byte, fp.Size+1) err = P.ToBytes(data[:fp.Size+1]) return data, err } // UnmarshalBinary must be able to decode the form generated by MarshalBinary. func (P *Point) UnmarshalBinary(data []byte) error { Q, err := FromBytes(data); *P = *Q; return err } // Double sets P = 2Q. func (P *Point) Double() { P.Add(P) } // Add sets P =P+Q.. func (P *Point) Add(Q *Point) { // This is formula (5) from "Twisted Edwards Curves Revisited" by // Hisil H., Wong K.KH., Carter G., Dawson E. (2008) // https://doi.org/10.1007/978-3-540-89255-7_20 x1, y1, z1, ta1, tb1 := &P.x, &P.y, &P.z, &P.ta, &P.tb x2, y2, z2, ta2, tb2 := &Q.x, &Q.y, &Q.z, &Q.ta, &Q.tb x3, y3, z3, E, H := &P.x, &P.y, &P.z, &P.ta, &P.tb A, B, C, D := &fp.Elt{}, &fp.Elt{}, &fp.Elt{}, &fp.Elt{} t1, t2, F, G := C, D, &fp.Elt{}, &fp.Elt{} fp.Mul(t1, ta1, tb1) // t1 = ta1*tb1 fp.Mul(t2, ta2, tb2) // t2 = ta2*tb2 fp.Mul(A, x1, x2) // A = x1*x2 fp.Mul(B, y1, y2) // B = y1*y2 fp.Mul(C, t1, t2) // t1*t2 fp.Mul(C, C, &paramD) // C = d*t1*t2 fp.Mul(D, z1, z2) // D = z1*z2 fp.Add(F, x1, y1) // x1+y1 fp.Add(E, x2, y2) // x2+y2 fp.Mul(E, E, F) // (x1+y1)*(x2+y2) fp.Sub(E, E, A) // (x1+y1)*(x2+y2)-A fp.Sub(E, E, B) // E = (x1+y1)*(x2+y2)-A-B fp.Sub(F, D, C) // F = D-C fp.Add(G, D, C) // G = D+C fp.Sub(H, B, A) // H = B-A fp.Mul(z3, F, G) // Z = F * G fp.Mul(x3, E, F) // X = E * F fp.Mul(y3, G, H) // Y = G * H, T = E * H }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/ecc/goldilocks/scalar.go
vendor/github.com/cloudflare/circl/ecc/goldilocks/scalar.go
package goldilocks import ( "encoding/binary" "math/bits" ) // ScalarSize is the size (in bytes) of scalars. const ScalarSize = 56 // 448 / 8 // _N is the number of 64-bit words to store scalars. const _N = 7 // 448 / 64 // Scalar represents a positive integer stored in little-endian order. type Scalar [ScalarSize]byte type scalar64 [_N]uint64 func (z *scalar64) fromScalar(x *Scalar) { z[0] = binary.LittleEndian.Uint64(x[0*8 : 1*8]) z[1] = binary.LittleEndian.Uint64(x[1*8 : 2*8]) z[2] = binary.LittleEndian.Uint64(x[2*8 : 3*8]) z[3] = binary.LittleEndian.Uint64(x[3*8 : 4*8]) z[4] = binary.LittleEndian.Uint64(x[4*8 : 5*8]) z[5] = binary.LittleEndian.Uint64(x[5*8 : 6*8]) z[6] = binary.LittleEndian.Uint64(x[6*8 : 7*8]) } func (z *scalar64) toScalar(x *Scalar) { binary.LittleEndian.PutUint64(x[0*8:1*8], z[0]) binary.LittleEndian.PutUint64(x[1*8:2*8], z[1]) binary.LittleEndian.PutUint64(x[2*8:3*8], z[2]) binary.LittleEndian.PutUint64(x[3*8:4*8], z[3]) binary.LittleEndian.PutUint64(x[4*8:5*8], z[4]) binary.LittleEndian.PutUint64(x[5*8:6*8], z[5]) binary.LittleEndian.PutUint64(x[6*8:7*8], z[6]) } // add calculates z = x + y. Assumes len(z) > max(len(x),len(y)). func add(z, x, y []uint64) uint64 { l, L, zz := len(x), len(y), y if l > L { l, L, zz = L, l, x } c := uint64(0) for i := 0; i < l; i++ { z[i], c = bits.Add64(x[i], y[i], c) } for i := l; i < L; i++ { z[i], c = bits.Add64(zz[i], 0, c) } return c } // sub calculates z = x - y. Assumes len(z) > max(len(x),len(y)). func sub(z, x, y []uint64) uint64 { l, L, zz := len(x), len(y), y if l > L { l, L, zz = L, l, x } c := uint64(0) for i := 0; i < l; i++ { z[i], c = bits.Sub64(x[i], y[i], c) } for i := l; i < L; i++ { z[i], c = bits.Sub64(zz[i], 0, c) } return c } // mulWord calculates z = x * y. Assumes len(z) >= len(x)+1. func mulWord(z, x []uint64, y uint64) { for i := range z { z[i] = 0 } carry := uint64(0) for i := range x { hi, lo := bits.Mul64(x[i], y) lo, cc := bits.Add64(lo, z[i], 0) hi, _ = bits.Add64(hi, 0, cc) z[i], cc = bits.Add64(lo, carry, 0) carry, _ = bits.Add64(hi, 0, cc) } z[len(x)] = carry } // Cmov moves x into z if b=1. func (z *scalar64) Cmov(b uint64, x *scalar64) { m := uint64(0) - b for i := range z { z[i] = (z[i] &^ m) | (x[i] & m) } } // leftShift shifts to the left the words of z returning the more significant word. func (z *scalar64) leftShift(low uint64) uint64 { high := z[_N-1] for i := _N - 1; i > 0; i-- { z[i] = z[i-1] } z[0] = low return high } // reduceOneWord calculates z = z + 2^448*x such that the result fits in a Scalar. func (z *scalar64) reduceOneWord(x uint64) { prod := (&scalar64{})[:] mulWord(prod, residue448[:], x) cc := add(z[:], z[:], prod) mulWord(prod, residue448[:], cc) add(z[:], z[:], prod) } // modOrder reduces z mod order. func (z *scalar64) modOrder() { var o64, x scalar64 o64.fromScalar(&order) // Performs: while (z >= order) { z = z-order } // At most 8 (eight) iterations reduce 3 bits by subtracting. for i := 0; i < 8; i++ { c := sub(x[:], z[:], o64[:]) // (c || x) = z-order z.Cmov(1-c, &x) // if c != 0 { z = x } } } // FromBytes stores z = x mod order, where x is a number stored in little-endian order. func (z *Scalar) FromBytes(x []byte) { n := len(x) nCeil := (n + 7) >> 3 for i := range z { z[i] = 0 } if nCeil < _N { copy(z[:], x) return } copy(z[:], x[8*(nCeil-_N):]) var z64 scalar64 z64.fromScalar(z) for i := nCeil - _N - 1; i >= 0; i-- { low := binary.LittleEndian.Uint64(x[8*i:]) high := z64.leftShift(low) z64.reduceOneWord(high) } z64.modOrder() z64.toScalar(z) } // divBy4 calculates z = x/4 mod order. func (z *Scalar) divBy4(x *Scalar) { z.Mul(x, &invFour) } // Red reduces z mod order. func (z *Scalar) Red() { var t scalar64; t.fromScalar(z); t.modOrder(); t.toScalar(z) } // Neg calculates z = -z mod order. func (z *Scalar) Neg() { z.Sub(&order, z) } // Add calculates z = x+y mod order. func (z *Scalar) Add(x, y *Scalar) { var z64, x64, y64, t scalar64 x64.fromScalar(x) y64.fromScalar(y) c := add(z64[:], x64[:], y64[:]) add(t[:], z64[:], residue448[:]) z64.Cmov(c, &t) z64.modOrder() z64.toScalar(z) } // Sub calculates z = x-y mod order. func (z *Scalar) Sub(x, y *Scalar) { var z64, x64, y64, t scalar64 x64.fromScalar(x) y64.fromScalar(y) c := sub(z64[:], x64[:], y64[:]) sub(t[:], z64[:], residue448[:]) z64.Cmov(c, &t) z64.modOrder() z64.toScalar(z) } // Mul calculates z = x*y mod order. func (z *Scalar) Mul(x, y *Scalar) { var z64, x64, y64 scalar64 prod := (&[_N + 1]uint64{})[:] x64.fromScalar(x) y64.fromScalar(y) mulWord(prod, x64[:], y64[_N-1]) copy(z64[:], prod[:_N]) z64.reduceOneWord(prod[_N]) for i := _N - 2; i >= 0; i-- { h := z64.leftShift(0) z64.reduceOneWord(h) mulWord(prod, x64[:], y64[i]) c := add(z64[:], z64[:], prod[:_N]) z64.reduceOneWord(prod[_N] + c) } z64.modOrder() z64.toScalar(z) } // IsZero returns true if z=0. func (z *Scalar) IsZero() bool { z.Red(); return *z == Scalar{} }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/ecc/goldilocks/twist_basemult.go
vendor/github.com/cloudflare/circl/ecc/goldilocks/twist_basemult.go
package goldilocks import ( "crypto/subtle" mlsb "github.com/cloudflare/circl/math/mlsbset" ) const ( // MLSBRecoding parameters fxT = 448 fxV = 2 fxW = 3 fx2w1 = 1 << (uint(fxW) - 1) ) // ScalarBaseMult returns kG where G is the generator point. func (e twistCurve) ScalarBaseMult(k *Scalar) *twistPoint { m, err := mlsb.New(fxT, fxV, fxW) if err != nil { panic(err) } if m.IsExtended() { panic("not extended") } var isZero int if k.IsZero() { isZero = 1 } subtle.ConstantTimeCopy(isZero, k[:], order[:]) minusK := *k isEven := 1 - int(k[0]&0x1) minusK.Neg() subtle.ConstantTimeCopy(isEven, k[:], minusK[:]) c, err := m.Encode(k[:]) if err != nil { panic(err) } gP := c.Exp(groupMLSB{}) P := gP.(*twistPoint) P.cneg(uint(isEven)) return P } type groupMLSB struct{} func (e groupMLSB) ExtendedEltP() mlsb.EltP { return nil } func (e groupMLSB) Sqr(x mlsb.EltG) { x.(*twistPoint).Double() } func (e groupMLSB) Mul(x mlsb.EltG, y mlsb.EltP) { x.(*twistPoint).mixAddZ1(y.(*preTwistPointAffine)) } func (e groupMLSB) Identity() mlsb.EltG { return twistCurve{}.Identity() } func (e groupMLSB) NewEltP() mlsb.EltP { return &preTwistPointAffine{} } func (e groupMLSB) Lookup(a mlsb.EltP, v uint, s, u int32) { Tabj := &tabFixMult[v] P := a.(*preTwistPointAffine) for k := range Tabj { P.cmov(&Tabj[k], uint(subtle.ConstantTimeEq(int32(k), u))) } P.cneg(int(s >> 31)) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/ecc/goldilocks/isogeny.go
vendor/github.com/cloudflare/circl/ecc/goldilocks/isogeny.go
package goldilocks import fp "github.com/cloudflare/circl/math/fp448" func (Curve) pull(P *twistPoint) *Point { return twistCurve{}.push(P) } func (twistCurve) pull(P *Point) *twistPoint { return Curve{}.push(P) } // push sends a point on the Goldilocks curve to a point on the twist curve. func (Curve) push(P *Point) *twistPoint { Q := &twistPoint{} Px, Py, Pz := &P.x, &P.y, &P.z a, b, c, d, e, f, g, h := &Q.x, &Q.y, &Q.z, &fp.Elt{}, &Q.ta, &Q.x, &Q.y, &Q.tb fp.Add(e, Px, Py) // x+y fp.Sqr(a, Px) // A = x^2 fp.Sqr(b, Py) // B = y^2 fp.Sqr(c, Pz) // z^2 fp.Add(c, c, c) // C = 2*z^2 *d = *a // D = A fp.Sqr(e, e) // (x+y)^2 fp.Sub(e, e, a) // (x+y)^2-A fp.Sub(e, e, b) // E = (x+y)^2-A-B fp.Add(h, b, d) // H = B+D fp.Sub(g, b, d) // G = B-D fp.Sub(f, c, h) // F = C-H fp.Mul(&Q.z, f, g) // Z = F * G fp.Mul(&Q.x, e, f) // X = E * F fp.Mul(&Q.y, g, h) // Y = G * H, // T = E * H return Q } // push sends a point on the twist curve to a point on the Goldilocks curve. func (twistCurve) push(P *twistPoint) *Point { Q := &Point{} Px, Py, Pz := &P.x, &P.y, &P.z a, b, c, d, e, f, g, h := &Q.x, &Q.y, &Q.z, &fp.Elt{}, &Q.ta, &Q.x, &Q.y, &Q.tb fp.Add(e, Px, Py) // x+y fp.Sqr(a, Px) // A = x^2 fp.Sqr(b, Py) // B = y^2 fp.Sqr(c, Pz) // z^2 fp.Add(c, c, c) // C = 2*z^2 fp.Neg(d, a) // D = -A fp.Sqr(e, e) // (x+y)^2 fp.Sub(e, e, a) // (x+y)^2-A fp.Sub(e, e, b) // E = (x+y)^2-A-B fp.Add(h, b, d) // H = B+D fp.Sub(g, b, d) // G = B-D fp.Sub(f, c, h) // F = C-H fp.Mul(&Q.z, f, g) // Z = F * G fp.Mul(&Q.x, e, f) // X = E * F fp.Mul(&Q.y, g, h) // Y = G * H, // T = E * H return Q }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/ecc/goldilocks/twistPoint.go
vendor/github.com/cloudflare/circl/ecc/goldilocks/twistPoint.go
package goldilocks import ( "fmt" fp "github.com/cloudflare/circl/math/fp448" ) type twistPoint struct{ x, y, z, ta, tb fp.Elt } type preTwistPointAffine struct{ addYX, subYX, dt2 fp.Elt } type preTwistPointProy struct { preTwistPointAffine z2 fp.Elt } func (P *twistPoint) String() string { return fmt.Sprintf("x: %v\ny: %v\nz: %v\nta: %v\ntb: %v", P.x, P.y, P.z, P.ta, P.tb) } // cneg conditionally negates the point if b=1. func (P *twistPoint) cneg(b uint) { t := &fp.Elt{} fp.Neg(t, &P.x) fp.Cmov(&P.x, t, b) fp.Neg(t, &P.ta) fp.Cmov(&P.ta, t, b) } // Double updates P with 2P. func (P *twistPoint) Double() { // This is formula (7) from "Twisted Edwards Curves Revisited" by // Hisil H., Wong K.KH., Carter G., Dawson E. (2008) // https://doi.org/10.1007/978-3-540-89255-7_20 Px, Py, Pz, Pta, Ptb := &P.x, &P.y, &P.z, &P.ta, &P.tb a, b, c, e, f, g, h := Px, Py, Pz, Pta, Px, Py, Ptb fp.Add(e, Px, Py) // x+y fp.Sqr(a, Px) // A = x^2 fp.Sqr(b, Py) // B = y^2 fp.Sqr(c, Pz) // z^2 fp.Add(c, c, c) // C = 2*z^2 fp.Add(h, a, b) // H = A+B fp.Sqr(e, e) // (x+y)^2 fp.Sub(e, e, h) // E = (x+y)^2-A-B fp.Sub(g, b, a) // G = B-A fp.Sub(f, c, g) // F = C-G fp.Mul(Pz, f, g) // Z = F * G fp.Mul(Px, e, f) // X = E * F fp.Mul(Py, g, h) // Y = G * H, T = E * H } // mixAdd calculates P= P+Q, where Q is a precomputed point with Z_Q = 1. func (P *twistPoint) mixAddZ1(Q *preTwistPointAffine) { fp.Add(&P.z, &P.z, &P.z) // D = 2*z1 (z2=1) P.coreAddition(Q) } // coreAddition calculates P=P+Q for curves with A=-1. func (P *twistPoint) coreAddition(Q *preTwistPointAffine) { // This is the formula following (5) from "Twisted Edwards Curves Revisited" by // Hisil H., Wong K.KH., Carter G., Dawson E. (2008) // https://doi.org/10.1007/978-3-540-89255-7_20 Px, Py, Pz, Pta, Ptb := &P.x, &P.y, &P.z, &P.ta, &P.tb addYX2, subYX2, dt2 := &Q.addYX, &Q.subYX, &Q.dt2 a, b, c, d, e, f, g, h := Px, Py, &fp.Elt{}, Pz, Pta, Px, Py, Ptb fp.Mul(c, Pta, Ptb) // t1 = ta*tb fp.Sub(h, Py, Px) // y1-x1 fp.Add(b, Py, Px) // y1+x1 fp.Mul(a, h, subYX2) // A = (y1-x1)*(y2-x2) fp.Mul(b, b, addYX2) // B = (y1+x1)*(y2+x2) fp.Mul(c, c, dt2) // C = 2*D*t1*t2 fp.Sub(e, b, a) // E = B-A fp.Add(h, b, a) // H = B+A fp.Sub(f, d, c) // F = D-C fp.Add(g, d, c) // G = D+C fp.Mul(Pz, f, g) // Z = F * G fp.Mul(Px, e, f) // X = E * F fp.Mul(Py, g, h) // Y = G * H, T = E * H } func (P *preTwistPointAffine) neg() { P.addYX, P.subYX = P.subYX, P.addYX fp.Neg(&P.dt2, &P.dt2) } func (P *preTwistPointAffine) cneg(b int) { t := &fp.Elt{} fp.Cswap(&P.addYX, &P.subYX, uint(b)) fp.Neg(t, &P.dt2) fp.Cmov(&P.dt2, t, uint(b)) } func (P *preTwistPointAffine) cmov(Q *preTwistPointAffine, b uint) { fp.Cmov(&P.addYX, &Q.addYX, b) fp.Cmov(&P.subYX, &Q.subYX, b) fp.Cmov(&P.dt2, &Q.dt2, b) } // mixAdd calculates P= P+Q, where Q is a precomputed point with Z_Q != 1. func (P *twistPoint) mixAdd(Q *preTwistPointProy) { fp.Mul(&P.z, &P.z, &Q.z2) // D = 2*z1*z2 P.coreAddition(&Q.preTwistPointAffine) } // oddMultiples calculates T[i] = (2*i-1)P for 0 < i < len(T). func (P *twistPoint) oddMultiples(T []preTwistPointProy) { if n := len(T); n > 0 { T[0].FromTwistPoint(P) _2P := *P _2P.Double() R := &preTwistPointProy{} R.FromTwistPoint(&_2P) for i := 1; i < n; i++ { P.mixAdd(R) T[i].FromTwistPoint(P) } } } // cmov conditionally moves Q into P if b=1. func (P *preTwistPointProy) cmov(Q *preTwistPointProy, b uint) { P.preTwistPointAffine.cmov(&Q.preTwistPointAffine, b) fp.Cmov(&P.z2, &Q.z2, b) } // FromTwistPoint precomputes some coordinates of Q for missed addition. func (P *preTwistPointProy) FromTwistPoint(Q *twistPoint) { fp.Add(&P.addYX, &Q.y, &Q.x) // addYX = X + Y fp.Sub(&P.subYX, &Q.y, &Q.x) // subYX = Y - X fp.Mul(&P.dt2, &Q.ta, &Q.tb) // T = ta*tb fp.Mul(&P.dt2, &P.dt2, &paramDTwist) // D*T fp.Add(&P.dt2, &P.dt2, &P.dt2) // dt2 = 2*D*T fp.Add(&P.z2, &Q.z, &Q.z) // z2 = 2*Z }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/sign/sign.go
vendor/github.com/cloudflare/circl/sign/sign.go
// Package sign provides unified interfaces for signature schemes. // // A register of schemes is available in the package // // github.com/cloudflare/circl/sign/schemes package sign import ( "crypto" "encoding" "errors" ) type SignatureOpts struct { // If non-empty, includes the given context in the signature if supported // and will cause an error during signing otherwise. Context string } // A public key is used to verify a signature set by the corresponding private // key. type PublicKey interface { // Returns the signature scheme for this public key. Scheme() Scheme Equal(crypto.PublicKey) bool encoding.BinaryMarshaler crypto.PublicKey } // A private key allows one to create signatures. type PrivateKey interface { // Returns the signature scheme for this private key. Scheme() Scheme Equal(crypto.PrivateKey) bool // For compatibility with Go standard library crypto.Signer crypto.PrivateKey encoding.BinaryMarshaler } // A Scheme represents a specific instance of a signature scheme. type Scheme interface { // Name of the scheme. Name() string // GenerateKey creates a new key-pair. GenerateKey() (PublicKey, PrivateKey, error) // Creates a signature using the PrivateKey on the given message and // returns the signature. opts are additional options which can be nil. // // Panics if key is nil or wrong type or opts context is not supported. Sign(sk PrivateKey, message []byte, opts *SignatureOpts) []byte // Checks whether the given signature is a valid signature set by // the private key corresponding to the given public key on the // given message. opts are additional options which can be nil. // // Panics if key is nil or wrong type or opts context is not supported. Verify(pk PublicKey, message []byte, signature []byte, opts *SignatureOpts) bool // Deterministically derives a keypair from a seed. If you're unsure, // you're better off using GenerateKey(). // // Panics if seed is not of length SeedSize(). DeriveKey(seed []byte) (PublicKey, PrivateKey) // Unmarshals a PublicKey from the provided buffer. UnmarshalBinaryPublicKey([]byte) (PublicKey, error) // Unmarshals a PublicKey from the provided buffer. UnmarshalBinaryPrivateKey([]byte) (PrivateKey, error) // Size of binary marshalled public keys. PublicKeySize() int // Size of binary marshalled public keys. PrivateKeySize() int // Size of signatures. SignatureSize() int // Size of seeds. SeedSize() int // Returns whether contexts are supported. SupportsContext() bool } var ( // ErrTypeMismatch is the error used if types of, for instance, private // and public keys don't match. ErrTypeMismatch = errors.New("types mismatch") // ErrSeedSize is the error used if the provided seed is of the wrong // size. ErrSeedSize = errors.New("wrong seed size") // ErrPubKeySize is the error used if the provided public key is of // the wrong size. ErrPubKeySize = errors.New("wrong size for public key") // ErrPrivKeySize is the error used if the provided private key is of // the wrong size. ErrPrivKeySize = errors.New("wrong size for private key") // ErrContextNotSupported is the error used if a context is not // supported. ErrContextNotSupported = errors.New("context not supported") // ErrContextTooLong is the error used if the context string is too long. ErrContextTooLong = errors.New("context string too long") )
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/sign/ed25519/modular.go
vendor/github.com/cloudflare/circl/sign/ed25519/modular.go
package ed25519 import ( "encoding/binary" "math/bits" ) var order = [paramB]byte{ 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, } // isLessThan returns true if 0 <= x < y, and assumes that slices have the same length. func isLessThan(x, y []byte) bool { i := len(x) - 1 for i > 0 && x[i] == y[i] { i-- } return x[i] < y[i] } // reduceModOrder calculates k = k mod order of the curve. func reduceModOrder(k []byte, is512Bit bool) { var X [((2 * paramB) * 8) / 64]uint64 numWords := len(k) >> 3 for i := 0; i < numWords; i++ { X[i] = binary.LittleEndian.Uint64(k[i*8 : (i+1)*8]) } red512(&X, is512Bit) for i := 0; i < numWords; i++ { binary.LittleEndian.PutUint64(k[i*8:(i+1)*8], X[i]) } } // red512 calculates x = x mod Order of the curve. func red512(x *[8]uint64, full bool) { // Implementation of Algs.(14.47)+(14.52) of Handbook of Applied // Cryptography, by A. Menezes, P. van Oorschot, and S. Vanstone. const ( ell0 = uint64(0x5812631a5cf5d3ed) ell1 = uint64(0x14def9dea2f79cd6) ell160 = uint64(0x812631a5cf5d3ed0) ell161 = uint64(0x4def9dea2f79cd65) ell162 = uint64(0x0000000000000001) ) var c0, c1, c2, c3 uint64 r0, r1, r2, r3, r4 := x[0], x[1], x[2], x[3], uint64(0) if full { q0, q1, q2, q3 := x[4], x[5], x[6], x[7] for i := 0; i < 3; i++ { h0, s0 := bits.Mul64(q0, ell160) h1, s1 := bits.Mul64(q1, ell160) h2, s2 := bits.Mul64(q2, ell160) h3, s3 := bits.Mul64(q3, ell160) s1, c0 = bits.Add64(h0, s1, 0) s2, c1 = bits.Add64(h1, s2, c0) s3, c2 = bits.Add64(h2, s3, c1) s4, _ := bits.Add64(h3, 0, c2) h0, l0 := bits.Mul64(q0, ell161) h1, l1 := bits.Mul64(q1, ell161) h2, l2 := bits.Mul64(q2, ell161) h3, l3 := bits.Mul64(q3, ell161) l1, c0 = bits.Add64(h0, l1, 0) l2, c1 = bits.Add64(h1, l2, c0) l3, c2 = bits.Add64(h2, l3, c1) l4, _ := bits.Add64(h3, 0, c2) s1, c0 = bits.Add64(s1, l0, 0) s2, c1 = bits.Add64(s2, l1, c0) s3, c2 = bits.Add64(s3, l2, c1) s4, c3 = bits.Add64(s4, l3, c2) s5, s6 := bits.Add64(l4, 0, c3) s2, c0 = bits.Add64(s2, q0, 0) s3, c1 = bits.Add64(s3, q1, c0) s4, c2 = bits.Add64(s4, q2, c1) s5, c3 = bits.Add64(s5, q3, c2) s6, s7 := bits.Add64(s6, 0, c3) q := q0 | q1 | q2 | q3 m := -((q | -q) >> 63) // if q=0 then m=0...0 else m=1..1 s0 &= m s1 &= m s2 &= m s3 &= m q0, q1, q2, q3 = s4, s5, s6, s7 if (i+1)%2 == 0 { r0, c0 = bits.Add64(r0, s0, 0) r1, c1 = bits.Add64(r1, s1, c0) r2, c2 = bits.Add64(r2, s2, c1) r3, c3 = bits.Add64(r3, s3, c2) r4, _ = bits.Add64(r4, 0, c3) } else { r0, c0 = bits.Sub64(r0, s0, 0) r1, c1 = bits.Sub64(r1, s1, c0) r2, c2 = bits.Sub64(r2, s2, c1) r3, c3 = bits.Sub64(r3, s3, c2) r4, _ = bits.Sub64(r4, 0, c3) } } m := -(r4 >> 63) r0, c0 = bits.Add64(r0, m&ell160, 0) r1, c1 = bits.Add64(r1, m&ell161, c0) r2, c2 = bits.Add64(r2, m&ell162, c1) r3, c3 = bits.Add64(r3, 0, c2) r4, _ = bits.Add64(r4, m&1, c3) x[4], x[5], x[6], x[7] = 0, 0, 0, 0 } q0 := (r4 << 4) | (r3 >> 60) r3 &= (uint64(1) << 60) - 1 h0, s0 := bits.Mul64(ell0, q0) h1, s1 := bits.Mul64(ell1, q0) s1, c0 = bits.Add64(h0, s1, 0) s2, _ := bits.Add64(h1, 0, c0) r0, c0 = bits.Sub64(r0, s0, 0) r1, c1 = bits.Sub64(r1, s1, c0) r2, c2 = bits.Sub64(r2, s2, c1) r3, _ = bits.Sub64(r3, 0, c2) x[0], x[1], x[2], x[3] = r0, r1, r2, r3 } // calculateS performs s = r+k*a mod Order of the curve. func calculateS(s, r, k, a []byte) { K := [4]uint64{ binary.LittleEndian.Uint64(k[0*8 : 1*8]), binary.LittleEndian.Uint64(k[1*8 : 2*8]), binary.LittleEndian.Uint64(k[2*8 : 3*8]), binary.LittleEndian.Uint64(k[3*8 : 4*8]), } S := [8]uint64{ binary.LittleEndian.Uint64(r[0*8 : 1*8]), binary.LittleEndian.Uint64(r[1*8 : 2*8]), binary.LittleEndian.Uint64(r[2*8 : 3*8]), binary.LittleEndian.Uint64(r[3*8 : 4*8]), } var c3 uint64 for i := range K { ai := binary.LittleEndian.Uint64(a[i*8 : (i+1)*8]) h0, l0 := bits.Mul64(K[0], ai) h1, l1 := bits.Mul64(K[1], ai) h2, l2 := bits.Mul64(K[2], ai) h3, l3 := bits.Mul64(K[3], ai) l1, c0 := bits.Add64(h0, l1, 0) l2, c1 := bits.Add64(h1, l2, c0) l3, c2 := bits.Add64(h2, l3, c1) l4, _ := bits.Add64(h3, 0, c2) S[i+0], c0 = bits.Add64(S[i+0], l0, 0) S[i+1], c1 = bits.Add64(S[i+1], l1, c0) S[i+2], c2 = bits.Add64(S[i+2], l2, c1) S[i+3], c3 = bits.Add64(S[i+3], l3, c2) S[i+4], _ = bits.Add64(S[i+4], l4, c3) } red512(&S, true) binary.LittleEndian.PutUint64(s[0*8:1*8], S[0]) binary.LittleEndian.PutUint64(s[1*8:2*8], S[1]) binary.LittleEndian.PutUint64(s[2*8:3*8], S[2]) binary.LittleEndian.PutUint64(s[3*8:4*8], S[3]) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/sign/ed25519/tables.go
vendor/github.com/cloudflare/circl/sign/ed25519/tables.go
package ed25519 import fp "github.com/cloudflare/circl/math/fp25519" var tabSign = [fxV][fx2w1]pointR3{ { pointR3{ addYX: fp.Elt{0x85, 0x3b, 0x8c, 0xf5, 0xc6, 0x93, 0xbc, 0x2f, 0x19, 0x0e, 0x8c, 0xfb, 0xc6, 0x2d, 0x93, 0xcf, 0xc2, 0x42, 0x3d, 0x64, 0x98, 0x48, 0x0b, 0x27, 0x65, 0xba, 0xd4, 0x33, 0x3a, 0x9d, 0xcf, 0x07}, subYX: fp.Elt{0x3e, 0x91, 0x40, 0xd7, 0x05, 0x39, 0x10, 0x9d, 0xb3, 0xbe, 0x40, 0xd1, 0x05, 0x9f, 0x39, 0xfd, 0x09, 0x8a, 0x8f, 0x68, 0x34, 0x84, 0xc1, 0xa5, 0x67, 0x12, 0xf8, 0x98, 0x92, 0x2f, 0xfd, 0x44}, dt2: fp.Elt{0x68, 0xaa, 0x7a, 0x87, 0x05, 0x12, 0xc9, 0xab, 0x9e, 0xc4, 0xaa, 0xcc, 0x23, 0xe8, 0xd9, 0x26, 0x8c, 0x59, 0x43, 0xdd, 0xcb, 0x7d, 0x1b, 0x5a, 0xa8, 0x65, 0x0c, 0x9f, 0x68, 0x7b, 0x11, 0x6f}, }, { addYX: fp.Elt{0x7c, 0xb0, 0x9e, 0xe6, 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xde, 0x8c, 0x4e, 0x77, 0x96, 0x38, 0x3b, 0xfe, 0xb6, 0x43, 0x3c, 0x86, 0x69, 0xc2, 0x72, 0x66, 0x1f, 0x6b, 0xf9, 0x87, 0xbc, 0x4f, 0x37, 0x3e, 0x3c}, dt2: fp.Elt{0xd2, 0x2f, 0x06, 0x6b, 0x08, 0x07, 0x69, 0x77, 0xc0, 0x94, 0xcc, 0xae, 0x43, 0x00, 0x59, 0x6e, 0xa3, 0x63, 0xa8, 0xdd, 0xfa, 0x24, 0x18, 0xd0, 0x35, 0xc7, 0x78, 0xf7, 0x0d, 0xd4, 0x5a, 0x1e}, }, { addYX: fp.Elt{0x45, 0xc1, 0x17, 0x51, 0xf8, 0xed, 0x7e, 0xc7, 0xa9, 0x1a, 0x11, 0x6e, 0x2d, 0xef, 0x0b, 0xd5, 0x3f, 0x98, 0xb0, 0xa3, 0x9d, 0x65, 0xf1, 0xcd, 0x53, 0x4a, 0x8a, 0x18, 0x70, 0x0a, 0x7f, 0x23}, subYX: fp.Elt{0xdd, 0xef, 0xbe, 0x3a, 0x31, 0xe0, 0xbc, 0xbe, 0x6d, 0x5d, 0x79, 0x87, 0xd6, 0xbe, 0x68, 0xe3, 0x59, 0x76, 0x8c, 0x86, 0x0e, 0x7a, 0x92, 0x13, 0x14, 0x8f, 0x67, 0xb3, 0xcb, 0x1a, 0x76, 0x76}, dt2: fp.Elt{0x56, 0x7a, 0x1c, 0x9d, 0xca, 0x96, 0xf9, 0xf9, 0x03, 0x21, 0xd4, 0xe8, 0xb3, 0xd5, 0xe9, 0x52, 0xc8, 0x54, 0x1e, 0x1b, 0x13, 0xb6, 0xfd, 0x47, 0x7d, 0x02, 0x32, 0x33, 0x27, 0xe2, 0x1f, 0x19}, }, }, } var tabVerif = [1 << (omegaFix - 2)]pointR3{ { /* 1P */ addYX: fp.Elt{0x85, 0x3b, 0x8c, 0xf5, 0xc6, 0x93, 0xbc, 0x2f, 0x19, 0x0e, 0x8c, 0xfb, 0xc6,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3, 0xb8, 0x01, 0xc8, 0x6d, 0x83, 0xf1, 0x9a, 0xa4, 0x3e, 0x05, 0x47, 0x5f, 0x03, 0xb3, 0xf3, 0xad, 0x77, 0x58, 0xba, 0x41, 0x9c, 0x52, 0xa7, 0x90, 0x0f, 0x6a, 0x1c, 0xbb, 0x9f, 0x7a}, }, { /* 9P */ addYX: fp.Elt{0x2f, 0x63, 0xa8, 0xa6, 0x8a, 0x67, 0x2e, 0x9b, 0xc5, 0x46, 0xbc, 0x51, 0x6f, 0x9e, 0x50, 0xa6, 0xb5, 0xf5, 0x86, 0xc6, 0xc9, 0x33, 0xb2, 0xce, 0x59, 0x7f, 0xdd, 0x8a, 0x33, 0xed, 0xb9, 0x34}, subYX: fp.Elt{0x64, 0x80, 0x9d, 0x03, 0x7e, 0x21, 0x6e, 0xf3, 0x9b, 0x41, 0x20, 0xf5, 0xb6, 0x81, 0xa0, 0x98, 0x44, 0xb0, 0x5e, 0xe7, 0x08, 0xc6, 0xcb, 0x96, 0x8f, 0x9c, 0xdc, 0xfa, 0x51, 0x5a, 0xc0, 0x49}, dt2: fp.Elt{0x1b, 0xaf, 0x45, 0x90, 0xbf, 0xe8, 0xb4, 0x06, 0x2f, 0xd2, 0x19, 0xa7, 0xe8, 0x83, 0xff, 0xe2, 0x16, 0xcf, 0xd4, 0x93, 0x29, 0xfc, 0xf6, 0xaa, 0x06, 0x8b, 0x00, 0x1b, 0x02, 0x72, 0xc1, 0x73}, }, { /* 11P */ addYX: fp.Elt{0xde, 0x2a, 0x80, 0x8a, 0x84, 0x00, 0xbf, 0x2f, 0x27, 0x2e, 0x30, 0x02, 0xcf, 0xfe, 0xd9, 0xe5, 0x06, 0x34, 0x70, 0x17, 0x71, 0x84, 0x3e, 0x11, 0xaf, 0x8f, 0x6d, 0x54, 0xe2, 0xaa, 0x75, 0x42}, subYX: fp.Elt{0x48, 0x43, 0x86, 0x49, 0x02, 0x5b, 0x5f, 0x31, 0x81, 0x83, 0x08, 0x77, 0x69, 0xb3, 0xd6, 0x3e, 0x95, 0xeb, 0x8d, 0x6a, 0x55, 0x75, 0xa0, 0xa3, 0x7f, 0xc7, 0xd5, 0x29, 0x80, 0x59, 0xab, 0x18}, dt2: fp.Elt{0xe9, 0x89, 0x60, 0xfd, 0xc5, 0x2c, 0x2b, 0xd8, 0xa4, 0xe4, 0x82, 0x32, 0xa1, 0xb4, 0x1e, 0x03, 0x22, 0x86, 0x1a, 0xb5, 0x99, 0x11, 0x31, 0x44, 0x48, 0xf9, 0x3d, 0xb5, 0x22, 0x55, 0xc6, 0x3d}, }, { /* 13P */ addYX: fp.Elt{0x6d, 0x7f, 0x00, 0xa2, 0x22, 0xc2, 0x70, 0xbf, 0xdb, 0xde, 0xbc, 0xb5, 0x9a, 0xb3, 0x84, 0xbf, 0x07, 0xba, 0x07, 0xfb, 0x12, 0x0e, 0x7a, 0x53, 0x41, 0xf2, 0x46, 0xc3, 0xee, 0xd7, 0x4f, 0x23}, subYX: fp.Elt{0x93, 0xbf, 0x7f, 0x32, 0x3b, 0x01, 0x6f, 0x50, 0x6b, 0x6f, 0x77, 0x9b, 0xc9, 0xeb, 0xfc, 0xae, 0x68, 0x59, 0xad, 0xaa, 0x32, 0xb2, 0x12, 0x9d, 0xa7, 0x24, 0x60, 0x17, 0x2d, 0x88, 0x67, 0x02}, dt2: fp.Elt{0x78, 0xa3, 0x2e, 0x73, 0x19, 0xa1, 0x60, 0x53, 0x71, 0xd4, 0x8d, 0xdf, 0xb1, 0xe6, 0x37, 0x24, 0x33, 0xe5, 0xa7, 0x91, 0xf8, 0x37, 0xef, 0xa2, 0x63, 0x78, 0x09, 0xaa, 0xfd, 0xa6, 0x7b, 0x49}, }, { /* 15P */ addYX: fp.Elt{0xa0, 0xea, 0xcf, 0x13, 0x03, 0xcc, 0xce, 0x24, 0x6d, 0x24, 0x9c, 0x18, 0x8d, 0xc2, 0x48, 0x86, 0xd0, 0xd4, 0xf2, 0xc1, 0xfa, 0xbd, 0xbd, 0x2d, 0x2b, 0xe7, 0x2d, 0xf1, 0x17, 0x29, 0xe2, 0x61}, subYX: fp.Elt{0x0b, 0xcf, 0x8c, 0x46, 0x86, 0xcd, 0x0b, 0x04, 0xd6, 0x10, 0x99, 0x2a, 0xa4, 0x9b, 0x82, 0xd3, 0x92, 0x51, 0xb2, 0x07, 0x08, 0x30, 0x08, 0x75, 0xbf, 0x5e, 0xd0, 0x18, 0x42, 0xcd, 0xb5, 0x43}, dt2: fp.Elt{0x16, 0xb5, 0xd0, 0x9b, 0x2f, 0x76, 0x9a, 0x5d, 0xee, 0xde, 0x3f, 0x37, 0x4e, 0xaf, 0x38, 0xeb, 0x70, 0x42, 0xd6, 0x93, 0x7d, 0x5a, 0x2e, 0x03, 0x42, 0xd8, 0xe4, 0x0a, 0x21, 0x61, 0x1d, 0x51}, }, { /* 17P */ addYX: fp.Elt{0x81, 0x9d, 0x0e, 0x95, 0xef, 0x76, 0xc6, 0x92, 0x4f, 0x04, 0xd7, 0xc0, 0xcd, 0x20, 0x46, 0xa5, 0x48, 0x12, 0x8f, 0x6f, 0x64, 0x36, 0x9b, 0xaa, 0xe3, 0x55, 0xb8, 0xdd, 0x24, 0x59, 0x32, 0x6d}, subYX: fp.Elt{0x87, 0xde, 0x20, 0x44, 0x48, 0x86, 0x13, 0x08, 0xb4, 0xed, 0x92, 0xb5, 0x16, 0xf0, 0x1c, 0x8a, 0x25, 0x2d, 0x94, 0x29, 0x27, 0x4e, 0xfa, 0x39, 0x10, 0x28, 0x48, 0xe2, 0x6f, 0xfe, 0xa7, 0x71}, dt2: fp.Elt{0x54, 0xc8, 0xc8, 0xa5, 0xb8, 0x82, 0x71, 0x6c, 0x03, 0x2a, 0x5f, 0xfe, 0x79, 0x14, 0xfd, 0x33, 0x0c, 0x8d, 0x77, 0x83, 0x18, 0x59, 0xcf, 0x72, 0xa9, 0xea, 0x9e, 0x55, 0xb6, 0xc4, 0x46, 0x47}, }, { /* 19P */ addYX: fp.Elt{0x2b, 0x9a, 0xc6, 0x6d, 0x3c, 0x7b, 0x77, 0xd3, 0x17, 0xf6, 0x89, 0x6f, 0x27, 0xb2, 0xfa, 0xde, 0xb5, 0x16, 0x3a, 0xb5, 0xf7, 0x1c, 0x65, 0x45, 0xb7, 0x9f, 0xfe, 0x34, 0xde, 0x51, 0x9a, 0x5c}, subYX: fp.Elt{0x47, 0x11, 0x74, 0x64, 0xc8, 0x46, 0x85, 0x34, 0x49, 0xc8, 0xfc, 0x0e, 0xdd, 0xae, 0x35, 0x7d, 0x32, 0xa3, 0x72, 0x06, 0x76, 0x9a, 0x93, 0xff, 0xd6, 0xe6, 0xb5, 0x7d, 0x49, 0x63, 0x96, 0x21}, dt2: fp.Elt{0x67, 0x0e, 0xf1, 0x79, 0xcf, 0xf1, 0x10, 0xf5, 0x5b, 0x51, 0x58, 0xe6, 0xa1, 0xda, 0xdd, 0xff, 0x77, 0x22, 0x14, 0x10, 0x17, 0xa7, 0xc3, 0x09, 0xbb, 0x23, 0x82, 0x60, 0x3c, 0x50, 0x04, 0x48}, }, { /* 21P */ addYX: fp.Elt{0xc7, 0x7f, 0xa3, 0x2c, 0xd0, 0x9e, 0x24, 0xc4, 0xab, 0xac, 0x15, 0xa6, 0xe3, 0xa0, 0x59, 0xa0, 0x23, 0x0e, 0x6e, 0xc9, 0xd7, 0x6e, 0xa9, 0x88, 0x6d, 0x69, 0x50, 0x16, 0xa5, 0x98, 0x33, 0x55}, subYX: fp.Elt{0x75, 0xd1, 0x36, 0x3a, 0xd2, 0x21, 0x68, 0x3b, 0x32, 0x9e, 0x9b, 0xe9, 0xa7, 0x0a, 0xb4, 0xbb, 0x47, 0x8a, 0x83, 0x20, 0xe4, 0x5c, 0x9e, 0x5d, 0x5e, 0x4c, 0xde, 0x58, 0x88, 0x09, 0x1e, 0x77}, dt2: fp.Elt{0xdf, 0x1e, 0x45, 0x78, 0xd2, 0xf5, 0x12, 0x9a, 0xcb, 0x9c, 0x89, 0x85, 0x79, 0x5d, 0xda, 0x3a, 0x08, 0x95, 0xa5, 0x9f, 0x2d, 0x4a, 0x7f, 0x47, 0x11, 0xa6, 0xf5, 0x8f, 0xd6, 0xd1, 0x5e, 0x5a}, }, { /* 23P */ addYX: fp.Elt{0x83, 0x0e, 0x15, 0xfe, 0x2a, 0x12, 0x95, 0x11, 0xd8, 0x35, 0x4b, 0x7e, 0x25, 0x9a, 0x20, 0xcf, 0x20, 0x1e, 0x71, 0x1e, 0x29, 0xf8, 0x87, 0x73, 0xf0, 0x92, 0xbf, 0xd8, 0x97, 0xb8, 0xac, 0x44}, subYX: fp.Elt{0x59, 0x73, 0x52, 0x58, 0xc5, 0xe0, 0xe5, 0xba, 0x7e, 0x9d, 0xdb, 0xca, 0x19, 0x5c, 0x2e, 0x39, 0xe9, 0xab, 0x1c, 0xda, 0x1e, 0x3c, 0x65, 0x28, 0x44, 0xdc, 0xef, 0x5f, 0x13, 0x60, 0x9b, 0x01}, dt2: fp.Elt{0x83, 0x4b, 0x13, 0x5e, 0x14, 0x68, 0x60, 0x1e, 0x16, 0x4c, 0x30, 0x24, 0x4f, 0xe6, 0xf5, 0xc4, 0xd7, 0x3e, 0x1a, 0xfc, 0xa8, 0x88, 0x6e, 0x50, 0x92, 0x2f, 0xad, 0xe6, 0xfd, 0x49, 0x0c, 0x15}, }, { /* 25P */ addYX: fp.Elt{0x38, 0x11, 0x47, 0x09, 0x95, 0xf2, 0x7b, 0x8e, 0x51, 0xa6, 0x75, 0x4f, 0x39, 0xef, 0x6f, 0x5d, 0xad, 0x08, 0xa7, 0x25, 0xc4, 0x79, 0xaf, 0x10, 0x22, 0x99, 0xb9, 0x5b, 0x07, 0x5a, 0x2b, 0x6b}, subYX: fp.Elt{0x68, 0xa8, 0xdc, 0x9c, 0x3c, 0x86, 0x49, 0xb8, 0xd0, 0x4a, 0x71, 0xb8, 0xdb, 0x44, 0x3f, 0xc8, 0x8d, 0x16, 0x36, 0x0c, 0x56, 0xe3, 0x3e, 0xfe, 0xc1, 0xfb, 0x05, 0x1e, 0x79, 0xd7, 0xa6, 0x78}, dt2: fp.Elt{0x76, 0xb9, 0xa0, 0x47, 0x4b, 0x70, 0xbf, 0x58, 0xd5, 0x48, 0x17, 0x74, 0x55, 0xb3, 0x01, 0xa6, 0x90, 0xf5, 0x42, 0xd5, 0xb1, 0x1f, 0x2b, 0xaa, 0x00, 0x5d, 0xd5, 0x4a, 0xfc, 0x7f, 0x5c, 0x72}, }, { /* 27P */ addYX: fp.Elt{0xb2, 0x99, 0xcf, 0xd1, 0x15, 0x67, 0x42, 0xe4, 0x34, 0x0d, 0xa2, 0x02, 0x11, 0xd5, 0x52, 0x73, 0x9f, 0x10, 0x12, 0x8b, 0x7b, 0x15, 0xd1, 0x23, 0xa3, 0xf3, 0xb1, 0x7c, 0x27, 0xc9, 0x4c, 0x79}, subYX: fp.Elt{0xc0, 0x98, 0xd0, 0x1c, 0xf7, 0x2b, 0x80, 0x91, 0x66, 0x63, 0x5e, 0xed, 0xa4, 0x6c, 0x41, 0xfe, 0x4c, 0x99, 0x02, 0x49, 0x71, 0x5d, 0x58, 0xdf, 0xe7, 0xfa, 0x55, 0xf8, 0x25, 0x46, 0xd5, 0x4c}, dt2: fp.Elt{0x53, 0x50, 0xac, 0xc2, 0x26, 0xc4, 0xf6, 0x4a, 0x58, 0x72, 0xf6, 0x32, 0xad, 0xed, 0x9a, 0xbc, 0x21, 0x10, 0x31, 0x0a, 0xf1, 0x32, 0xd0, 0x2a, 0x85, 0x8e, 0xcc, 0x6f, 0x7b, 0x35, 0x08, 0x70}, }, { /* 29P */ addYX: fp.Elt{0x01, 0x3f, 0x77, 0x38, 0x27, 0x67, 0x88, 0x0b, 0xfb, 0xcc, 0xfb, 0x95, 0xfa, 0xc8, 0xcc, 0xb8, 0xb6, 0x29, 0xad, 0xb9, 0xa3, 0xd5, 0x2d, 0x8d, 0x6a, 0x0f, 0xad, 0x51, 0x98, 0x7e, 0xef, 0x06}, subYX: fp.Elt{0x34, 0x4a, 0x58, 0x82, 0xbb, 0x9f, 0x1b, 0xd0, 0x2b, 0x79, 0xb4, 0xd2, 0x63, 0x64, 0xab, 0x47, 0x02, 0x62, 0x53, 0x48, 0x9c, 0x63, 0x31, 0xb6, 0x28, 0xd4, 0xd6, 0x69, 0x36, 0x2a, 0xa9, 0x13}, dt2: fp.Elt{0xe5, 0x7d, 0x57, 0xc0, 0x1c, 0x77, 0x93, 0xca, 0x5c, 0xdc, 0x35, 0x50, 0x1e, 0xe4, 0x40, 0x75, 0x71, 0xe0, 0x02, 0xd8, 0x01, 0x0f, 0x68, 0x24, 0x6a, 0xf8, 0x2a, 0x8a, 0xdf, 0x6d, 0x29, 0x3c}, }, { /* 31P */ addYX: fp.Elt{0x13, 0xa7, 0x14, 0xd9, 0xf9, 0x15, 0xad, 0xae, 0x12, 0xf9, 0x8f, 0x8c, 0xf9, 0x7b, 0x2f, 0xa9, 0x30, 0xd7, 0x53, 0x9f, 0x17, 0x23, 0xf8, 0xaf, 0xba, 0x77, 0x0c, 0x49, 0x93, 0xd3, 0x99, 0x7a}, subYX: fp.Elt{0x41, 0x25, 0x1f, 0xbb, 0x2e, 0x4d, 0xeb, 0xfc, 0x1f, 0xb9, 0xad, 0x40, 0xc7, 0x10, 0x95, 0xb8, 0x05, 0xad, 0xa1, 0xd0, 0x7d, 0xa3, 0x71, 0xfc, 0x7b, 0x71, 0x47, 0x07, 0x70, 0x2c, 0x89, 0x0a}, dt2: fp.Elt{0xe8, 0xa3, 0xbd, 0x36, 0x24, 0xed, 0x52, 0x8f, 0x94, 0x07, 0xe8, 0x57, 0x41, 0xc8, 0xa8, 0x77, 0xe0, 0x9c, 0x2f, 0x26, 0x63, 0x65, 0xa9, 0xa5, 0xd2, 0xf7, 0x02, 0x83, 0xd2, 0x62, 0x67, 0x28}, }, { /* 33P */ addYX: fp.Elt{0x25, 0x5b, 0xe3, 0x3c, 0x09, 0x36, 0x78, 0x4e, 0x97, 0xaa, 0x6b, 0xb2, 0x1d, 0x18, 0xe1, 0x82, 0x3f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xa9, 0x8b, 0x13, 0x57, 0x07, 0x2b, 0x32, 0xe9, 0xe1, 0x4c, 0x0b, 0x79, 0xa8, 0xad, 0xb8, 0x38}, dt2: fp.Elt{0x5d, 0xf9, 0x51, 0xdf, 0x9c, 0x4a, 0xc0, 0xb5, 0xac, 0xde, 0x1f, 0xcb, 0xae, 0x52, 0x39, 0x2b, 0xda, 0x66, 0x8b, 0x32, 0x8b, 0x6d, 0x10, 0x1d, 0x53, 0x19, 0xba, 0xce, 0x32, 0xeb, 0x9a, 0x04}, }, { /* 45P */ addYX: fp.Elt{0x31, 0x79, 0xfc, 0x75, 0x0b, 0x7d, 0x50, 0xaa, 0xd3, 0x25, 0x67, 0x7a, 0x4b, 0x92, 0xef, 0x0f, 0x30, 0x39, 0x6b, 0x39, 0x2b, 0x54, 0x82, 0x1d, 0xfc, 0x74, 0xf6, 0x30, 0x75, 0xe1, 0x5e, 0x79}, subYX: fp.Elt{0x7e, 0xfe, 0xdc, 0x63, 0x3c, 0x7d, 0x76, 0xd7, 0x40, 0x6e, 0x85, 0x97, 0x48, 0x59, 0x9c, 0x20, 0x13, 0x7c, 0x4f, 0xe1, 0x61, 0x68, 0x67, 0xb6, 0xfc, 0x25, 0xd6, 0xc8, 0xe0, 0x65, 0xc6, 0x51}, dt2: fp.Elt{0x81, 0xbd, 0xec, 0x52, 0x0a, 0x5b, 0x4a, 0x25, 0xe7, 0xaf, 0x34, 0xe0, 0x6e, 0x1f, 0x41, 0x5d, 0x31, 0x4a, 0xee, 0xca, 0x0d, 0x4d, 0xa2, 0xe6, 0x77, 0x44, 0xc5, 0x9d, 0xf4, 0x9b, 0xd1, 0x6c}, }, { /* 47P */ addYX: fp.Elt{0x86, 0xc3, 0xaf, 0x65, 0x21, 0x61, 0xfe, 0x1f, 0x10, 0x1b, 0xd5, 0xb8, 0x88, 0x2a, 0x2a, 0x08, 0xaa, 0x0b, 0x99, 0x20, 0x7e, 0x62, 0xf6, 0x76, 0xe7, 0x43, 0x9e, 0x42, 0xa7, 0xb3, 0x01, 0x5e}, subYX: fp.Elt{0xa3, 0x9c, 0x17, 0x52, 0x90, 0x61, 0x87, 0x7e, 0x85, 0x9f, 0x2c, 0x0b, 0x06, 0x0a, 0x1d, 0x57, 0x1e, 0x71, 0x99, 0x84, 0xa8, 0xba, 0xa2, 0x80, 0x38, 0xe6, 0xb2, 0x40, 0xdb, 0xf3, 0x20, 0x75}, dt2: fp.Elt{0xa1, 0x57, 0x93, 0xd3, 0xe3, 0x0b, 0xb5, 0x3d, 0xa5, 0x94, 0x9e, 0x59, 0xdd, 0x6c, 0x7b, 0x96, 0x6e, 0x1e, 0x31, 0xdf, 0x64, 0x9a, 0x30, 0x1a, 0x86, 0xc9, 0xf3, 0xce, 0x9c, 0x2c, 0x09, 0x71}, }, { /* 49P */ addYX: fp.Elt{0xcf, 0x1d, 0x05, 0x74, 0xac, 0xd8, 0x6b, 0x85, 0x1e, 0xaa, 0xb7, 0x55, 0x08, 0xa4, 0xf6, 0x03, 0xeb, 0x3c, 0x74, 0xc9, 0xcb, 0xe7, 0x4a, 0x3a, 0xde, 0xab, 0x37, 0x71, 0xbb, 0xa5, 0x73, 0x41}, subYX: fp.Elt{0x8c, 0x91, 0x64, 0x03, 0x3f, 0x52, 0xd8, 0x53, 0x1c, 0x6b, 0xab, 0x3f, 0xf4, 0x04, 0xb4, 0xa2, 0xa4, 0xe5, 0x81, 0x66, 0x9e, 0x4a, 0x0b, 0x08, 0xa7, 0x7b, 0x25, 0xd0, 0x03, 0x5b, 0xa1, 0x0e}, dt2: fp.Elt{0x8a, 0x21, 0xf9, 0xf0, 0x31, 0x6e, 0xc5, 0x17, 0x08, 0x47, 0xfc, 0x1a, 0x2b, 0x6e, 0x69, 0x5a, 0x76, 0xf1, 0xb2, 0xf4, 0x68, 0x16, 0x93, 0xf7, 0x67, 0x3a, 0x4e, 0x4a, 0x61, 0x65, 0xc5, 0x5f}, }, { /* 51P */ addYX: fp.Elt{0x8e, 0x98, 0x90, 0x77, 0xe6, 0xe1, 0x92, 0x48, 0x22, 0xd7, 0x5c, 0x1c, 0x0f, 0x95, 0xd5, 0x01, 0xed, 0x3e, 0x92, 0xe5, 0x9a, 0x81, 0xb0, 0xe3, 0x1b, 0x65, 0x46, 0x9d, 0x40, 0xc7, 0x14, 0x32}, subYX: fp.Elt{0xe5, 0x7a, 0x6d, 0xc4, 0x0d, 0x57, 0x6e, 0x13, 0x8f, 0xdc, 0xf8, 0x54, 0xcc, 0xaa, 0xd0, 0x0f, 0x86, 0xad, 0x0d, 0x31, 0x03, 0x9f, 0x54, 0x59, 0xa1, 0x4a, 0x45, 0x4c, 0x41, 0x1c, 0x71, 0x62}, dt2: fp.Elt{0x70, 0x17, 0x65, 0x06, 0x74, 0x82, 0x29, 0x13, 0x36, 0x94, 0x27, 0x8a, 0x66, 0xa0, 0xa4, 0x3b, 0x3c, 0x22, 0x5d, 0x18, 0xec, 0xb8, 0xb6, 0xd9, 0x3c, 0x83, 0xcb, 0x3e, 0x07, 0x94, 0xea, 0x5b}, }, { /* 53P */ addYX: fp.Elt{0xf8, 0xd2, 0x43, 0xf3, 0x63, 0xce, 0x70, 0xb4, 0xf1, 0xe8, 0x43, 0x05, 0x8f, 0xba, 0x67, 0x00, 0x6f, 0x7b, 0x11, 0xa2, 0xa1, 0x51, 0xda, 0x35, 0x2f, 0xbd, 0xf1, 0x44, 0x59, 0x78, 0xd0, 0x4a}, subYX: fp.Elt{0xe4, 0x9b, 0xc8, 0x12, 0x09, 0xbf, 0x1d, 0x64, 0x9c, 0x57, 0x6e, 0x7d, 0x31, 0x8b, 0xf3, 0xac, 0x65, 0xb0, 0x97, 0xf6, 0x02, 0x9e, 0xfe, 0xab, 0xec, 0x1e, 0xf6, 0x48, 0xc1, 0xd5, 0xac, 0x3a}, dt2: fp.Elt{0x01, 0x83, 0x31, 0xc3, 0x34, 0x3b, 0x8e, 0x85, 0x26, 0x68, 0x31, 0x07, 0x47, 0xc0, 0x99, 0xdc, 0x8c, 0xa8,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, 0x1e, 0xf5, 0x0f, 0xaf, 0x1f, 0x3f, 0xd3, 0x67, 0x89, 0x1a, 0xf5, 0x78, 0x3c, 0x03, 0x60, 0x50, 0xe1, 0xbf, 0xc2, 0x6e, 0x86, 0x1a, 0xe2, 0xe8, 0x29, 0x6f, 0x3c, 0x23}, dt2: fp.Elt{0x81, 0xc7, 0x18, 0x7f, 0x10, 0xd5, 0xf4, 0xd2, 0x28, 0x9d, 0x7e, 0x52, 0xf2, 0xcd, 0x2e, 0x12, 0x41, 0x33, 0x3d, 0x3d, 0x2a, 0x86, 0x0a, 0xa7, 0xe3, 0x4c, 0x91, 0x11, 0x89, 0x77, 0xb7, 0x1d}, }, { /* 63P */ addYX: fp.Elt{0xb6, 0x1a, 0x70, 0xdd, 0x69, 0x47, 0x39, 0xb3, 0xa5, 0x8d, 0xcf, 0x19, 0xd4, 0xde, 0xb8, 0xe2, 0x52, 0xc8, 0x2a, 0xfd, 0x61, 0x41, 0xdf, 0x15, 0xbe, 0x24, 0x7d, 0x01, 0x8a, 0xca, 0xe2, 0x7a}, subYX: fp.Elt{0x6f, 0xc2, 0x6b, 0x7c, 0x39, 0x52, 0xf3, 0xdd, 0x13, 0x01, 0xd5, 0x53, 0xcc, 0xe2, 0x97, 0x7a, 0x30, 0xa3, 0x79, 0xbf, 0x3a, 0xf4, 0x74, 0x7c, 0xfc, 0xad, 0xe2, 0x26, 0xad, 0x97, 0xad, 0x31}, dt2: fp.Elt{0x62, 0xb9, 0x20, 0x09, 0xed, 0x17, 0xe8, 0xb7, 0x9d, 0xda, 0x19, 0x3f, 0xcc, 0x18, 0x85, 0x1e, 0x64, 0x0a, 0x56, 0x25, 0x4f, 0xc1, 0x91, 0xe4, 0x83, 0x2c, 0x62, 0xa6, 0x53, 0xfc, 0xd1, 0x1e}, }, }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/sign/ed25519/signapi.go
vendor/github.com/cloudflare/circl/sign/ed25519/signapi.go
package ed25519 import ( "crypto/rand" "encoding/asn1" "github.com/cloudflare/circl/sign" ) var sch sign.Scheme = &scheme{} // Scheme returns a signature interface. func Scheme() sign.Scheme { return sch } type scheme struct{} func (*scheme) Name() string { return "Ed25519" } func (*scheme) PublicKeySize() int { return PublicKeySize } func (*scheme) PrivateKeySize() int { return PrivateKeySize } func (*scheme) SignatureSize() int { return SignatureSize } func (*scheme) SeedSize() int { return SeedSize } func (*scheme) TLSIdentifier() uint { return 0x0807 } func (*scheme) SupportsContext() bool { return false } func (*scheme) Oid() asn1.ObjectIdentifier { return asn1.ObjectIdentifier{1, 3, 101, 112} } func (*scheme) GenerateKey() (sign.PublicKey, sign.PrivateKey, error) { return GenerateKey(rand.Reader) } func (*scheme) Sign( sk sign.PrivateKey, message []byte, opts *sign.SignatureOpts, ) []byte { priv, ok := sk.(PrivateKey) if !ok { panic(sign.ErrTypeMismatch) } if opts != nil && opts.Context != "" { panic(sign.ErrContextNotSupported) } return Sign(priv, message) } func (*scheme) Verify( pk sign.PublicKey, message, signature []byte, opts *sign.SignatureOpts, ) bool { pub, ok := pk.(PublicKey) if !ok { panic(sign.ErrTypeMismatch) } if opts != nil { if opts.Context != "" { panic(sign.ErrContextNotSupported) } } return Verify(pub, message, signature) } func (*scheme) DeriveKey(seed []byte) (sign.PublicKey, sign.PrivateKey) { privateKey := NewKeyFromSeed(seed) publicKey := make(PublicKey, PublicKeySize) copy(publicKey, privateKey[SeedSize:]) return publicKey, privateKey } func (*scheme) UnmarshalBinaryPublicKey(buf []byte) (sign.PublicKey, error) { if len(buf) < PublicKeySize { return nil, sign.ErrPubKeySize } pub := make(PublicKey, PublicKeySize) copy(pub, buf[:PublicKeySize]) return pub, nil } func (*scheme) UnmarshalBinaryPrivateKey(buf []byte) (sign.PrivateKey, error) { if len(buf) < PrivateKeySize { return nil, sign.ErrPrivKeySize } priv := make(PrivateKey, PrivateKeySize) copy(priv, buf[:PrivateKeySize]) return priv, nil }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/sign/ed25519/point.go
vendor/github.com/cloudflare/circl/sign/ed25519/point.go
package ed25519 import fp "github.com/cloudflare/circl/math/fp25519" type ( pointR1 struct{ x, y, z, ta, tb fp.Elt } pointR2 struct { pointR3 z2 fp.Elt } ) type pointR3 struct{ addYX, subYX, dt2 fp.Elt } func (P *pointR1) neg() { fp.Neg(&P.x, &P.x) fp.Neg(&P.ta, &P.ta) } func (P *pointR1) SetIdentity() { P.x = fp.Elt{} fp.SetOne(&P.y) fp.SetOne(&P.z) P.ta = fp.Elt{} P.tb = fp.Elt{} } func (P *pointR1) toAffine() { fp.Inv(&P.z, &P.z) fp.Mul(&P.x, &P.x, &P.z) fp.Mul(&P.y, &P.y, &P.z) fp.Modp(&P.x) fp.Modp(&P.y) fp.SetOne(&P.z) P.ta = P.x P.tb = P.y } func (P *pointR1) ToBytes(k []byte) error { P.toAffine() var x [fp.Size]byte err := fp.ToBytes(k[:fp.Size], &P.y) if err != nil { return err } err = fp.ToBytes(x[:], &P.x) if err != nil { return err } b := x[0] & 1 k[paramB-1] = k[paramB-1] | (b << 7) return nil } func (P *pointR1) FromBytes(k []byte) bool { if len(k) != paramB { panic("wrong size") } signX := k[paramB-1] >> 7 copy(P.y[:], k[:fp.Size]) P.y[fp.Size-1] &= 0x7F p := fp.P() if !isLessThan(P.y[:], p[:]) { return false } one, u, v := &fp.Elt{}, &fp.Elt{}, &fp.Elt{} fp.SetOne(one) fp.Sqr(u, &P.y) // u = y^2 fp.Mul(v, u, &paramD) // v = dy^2 fp.Sub(u, u, one) // u = y^2-1 fp.Add(v, v, one) // v = dy^2+1 isQR := fp.InvSqrt(&P.x, u, v) // x = sqrt(u/v) if !isQR { return false } fp.Modp(&P.x) // x = x mod p if fp.IsZero(&P.x) && signX == 1 { return false } if signX != (P.x[0] & 1) { fp.Neg(&P.x, &P.x) } P.ta = P.x P.tb = P.y fp.SetOne(&P.z) return true } // double calculates 2P for curves with A=-1. func (P *pointR1) double() { Px, Py, Pz, Pta, Ptb := &P.x, &P.y, &P.z, &P.ta, &P.tb a, b, c, e, f, g, h := Px, Py, Pz, Pta, Px, Py, Ptb fp.Add(e, Px, Py) // x+y fp.Sqr(a, Px) // A = x^2 fp.Sqr(b, Py) // B = y^2 fp.Sqr(c, Pz) // z^2 fp.Add(c, c, c) // C = 2*z^2 fp.Add(h, a, b) // H = A+B fp.Sqr(e, e) // (x+y)^2 fp.Sub(e, e, h) // E = (x+y)^2-A-B fp.Sub(g, b, a) // G = B-A fp.Sub(f, c, g) // F = C-G fp.Mul(Pz, f, g) // Z = F * G fp.Mul(Px, e, f) // X = E * F fp.Mul(Py, g, h) // Y = G * H, T = E * H } func (P *pointR1) mixAdd(Q *pointR3) { fp.Add(&P.z, &P.z, &P.z) // D = 2*z1 P.coreAddition(Q) } func (P *pointR1) add(Q *pointR2) { fp.Mul(&P.z, &P.z, &Q.z2) // D = 2*z1*z2 P.coreAddition(&Q.pointR3) } // coreAddition calculates P=P+Q for curves with A=-1. func (P *pointR1) coreAddition(Q *pointR3) { Px, Py, Pz, Pta, Ptb := &P.x, &P.y, &P.z, &P.ta, &P.tb addYX2, subYX2, dt2 := &Q.addYX, &Q.subYX, &Q.dt2 a, b, c, d, e, f, g, h := Px, Py, &fp.Elt{}, Pz, Pta, Px, Py, Ptb fp.Mul(c, Pta, Ptb) // t1 = ta*tb fp.Sub(h, Py, Px) // y1-x1 fp.Add(b, Py, Px) // y1+x1 fp.Mul(a, h, subYX2) // A = (y1-x1)*(y2-x2) fp.Mul(b, b, addYX2) // B = (y1+x1)*(y2+x2) fp.Mul(c, c, dt2) // C = 2*D*t1*t2 fp.Sub(e, b, a) // E = B-A fp.Add(h, b, a) // H = B+A fp.Sub(f, d, c) // F = D-C fp.Add(g, d, c) // G = D+C fp.Mul(Pz, f, g) // Z = F * G fp.Mul(Px, e, f) // X = E * F fp.Mul(Py, g, h) // Y = G * H, T = E * H } func (P *pointR1) oddMultiples(T []pointR2) { var R pointR2 n := len(T) T[0].fromR1(P) _2P := *P _2P.double() R.fromR1(&_2P) for i := 1; i < n; i++ { P.add(&R) T[i].fromR1(P) } } func (P *pointR1) isEqual(Q *pointR1) bool { l, r := &fp.Elt{}, &fp.Elt{} fp.Mul(l, &P.x, &Q.z) fp.Mul(r, &Q.x, &P.z) fp.Sub(l, l, r) b := fp.IsZero(l) fp.Mul(l, &P.y, &Q.z) fp.Mul(r, &Q.y, &P.z) fp.Sub(l, l, r) b = b && fp.IsZero(l) fp.Mul(l, &P.ta, &P.tb) fp.Mul(l, l, &Q.z) fp.Mul(r, &Q.ta, &Q.tb) fp.Mul(r, r, &P.z) fp.Sub(l, l, r) b = b && fp.IsZero(l) return b && !fp.IsZero(&P.z) && !fp.IsZero(&Q.z) } func (P *pointR3) neg() { P.addYX, P.subYX = P.subYX, P.addYX fp.Neg(&P.dt2, &P.dt2) } func (P *pointR2) fromR1(Q *pointR1) { fp.Add(&P.addYX, &Q.y, &Q.x) fp.Sub(&P.subYX, &Q.y, &Q.x) fp.Mul(&P.dt2, &Q.ta, &Q.tb) fp.Mul(&P.dt2, &P.dt2, &paramD) fp.Add(&P.dt2, &P.dt2, &P.dt2) fp.Add(&P.z2, &Q.z, &Q.z) } func (P *pointR3) cneg(b int) { t := &fp.Elt{} fp.Cswap(&P.addYX, &P.subYX, uint(b)) fp.Neg(t, &P.dt2) fp.Cmov(&P.dt2, t, uint(b)) } func (P *pointR3) cmov(Q *pointR3, b int) { fp.Cmov(&P.addYX, &Q.addYX, uint(b)) fp.Cmov(&P.subYX, &Q.subYX, uint(b)) fp.Cmov(&P.dt2, &Q.dt2, uint(b)) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/sign/ed25519/pubkey112.go
vendor/github.com/cloudflare/circl/sign/ed25519/pubkey112.go
//go:build !go1.13 // +build !go1.13 package ed25519 // PublicKey is the type of Ed25519 public keys. type PublicKey []byte
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/sign/ed25519/pubkey.go
vendor/github.com/cloudflare/circl/sign/ed25519/pubkey.go
//go:build go1.13 // +build go1.13 package ed25519 import cryptoEd25519 "crypto/ed25519" // PublicKey is the type of Ed25519 public keys. type PublicKey cryptoEd25519.PublicKey
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/sign/ed25519/ed25519.go
vendor/github.com/cloudflare/circl/sign/ed25519/ed25519.go
// Package ed25519 implements Ed25519 signature scheme as described in RFC-8032. // // This package provides optimized implementations of the three signature // variants and maintaining closer compatibility with crypto/ed25519. // // | Scheme Name | Sign Function | Verification | Context | // |-------------|-------------------|---------------|-------------------| // | Ed25519 | Sign | Verify | None | // | Ed25519Ph | SignPh | VerifyPh | Yes, can be empty | // | Ed25519Ctx | SignWithCtx | VerifyWithCtx | Yes, non-empty | // | All above | (PrivateKey).Sign | VerifyAny | As above | // // Specific functions for sign and verify are defined. A generic signing // function for all schemes is available through the crypto.Signer interface, // which is implemented by the PrivateKey type. A correspond all-in-one // verification method is provided by the VerifyAny function. // // Signing with Ed25519Ph or Ed25519Ctx requires a context string for domain // separation. This parameter is passed using a SignerOptions struct defined // in this package. While Ed25519Ph accepts an empty context, Ed25519Ctx // enforces non-empty context strings. // // # Compatibility with crypto.ed25519 // // These functions are compatible with the “Ed25519” function defined in // RFC-8032. However, unlike RFC 8032's formulation, this package's private // key representation includes a public key suffix to make multiple signing // operations with the same key more efficient. This package refers to the // RFC-8032 private key as the “seed”. // // References // // - RFC-8032: https://rfc-editor.org/rfc/rfc8032.txt // - Ed25519: https://ed25519.cr.yp.to/ // - EdDSA: High-speed high-security signatures. https://doi.org/10.1007/s13389-012-0027-1 package ed25519 import ( "bytes" "crypto" cryptoRand "crypto/rand" "crypto/sha512" "crypto/subtle" "errors" "fmt" "io" "strconv" "github.com/cloudflare/circl/sign" ) const ( // ContextMaxSize is the maximum length (in bytes) allowed for context. ContextMaxSize = 255 // PublicKeySize is the size, in bytes, of public keys as used in this package. PublicKeySize = 32 // PrivateKeySize is the size, in bytes, of private keys as used in this package. PrivateKeySize = 64 // SignatureSize is the size, in bytes, of signatures generated and verified by this package. SignatureSize = 64 // SeedSize is the size, in bytes, of private key seeds. These are the private key representations used by RFC 8032. SeedSize = 32 ) const ( paramB = 256 / 8 // Size of keys in bytes. ) // SignerOptions implements crypto.SignerOpts and augments with parameters // that are specific to the Ed25519 signature schemes. type SignerOptions struct { // Hash must be crypto.Hash(0) for Ed25519/Ed25519ctx, or crypto.SHA512 // for Ed25519ph. crypto.Hash // Context is an optional domain separation string for Ed25519ph and a // must for Ed25519ctx. Its length must be less or equal than 255 bytes. Context string // Scheme is an identifier for choosing a signature scheme. The zero value // is ED25519. Scheme SchemeID } // SchemeID is an identifier for each signature scheme. type SchemeID uint const ( ED25519 SchemeID = iota ED25519Ph ED25519Ctx ) // PrivateKey is the type of Ed25519 private keys. It implements crypto.Signer. type PrivateKey []byte // Equal reports whether priv and x have the same value. func (priv PrivateKey) Equal(x crypto.PrivateKey) bool { xx, ok := x.(PrivateKey) return ok && subtle.ConstantTimeCompare(priv, xx) == 1 } // Public returns the PublicKey corresponding to priv. func (priv PrivateKey) Public() crypto.PublicKey { publicKey := make(PublicKey, PublicKeySize) copy(publicKey, priv[SeedSize:]) return publicKey } // Seed returns the private key seed corresponding to priv. It is provided for // interoperability with RFC 8032. RFC 8032's private keys correspond to seeds // in this package. func (priv PrivateKey) Seed() []byte { seed := make([]byte, SeedSize) copy(seed, priv[:SeedSize]) return seed } func (priv PrivateKey) Scheme() sign.Scheme { return sch } func (pub PublicKey) Scheme() sign.Scheme { return sch } func (priv PrivateKey) MarshalBinary() (data []byte, err error) { privateKey := make(PrivateKey, PrivateKeySize) copy(privateKey, priv) return privateKey, nil } func (pub PublicKey) MarshalBinary() (data []byte, err error) { publicKey := make(PublicKey, PublicKeySize) copy(publicKey, pub) return publicKey, nil } // Equal reports whether pub and x have the same value. func (pub PublicKey) Equal(x crypto.PublicKey) bool { xx, ok := x.(PublicKey) return ok && bytes.Equal(pub, xx) } // Sign creates a signature of a message with priv key. // This function is compatible with crypto.ed25519 and also supports the // three signature variants defined in RFC-8032, namely Ed25519 (or pure // EdDSA), Ed25519Ph, and Ed25519Ctx. // The opts.HashFunc() must return zero to specify either Ed25519 or Ed25519Ctx // variant. This can be achieved by passing crypto.Hash(0) as the value for // opts. // The opts.HashFunc() must return SHA512 to specify the Ed25519Ph variant. // This can be achieved by passing crypto.SHA512 as the value for opts. // Use a SignerOptions struct (defined in this package) to pass a context // string for signing. func (priv PrivateKey) Sign( rand io.Reader, message []byte, opts crypto.SignerOpts, ) (signature []byte, err error) { var ctx string var scheme SchemeID if o, ok := opts.(SignerOptions); ok { ctx = o.Context scheme = o.Scheme } switch true { case scheme == ED25519 && opts.HashFunc() == crypto.Hash(0): return Sign(priv, message), nil case scheme == ED25519Ph && opts.HashFunc() == crypto.SHA512: return SignPh(priv, message, ctx), nil case scheme == ED25519Ctx && opts.HashFunc() == crypto.Hash(0) && len(ctx) > 0: return SignWithCtx(priv, message, ctx), nil default: return nil, errors.New("ed25519: bad hash algorithm") } } // GenerateKey generates a public/private key pair using entropy from rand. // If rand is nil, crypto/rand.Reader will be used. func GenerateKey(rand io.Reader) (PublicKey, PrivateKey, error) { if rand == nil { rand = cryptoRand.Reader } seed := make([]byte, SeedSize) if _, err := io.ReadFull(rand, seed); err != nil { return nil, nil, err } privateKey := NewKeyFromSeed(seed) publicKey := make(PublicKey, PublicKeySize) copy(publicKey, privateKey[SeedSize:]) return publicKey, privateKey, nil } // NewKeyFromSeed calculates a private key from a seed. It will panic if // len(seed) is not SeedSize. This function is provided for interoperability // with RFC 8032. RFC 8032's private keys correspond to seeds in this // package. func NewKeyFromSeed(seed []byte) PrivateKey { privateKey := make(PrivateKey, PrivateKeySize) newKeyFromSeed(privateKey, seed) return privateKey } func newKeyFromSeed(privateKey, seed []byte) { if l := len(seed); l != SeedSize { panic("ed25519: bad seed length: " + strconv.Itoa(l)) } var P pointR1 k := sha512.Sum512(seed) clamp(k[:]) reduceModOrder(k[:paramB], false) P.fixedMult(k[:paramB]) copy(privateKey[:SeedSize], seed) _ = P.ToBytes(privateKey[SeedSize:]) } func signAll(signature []byte, privateKey PrivateKey, message, ctx []byte, preHash bool) { if l := len(privateKey); l != PrivateKeySize { panic("ed25519: bad private key length: " + strconv.Itoa(l)) } H := sha512.New() var PHM []byte if preHash { _, _ = H.Write(message) PHM = H.Sum(nil) H.Reset() } else { PHM = message } // 1. Hash the 32-byte private key using SHA-512. _, _ = H.Write(privateKey[:SeedSize]) h := H.Sum(nil) clamp(h[:]) prefix, s := h[paramB:], h[:paramB] // 2. Compute SHA-512(dom2(F, C) || prefix || PH(M)) H.Reset() writeDom(H, ctx, preHash) _, _ = H.Write(prefix) _, _ = H.Write(PHM) r := H.Sum(nil) reduceModOrder(r[:], true) // 3. Compute the point [r]B. var P pointR1 P.fixedMult(r[:paramB]) R := (&[paramB]byte{})[:] if err := P.ToBytes(R); err != nil { panic(err) } // 4. Compute SHA512(dom2(F, C) || R || A || PH(M)). H.Reset() writeDom(H, ctx, preHash) _, _ = H.Write(R) _, _ = H.Write(privateKey[SeedSize:]) _, _ = H.Write(PHM) hRAM := H.Sum(nil) reduceModOrder(hRAM[:], true) // 5. Compute S = (r + k * s) mod order. S := (&[paramB]byte{})[:] calculateS(S, r[:paramB], hRAM[:paramB], s) // 6. The signature is the concatenation of R and S. copy(signature[:paramB], R[:]) copy(signature[paramB:], S[:]) } // Sign signs the message with privateKey and returns a signature. // This function supports the signature variant defined in RFC-8032: Ed25519, // also known as the pure version of EdDSA. // It will panic if len(privateKey) is not PrivateKeySize. func Sign(privateKey PrivateKey, message []byte) []byte { signature := make([]byte, SignatureSize) signAll(signature, privateKey, message, []byte(""), false) return signature } // SignPh creates a signature of a message with private key and context. // This function supports the signature variant defined in RFC-8032: Ed25519ph, // meaning it internally hashes the message using SHA-512, and optionally // accepts a context string. // It will panic if len(privateKey) is not PrivateKeySize. // Context could be passed to this function, which length should be no more than // ContextMaxSize=255. It can be empty. func SignPh(privateKey PrivateKey, message []byte, ctx string) []byte { if len(ctx) > ContextMaxSize { panic(fmt.Errorf("ed25519: bad context length: %v", len(ctx))) } signature := make([]byte, SignatureSize) signAll(signature, privateKey, message, []byte(ctx), true) return signature } // SignWithCtx creates a signature of a message with private key and context. // This function supports the signature variant defined in RFC-8032: Ed25519ctx, // meaning it accepts a non-empty context string. // It will panic if len(privateKey) is not PrivateKeySize. // Context must be passed to this function, which length should be no more than // ContextMaxSize=255 and cannot be empty. func SignWithCtx(privateKey PrivateKey, message []byte, ctx string) []byte { if len(ctx) == 0 || len(ctx) > ContextMaxSize { panic(fmt.Errorf("ed25519: bad context length: %v > %v", len(ctx), ContextMaxSize)) } signature := make([]byte, SignatureSize) signAll(signature, privateKey, message, []byte(ctx), false) return signature } func verify(public PublicKey, message, signature, ctx []byte, preHash bool) bool { if len(public) != PublicKeySize || len(signature) != SignatureSize || !isLessThanOrder(signature[paramB:]) { return false } var P pointR1 if ok := P.FromBytes(public); !ok { return false } H := sha512.New() var PHM []byte if preHash { _, _ = H.Write(message) PHM = H.Sum(nil) H.Reset() } else { PHM = message } R := signature[:paramB] writeDom(H, ctx, preHash) _, _ = H.Write(R) _, _ = H.Write(public) _, _ = H.Write(PHM) hRAM := H.Sum(nil) reduceModOrder(hRAM[:], true) var Q pointR1 encR := (&[paramB]byte{})[:] P.neg() Q.doubleMult(&P, signature[paramB:], hRAM[:paramB]) _ = Q.ToBytes(encR) return bytes.Equal(R, encR) } // VerifyAny returns true if the signature is valid. Failure cases are invalid // signature, or when the public key cannot be decoded. // This function supports all the three signature variants defined in RFC-8032, // namely Ed25519 (or pure EdDSA), Ed25519Ph, and Ed25519Ctx. // The opts.HashFunc() must return zero to specify either Ed25519 or Ed25519Ctx // variant. This can be achieved by passing crypto.Hash(0) as the value for opts. // The opts.HashFunc() must return SHA512 to specify the Ed25519Ph variant. // This can be achieved by passing crypto.SHA512 as the value for opts. // Use a SignerOptions struct to pass a context string for signing. func VerifyAny(public PublicKey, message, signature []byte, opts crypto.SignerOpts) bool { var ctx string var scheme SchemeID if o, ok := opts.(SignerOptions); ok { ctx = o.Context scheme = o.Scheme } switch true { case scheme == ED25519 && opts.HashFunc() == crypto.Hash(0): return Verify(public, message, signature) case scheme == ED25519Ph && opts.HashFunc() == crypto.SHA512: return VerifyPh(public, message, signature, ctx) case scheme == ED25519Ctx && opts.HashFunc() == crypto.Hash(0) && len(ctx) > 0: return VerifyWithCtx(public, message, signature, ctx) default: return false } } // Verify returns true if the signature is valid. Failure cases are invalid // signature, or when the public key cannot be decoded. // This function supports the signature variant defined in RFC-8032: Ed25519, // also known as the pure version of EdDSA. func Verify(public PublicKey, message, signature []byte) bool { return verify(public, message, signature, []byte(""), false) } // VerifyPh returns true if the signature is valid. Failure cases are invalid // signature, or when the public key cannot be decoded. // This function supports the signature variant defined in RFC-8032: Ed25519ph, // meaning it internally hashes the message using SHA-512. // Context could be passed to this function, which length should be no more than // 255. It can be empty. func VerifyPh(public PublicKey, message, signature []byte, ctx string) bool { return verify(public, message, signature, []byte(ctx), true) } // VerifyWithCtx returns true if the signature is valid. Failure cases are invalid // signature, or when the public key cannot be decoded, or when context is // not provided. // This function supports the signature variant defined in RFC-8032: Ed25519ctx, // meaning it does not handle prehashed messages. Non-empty context string must be // provided, and must not be more than 255 of length. func VerifyWithCtx(public PublicKey, message, signature []byte, ctx string) bool { if len(ctx) == 0 || len(ctx) > ContextMaxSize { return false } return verify(public, message, signature, []byte(ctx), false) } func clamp(k []byte) { k[0] &= 248 k[paramB-1] = (k[paramB-1] & 127) | 64 } // isLessThanOrder returns true if 0 <= x < order. func isLessThanOrder(x []byte) bool { i := len(order) - 1 for i > 0 && x[i] == order[i] { i-- } return x[i] < order[i] } func writeDom(h io.Writer, ctx []byte, preHash bool) { dom2 := "SigEd25519 no Ed25519 collisions" if len(ctx) > 0 { _, _ = h.Write([]byte(dom2)) if preHash { _, _ = h.Write([]byte{byte(0x01), byte(len(ctx))}) } else { _, _ = h.Write([]byte{byte(0x00), byte(len(ctx))}) } _, _ = h.Write(ctx) } else if preHash { _, _ = h.Write([]byte(dom2)) _, _ = h.Write([]byte{0x01, 0x00}) } }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/sign/ed25519/mult.go
vendor/github.com/cloudflare/circl/sign/ed25519/mult.go
package ed25519 import ( "crypto/subtle" "encoding/binary" "math/bits" "github.com/cloudflare/circl/internal/conv" "github.com/cloudflare/circl/math" fp "github.com/cloudflare/circl/math/fp25519" ) var paramD = fp.Elt{ 0xa3, 0x78, 0x59, 0x13, 0xca, 0x4d, 0xeb, 0x75, 0xab, 0xd8, 0x41, 0x41, 0x4d, 0x0a, 0x70, 0x00, 0x98, 0xe8, 0x79, 0x77, 0x79, 0x40, 0xc7, 0x8c, 0x73, 0xfe, 0x6f, 0x2b, 0xee, 0x6c, 0x03, 0x52, } // mLSBRecoding parameters. const ( fxT = 257 fxV = 2 fxW = 3 fx2w1 = 1 << (uint(fxW) - 1) numWords64 = (paramB * 8 / 64) ) // mLSBRecoding is the odd-only modified LSB-set. // // Reference: // // "Efficient and secure algorithms for GLV-based scalar multiplication and // their implementation on GLV–GLS curves" by (Faz-Hernandez et al.) // http://doi.org/10.1007/s13389-014-0085-7. func mLSBRecoding(L []int8, k []byte) { const ee = (fxT + fxW*fxV - 1) / (fxW * fxV) const dd = ee * fxV const ll = dd * fxW if len(L) == (ll + 1) { var m [numWords64 + 1]uint64 for i := 0; i < numWords64; i++ { m[i] = binary.LittleEndian.Uint64(k[8*i : 8*i+8]) } condAddOrderN(&m) L[dd-1] = 1 for i := 0; i < dd-1; i++ { kip1 := (m[(i+1)/64] >> (uint(i+1) % 64)) & 0x1 L[i] = int8(kip1<<1) - 1 } { // right-shift by d right := uint(dd % 64) left := uint(64) - right lim := ((numWords64+1)*64 - dd) / 64 j := dd / 64 for i := 0; i < lim; i++ { m[i] = (m[i+j] >> right) | (m[i+j+1] << left) } m[lim] = m[lim+j] >> right } for i := dd; i < ll; i++ { L[i] = L[i%dd] * int8(m[0]&0x1) div2subY(m[:], int64(L[i]>>1), numWords64) } L[ll] = int8(m[0]) } } // absolute returns always a positive value. func absolute(x int32) int32 { mask := x >> 31 return (x + mask) ^ mask } // condAddOrderN updates x = x+order if x is even, otherwise x remains unchanged. func condAddOrderN(x *[numWords64 + 1]uint64) { isOdd := (x[0] & 0x1) - 1 c := uint64(0) for i := 0; i < numWords64; i++ { orderWord := binary.LittleEndian.Uint64(order[8*i : 8*i+8]) o := isOdd & orderWord x0, c0 := bits.Add64(x[i], o, c) x[i] = x0 c = c0 } x[numWords64], _ = bits.Add64(x[numWords64], 0, c) } // div2subY update x = (x/2) - y. func div2subY(x []uint64, y int64, l int) { s := uint64(y >> 63) for i := 0; i < l-1; i++ { x[i] = (x[i] >> 1) | (x[i+1] << 63) } x[l-1] = (x[l-1] >> 1) b := uint64(0) x0, b0 := bits.Sub64(x[0], uint64(y), b) x[0] = x0 b = b0 for i := 1; i < l-1; i++ { x0, b0 := bits.Sub64(x[i], s, b) x[i] = x0 b = b0 } x[l-1], _ = bits.Sub64(x[l-1], s, b) } func (P *pointR1) fixedMult(scalar []byte) { if len(scalar) != paramB { panic("wrong scalar size") } const ee = (fxT + fxW*fxV - 1) / (fxW * fxV) const dd = ee * fxV const ll = dd * fxW L := make([]int8, ll+1) mLSBRecoding(L[:], scalar) S := &pointR3{} P.SetIdentity() for ii := ee - 1; ii >= 0; ii-- { P.double() for j := 0; j < fxV; j++ { dig := L[fxW*dd-j*ee+ii-ee] for i := (fxW-1)*dd - j*ee + ii - ee; i >= (2*dd - j*ee + ii - ee); i = i - dd { dig = 2*dig + L[i] } idx := absolute(int32(dig)) sig := L[dd-j*ee+ii-ee] Tabj := &tabSign[fxV-j-1] for k := 0; k < fx2w1; k++ { S.cmov(&Tabj[k], subtle.ConstantTimeEq(int32(k), idx)) } S.cneg(subtle.ConstantTimeEq(int32(sig), -1)) P.mixAdd(S) } } } const ( omegaFix = 7 omegaVar = 5 ) // doubleMult returns P=mG+nQ. func (P *pointR1) doubleMult(Q *pointR1, m, n []byte) { nafFix := math.OmegaNAF(conv.BytesLe2BigInt(m), omegaFix) nafVar := math.OmegaNAF(conv.BytesLe2BigInt(n), omegaVar) if len(nafFix) > len(nafVar) { nafVar = append(nafVar, make([]int32, len(nafFix)-len(nafVar))...) } else if len(nafFix) < len(nafVar) { nafFix = append(nafFix, make([]int32, len(nafVar)-len(nafFix))...) } var TabQ [1 << (omegaVar - 2)]pointR2 Q.oddMultiples(TabQ[:]) P.SetIdentity() for i := len(nafFix) - 1; i >= 0; i-- { P.double() // Generator point if nafFix[i] != 0 { idxM := absolute(nafFix[i]) >> 1 R := tabVerif[idxM] if nafFix[i] < 0 { R.neg() } P.mixAdd(&R) } // Variable input point if nafVar[i] != 0 { idxN := absolute(nafVar[i]) >> 1 S := TabQ[idxN] if nafVar[i] < 0 { S.neg() } P.add(&S) } } }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/sign/ed448/ed448.go
vendor/github.com/cloudflare/circl/sign/ed448/ed448.go
// Package ed448 implements Ed448 signature scheme as described in RFC-8032. // // This package implements two signature variants. // // | Scheme Name | Sign Function | Verification | Context | // |-------------|-------------------|---------------|-------------------| // | Ed448 | Sign | Verify | Yes, can be empty | // | Ed448Ph | SignPh | VerifyPh | Yes, can be empty | // | All above | (PrivateKey).Sign | VerifyAny | As above | // // Specific functions for sign and verify are defined. A generic signing // function for all schemes is available through the crypto.Signer interface, // which is implemented by the PrivateKey type. A correspond all-in-one // verification method is provided by the VerifyAny function. // // Both schemes require a context string for domain separation. This parameter // is passed using a SignerOptions struct defined in this package. // // References: // // - RFC8032: https://rfc-editor.org/rfc/rfc8032.txt // - EdDSA for more curves: https://eprint.iacr.org/2015/677 // - High-speed high-security signatures: https://doi.org/10.1007/s13389-012-0027-1 package ed448 import ( "bytes" "crypto" cryptoRand "crypto/rand" "crypto/subtle" "errors" "fmt" "io" "strconv" "github.com/cloudflare/circl/ecc/goldilocks" "github.com/cloudflare/circl/internal/sha3" "github.com/cloudflare/circl/sign" ) const ( // ContextMaxSize is the maximum length (in bytes) allowed for context. ContextMaxSize = 255 // PublicKeySize is the length in bytes of Ed448 public keys. PublicKeySize = 57 // PrivateKeySize is the length in bytes of Ed448 private keys. PrivateKeySize = 114 // SignatureSize is the length in bytes of signatures. SignatureSize = 114 // SeedSize is the size, in bytes, of private key seeds. These are the private key representations used by RFC 8032. SeedSize = 57 ) const ( paramB = 456 / 8 // Size of keys in bytes. hashSize = 2 * paramB // Size of the hash function's output. ) // SignerOptions implements crypto.SignerOpts and augments with parameters // that are specific to the Ed448 signature schemes. type SignerOptions struct { // Hash must be crypto.Hash(0) for both Ed448 and Ed448Ph. crypto.Hash // Context is an optional domain separation string for signing. // Its length must be less or equal than 255 bytes. Context string // Scheme is an identifier for choosing a signature scheme. Scheme SchemeID } // SchemeID is an identifier for each signature scheme. type SchemeID uint const ( ED448 SchemeID = iota ED448Ph ) // PublicKey is the type of Ed448 public keys. type PublicKey []byte // Equal reports whether pub and x have the same value. func (pub PublicKey) Equal(x crypto.PublicKey) bool { xx, ok := x.(PublicKey) return ok && bytes.Equal(pub, xx) } // PrivateKey is the type of Ed448 private keys. It implements crypto.Signer. type PrivateKey []byte // Equal reports whether priv and x have the same value. func (priv PrivateKey) Equal(x crypto.PrivateKey) bool { xx, ok := x.(PrivateKey) return ok && subtle.ConstantTimeCompare(priv, xx) == 1 } // Public returns the PublicKey corresponding to priv. func (priv PrivateKey) Public() crypto.PublicKey { publicKey := make([]byte, PublicKeySize) copy(publicKey, priv[SeedSize:]) return PublicKey(publicKey) } // Seed returns the private key seed corresponding to priv. It is provided for // interoperability with RFC 8032. RFC 8032's private keys correspond to seeds // in this package. func (priv PrivateKey) Seed() []byte { seed := make([]byte, SeedSize) copy(seed, priv[:SeedSize]) return seed } func (priv PrivateKey) Scheme() sign.Scheme { return sch } func (pub PublicKey) Scheme() sign.Scheme { return sch } func (priv PrivateKey) MarshalBinary() (data []byte, err error) { privateKey := make(PrivateKey, PrivateKeySize) copy(privateKey, priv) return privateKey, nil } func (pub PublicKey) MarshalBinary() (data []byte, err error) { publicKey := make(PublicKey, PublicKeySize) copy(publicKey, pub) return publicKey, nil } // Sign creates a signature of a message given a key pair. // This function supports all the two signature variants defined in RFC-8032, // namely Ed448 (or pure EdDSA) and Ed448Ph. // The opts.HashFunc() must return zero to the specify Ed448 variant. This can // be achieved by passing crypto.Hash(0) as the value for opts. // Use an Options struct to pass a bool indicating that the ed448Ph variant // should be used. // The struct can also be optionally used to pass a context string for signing. func (priv PrivateKey) Sign( rand io.Reader, message []byte, opts crypto.SignerOpts, ) (signature []byte, err error) { var ctx string var scheme SchemeID if o, ok := opts.(SignerOptions); ok { ctx = o.Context scheme = o.Scheme } switch true { case scheme == ED448 && opts.HashFunc() == crypto.Hash(0): return Sign(priv, message, ctx), nil case scheme == ED448Ph && opts.HashFunc() == crypto.Hash(0): return SignPh(priv, message, ctx), nil default: return nil, errors.New("ed448: bad hash algorithm") } } // GenerateKey generates a public/private key pair using entropy from rand. // If rand is nil, crypto/rand.Reader will be used. func GenerateKey(rand io.Reader) (PublicKey, PrivateKey, error) { if rand == nil { rand = cryptoRand.Reader } seed := make(PrivateKey, SeedSize) if _, err := io.ReadFull(rand, seed); err != nil { return nil, nil, err } privateKey := NewKeyFromSeed(seed) publicKey := make([]byte, PublicKeySize) copy(publicKey, privateKey[SeedSize:]) return publicKey, privateKey, nil } // NewKeyFromSeed calculates a private key from a seed. It will panic if // len(seed) is not SeedSize. This function is provided for interoperability // with RFC 8032. RFC 8032's private keys correspond to seeds in this // package. func NewKeyFromSeed(seed []byte) PrivateKey { privateKey := make([]byte, PrivateKeySize) newKeyFromSeed(privateKey, seed) return privateKey } func newKeyFromSeed(privateKey, seed []byte) { if l := len(seed); l != SeedSize { panic("ed448: bad seed length: " + strconv.Itoa(l)) } var h [hashSize]byte H := sha3.NewShake256() _, _ = H.Write(seed) _, _ = H.Read(h[:]) s := &goldilocks.Scalar{} deriveSecretScalar(s, h[:paramB]) copy(privateKey[:SeedSize], seed) _ = goldilocks.Curve{}.ScalarBaseMult(s).ToBytes(privateKey[SeedSize:]) } func signAll(signature []byte, privateKey PrivateKey, message, ctx []byte, preHash bool) { if len(ctx) > ContextMaxSize { panic(fmt.Errorf("ed448: bad context length: %v", len(ctx))) } H := sha3.NewShake256() var PHM []byte if preHash { var h [64]byte _, _ = H.Write(message) _, _ = H.Read(h[:]) PHM = h[:] H.Reset() } else { PHM = message } // 1. Hash the 57-byte private key using SHAKE256(x, 114). var h [hashSize]byte _, _ = H.Write(privateKey[:SeedSize]) _, _ = H.Read(h[:]) s := &goldilocks.Scalar{} deriveSecretScalar(s, h[:paramB]) prefix := h[paramB:] // 2. Compute SHAKE256(dom4(F, C) || prefix || PH(M), 114). var rPM [hashSize]byte H.Reset() writeDom(&H, ctx, preHash) _, _ = H.Write(prefix) _, _ = H.Write(PHM) _, _ = H.Read(rPM[:]) // 3. Compute the point [r]B. r := &goldilocks.Scalar{} r.FromBytes(rPM[:]) R := (&[paramB]byte{})[:] if err := (goldilocks.Curve{}.ScalarBaseMult(r).ToBytes(R)); err != nil { panic(err) } // 4. Compute SHAKE256(dom4(F, C) || R || A || PH(M), 114) var hRAM [hashSize]byte H.Reset() writeDom(&H, ctx, preHash) _, _ = H.Write(R) _, _ = H.Write(privateKey[SeedSize:]) _, _ = H.Write(PHM) _, _ = H.Read(hRAM[:]) // 5. Compute S = (r + k * s) mod order. k := &goldilocks.Scalar{} k.FromBytes(hRAM[:]) S := &goldilocks.Scalar{} S.Mul(k, s) S.Add(S, r) // 6. The signature is the concatenation of R and S. copy(signature[:paramB], R[:]) copy(signature[paramB:], S[:]) } // Sign signs the message with privateKey and returns a signature. // This function supports the signature variant defined in RFC-8032: Ed448, // also known as the pure version of EdDSA. // It will panic if len(privateKey) is not PrivateKeySize. func Sign(priv PrivateKey, message []byte, ctx string) []byte { signature := make([]byte, SignatureSize) signAll(signature, priv, message, []byte(ctx), false) return signature } // SignPh creates a signature of a message given a keypair. // This function supports the signature variant defined in RFC-8032: Ed448ph, // meaning it internally hashes the message using SHAKE-256. // Context could be passed to this function, which length should be no more than // 255. It can be empty. func SignPh(priv PrivateKey, message []byte, ctx string) []byte { signature := make([]byte, SignatureSize) signAll(signature, priv, message, []byte(ctx), true) return signature } func verify(public PublicKey, message, signature, ctx []byte, preHash bool) bool { if len(public) != PublicKeySize || len(signature) != SignatureSize || len(ctx) > ContextMaxSize || !isLessThanOrder(signature[paramB:]) { return false } P, err := goldilocks.FromBytes(public) if err != nil { return false } H := sha3.NewShake256() var PHM []byte if preHash { var h [64]byte _, _ = H.Write(message) _, _ = H.Read(h[:]) PHM = h[:] H.Reset() } else { PHM = message } var hRAM [hashSize]byte R := signature[:paramB] writeDom(&H, ctx, preHash) _, _ = H.Write(R) _, _ = H.Write(public) _, _ = H.Write(PHM) _, _ = H.Read(hRAM[:]) k := &goldilocks.Scalar{} k.FromBytes(hRAM[:]) S := &goldilocks.Scalar{} S.FromBytes(signature[paramB:]) encR := (&[paramB]byte{})[:] P.Neg() _ = goldilocks.Curve{}.CombinedMult(S, k, P).ToBytes(encR) return bytes.Equal(R, encR) } // VerifyAny returns true if the signature is valid. Failure cases are invalid // signature, or when the public key cannot be decoded. // This function supports all the two signature variants defined in RFC-8032, // namely Ed448 (or pure EdDSA) and Ed448Ph. // The opts.HashFunc() must return zero, this can be achieved by passing // crypto.Hash(0) as the value for opts. // Use a SignerOptions struct to pass a context string for signing. func VerifyAny(public PublicKey, message, signature []byte, opts crypto.SignerOpts) bool { var ctx string var scheme SchemeID if o, ok := opts.(SignerOptions); ok { ctx = o.Context scheme = o.Scheme } switch true { case scheme == ED448 && opts.HashFunc() == crypto.Hash(0): return Verify(public, message, signature, ctx) case scheme == ED448Ph && opts.HashFunc() == crypto.Hash(0): return VerifyPh(public, message, signature, ctx) default: return false } } // Verify returns true if the signature is valid. Failure cases are invalid // signature, or when the public key cannot be decoded. // This function supports the signature variant defined in RFC-8032: Ed448, // also known as the pure version of EdDSA. func Verify(public PublicKey, message, signature []byte, ctx string) bool { return verify(public, message, signature, []byte(ctx), false) } // VerifyPh returns true if the signature is valid. Failure cases are invalid // signature, or when the public key cannot be decoded. // This function supports the signature variant defined in RFC-8032: Ed448ph, // meaning it internally hashes the message using SHAKE-256. // Context could be passed to this function, which length should be no more than // 255. It can be empty. func VerifyPh(public PublicKey, message, signature []byte, ctx string) bool { return verify(public, message, signature, []byte(ctx), true) } func deriveSecretScalar(s *goldilocks.Scalar, h []byte) { h[0] &= 0xFC // The two least significant bits of the first octet are cleared, h[paramB-1] = 0x00 // all eight bits the last octet are cleared, and h[paramB-2] |= 0x80 // the highest bit of the second to last octet is set. s.FromBytes(h[:paramB]) } // isLessThanOrder returns true if 0 <= x < order and if the last byte of x is zero. func isLessThanOrder(x []byte) bool { order := goldilocks.Curve{}.Order() i := len(order) - 1 for i > 0 && x[i] == order[i] { i-- } return x[paramB-1] == 0 && x[i] < order[i] } func writeDom(h io.Writer, ctx []byte, preHash bool) { dom4 := "SigEd448" _, _ = h.Write([]byte(dom4)) if preHash { _, _ = h.Write([]byte{byte(0x01), byte(len(ctx))}) } else { _, _ = h.Write([]byte{byte(0x00), byte(len(ctx))}) } _, _ = h.Write(ctx) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/sign/ed448/signapi.go
vendor/github.com/cloudflare/circl/sign/ed448/signapi.go
package ed448 import ( "crypto/rand" "encoding/asn1" "github.com/cloudflare/circl/sign" ) var sch sign.Scheme = &scheme{} // Scheme returns a signature interface. func Scheme() sign.Scheme { return sch } type scheme struct{} func (*scheme) Name() string { return "Ed448" } func (*scheme) PublicKeySize() int { return PublicKeySize } func (*scheme) PrivateKeySize() int { return PrivateKeySize } func (*scheme) SignatureSize() int { return SignatureSize } func (*scheme) SeedSize() int { return SeedSize } func (*scheme) TLSIdentifier() uint { return 0x0808 } func (*scheme) SupportsContext() bool { return true } func (*scheme) Oid() asn1.ObjectIdentifier { return asn1.ObjectIdentifier{1, 3, 101, 113} } func (*scheme) GenerateKey() (sign.PublicKey, sign.PrivateKey, error) { return GenerateKey(rand.Reader) } func (*scheme) Sign( sk sign.PrivateKey, message []byte, opts *sign.SignatureOpts, ) []byte { priv, ok := sk.(PrivateKey) if !ok { panic(sign.ErrTypeMismatch) } ctx := "" if opts != nil { ctx = opts.Context } return Sign(priv, message, ctx) } func (*scheme) Verify( pk sign.PublicKey, message, signature []byte, opts *sign.SignatureOpts, ) bool { pub, ok := pk.(PublicKey) if !ok { panic(sign.ErrTypeMismatch) } ctx := "" if opts != nil { ctx = opts.Context } return Verify(pub, message, signature, ctx) } func (*scheme) DeriveKey(seed []byte) (sign.PublicKey, sign.PrivateKey) { privateKey := NewKeyFromSeed(seed) publicKey := make(PublicKey, PublicKeySize) copy(publicKey, privateKey[SeedSize:]) return publicKey, privateKey } func (*scheme) UnmarshalBinaryPublicKey(buf []byte) (sign.PublicKey, error) { if len(buf) < PublicKeySize { return nil, sign.ErrPubKeySize } pub := make(PublicKey, PublicKeySize) copy(pub, buf[:PublicKeySize]) return pub, nil } func (*scheme) UnmarshalBinaryPrivateKey(buf []byte) (sign.PrivateKey, error) { if len(buf) < PrivateKeySize { return nil, sign.ErrPrivKeySize } priv := make(PrivateKey, PrivateKeySize) copy(priv, buf[:PrivateKeySize]) return priv, nil }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/integer.go
vendor/github.com/cloudflare/circl/math/integer.go
package math import "math/bits" // NextPow2 finds the next power of two (N=2^k, k>=0) greater than n. // If n is already a power of two, then this function returns n, and log2(n). func NextPow2(n uint) (N uint, k uint) { if bits.OnesCount(n) == 1 { k = uint(bits.TrailingZeros(n)) N = n } else { k = uint(bits.Len(n)) N = uint(1) << k } return }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/wnaf.go
vendor/github.com/cloudflare/circl/math/wnaf.go
// Package math provides some utility functions for big integers. package math import "math/big" // SignedDigit obtains the signed-digit recoding of n and returns a list L of // digits such that n = sum( L[i]*2^(i*(w-1)) ), and each L[i] is an odd number // in the set {±1, ±3, ..., ±2^(w-1)-1}. The third parameter ensures that the // output has ceil(l/(w-1)) digits. // // Restrictions: // - n is odd and n > 0. // - 1 < w < 32. // - l >= bit length of n. // // References: // - Alg.6 in "Exponent Recoding and Regular Exponentiation Algorithms" // by Joye-Tunstall. http://doi.org/10.1007/978-3-642-02384-2_21 // - Alg.6 in "Selecting Elliptic Curves for Cryptography: An Efficiency and // Security Analysis" by Bos et al. http://doi.org/10.1007/s13389-015-0097-y func SignedDigit(n *big.Int, w, l uint) []int32 { if n.Sign() <= 0 || n.Bit(0) == 0 { panic("n must be non-zero, odd, and positive") } if w <= 1 || w >= 32 { panic("Verify that 1 < w < 32") } if uint(n.BitLen()) > l { panic("n is too big to fit in l digits") } lenN := (l + (w - 1) - 1) / (w - 1) // ceil(l/(w-1)) L := make([]int32, lenN+1) var k, v big.Int k.Set(n) var i uint for i = 0; i < lenN; i++ { words := k.Bits() value := int32(words[0] & ((1 << w) - 1)) value -= int32(1) << (w - 1) L[i] = value v.SetInt64(int64(value)) k.Sub(&k, &v) k.Rsh(&k, w-1) } L[i] = int32(k.Int64()) return L } // OmegaNAF obtains the window-w Non-Adjacent Form of a positive number n and // 1 < w < 32. The returned slice L holds n = sum( L[i]*2^i ). // // Reference: // - Alg.9 "Efficient arithmetic on Koblitz curves" by Solinas. // http://doi.org/10.1023/A:1008306223194 func OmegaNAF(n *big.Int, w uint) (L []int32) { if n.Sign() < 0 { panic("n must be positive") } if w <= 1 || w >= 32 { panic("Verify that 1 < w < 32") } L = make([]int32, n.BitLen()+1) var k, v big.Int k.Set(n) i := 0 for ; k.Sign() > 0; i++ { value := int32(0) if k.Bit(0) == 1 { words := k.Bits() value = int32(words[0] & ((1 << w) - 1)) if value >= (int32(1) << (w - 1)) { value -= int32(1) << w } v.SetInt64(int64(value)) k.Sub(&k, &v) } L[i] = value k.Rsh(&k, 1) } return L[:i] }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/primes.go
vendor/github.com/cloudflare/circl/math/primes.go
package math import ( "crypto/rand" "io" "math/big" ) // IsSafePrime reports whether p is (probably) a safe prime. // The prime p=2*q+1 is safe prime if both p and q are primes. // Note that ProbablyPrime is not suitable for judging primes // that an adversary may have crafted to fool the test. func IsSafePrime(p *big.Int) bool { pdiv2 := new(big.Int).Rsh(p, 1) return p.ProbablyPrime(20) && pdiv2.ProbablyPrime(20) } // SafePrime returns a number of the given bit length that is a safe prime with high probability. // The number returned p=2*q+1 is a safe prime if both p and q are primes. // SafePrime will return error for any error returned by rand.Read or if bits < 2. func SafePrime(random io.Reader, bits int) (*big.Int, error) { one := big.NewInt(1) p := new(big.Int) for { q, err := rand.Prime(random, bits-1) if err != nil { return nil, err } p.Lsh(q, 1).Add(p, one) if p.ProbablyPrime(20) { return p, nil } } }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/mlsbset/power.go
vendor/github.com/cloudflare/circl/math/mlsbset/power.go
package mlsbset import "fmt" // Power is a valid exponent produced by the MLSBSet encoding algorithm. type Power struct { set Encoder // parameters of code. s []int32 // set of signs. b []int32 // set of digits. c int // carry is {0,1}. } // Exp is calculates x^k, where x is a predetermined element of a group G. func (p *Power) Exp(G Group) EltG { a, b := G.Identity(), G.NewEltP() for e := int(p.set.p.E - 1); e >= 0; e-- { G.Sqr(a) for v := uint(0); v < p.set.p.V; v++ { sgnElt, idElt := p.Digit(v, uint(e)) G.Lookup(b, v, sgnElt, idElt) G.Mul(a, b) } } if p.set.IsExtended() && p.c == 1 { G.Mul(a, G.ExtendedEltP()) } return a } // Digit returns the (v,e)-th digit and its sign. func (p *Power) Digit(v, e uint) (sgn, dig int32) { sgn = p.bit(0, v, e) dig = 0 for i := p.set.p.W - 1; i > 0; i-- { dig = 2*dig + p.bit(i, v, e) } mask := dig >> 31 dig = (dig + mask) ^ mask return sgn, dig } // bit returns the (w,v,e)-th bit of the code. func (p *Power) bit(w, v, e uint) int32 { if !(w < p.set.p.W && v < p.set.p.V && e < p.set.p.E) { panic(fmt.Errorf("indexes outside (%v,%v,%v)", w, v, e)) } if w == 0 { return p.s[p.set.p.E*v+e] } return p.b[p.set.p.D*(w-1)+p.set.p.E*v+e] } func (p *Power) String() string { dig := "" for j := uint(0); j < p.set.p.V; j++ { for i := uint(0); i < p.set.p.E; i++ { s, d := p.Digit(j, i) dig += fmt.Sprintf("(%2v,%2v) = %+2v %+2v\n", j, i, s, d) } } return fmt.Sprintf("len: %v\ncarry: %v\ndigits:\n%v", len(p.b)+len(p.s), p.c, dig) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/mlsbset/mlsbset.go
vendor/github.com/cloudflare/circl/math/mlsbset/mlsbset.go
// Package mlsbset provides a constant-time exponentiation method with precomputation. // // References: "Efficient and secure algorithms for GLV-based scalar // multiplication and their implementation on GLV–GLS curves" by (Faz-Hernandez et al.) // - https://doi.org/10.1007/s13389-014-0085-7 // - https://eprint.iacr.org/2013/158 package mlsbset import ( "errors" "fmt" "math/big" "github.com/cloudflare/circl/internal/conv" ) // EltG is a group element. type EltG interface{} // EltP is a precomputed group element. type EltP interface{} // Group defines the operations required by MLSBSet exponentiation method. type Group interface { Identity() EltG // Returns the identity of the group. Sqr(x EltG) // Calculates x = x^2. Mul(x EltG, y EltP) // Calculates x = x*y. NewEltP() EltP // Returns an arbitrary precomputed element. ExtendedEltP() EltP // Returns the precomputed element x^(2^(w*d)). Lookup(a EltP, v uint, s, u int32) // Sets a = s*T[v][u]. } // Params contains the parameters of the encoding. type Params struct { T uint // T is the maximum size (in bits) of exponents. V uint // V is the number of tables. W uint // W is the window size. E uint // E is the number of digits per table. D uint // D is the number of digits in total. L uint // L is the length of the code. } // Encoder allows to convert integers into valid powers. type Encoder struct{ p Params } // New produces an encoder of the MLSBSet algorithm. func New(t, v, w uint) (Encoder, error) { if !(t > 1 && v >= 1 && w >= 2) { return Encoder{}, errors.New("t>1, v>=1, w>=2") } e := (t + w*v - 1) / (w * v) d := e * v l := d * w return Encoder{Params{t, v, w, e, d, l}}, nil } // Encode converts an odd integer k into a valid power for exponentiation. func (m Encoder) Encode(k []byte) (*Power, error) { if len(k) == 0 { return nil, errors.New("empty slice") } if !(len(k) <= int(m.p.L+7)>>3) { return nil, errors.New("k too big") } if k[0]%2 == 0 { return nil, errors.New("k must be odd") } ap := int((m.p.L+7)/8) - len(k) k = append(k, make([]byte, ap)...) s := m.signs(k) b := make([]int32, m.p.L-m.p.D) c := conv.BytesLe2BigInt(k) c.Rsh(c, m.p.D) var bi big.Int for i := m.p.D; i < m.p.L; i++ { c0 := int32(c.Bit(0)) b[i-m.p.D] = s[i%m.p.D] * c0 bi.SetInt64(int64(b[i-m.p.D] >> 1)) c.Rsh(c, 1) c.Sub(c, &bi) } carry := int(c.Int64()) return &Power{m, s, b, carry}, nil } // signs calculates the set of signs. func (m Encoder) signs(k []byte) []int32 { s := make([]int32, m.p.D) s[m.p.D-1] = 1 for i := uint(1); i < m.p.D; i++ { ki := int32((k[i>>3] >> (i & 0x7)) & 0x1) s[i-1] = 2*ki - 1 } return s } // GetParams returns the complementary parameters of the encoding. func (m Encoder) GetParams() Params { return m.p } // tableSize returns the size of each table. func (m Encoder) tableSize() uint { return 1 << (m.p.W - 1) } // Elts returns the total number of elements that must be precomputed. func (m Encoder) Elts() uint { return m.p.V * m.tableSize() } // IsExtended returns true if the element x^(2^(wd)) must be calculated. func (m Encoder) IsExtended() bool { q := m.p.T / (m.p.V * m.p.W); return m.p.T == q*m.p.V*m.p.W } // Ops returns the number of squares and multiplications executed during an exponentiation. func (m Encoder) Ops() (S uint, M uint) { S = m.p.E M = m.p.E * m.p.V if m.IsExtended() { M++ } return } func (m Encoder) String() string { return fmt.Sprintf("T: %v W: %v V: %v e: %v d: %v l: %v wv|t: %v", m.p.T, m.p.W, m.p.V, m.p.E, m.p.D, m.p.L, m.IsExtended()) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/fp25519/fp_amd64.go
vendor/github.com/cloudflare/circl/math/fp25519/fp_amd64.go
//go:build amd64 && !purego // +build amd64,!purego package fp25519 import ( "golang.org/x/sys/cpu" ) var hasBmi2Adx = cpu.X86.HasBMI2 && cpu.X86.HasADX var _ = hasBmi2Adx func cmov(x, y *Elt, n uint) { cmovAmd64(x, y, n) } func cswap(x, y *Elt, n uint) { cswapAmd64(x, y, n) } func add(z, x, y *Elt) { addAmd64(z, x, y) } func sub(z, x, y *Elt) { subAmd64(z, x, y) } func addsub(x, y *Elt) { addsubAmd64(x, y) } func mul(z, x, y *Elt) { mulAmd64(z, x, y) } func sqr(z, x *Elt) { sqrAmd64(z, x) } func modp(z *Elt) { modpAmd64(z) } //go:noescape func cmovAmd64(x, y *Elt, n uint) //go:noescape func cswapAmd64(x, y *Elt, n uint) //go:noescape func addAmd64(z, x, y *Elt) //go:noescape func subAmd64(z, x, y *Elt) //go:noescape func addsubAmd64(x, y *Elt) //go:noescape func mulAmd64(z, x, y *Elt) //go:noescape func sqrAmd64(z, x *Elt) //go:noescape func modpAmd64(z *Elt)
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/fp25519/fp.go
vendor/github.com/cloudflare/circl/math/fp25519/fp.go
// Package fp25519 provides prime field arithmetic over GF(2^255-19). package fp25519 import ( "errors" "github.com/cloudflare/circl/internal/conv" ) // Size in bytes of an element. const Size = 32 // Elt is a prime field element. type Elt [Size]byte func (e Elt) String() string { return conv.BytesLe2Hex(e[:]) } // p is the prime modulus 2^255-19. var p = Elt{ 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, } // P returns the prime modulus 2^255-19. func P() Elt { return p } // ToBytes stores in b the little-endian byte representation of x. func ToBytes(b []byte, x *Elt) error { if len(b) != Size { return errors.New("wrong size") } Modp(x) copy(b, x[:]) return nil } // IsZero returns true if x is equal to 0. func IsZero(x *Elt) bool { Modp(x); return *x == Elt{} } // SetOne assigns x=1. func SetOne(x *Elt) { *x = Elt{}; x[0] = 1 } // Neg calculates z = -x. func Neg(z, x *Elt) { Sub(z, &p, x) } // InvSqrt calculates z = sqrt(x/y) iff x/y is a quadratic-residue, which is // indicated by returning isQR = true. Otherwise, when x/y is a quadratic // non-residue, z will have an undetermined value and isQR = false. func InvSqrt(z, x, y *Elt) (isQR bool) { sqrtMinusOne := &Elt{ 0xb0, 0xa0, 0x0e, 0x4a, 0x27, 0x1b, 0xee, 0xc4, 0x78, 0xe4, 0x2f, 0xad, 0x06, 0x18, 0x43, 0x2f, 0xa7, 0xd7, 0xfb, 0x3d, 0x99, 0x00, 0x4d, 0x2b, 0x0b, 0xdf, 0xc1, 0x4f, 0x80, 0x24, 0x83, 0x2b, } t0, t1, t2, t3 := &Elt{}, &Elt{}, &Elt{}, &Elt{} Mul(t0, x, y) // t0 = u*v Sqr(t1, y) // t1 = v^2 Mul(t2, t0, t1) // t2 = u*v^3 Sqr(t0, t1) // t0 = v^4 Mul(t1, t0, t2) // t1 = u*v^7 var Tab [4]*Elt Tab[0] = &Elt{} Tab[1] = &Elt{} Tab[2] = t3 Tab[3] = t1 *Tab[0] = *t1 Sqr(Tab[0], Tab[0]) Sqr(Tab[1], Tab[0]) Sqr(Tab[1], Tab[1]) Mul(Tab[1], Tab[1], Tab[3]) Mul(Tab[0], Tab[0], Tab[1]) Sqr(Tab[0], Tab[0]) Mul(Tab[0], Tab[0], Tab[1]) Sqr(Tab[1], Tab[0]) for i := 0; i < 4; i++ { Sqr(Tab[1], Tab[1]) } Mul(Tab[1], Tab[1], Tab[0]) Sqr(Tab[2], Tab[1]) for i := 0; i < 4; i++ { Sqr(Tab[2], Tab[2]) } Mul(Tab[2], Tab[2], Tab[0]) Sqr(Tab[1], Tab[2]) for i := 0; i < 14; i++ { Sqr(Tab[1], Tab[1]) } Mul(Tab[1], Tab[1], Tab[2]) Sqr(Tab[2], Tab[1]) for i := 0; i < 29; i++ { Sqr(Tab[2], Tab[2]) } Mul(Tab[2], Tab[2], Tab[1]) Sqr(Tab[1], Tab[2]) for i := 0; i < 59; i++ { Sqr(Tab[1], Tab[1]) } Mul(Tab[1], Tab[1], Tab[2]) for i := 0; i < 5; i++ { Sqr(Tab[1], Tab[1]) } Mul(Tab[1], Tab[1], Tab[0]) Sqr(Tab[2], Tab[1]) for i := 0; i < 124; i++ { Sqr(Tab[2], Tab[2]) } Mul(Tab[2], Tab[2], Tab[1]) Sqr(Tab[2], Tab[2]) Sqr(Tab[2], Tab[2]) Mul(Tab[2], Tab[2], Tab[3]) Mul(z, t3, t2) // z = xy^(p+3)/8 = xy^3*(xy^7)^(p-5)/8 // Checking whether y z^2 == x Sqr(t0, z) // t0 = z^2 Mul(t0, t0, y) // t0 = yz^2 Sub(t1, t0, x) // t1 = t0-u Add(t2, t0, x) // t2 = t0+u if IsZero(t1) { return true } else if IsZero(t2) { Mul(z, z, sqrtMinusOne) // z = z*sqrt(-1) return true } else { return false } } // Inv calculates z = 1/x mod p. func Inv(z, x *Elt) { x0, x1, x2 := &Elt{}, &Elt{}, &Elt{} Sqr(x1, x) Sqr(x0, x1) Sqr(x0, x0) Mul(x0, x0, x) Mul(z, x0, x1) Sqr(x1, z) Mul(x0, x0, x1) Sqr(x1, x0) for i := 0; i < 4; i++ { Sqr(x1, x1) } Mul(x0, x0, x1) Sqr(x1, x0) for i := 0; i < 9; i++ { Sqr(x1, x1) } Mul(x1, x1, x0) Sqr(x2, x1) for i := 0; i < 19; i++ { Sqr(x2, x2) } Mul(x2, x2, x1) for i := 0; i < 10; i++ { Sqr(x2, x2) } Mul(x2, x2, x0) Sqr(x0, x2) for i := 0; i < 49; i++ { Sqr(x0, x0) } Mul(x0, x0, x2) Sqr(x1, x0) for i := 0; i < 99; i++ { Sqr(x1, x1) } Mul(x1, x1, x0) for i := 0; i < 50; i++ { Sqr(x1, x1) } Mul(x1, x1, x2) for i := 0; i < 5; i++ { Sqr(x1, x1) } Mul(z, z, x1) } // Cmov assigns y to x if n is 1. func Cmov(x, y *Elt, n uint) { cmov(x, y, n) } // Cswap interchanges x and y if n is 1. func Cswap(x, y *Elt, n uint) { cswap(x, y, n) } // Add calculates z = x+y mod p. func Add(z, x, y *Elt) { add(z, x, y) } // Sub calculates z = x-y mod p. func Sub(z, x, y *Elt) { sub(z, x, y) } // AddSub calculates (x,y) = (x+y mod p, x-y mod p). func AddSub(x, y *Elt) { addsub(x, y) } // Mul calculates z = x*y mod p. func Mul(z, x, y *Elt) { mul(z, x, y) } // Sqr calculates z = x^2 mod p. func Sqr(z, x *Elt) { sqr(z, x) } // Modp ensures that z is between [0,p-1]. func Modp(z *Elt) { modp(z) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/fp25519/fp_noasm.go
vendor/github.com/cloudflare/circl/math/fp25519/fp_noasm.go
//go:build !amd64 || purego // +build !amd64 purego package fp25519 func cmov(x, y *Elt, n uint) { cmovGeneric(x, y, n) } func cswap(x, y *Elt, n uint) { cswapGeneric(x, y, n) } func add(z, x, y *Elt) { addGeneric(z, x, y) } func sub(z, x, y *Elt) { subGeneric(z, x, y) } func addsub(x, y *Elt) { addsubGeneric(x, y) } func mul(z, x, y *Elt) { mulGeneric(z, x, y) } func sqr(z, x *Elt) { sqrGeneric(z, x) } func modp(z *Elt) { modpGeneric(z) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/fp25519/fp_generic.go
vendor/github.com/cloudflare/circl/math/fp25519/fp_generic.go
package fp25519 import ( "encoding/binary" "math/bits" ) func cmovGeneric(x, y *Elt, n uint) { m := -uint64(n & 0x1) x0 := binary.LittleEndian.Uint64(x[0*8 : 1*8]) x1 := binary.LittleEndian.Uint64(x[1*8 : 2*8]) x2 := binary.LittleEndian.Uint64(x[2*8 : 3*8]) x3 := binary.LittleEndian.Uint64(x[3*8 : 4*8]) y0 := binary.LittleEndian.Uint64(y[0*8 : 1*8]) y1 := binary.LittleEndian.Uint64(y[1*8 : 2*8]) y2 := binary.LittleEndian.Uint64(y[2*8 : 3*8]) y3 := binary.LittleEndian.Uint64(y[3*8 : 4*8]) x0 = (x0 &^ m) | (y0 & m) x1 = (x1 &^ m) | (y1 & m) x2 = (x2 &^ m) | (y2 & m) x3 = (x3 &^ m) | (y3 & m) binary.LittleEndian.PutUint64(x[0*8:1*8], x0) binary.LittleEndian.PutUint64(x[1*8:2*8], x1) binary.LittleEndian.PutUint64(x[2*8:3*8], x2) binary.LittleEndian.PutUint64(x[3*8:4*8], x3) } func cswapGeneric(x, y *Elt, n uint) { m := -uint64(n & 0x1) x0 := binary.LittleEndian.Uint64(x[0*8 : 1*8]) x1 := binary.LittleEndian.Uint64(x[1*8 : 2*8]) x2 := binary.LittleEndian.Uint64(x[2*8 : 3*8]) x3 := binary.LittleEndian.Uint64(x[3*8 : 4*8]) y0 := binary.LittleEndian.Uint64(y[0*8 : 1*8]) y1 := binary.LittleEndian.Uint64(y[1*8 : 2*8]) y2 := binary.LittleEndian.Uint64(y[2*8 : 3*8]) y3 := binary.LittleEndian.Uint64(y[3*8 : 4*8]) t0 := m & (x0 ^ y0) t1 := m & (x1 ^ y1) t2 := m & (x2 ^ y2) t3 := m & (x3 ^ y3) x0 ^= t0 x1 ^= t1 x2 ^= t2 x3 ^= t3 y0 ^= t0 y1 ^= t1 y2 ^= t2 y3 ^= t3 binary.LittleEndian.PutUint64(x[0*8:1*8], x0) binary.LittleEndian.PutUint64(x[1*8:2*8], x1) binary.LittleEndian.PutUint64(x[2*8:3*8], x2) binary.LittleEndian.PutUint64(x[3*8:4*8], x3) binary.LittleEndian.PutUint64(y[0*8:1*8], y0) binary.LittleEndian.PutUint64(y[1*8:2*8], y1) binary.LittleEndian.PutUint64(y[2*8:3*8], y2) binary.LittleEndian.PutUint64(y[3*8:4*8], y3) } func addGeneric(z, x, y *Elt) { x0 := binary.LittleEndian.Uint64(x[0*8 : 1*8]) x1 := binary.LittleEndian.Uint64(x[1*8 : 2*8]) x2 := binary.LittleEndian.Uint64(x[2*8 : 3*8]) x3 := binary.LittleEndian.Uint64(x[3*8 : 4*8]) y0 := binary.LittleEndian.Uint64(y[0*8 : 1*8]) y1 := binary.LittleEndian.Uint64(y[1*8 : 2*8]) y2 := binary.LittleEndian.Uint64(y[2*8 : 3*8]) y3 := binary.LittleEndian.Uint64(y[3*8 : 4*8]) z0, c0 := bits.Add64(x0, y0, 0) z1, c1 := bits.Add64(x1, y1, c0) z2, c2 := bits.Add64(x2, y2, c1) z3, c3 := bits.Add64(x3, y3, c2) z0, c0 = bits.Add64(z0, (-c3)&38, 0) z1, c1 = bits.Add64(z1, 0, c0) z2, c2 = bits.Add64(z2, 0, c1) z3, c3 = bits.Add64(z3, 0, c2) z0, _ = bits.Add64(z0, (-c3)&38, 0) binary.LittleEndian.PutUint64(z[0*8:1*8], z0) binary.LittleEndian.PutUint64(z[1*8:2*8], z1) binary.LittleEndian.PutUint64(z[2*8:3*8], z2) binary.LittleEndian.PutUint64(z[3*8:4*8], z3) } func subGeneric(z, x, y *Elt) { x0 := binary.LittleEndian.Uint64(x[0*8 : 1*8]) x1 := binary.LittleEndian.Uint64(x[1*8 : 2*8]) x2 := binary.LittleEndian.Uint64(x[2*8 : 3*8]) x3 := binary.LittleEndian.Uint64(x[3*8 : 4*8]) y0 := binary.LittleEndian.Uint64(y[0*8 : 1*8]) y1 := binary.LittleEndian.Uint64(y[1*8 : 2*8]) y2 := binary.LittleEndian.Uint64(y[2*8 : 3*8]) y3 := binary.LittleEndian.Uint64(y[3*8 : 4*8]) z0, c0 := bits.Sub64(x0, y0, 0) z1, c1 := bits.Sub64(x1, y1, c0) z2, c2 := bits.Sub64(x2, y2, c1) z3, c3 := bits.Sub64(x3, y3, c2) z0, c0 = bits.Sub64(z0, (-c3)&38, 0) z1, c1 = bits.Sub64(z1, 0, c0) z2, c2 = bits.Sub64(z2, 0, c1) z3, c3 = bits.Sub64(z3, 0, c2) z0, _ = bits.Sub64(z0, (-c3)&38, 0) binary.LittleEndian.PutUint64(z[0*8:1*8], z0) binary.LittleEndian.PutUint64(z[1*8:2*8], z1) binary.LittleEndian.PutUint64(z[2*8:3*8], z2) binary.LittleEndian.PutUint64(z[3*8:4*8], z3) } func addsubGeneric(x, y *Elt) { z := &Elt{} addGeneric(z, x, y) subGeneric(y, x, y) *x = *z } func mulGeneric(z, x, y *Elt) { x0 := binary.LittleEndian.Uint64(x[0*8 : 1*8]) x1 := binary.LittleEndian.Uint64(x[1*8 : 2*8]) x2 := binary.LittleEndian.Uint64(x[2*8 : 3*8]) x3 := binary.LittleEndian.Uint64(x[3*8 : 4*8]) y0 := binary.LittleEndian.Uint64(y[0*8 : 1*8]) y1 := binary.LittleEndian.Uint64(y[1*8 : 2*8]) y2 := binary.LittleEndian.Uint64(y[2*8 : 3*8]) y3 := binary.LittleEndian.Uint64(y[3*8 : 4*8]) yi := y0 h0, l0 := bits.Mul64(x0, yi) h1, l1 := bits.Mul64(x1, yi) h2, l2 := bits.Mul64(x2, yi) h3, l3 := bits.Mul64(x3, yi) z0 := l0 a0, c0 := bits.Add64(h0, l1, 0) a1, c1 := bits.Add64(h1, l2, c0) a2, c2 := bits.Add64(h2, l3, c1) a3, _ := bits.Add64(h3, 0, c2) yi = y1 h0, l0 = bits.Mul64(x0, yi) h1, l1 = bits.Mul64(x1, yi) h2, l2 = bits.Mul64(x2, yi) h3, l3 = bits.Mul64(x3, yi) z1, c0 := bits.Add64(a0, l0, 0) h0, c1 = bits.Add64(h0, l1, c0) h1, c2 = bits.Add64(h1, l2, c1) h2, c3 := bits.Add64(h2, l3, c2) h3, _ = bits.Add64(h3, 0, c3) a0, c0 = bits.Add64(a1, h0, 0) a1, c1 = bits.Add64(a2, h1, c0) a2, c2 = bits.Add64(a3, h2, c1) a3, _ = bits.Add64(0, h3, c2) yi = y2 h0, l0 = bits.Mul64(x0, yi) h1, l1 = bits.Mul64(x1, yi) h2, l2 = bits.Mul64(x2, yi) h3, l3 = bits.Mul64(x3, yi) z2, c0 := bits.Add64(a0, l0, 0) h0, c1 = bits.Add64(h0, l1, c0) h1, c2 = bits.Add64(h1, l2, c1) h2, c3 = bits.Add64(h2, l3, c2) h3, _ = bits.Add64(h3, 0, c3) a0, c0 = bits.Add64(a1, h0, 0) a1, c1 = bits.Add64(a2, h1, c0) a2, c2 = bits.Add64(a3, h2, c1) a3, _ = bits.Add64(0, h3, c2) yi = y3 h0, l0 = bits.Mul64(x0, yi) h1, l1 = bits.Mul64(x1, yi) h2, l2 = bits.Mul64(x2, yi) h3, l3 = bits.Mul64(x3, yi) z3, c0 := bits.Add64(a0, l0, 0) h0, c1 = bits.Add64(h0, l1, c0) h1, c2 = bits.Add64(h1, l2, c1) h2, c3 = bits.Add64(h2, l3, c2) h3, _ = bits.Add64(h3, 0, c3) z4, c0 := bits.Add64(a1, h0, 0) z5, c1 := bits.Add64(a2, h1, c0) z6, c2 := bits.Add64(a3, h2, c1) z7, _ := bits.Add64(0, h3, c2) red64(z, z0, z1, z2, z3, z4, z5, z6, z7) } func sqrGeneric(z, x *Elt) { x0 := binary.LittleEndian.Uint64(x[0*8 : 1*8]) x1 := binary.LittleEndian.Uint64(x[1*8 : 2*8]) x2 := binary.LittleEndian.Uint64(x[2*8 : 3*8]) x3 := binary.LittleEndian.Uint64(x[3*8 : 4*8]) h0, a0 := bits.Mul64(x0, x1) h1, l1 := bits.Mul64(x0, x2) h2, l2 := bits.Mul64(x0, x3) h3, l3 := bits.Mul64(x3, x1) h4, l4 := bits.Mul64(x3, x2) h, l := bits.Mul64(x1, x2) a1, c0 := bits.Add64(l1, h0, 0) a2, c1 := bits.Add64(l2, h1, c0) a3, c2 := bits.Add64(l3, h2, c1) a4, c3 := bits.Add64(l4, h3, c2) a5, _ := bits.Add64(h4, 0, c3) a2, c0 = bits.Add64(a2, l, 0) a3, c1 = bits.Add64(a3, h, c0) a4, c2 = bits.Add64(a4, 0, c1) a5, c3 = bits.Add64(a5, 0, c2) a6, _ := bits.Add64(0, 0, c3) a0, c0 = bits.Add64(a0, a0, 0) a1, c1 = bits.Add64(a1, a1, c0) a2, c2 = bits.Add64(a2, a2, c1) a3, c3 = bits.Add64(a3, a3, c2) a4, c4 := bits.Add64(a4, a4, c3) a5, c5 := bits.Add64(a5, a5, c4) a6, _ = bits.Add64(a6, a6, c5) b1, b0 := bits.Mul64(x0, x0) b3, b2 := bits.Mul64(x1, x1) b5, b4 := bits.Mul64(x2, x2) b7, b6 := bits.Mul64(x3, x3) b1, c0 = bits.Add64(b1, a0, 0) b2, c1 = bits.Add64(b2, a1, c0) b3, c2 = bits.Add64(b3, a2, c1) b4, c3 = bits.Add64(b4, a3, c2) b5, c4 = bits.Add64(b5, a4, c3) b6, c5 = bits.Add64(b6, a5, c4) b7, _ = bits.Add64(b7, a6, c5) red64(z, b0, b1, b2, b3, b4, b5, b6, b7) } func modpGeneric(x *Elt) { x0 := binary.LittleEndian.Uint64(x[0*8 : 1*8]) x1 := binary.LittleEndian.Uint64(x[1*8 : 2*8]) x2 := binary.LittleEndian.Uint64(x[2*8 : 3*8]) x3 := binary.LittleEndian.Uint64(x[3*8 : 4*8]) // CX = C[255] ? 38 : 19 cx := uint64(19) << (x3 >> 63) // PUT BIT 255 IN CARRY FLAG AND CLEAR x3 &^= 1 << 63 x0, c0 := bits.Add64(x0, cx, 0) x1, c1 := bits.Add64(x1, 0, c0) x2, c2 := bits.Add64(x2, 0, c1) x3, _ = bits.Add64(x3, 0, c2) // TEST FOR BIT 255 AGAIN; ONLY TRIGGERED ON OVERFLOW MODULO 2^255-19 // cx = C[255] ? 0 : 19 cx = uint64(19) &^ (-(x3 >> 63)) // CLEAR BIT 255 x3 &^= 1 << 63 x0, c0 = bits.Sub64(x0, cx, 0) x1, c1 = bits.Sub64(x1, 0, c0) x2, c2 = bits.Sub64(x2, 0, c1) x3, _ = bits.Sub64(x3, 0, c2) binary.LittleEndian.PutUint64(x[0*8:1*8], x0) binary.LittleEndian.PutUint64(x[1*8:2*8], x1) binary.LittleEndian.PutUint64(x[2*8:3*8], x2) binary.LittleEndian.PutUint64(x[3*8:4*8], x3) } func red64(z *Elt, x0, x1, x2, x3, x4, x5, x6, x7 uint64) { h0, l0 := bits.Mul64(x4, 38) h1, l1 := bits.Mul64(x5, 38) h2, l2 := bits.Mul64(x6, 38) h3, l3 := bits.Mul64(x7, 38) l1, c0 := bits.Add64(h0, l1, 0) l2, c1 := bits.Add64(h1, l2, c0) l3, c2 := bits.Add64(h2, l3, c1) l4, _ := bits.Add64(h3, 0, c2) l0, c0 = bits.Add64(l0, x0, 0) l1, c1 = bits.Add64(l1, x1, c0) l2, c2 = bits.Add64(l2, x2, c1) l3, c3 := bits.Add64(l3, x3, c2) l4, _ = bits.Add64(l4, 0, c3) _, l4 = bits.Mul64(l4, 38) l0, c0 = bits.Add64(l0, l4, 0) z1, c1 := bits.Add64(l1, 0, c0) z2, c2 := bits.Add64(l2, 0, c1) z3, c3 := bits.Add64(l3, 0, c2) z0, _ := bits.Add64(l0, (-c3)&38, 0) binary.LittleEndian.PutUint64(z[0*8:1*8], z0) binary.LittleEndian.PutUint64(z[1*8:2*8], z1) binary.LittleEndian.PutUint64(z[2*8:3*8], z2) binary.LittleEndian.PutUint64(z[3*8:4*8], z3) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/fp448/fp_amd64.go
vendor/github.com/cloudflare/circl/math/fp448/fp_amd64.go
//go:build amd64 && !purego // +build amd64,!purego package fp448 import ( "golang.org/x/sys/cpu" ) var hasBmi2Adx = cpu.X86.HasBMI2 && cpu.X86.HasADX var _ = hasBmi2Adx func cmov(x, y *Elt, n uint) { cmovAmd64(x, y, n) } func cswap(x, y *Elt, n uint) { cswapAmd64(x, y, n) } func add(z, x, y *Elt) { addAmd64(z, x, y) } func sub(z, x, y *Elt) { subAmd64(z, x, y) } func addsub(x, y *Elt) { addsubAmd64(x, y) } func mul(z, x, y *Elt) { mulAmd64(z, x, y) } func sqr(z, x *Elt) { sqrAmd64(z, x) } /* Functions defined in fp_amd64.s */ //go:noescape func cmovAmd64(x, y *Elt, n uint) //go:noescape func cswapAmd64(x, y *Elt, n uint) //go:noescape func addAmd64(z, x, y *Elt) //go:noescape func subAmd64(z, x, y *Elt) //go:noescape func addsubAmd64(x, y *Elt) //go:noescape func mulAmd64(z, x, y *Elt) //go:noescape func sqrAmd64(z, x *Elt)
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/fp448/fp.go
vendor/github.com/cloudflare/circl/math/fp448/fp.go
// Package fp448 provides prime field arithmetic over GF(2^448-2^224-1). package fp448 import ( "errors" "github.com/cloudflare/circl/internal/conv" ) // Size in bytes of an element. const Size = 56 // Elt is a prime field element. type Elt [Size]byte func (e Elt) String() string { return conv.BytesLe2Hex(e[:]) } // p is the prime modulus 2^448-2^224-1. var p = Elt{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, } // P returns the prime modulus 2^448-2^224-1. func P() Elt { return p } // ToBytes stores in b the little-endian byte representation of x. func ToBytes(b []byte, x *Elt) error { if len(b) != Size { return errors.New("wrong size") } Modp(x) copy(b, x[:]) return nil } // IsZero returns true if x is equal to 0. func IsZero(x *Elt) bool { Modp(x); return *x == Elt{} } // IsOne returns true if x is equal to 1. func IsOne(x *Elt) bool { Modp(x); return *x == Elt{1} } // SetOne assigns x=1. func SetOne(x *Elt) { *x = Elt{1} } // One returns the 1 element. func One() (x Elt) { x = Elt{1}; return } // Neg calculates z = -x. func Neg(z, x *Elt) { Sub(z, &p, x) } // Modp ensures that z is between [0,p-1]. func Modp(z *Elt) { Sub(z, z, &p) } // InvSqrt calculates z = sqrt(x/y) iff x/y is a quadratic-residue. If so, // isQR = true; otherwise, isQR = false, since x/y is a quadratic non-residue, // and z = sqrt(-x/y). func InvSqrt(z, x, y *Elt) (isQR bool) { // First note that x^(2(k+1)) = x^(p-1)/2 * x = legendre(x) * x // so that's x if x is a quadratic residue and -x otherwise. // Next, y^(6k+3) = y^(4k+2) * y^(2k+1) = y^(p-1) * y^((p-1)/2) = legendre(y). // So the z we compute satisfies z^2 y = x^(2(k+1)) y^(6k+3) = legendre(x)*legendre(y). // Thus if x and y are quadratic residues, then z is indeed sqrt(x/y). t0, t1 := &Elt{}, &Elt{} Mul(t0, x, y) // x*y Sqr(t1, y) // y^2 Mul(t1, t0, t1) // x*y^3 powPminus3div4(z, t1) // (x*y^3)^k Mul(z, z, t0) // z = x*y*(x*y^3)^k = x^(k+1) * y^(3k+1) // Check if x/y is a quadratic residue Sqr(t0, z) // z^2 Mul(t0, t0, y) // y*z^2 Sub(t0, t0, x) // y*z^2-x return IsZero(t0) } // Inv calculates z = 1/x mod p. func Inv(z, x *Elt) { // Calculates z = x^(4k+1) = x^(p-3+1) = x^(p-2) = x^-1, where k = (p-3)/4. t := &Elt{} powPminus3div4(t, x) // t = x^k Sqr(t, t) // t = x^2k Sqr(t, t) // t = x^4k Mul(z, t, x) // z = x^(4k+1) } // powPminus3div4 calculates z = x^k mod p, where k = (p-3)/4. func powPminus3div4(z, x *Elt) { x0, x1 := &Elt{}, &Elt{} Sqr(z, x) Mul(z, z, x) Sqr(x0, z) Mul(x0, x0, x) Sqr(z, x0) Sqr(z, z) Sqr(z, z) Mul(z, z, x0) Sqr(x1, z) for i := 0; i < 5; i++ { Sqr(x1, x1) } Mul(x1, x1, z) Sqr(z, x1) for i := 0; i < 11; i++ { Sqr(z, z) } Mul(z, z, x1) Sqr(z, z) Sqr(z, z) Sqr(z, z) Mul(z, z, x0) Sqr(x1, z) for i := 0; i < 26; i++ { Sqr(x1, x1) } Mul(x1, x1, z) Sqr(z, x1) for i := 0; i < 53; i++ { Sqr(z, z) } Mul(z, z, x1) Sqr(z, z) Sqr(z, z) Sqr(z, z) Mul(z, z, x0) Sqr(x1, z) for i := 0; i < 110; i++ { Sqr(x1, x1) } Mul(x1, x1, z) Sqr(z, x1) Mul(z, z, x) for i := 0; i < 223; i++ { Sqr(z, z) } Mul(z, z, x1) } // Cmov assigns y to x if n is 1. func Cmov(x, y *Elt, n uint) { cmov(x, y, n) } // Cswap interchanges x and y if n is 1. func Cswap(x, y *Elt, n uint) { cswap(x, y, n) } // Add calculates z = x+y mod p. func Add(z, x, y *Elt) { add(z, x, y) } // Sub calculates z = x-y mod p. func Sub(z, x, y *Elt) { sub(z, x, y) } // AddSub calculates (x,y) = (x+y mod p, x-y mod p). func AddSub(x, y *Elt) { addsub(x, y) } // Mul calculates z = x*y mod p. func Mul(z, x, y *Elt) { mul(z, x, y) } // Sqr calculates z = x^2 mod p. func Sqr(z, x *Elt) { sqr(z, x) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/fp448/fuzzer.go
vendor/github.com/cloudflare/circl/math/fp448/fuzzer.go
//go:build gofuzz // +build gofuzz // How to run the fuzzer: // // $ go get -u github.com/dvyukov/go-fuzz/go-fuzz // $ go get -u github.com/dvyukov/go-fuzz/go-fuzz-build // $ go-fuzz-build -libfuzzer -func FuzzReduction -o lib.a // $ clang -fsanitize=fuzzer lib.a -o fu.exe // $ ./fu.exe package fp448 import ( "encoding/binary" "fmt" "math/big" "github.com/cloudflare/circl/internal/conv" ) // FuzzReduction is a fuzzer target for red64 function, which reduces t // (112 bits) to a number t' (56 bits) congruent modulo p448. func FuzzReduction(data []byte) int { if len(data) != 2*Size { return -1 } var got, want Elt var lo, hi [7]uint64 a := data[:Size] b := data[Size:] lo[0] = binary.LittleEndian.Uint64(a[0*8 : 1*8]) lo[1] = binary.LittleEndian.Uint64(a[1*8 : 2*8]) lo[2] = binary.LittleEndian.Uint64(a[2*8 : 3*8]) lo[3] = binary.LittleEndian.Uint64(a[3*8 : 4*8]) lo[4] = binary.LittleEndian.Uint64(a[4*8 : 5*8]) lo[5] = binary.LittleEndian.Uint64(a[5*8 : 6*8]) lo[6] = binary.LittleEndian.Uint64(a[6*8 : 7*8]) hi[0] = binary.LittleEndian.Uint64(b[0*8 : 1*8]) hi[1] = binary.LittleEndian.Uint64(b[1*8 : 2*8]) hi[2] = binary.LittleEndian.Uint64(b[2*8 : 3*8]) hi[3] = binary.LittleEndian.Uint64(b[3*8 : 4*8]) hi[4] = binary.LittleEndian.Uint64(b[4*8 : 5*8]) hi[5] = binary.LittleEndian.Uint64(b[5*8 : 6*8]) hi[6] = binary.LittleEndian.Uint64(b[6*8 : 7*8]) red64(&got, &lo, &hi) t := conv.BytesLe2BigInt(data[:2*Size]) two448 := big.NewInt(1) two448.Lsh(two448, 448) // 2^448 mask448 := big.NewInt(1) mask448.Sub(two448, mask448) // 2^448-1 two224plus1 := big.NewInt(1) two224plus1.Lsh(two224plus1, 224) two224plus1.Add(two224plus1, big.NewInt(1)) // 2^224+1 var loBig, hiBig big.Int for t.Cmp(two448) >= 0 { loBig.And(t, mask448) hiBig.Rsh(t, 448) t.Mul(&hiBig, two224plus1) t.Add(t, &loBig) } conv.BigInt2BytesLe(want[:], t) if got != want { fmt.Printf("in: %v\n", conv.BytesLe2BigInt(data[:2*Size])) fmt.Printf("got: %v\n", got) fmt.Printf("want: %v\n", want) panic("error found") } return 1 }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/fp448/fp_noasm.go
vendor/github.com/cloudflare/circl/math/fp448/fp_noasm.go
//go:build !amd64 || purego // +build !amd64 purego package fp448 func cmov(x, y *Elt, n uint) { cmovGeneric(x, y, n) } func cswap(x, y *Elt, n uint) { cswapGeneric(x, y, n) } func add(z, x, y *Elt) { addGeneric(z, x, y) } func sub(z, x, y *Elt) { subGeneric(z, x, y) } func addsub(x, y *Elt) { addsubGeneric(x, y) } func mul(z, x, y *Elt) { mulGeneric(z, x, y) } func sqr(z, x *Elt) { sqrGeneric(z, x) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/math/fp448/fp_generic.go
vendor/github.com/cloudflare/circl/math/fp448/fp_generic.go
package fp448 import ( "encoding/binary" "math/bits" ) func cmovGeneric(x, y *Elt, n uint) { m := -uint64(n & 0x1) x0 := binary.LittleEndian.Uint64(x[0*8 : 1*8]) x1 := binary.LittleEndian.Uint64(x[1*8 : 2*8]) x2 := binary.LittleEndian.Uint64(x[2*8 : 3*8]) x3 := binary.LittleEndian.Uint64(x[3*8 : 4*8]) x4 := binary.LittleEndian.Uint64(x[4*8 : 5*8]) x5 := binary.LittleEndian.Uint64(x[5*8 : 6*8]) x6 := binary.LittleEndian.Uint64(x[6*8 : 7*8]) y0 := binary.LittleEndian.Uint64(y[0*8 : 1*8]) y1 := binary.LittleEndian.Uint64(y[1*8 : 2*8]) y2 := binary.LittleEndian.Uint64(y[2*8 : 3*8]) y3 := binary.LittleEndian.Uint64(y[3*8 : 4*8]) y4 := binary.LittleEndian.Uint64(y[4*8 : 5*8]) y5 := binary.LittleEndian.Uint64(y[5*8 : 6*8]) y6 := binary.LittleEndian.Uint64(y[6*8 : 7*8]) x0 = (x0 &^ m) | (y0 & m) x1 = (x1 &^ m) | (y1 & m) x2 = (x2 &^ m) | (y2 & m) x3 = (x3 &^ m) | (y3 & m) x4 = (x4 &^ m) | (y4 & m) x5 = (x5 &^ m) | (y5 & m) x6 = (x6 &^ m) | (y6 & m) binary.LittleEndian.PutUint64(x[0*8:1*8], x0) binary.LittleEndian.PutUint64(x[1*8:2*8], x1) binary.LittleEndian.PutUint64(x[2*8:3*8], x2) binary.LittleEndian.PutUint64(x[3*8:4*8], x3) binary.LittleEndian.PutUint64(x[4*8:5*8], x4) binary.LittleEndian.PutUint64(x[5*8:6*8], x5) binary.LittleEndian.PutUint64(x[6*8:7*8], x6) } func cswapGeneric(x, y *Elt, n uint) { m := -uint64(n & 0x1) x0 := binary.LittleEndian.Uint64(x[0*8 : 1*8]) x1 := binary.LittleEndian.Uint64(x[1*8 : 2*8]) x2 := binary.LittleEndian.Uint64(x[2*8 : 3*8]) x3 := binary.LittleEndian.Uint64(x[3*8 : 4*8]) x4 := binary.LittleEndian.Uint64(x[4*8 : 5*8]) x5 := binary.LittleEndian.Uint64(x[5*8 : 6*8]) x6 := binary.LittleEndian.Uint64(x[6*8 : 7*8]) y0 := binary.LittleEndian.Uint64(y[0*8 : 1*8]) y1 := binary.LittleEndian.Uint64(y[1*8 : 2*8]) y2 := binary.LittleEndian.Uint64(y[2*8 : 3*8]) y3 := binary.LittleEndian.Uint64(y[3*8 : 4*8]) y4 := binary.LittleEndian.Uint64(y[4*8 : 5*8]) y5 := binary.LittleEndian.Uint64(y[5*8 : 6*8]) y6 := binary.LittleEndian.Uint64(y[6*8 : 7*8]) t0 := m & (x0 ^ y0) t1 := m & (x1 ^ y1) t2 := m & (x2 ^ y2) t3 := m & (x3 ^ y3) t4 := m & (x4 ^ y4) t5 := m & (x5 ^ y5) t6 := m & (x6 ^ y6) x0 ^= t0 x1 ^= t1 x2 ^= t2 x3 ^= t3 x4 ^= t4 x5 ^= t5 x6 ^= t6 y0 ^= t0 y1 ^= t1 y2 ^= t2 y3 ^= t3 y4 ^= t4 y5 ^= t5 y6 ^= t6 binary.LittleEndian.PutUint64(x[0*8:1*8], x0) binary.LittleEndian.PutUint64(x[1*8:2*8], x1) binary.LittleEndian.PutUint64(x[2*8:3*8], x2) binary.LittleEndian.PutUint64(x[3*8:4*8], x3) binary.LittleEndian.PutUint64(x[4*8:5*8], x4) binary.LittleEndian.PutUint64(x[5*8:6*8], x5) binary.LittleEndian.PutUint64(x[6*8:7*8], x6) binary.LittleEndian.PutUint64(y[0*8:1*8], y0) binary.LittleEndian.PutUint64(y[1*8:2*8], y1) binary.LittleEndian.PutUint64(y[2*8:3*8], y2) binary.LittleEndian.PutUint64(y[3*8:4*8], y3) binary.LittleEndian.PutUint64(y[4*8:5*8], y4) binary.LittleEndian.PutUint64(y[5*8:6*8], y5) binary.LittleEndian.PutUint64(y[6*8:7*8], y6) } func addGeneric(z, x, y *Elt) { x0 := binary.LittleEndian.Uint64(x[0*8 : 1*8]) x1 := binary.LittleEndian.Uint64(x[1*8 : 2*8]) x2 := binary.LittleEndian.Uint64(x[2*8 : 3*8]) x3 := binary.LittleEndian.Uint64(x[3*8 : 4*8]) x4 := binary.LittleEndian.Uint64(x[4*8 : 5*8]) x5 := binary.LittleEndian.Uint64(x[5*8 : 6*8]) x6 := binary.LittleEndian.Uint64(x[6*8 : 7*8]) y0 := binary.LittleEndian.Uint64(y[0*8 : 1*8]) y1 := binary.LittleEndian.Uint64(y[1*8 : 2*8]) y2 := binary.LittleEndian.Uint64(y[2*8 : 3*8]) y3 := binary.LittleEndian.Uint64(y[3*8 : 4*8]) y4 := binary.LittleEndian.Uint64(y[4*8 : 5*8]) y5 := binary.LittleEndian.Uint64(y[5*8 : 6*8]) y6 := binary.LittleEndian.Uint64(y[6*8 : 7*8]) z0, c0 := bits.Add64(x0, y0, 0) z1, c1 := bits.Add64(x1, y1, c0) z2, c2 := bits.Add64(x2, y2, c1) z3, c3 := bits.Add64(x3, y3, c2) z4, c4 := bits.Add64(x4, y4, c3) z5, c5 := bits.Add64(x5, y5, c4) z6, z7 := bits.Add64(x6, y6, c5) z0, c0 = bits.Add64(z0, z7, 0) z1, c1 = bits.Add64(z1, 0, c0) z2, c2 = bits.Add64(z2, 0, c1) z3, c3 = bits.Add64(z3, z7<<32, c2) z4, c4 = bits.Add64(z4, 0, c3) z5, c5 = bits.Add64(z5, 0, c4) z6, z7 = bits.Add64(z6, 0, c5) z0, c0 = bits.Add64(z0, z7, 0) z1, c1 = bits.Add64(z1, 0, c0) z2, c2 = bits.Add64(z2, 0, c1) z3, c3 = bits.Add64(z3, z7<<32, c2) z4, c4 = bits.Add64(z4, 0, c3) z5, c5 = bits.Add64(z5, 0, c4) z6, _ = bits.Add64(z6, 0, c5) binary.LittleEndian.PutUint64(z[0*8:1*8], z0) binary.LittleEndian.PutUint64(z[1*8:2*8], z1) binary.LittleEndian.PutUint64(z[2*8:3*8], z2) binary.LittleEndian.PutUint64(z[3*8:4*8], z3) binary.LittleEndian.PutUint64(z[4*8:5*8], z4) binary.LittleEndian.PutUint64(z[5*8:6*8], z5) binary.LittleEndian.PutUint64(z[6*8:7*8], z6) } func subGeneric(z, x, y *Elt) { x0 := binary.LittleEndian.Uint64(x[0*8 : 1*8]) x1 := binary.LittleEndian.Uint64(x[1*8 : 2*8]) x2 := binary.LittleEndian.Uint64(x[2*8 : 3*8]) x3 := binary.LittleEndian.Uint64(x[3*8 : 4*8]) x4 := binary.LittleEndian.Uint64(x[4*8 : 5*8]) x5 := binary.LittleEndian.Uint64(x[5*8 : 6*8]) x6 := binary.LittleEndian.Uint64(x[6*8 : 7*8]) y0 := binary.LittleEndian.Uint64(y[0*8 : 1*8]) y1 := binary.LittleEndian.Uint64(y[1*8 : 2*8]) y2 := binary.LittleEndian.Uint64(y[2*8 : 3*8]) y3 := binary.LittleEndian.Uint64(y[3*8 : 4*8]) y4 := binary.LittleEndian.Uint64(y[4*8 : 5*8]) y5 := binary.LittleEndian.Uint64(y[5*8 : 6*8]) y6 := binary.LittleEndian.Uint64(y[6*8 : 7*8]) z0, c0 := bits.Sub64(x0, y0, 0) z1, c1 := bits.Sub64(x1, y1, c0) z2, c2 := bits.Sub64(x2, y2, c1) z3, c3 := bits.Sub64(x3, y3, c2) z4, c4 := bits.Sub64(x4, y4, c3) z5, c5 := bits.Sub64(x5, y5, c4) z6, z7 := bits.Sub64(x6, y6, c5) z0, c0 = bits.Sub64(z0, z7, 0) z1, c1 = bits.Sub64(z1, 0, c0) z2, c2 = bits.Sub64(z2, 0, c1) z3, c3 = bits.Sub64(z3, z7<<32, c2) z4, c4 = bits.Sub64(z4, 0, c3) z5, c5 = bits.Sub64(z5, 0, c4) z6, z7 = bits.Sub64(z6, 0, c5) z0, c0 = bits.Sub64(z0, z7, 0) z1, c1 = bits.Sub64(z1, 0, c0) z2, c2 = bits.Sub64(z2, 0, c1) z3, c3 = bits.Sub64(z3, z7<<32, c2) z4, c4 = bits.Sub64(z4, 0, c3) z5, c5 = bits.Sub64(z5, 0, c4) z6, _ = bits.Sub64(z6, 0, c5) binary.LittleEndian.PutUint64(z[0*8:1*8], z0) binary.LittleEndian.PutUint64(z[1*8:2*8], z1) binary.LittleEndian.PutUint64(z[2*8:3*8], z2) binary.LittleEndian.PutUint64(z[3*8:4*8], z3) binary.LittleEndian.PutUint64(z[4*8:5*8], z4) binary.LittleEndian.PutUint64(z[5*8:6*8], z5) binary.LittleEndian.PutUint64(z[6*8:7*8], z6) } func addsubGeneric(x, y *Elt) { z := &Elt{} addGeneric(z, x, y) subGeneric(y, x, y) *x = *z } func mulGeneric(z, x, y *Elt) { x0 := binary.LittleEndian.Uint64(x[0*8 : 1*8]) x1 := binary.LittleEndian.Uint64(x[1*8 : 2*8]) x2 := binary.LittleEndian.Uint64(x[2*8 : 3*8]) x3 := binary.LittleEndian.Uint64(x[3*8 : 4*8]) x4 := binary.LittleEndian.Uint64(x[4*8 : 5*8]) x5 := binary.LittleEndian.Uint64(x[5*8 : 6*8]) x6 := binary.LittleEndian.Uint64(x[6*8 : 7*8]) y0 := binary.LittleEndian.Uint64(y[0*8 : 1*8]) y1 := binary.LittleEndian.Uint64(y[1*8 : 2*8]) y2 := binary.LittleEndian.Uint64(y[2*8 : 3*8]) y3 := binary.LittleEndian.Uint64(y[3*8 : 4*8]) y4 := binary.LittleEndian.Uint64(y[4*8 : 5*8]) y5 := binary.LittleEndian.Uint64(y[5*8 : 6*8]) y6 := binary.LittleEndian.Uint64(y[6*8 : 7*8]) yy := [7]uint64{y0, y1, y2, y3, y4, y5, y6} zz := [7]uint64{} yi := yy[0] h0, l0 := bits.Mul64(x0, yi) h1, l1 := bits.Mul64(x1, yi) h2, l2 := bits.Mul64(x2, yi) h3, l3 := bits.Mul64(x3, yi) h4, l4 := bits.Mul64(x4, yi) h5, l5 := bits.Mul64(x5, yi) h6, l6 := bits.Mul64(x6, yi) zz[0] = l0 a0, c0 := bits.Add64(h0, l1, 0) a1, c1 := bits.Add64(h1, l2, c0) a2, c2 := bits.Add64(h2, l3, c1) a3, c3 := bits.Add64(h3, l4, c2) a4, c4 := bits.Add64(h4, l5, c3) a5, c5 := bits.Add64(h5, l6, c4) a6, _ := bits.Add64(h6, 0, c5) for i := 1; i < 7; i++ { yi = yy[i] h0, l0 = bits.Mul64(x0, yi) h1, l1 = bits.Mul64(x1, yi) h2, l2 = bits.Mul64(x2, yi) h3, l3 = bits.Mul64(x3, yi) h4, l4 = bits.Mul64(x4, yi) h5, l5 = bits.Mul64(x5, yi) h6, l6 = bits.Mul64(x6, yi) zz[i], c0 = bits.Add64(a0, l0, 0) a0, c1 = bits.Add64(a1, l1, c0) a1, c2 = bits.Add64(a2, l2, c1) a2, c3 = bits.Add64(a3, l3, c2) a3, c4 = bits.Add64(a4, l4, c3) a4, c5 = bits.Add64(a5, l5, c4) a5, a6 = bits.Add64(a6, l6, c5) a0, c0 = bits.Add64(a0, h0, 0) a1, c1 = bits.Add64(a1, h1, c0) a2, c2 = bits.Add64(a2, h2, c1) a3, c3 = bits.Add64(a3, h3, c2) a4, c4 = bits.Add64(a4, h4, c3) a5, c5 = bits.Add64(a5, h5, c4) a6, _ = bits.Add64(a6, h6, c5) } red64(z, &zz, &[7]uint64{a0, a1, a2, a3, a4, a5, a6}) } func sqrGeneric(z, x *Elt) { mulGeneric(z, x, x) } func red64(z *Elt, l, h *[7]uint64) { /* (2C13, 2C12, 2C11, 2C10|C10, C9, C8, C7) + (C6,...,C0) */ h0 := h[0] h1 := h[1] h2 := h[2] h3 := ((h[3] & (0xFFFFFFFF << 32)) << 1) | (h[3] & 0xFFFFFFFF) h4 := (h[3] >> 63) | (h[4] << 1) h5 := (h[4] >> 63) | (h[5] << 1) h6 := (h[5] >> 63) | (h[6] << 1) h7 := (h[6] >> 63) l0, c0 := bits.Add64(h0, l[0], 0) l1, c1 := bits.Add64(h1, l[1], c0) l2, c2 := bits.Add64(h2, l[2], c1) l3, c3 := bits.Add64(h3, l[3], c2) l4, c4 := bits.Add64(h4, l[4], c3) l5, c5 := bits.Add64(h5, l[5], c4) l6, c6 := bits.Add64(h6, l[6], c5) l7, _ := bits.Add64(h7, 0, c6) /* (C10C9, C9C8,C8C7,C7C13,C13C12,C12C11,C11C10) + (C6,...,C0) */ h0 = (h[3] >> 32) | (h[4] << 32) h1 = (h[4] >> 32) | (h[5] << 32) h2 = (h[5] >> 32) | (h[6] << 32) h3 = (h[6] >> 32) | (h[0] << 32) h4 = (h[0] >> 32) | (h[1] << 32) h5 = (h[1] >> 32) | (h[2] << 32) h6 = (h[2] >> 32) | (h[3] << 32) l0, c0 = bits.Add64(l0, h0, 0) l1, c1 = bits.Add64(l1, h1, c0) l2, c2 = bits.Add64(l2, h2, c1) l3, c3 = bits.Add64(l3, h3, c2) l4, c4 = bits.Add64(l4, h4, c3) l5, c5 = bits.Add64(l5, h5, c4) l6, c6 = bits.Add64(l6, h6, c5) l7, _ = bits.Add64(l7, 0, c6) /* (C7) + (C6,...,C0) */ l0, c0 = bits.Add64(l0, l7, 0) l1, c1 = bits.Add64(l1, 0, c0) l2, c2 = bits.Add64(l2, 0, c1) l3, c3 = bits.Add64(l3, l7<<32, c2) l4, c4 = bits.Add64(l4, 0, c3) l5, c5 = bits.Add64(l5, 0, c4) l6, l7 = bits.Add64(l6, 0, c5) /* (C7) + (C6,...,C0) */ l0, c0 = bits.Add64(l0, l7, 0) l1, c1 = bits.Add64(l1, 0, c0) l2, c2 = bits.Add64(l2, 0, c1) l3, c3 = bits.Add64(l3, l7<<32, c2) l4, c4 = bits.Add64(l4, 0, c3) l5, c5 = bits.Add64(l5, 0, c4) l6, _ = bits.Add64(l6, 0, c5) binary.LittleEndian.PutUint64(z[0*8:1*8], l0) binary.LittleEndian.PutUint64(z[1*8:2*8], l1) binary.LittleEndian.PutUint64(z[2*8:3*8], l2) binary.LittleEndian.PutUint64(z[3*8:4*8], l3) binary.LittleEndian.PutUint64(z[4*8:5*8], l4) binary.LittleEndian.PutUint64(z[5*8:6*8], l5) binary.LittleEndian.PutUint64(z[6*8:7*8], l6) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x25519/curve.go
vendor/github.com/cloudflare/circl/dh/x25519/curve.go
package x25519 import ( fp "github.com/cloudflare/circl/math/fp25519" ) // ladderJoye calculates a fixed-point multiplication with the generator point. // The algorithm is the right-to-left Joye's ladder as described // in "How to precompute a ladder" in SAC'2017. func ladderJoye(k *Key) { w := [5]fp.Elt{} // [mu,x1,z1,x2,z2] order must be preserved. fp.SetOne(&w[1]) // x1 = 1 fp.SetOne(&w[2]) // z1 = 1 w[3] = fp.Elt{ // x2 = G-S 0xbd, 0xaa, 0x2f, 0xc8, 0xfe, 0xe1, 0x94, 0x7e, 0xf8, 0xed, 0xb2, 0x14, 0xae, 0x95, 0xf0, 0xbb, 0xe2, 0x48, 0x5d, 0x23, 0xb9, 0xa0, 0xc7, 0xad, 0x34, 0xab, 0x7c, 0xe2, 0xee, 0xcd, 0xae, 0x1e, } fp.SetOne(&w[4]) // z2 = 1 const n = 255 const h = 3 swap := uint(1) for s := 0; s < n-h; s++ { i := (s + h) / 8 j := (s + h) % 8 bit := uint((k[i] >> uint(j)) & 1) copy(w[0][:], tableGenerator[s*Size:(s+1)*Size]) diffAdd(&w, swap^bit) swap = bit } for s := 0; s < h; s++ { double(&w[1], &w[2]) } toAffine((*[fp.Size]byte)(k), &w[1], &w[2]) } // ladderMontgomery calculates a generic scalar point multiplication // The algorithm implemented is the left-to-right Montgomery's ladder. func ladderMontgomery(k, xP *Key) { w := [5]fp.Elt{} // [x1, x2, z2, x3, z3] order must be preserved. w[0] = *(*fp.Elt)(xP) // x1 = xP fp.SetOne(&w[1]) // x2 = 1 w[3] = *(*fp.Elt)(xP) // x3 = xP fp.SetOne(&w[4]) // z3 = 1 move := uint(0) for s := 255 - 1; s >= 0; s-- { i := s / 8 j := s % 8 bit := uint((k[i] >> uint(j)) & 1) ladderStep(&w, move^bit) move = bit } toAffine((*[fp.Size]byte)(k), &w[1], &w[2]) } func toAffine(k *[fp.Size]byte, x, z *fp.Elt) { fp.Inv(z, z) fp.Mul(x, x, z) _ = fp.ToBytes(k[:], x) } var lowOrderPoints = [5]fp.Elt{ { /* (0,_,1) point of order 2 on Curve25519 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, { /* (1,_,1) point of order 4 on Curve25519 */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, { /* (x,_,1) first point of order 8 on Curve25519 */ 0xe0, 0xeb, 0x7a, 0x7c, 0x3b, 0x41, 0xb8, 0xae, 0x16, 0x56, 0xe3, 0xfa, 0xf1, 0x9f, 0xc4, 0x6a, 0xda, 0x09, 0x8d, 0xeb, 0x9c, 0x32, 0xb1, 0xfd, 0x86, 0x62, 0x05, 0x16, 0x5f, 0x49, 0xb8, 0x00, }, { /* (x,_,1) second point of order 8 on Curve25519 */ 0x5f, 0x9c, 0x95, 0xbc, 0xa3, 0x50, 0x8c, 0x24, 0xb1, 0xd0, 0xb1, 0x55, 0x9c, 0x83, 0xef, 0x5b, 0x04, 0x44, 0x5c, 0xc4, 0x58, 0x1c, 0x8e, 0x86, 0xd8, 0x22, 0x4e, 0xdd, 0xd0, 0x9f, 0x11, 0x57, }, { /* (-1,_,1) a point of order 4 on the twist of Curve25519 */ 0xec, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, }, }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x25519/table.go
vendor/github.com/cloudflare/circl/dh/x25519/table.go
package x25519 import "github.com/cloudflare/circl/math/fp25519" // tableGenerator contains the set of points: // // t[i] = (xi+1)/(xi-1), // // where (xi,yi) = 2^iG and G is the generator point // Size = (256)*(256/8) = 8192 bytes. var tableGenerator = [256 * fp25519.Size]byte{ /* (2^ 0)P */ 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5f, /* (2^ 1)P */ 0x96, 0xfe, 0xaa, 0x16, 0xf4, 0x20, 0x82, 0x6b, 0x34, 0x6a, 0x56, 0x4f, 0x2b, 0xeb, 0xeb, 0x82, 0x0f, 0x95, 0xa5, 0x75, 0xb0, 0xa5, 0xa9, 0xd5, 0xf4, 0x88, 0x24, 0x4b, 0xcf, 0xb2, 0x42, 0x51, /* (2^ 2)P */ 0x0c, 0x68, 0x69, 0x00, 0x75, 0xbc, 0xae, 0x6a, 0x41, 0x9c, 0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e2, 0xfc, 0xb1, 0x32, 0x68, 0xba, 0x3f, 0xd7, 0xc5, 0x81, 0x95, 0x83, 0x4d, 0x5a, 0xdb, 0xff, 0x20, /* (2^ 19)P */ 0xad, 0x0f, 0x5d, 0xbe, 0x67, 0xd3, 0x83, 0xa2, 0x75, 0x44, 0x16, 0x8b, 0xca, 0x25, 0x2b, 0x6c, 0x2e, 0xf2, 0xaa, 0x7c, 0x46, 0x35, 0x49, 0x9d, 0x49, 0xff, 0x85, 0xee, 0x8e, 0x40, 0x66, 0x51, /* (2^ 20)P */ 0x61, 0xe3, 0xb4, 0xfa, 0xa2, 0xba, 0x67, 0x3c, 0xef, 0x5c, 0xf3, 0x7e, 0xc6, 0x33, 0xe4, 0xb3, 0x1c, 0x9b, 0x15, 0x41, 0x92, 0x72, 0x59, 0x52, 0x33, 0xab, 0xb0, 0xd5, 0x92, 0x18, 0x62, 0x6a, /* (2^ 21)P */ 0xcb, 0xcd, 0x55, 0x75, 0x38, 0x4a, 0xb7, 0x20, 0x3f, 0x92, 0x08, 0x12, 0x0e, 0xa1, 0x2a, 0x53, 0xd1, 0x1d, 0x28, 0x62, 0x77, 0x7b, 0xa1, 0xea, 0xbf, 0x44, 0x5c, 0xf0, 0x43, 0x34, 0xab, 0x61, /* (2^ 22)P */ 0xf8, 0xde, 0x24, 0x23, 0x42, 0x6c, 0x7a, 0x25, 0x7f, 0xcf, 0xe3, 0x17, 0x10, 0x6c, 0x1c, 0x13, 0x57, 0xa2, 0x30, 0xf6, 0x39, 0x87, 0x75, 0x23, 0x80, 0x85, 0xa7, 0x01, 0x7a, 0x40, 0x5a, 0x29, /* (2^ 23)P */ 0xd9, 0xa8, 0x5d, 0x6d, 0x24, 0x43, 0xc4, 0xf8, 0x5d, 0xfa, 0x52, 0x0c, 0x45, 0x75, 0xd7, 0x19, 0x3d, 0xf8, 0x1b, 0x73, 0x92, 0xfc, 0xfc, 0x2a, 0x00, 0x47, 0x2b, 0x1b, 0xe8, 0xc8, 0x10,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38, 0x99, 0x95, 0xef, 0xc5, 0xd5, 0xd1, 0x40, 0xfc, 0xf8, 0x0c, 0x8f, 0x2f, 0xbe, 0x14, 0x45, 0x20, 0xee, 0x35, 0xe6, 0x01, 0x27, /* (2^ 30)P */ 0x14, 0x65, 0x15, 0x20, 0x00, 0xa8, 0x9f, 0x62, 0xce, 0xc1, 0xa8, 0x64, 0x87, 0x86, 0x23, 0xf2, 0x0e, 0x06, 0x3f, 0x0b, 0xff, 0x4f, 0x89, 0x5b, 0xfa, 0xa3, 0x08, 0xf7, 0x4c, 0x94, 0xd9, 0x60, /* (2^ 31)P */ 0x1f, 0x20, 0x7a, 0x1c, 0x1a, 0x00, 0xea, 0xae, 0x63, 0xce, 0xe2, 0x3e, 0x63, 0x6a, 0xf1, 0xeb, 0xe1, 0x07, 0x7a, 0x4c, 0x59, 0x09, 0x77, 0x6f, 0xcb, 0x08, 0x02, 0x0d, 0x15, 0x58, 0xb9, 0x79, /* (2^ 32)P */ 0xe7, 0x10, 0xd4, 0x01, 0x53, 0x5e, 0xb5, 0x24, 0x4d, 0xc8, 0xfd, 0xf3, 0xdf, 0x4e, 0xa3, 0xe3, 0xd8, 0x32, 0x40, 0x90, 0xe4, 0x68, 0x87, 0xd8, 0xec, 0xae, 0x3a, 0x7b, 0x42, 0x84, 0x13, 0x13, /* (2^ 33)P */ 0x14, 0x4f, 0x23, 0x86, 0x12, 0xe5, 0x05, 0x84, 0x29, 0xc5, 0xb4, 0xad, 0x39, 0x47, 0xdc, 0x14, 0xfd, 0x4f, 0x63, 0x50, 0xb2, 0xb5, 0xa2, 0xb8, 0x93, 0xff, 0xa7, 0xd8, 0x4a, 0xa9, 0xe2, 0x2f, /* (2^ 34)P */ 0xdd, 0xfa, 0x43, 0xe8, 0xef, 0x57, 0x5c, 0xec, 0x18, 0x99, 0xbb, 0xf0, 0x40, 0xce, 0x43, 0x28, 0x05, 0x63, 0x3d, 0xcf, 0xd6, 0x61, 0xb5, 0xa4, 0x7e, 0x77, 0xfb, 0xe8, 0xbd, 0x29, 0x36, 0x74, /* (2^ 35)P */ 0x8f, 0x73, 0xaf, 0xbb, 0x46, 0xdd, 0x3e, 0x34, 0x51, 0xa6, 0x01, 0xb1, 0x28, 0x18, 0x98, 0xed, 0x7a, 0x79, 0x2c, 0x88, 0x0b, 0x76, 0x01, 0xa4, 0x30, 0x87, 0xc8, 0x8d, 0xe2, 0x23, 0xc2, 0x1f, /* (2^ 36)P */ 0x0e, 0xba, 0x0f, 0xfc, 0x91, 0x4e, 0x60, 0x48, 0xa4, 0x6f, 0x2c, 0x05, 0x8f, 0xf7, 0x37, 0xb6, 0x9c, 0x23, 0xe9, 0x09, 0x3d, 0xac, 0xcc, 0x91, 0x7c, 0x68, 0x7a, 0x43, 0xd4, 0xee, 0xf7, 0x23, /* (2^ 37)P */ 0x00, 0xd8, 0x9b, 0x8d, 0x11, 0xb1, 0x73, 0x51, 0xa7, 0xd4, 0x89, 0x31, 0xb6, 0x41, 0xd6, 0x29, 0x86, 0xc5, 0xbb, 0x88, 0x79, 0x17, 0xbf, 0xfd, 0xf5, 0x1d, 0xd8, 0xca, 0x4f, 0x89, 0x59, 0x29, /* (2^ 38)P */ 0x99, 0xc8, 0xbb, 0xb4, 0xf3, 0x8e, 0xbc, 0xae, 0xb9, 0x92, 0x69, 0xb2, 0x5a, 0x99, 0x48, 0x41, 0xfb, 0x2c, 0xf9, 0x34, 0x01, 0x0b, 0xe2, 0x24, 0xe8, 0xde, 0x05, 0x4a, 0x89, 0x58, 0xd1, 0x40, /* (2^ 39)P */ 0xf6, 0x76, 0xaf, 0x85, 0x11, 0x0b, 0xb0, 0x46, 0x79, 0x7a, 0x18, 0x73, 0x78, 0xc7, 0xba, 0x26, 0x5f, 0xff, 0x8f, 0xab, 0x95, 0xbf, 0xc0, 0x3d, 0xd7, 0x24, 0x55, 0x94, 0xd8, 0x8b, 0x60, 0x2a, /* (2^ 40)P */ 0x02, 0x63, 0x44, 0xbd, 0x88, 0x95, 0x44, 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a, 0x59, 0xa5, 0xa5, 0xb6, 0x33, 0x53, 0xa6, 0x91, 0xdb, 0x5e, 0x70, /* (2^ 46)P */ 0xf7, 0xa5, 0xb9, 0x0b, 0x5e, 0xe1, 0x8e, 0x04, 0x5d, 0xaf, 0x0a, 0x9e, 0xca, 0xcf, 0x40, 0x32, 0x0b, 0xa4, 0xc4, 0xed, 0xce, 0x71, 0x4b, 0x8f, 0x6d, 0x4a, 0x54, 0xde, 0xa3, 0x0d, 0x1c, 0x62, /* (2^ 47)P */ 0x91, 0x40, 0x8c, 0xa0, 0x36, 0x28, 0x87, 0x92, 0x45, 0x14, 0xc9, 0x10, 0xb0, 0x75, 0x83, 0xce, 0x94, 0x63, 0x27, 0x4f, 0x52, 0xeb, 0x72, 0x8a, 0x35, 0x36, 0xc8, 0x7e, 0xfa, 0xfc, 0x67, 0x26, /* (2^ 48)P */ 0x2a, 0x75, 0xe8, 0x45, 0x33, 0x17, 0x4c, 0x7f, 0xa5, 0x79, 0x70, 0xee, 0xfe, 0x47, 0x1b, 0x06, 0x34, 0xff, 0x86, 0x9f, 0xfa, 0x9a, 0xdd, 0x25, 0x9c, 0xc8, 0x5d, 0x42, 0xf5, 0xce, 0x80, 0x37, /* (2^ 49)P */ 0xe9, 0xb4, 0x3b, 0x51, 0x5a, 0x03, 0x46, 0x1a, 0xda, 0x5a, 0x57, 0xac, 0x79, 0xf3, 0x1e, 0x3e, 0x50, 0x4b, 0xa2, 0x5f, 0x1c, 0x5f, 0x8c, 0xc7, 0x22, 0x9f, 0xfd, 0x34, 0x76, 0x96, 0x1a, 0x32, /* (2^ 50)P */ 0xfa, 0x27, 0x6e, 0x82, 0xb8, 0x07, 0x67, 0x94, 0xd0, 0x6f, 0x50, 0x4c, 0xd6, 0x84, 0xca, 0x3d, 0x36, 0x14, 0xe9, 0x75, 0x80, 0x21, 0x89, 0xc1, 0x84, 0x84, 0x3b, 0x9b, 0x16, 0x84, 0x92, 0x6d, /* (2^ 51)P */ 0xdf, 0x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, 0x9f, 0x03, 0xa1, 0x0b, 0x0e, 0xff, 0x4f, 0xce, 0xd4, 0x02, 0x45, /* (2^100)P */ 0x89, 0xc1, 0x37, 0x68, 0x10, 0x54, 0x20, 0xeb, 0x3c, 0xb9, 0xd3, 0x6d, 0x4c, 0x54, 0xf6, 0xd0, 0x4f, 0xd7, 0x16, 0xc4, 0x64, 0x70, 0x72, 0x40, 0xf0, 0x2e, 0x50, 0x4b, 0x11, 0xc6, 0x15, 0x6e, /* (2^101)P */ 0x6b, 0xa7, 0xb1, 0xcf, 0x98, 0xa3, 0xf2, 0x4d, 0xb1, 0xf6, 0xf2, 0x19, 0x74, 0x6c, 0x25, 0x11, 0x43, 0x60, 0x6e, 0x06, 0x62, 0x79, 0x49, 0x4a, 0x44, 0x5b, 0x35, 0x41, 0xab, 0x3a, 0x5b, 0x70, /* (2^102)P */ 0xd8, 0xb1, 0x97, 0xd7, 0x36, 0xf5, 0x5e, 0x36, 0xdb, 0xf0, 0xdd, 0x22, 0xd6, 0x6b, 0x07, 0x00, 0x88, 0x5a, 0x57, 0xe0, 0xb0, 0x33, 0xbf, 0x3b, 0x4d, 0xca, 0xe4, 0xc8, 0x05, 0xaa, 0x77, 0x37, /* (2^103)P */ 0x5f, 0xdb, 0x78, 0x55, 0xc8, 0x45, 0x27, 0x39, 0xe2, 0x5a, 0xae, 0xdb, 0x49, 0x41, 0xda, 0x6f, 0x67, 0x98, 0xdc, 0x8a, 0x0b, 0xb0, 0xf0, 0xb1, 0xa3, 0x1d, 0x6f, 0xd3, 0x37, 0x34, 0x96, 0x09, /* (2^104)P */ 0x53, 0x38, 0xdc, 0xa5, 0x90, 0x4e, 0x82, 0x7e, 0xbd, 0x5c, 0x13, 0x1f, 0x64, 0xf6, 0xb5, 0xcc, 0xcc, 0x8f, 0xce, 0x87, 0x6c, 0xd8, 0x36, 0x67, 0x9f, 0x24, 0x04, 0x66, 0xe2, 0x3c, 0x5f, 0x62, /* (2^105)P */ 0x3f, 0xf6, 0x02, 0x95, 0x05, 0xc8, 0x8a, 0xaf, 0x69, 0x14, 0x35, 0x2e, 0x0a, 0xe7, 0x05, 0x0c, 0x05, 0x63, 0x4b, 0x76, 0x9c, 0x2e, 0x29, 0x35, 0xc3, 0x3a, 0xe2, 0xc7, 0x60, 0x43, 0x39, 0x1a, /* (2^106)P */ 0x64, 0x32, 0x18, 0x51, 0x32, 0xd5, 0xc6, 0xd5, 0x4f, 0xb7, 0xc2, 0x43, 0xbd, 0x5a, 0x06, 0x62, 0x9b, 0x3f, 0x97, 0x3b, 0xd0, 0xf5, 0xfb, 0xb5, 0x5e, 0x6e, 0x20, 0x61, 0x36, 0xda, 0xa3, 0x13, /* (2^107)P */ 0xe5, 0x94, 0x5d, 0x72, 0x37, 0x58, 0xbd, 0xc6, 0xc5, 0x16, 0x50, 0x20, 0x12, 0x09, 0xe3, 0x18, 0x68, 0x3c, 0x03, 0x70, 0x15, 0xce, 0x88, 0x20, 0x87, 0x79, 0x83, 0x5c, 0x49, 0x1f, 0xba, 0x7f, /* (2^108)P */ 0x9d, 0x07, 0xf9, 0xf2, 0x23, 0x74, 0x8c, 0x5a, 0xc5, 0x3f, 0x02, 0x34, 0x7b, 0x15, 0x35, 0x17, 0x51, 0xb3, 0xfa, 0xd2, 0x9a, 0xb4, 0xf9, 0xe4, 0x3c, 0xe3, 0x78, 0xc8, 0x72, 0xff, 0x91, 0x66, /* (2^109)P */ 0x3e, 0xff, 0x5e, 0xdc, 0xde, 0x2a, 0x2c, 0x12, 0xf4, 0x6c, 0x95, 0xd8, 0xf1, 0x4b, 0xdd, 0xf8, 0xda, 0x5b, 0x9e, 0x9e, 0x5d, 0x20, 0x86, 0xeb, 0x43, 0xc7, 0x75, 0xd9, 0xb9, 0x92, 0x9b, 0x04, /* (2^110)P */ 0x5a, 0xc0, 0xf6, 0xb0, 0x30, 0x97, 0x37, 0xa5, 0x53, 0xa5, 0xf3, 0xc6, 0xac, 0xff, 0xa0, 0x72, 0x6d, 0xcd, 0x0d, 0xb2, 0x34, 0x2c, 0x03, 0xb0, 0x4a, 0x16, 0xd5, 0x88, 0xbc, 0x9d, 0x0e, 0x47, /* (2^111)P */ 0x47, 0xc0, 0x37, 0xa2, 0x0c, 0xf1, 0x9c, 0xb1, 0xa2, 0x81, 0x6c, 0x1f, 0x71, 0x66, 0x54, 0xb6, 0x43, 0x0b, 0xd8, 0x6d, 0xd1, 0x1b, 0x32, 0xb3, 0x8e, 0xbe, 0x5f, 0x0c, 0x60, 0x4f, 0xc1, 0x48, /* (2^112)P */ 0x03, 0xc8, 0xa6, 0x4a, 0x26, 0x1c, 0x45, 0x66, 0xa6, 0x7d, 0xfa, 0xa4, 0x04, 0x39, 0x6e, 0xb6, 0x95, 0x83, 0x12, 0xb3, 0xb0, 0x19, 0x5f, 0xd4, 0x10, 0xbc, 0xc9, 0xc3, 0x27, 0x26, 0x60, 0x31, /* (2^113)P */ 0x0d, 0xe1, 0xe4, 0x32, 0x48, 0xdc, 0x20, 0x31, 0xf7, 0x17, 0xc7, 0x56, 0x67, 0xc4, 0x20, 0xeb, 0x94, 0x02, 0x28, 0x67, 0x3f, 0x2e, 0xf5, 0x00, 0x09, 0xc5, 0x30, 0x47, 0xc1, 0x4f, 0x6d, 0x56, /* (2^114)P */ 0x06, 0x72, 0x83, 0xfd, 0x40, 0x5d, 0x3a, 0x7e, 0x7a, 0x54, 0x59, 0x71, 0xdc, 0x26, 0xe9, 0xc1, 0x95, 0x60, 0x8d, 0xa6, 0xfb, 0x30, 0x67, 0x21, 0xa7, 0xce, 0x69, 0x3f, 0x84, 0xc3, 0xe8, 0x22, /* (2^115)P */ 0x2b, 0x4b, 0x0e, 0x93, 0xe8, 0x74, 0xd0, 0x33, 0x16, 0x58, 0xd1, 0x84, 0x0e, 0x35, 0xe4, 0xb6, 0x65, 0x23, 0xba, 0xd6, 0x6a, 0xc2, 0x34, 0x55, 0xf3, 0xf3, 0xf1, 0x89, 0x2f, 0xc1, 0x73, 0x77, /* (2^116)P */ 0xaa, 0x62, 0x79, 0xa5, 0x4d, 0x40, 0xba, 0x8c, 0x56, 0xce, 0x99, 0x19, 0xa8, 0x97, 0x98, 0x5b, 0xfc, 0x92, 0x16, 0x12, 0x2f, 0x86, 0x8e, 0x50, 0x91, 0xc2, 0x93, 0xa0, 0x7f, 0x90, 0x81, 0x3a, /* (2^117)P */ 0x10, 0xa5, 0x25, 0x47, 0xff, 0xd0, 0xde, 0x0d, 0x03, 0xc5, 0x3f, 0x67, 0x10, 0xcc, 0xd8, 0x10, 0x89, 0x4e, 0x1f, 0x9f, 0x1c, 0x15, 0x9d, 0x5b, 0x4c, 0xa4, 0x09, 0xcb, 0xd5, 0xc1, 0xa5, 0x32, /* (2^118)P */ 0xfb, 0x41, 0x05, 0xb9, 0x42, 0xa4, 0x0a, 0x1e, 0xdb, 0x85, 0xb4, 0xc1, 0x7c, 0xeb, 0x85, 0x5f, 0xe5, 0xf2, 0x9d, 0x8a, 0xce, 0x95, 0xe5, 0xbe, 0x36, 0x22, 0x42, 0x22, 0xc7, 0x96, 0xe4, 0x25, /* (2^119)P */ 0xb9, 0xe5, 0x0f, 0xcd, 0x46, 0x3c, 0xdf, 0x5e, 0x88, 0x33, 0xa4, 0xd2, 0x7e, 0x5a, 0xe7, 0x34, 0x52, 0xe3, 0x61, 0xd7, 0x11, 0xde, 0x88, 0xe4, 0x5c, 0x54, 0x85, 0xa0, 0x01, 0x8a, 0x87, 0x0e, /* (2^120)P */ 0x04, 0xbb, 0x21, 0xe0, 0x77, 0x3c, 0x49, 0xba, 0x9a, 0x89, 0xdf, 0xc7, 0x43, 0x18, 0x4d, 0x2b, 0x67, 0x0d, 0xe8, 0x7a, 0x48, 0x7a, 0xa3, 0x9e, 0x94, 0x17, 0xe4, 0x11, 0x80, 0x95, 0xa9, 0x67, /* (2^121)P */ 0x65, 0xb0, 0x97, 0x66, 0x1a, 0x05, 0x58, 0x4b, 0xd4, 0xa6, 0x6b, 0x8d, 0x7d, 0x3f, 0xe3, 0x47, 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0x0a, /* (2^127)P */ 0x15, 0xf6, 0xe1, 0xb3, 0xa8, 0x1b, 0x69, 0x72, 0xfa, 0x3f, 0xbe, 0x1f, 0x70, 0xe9, 0xb4, 0x32, 0x68, 0x78, 0xbb, 0x39, 0x2e, 0xd9, 0xb6, 0x97, 0xe8, 0x39, 0x2e, 0xa0, 0xde, 0x53, 0xfe, 0x2c, /* (2^128)P */ 0xb0, 0x52, 0xcd, 0x85, 0xcd, 0x92, 0x73, 0x68, 0x31, 0x98, 0xe2, 0x10, 0xc9, 0x66, 0xff, 0x27, 0x06, 0x2d, 0x83, 0xa9, 0x56, 0x45, 0x13, 0x97, 0xa0, 0xf8, 0x84, 0x0a, 0x36, 0xb0, 0x9b, 0x26, /* (2^129)P */ 0x5c, 0xf8, 0x43, 0x76, 0x45, 0x55, 0x6e, 0x70, 0x1b, 0x7d, 0x59, 0x9b, 0x8c, 0xa4, 0x34, 0x37, 0x72, 0xa4, 0xef, 0xc6, 0xe8, 0x91, 0xee, 0x7a, 0xe0, 0xd9, 0xa9, 0x98, 0xc1, 0xab, 0xd6, 0x5c, /* (2^130)P */ 0x1a, 0xe4, 0x3c, 0xcb, 0x06, 0xde, 0x04, 0x0e, 0x38, 0xe1, 0x02, 0x34, 0x89, 0xeb, 0xc6, 0xd8, 0x72, 0x37, 0x6e, 0x68, 0xbb, 0x59, 0x46, 0x90, 0xc8, 0xa8, 0x6b, 0x74, 0x71, 0xc3, 0x15, 0x72, /* (2^131)P */ 0xd9, 0xa2, 0xe4, 0xea, 0x7e, 0xa9, 0x12, 0xfd, 0xc5, 0xf2, 0x94, 0x63, 0x51, 0xb7, 0x14, 0x95, 0x94, 0xf2, 0x08, 0x92, 0x80, 0xd5, 0x6f, 0x26, 0xb9, 0x26, 0x9a, 0x61, 0x85, 0x70, 0x84, 0x5c, /* (2^132)P */ 0xea, 0x94, 0xd6, 0xfe, 0x10, 0x54, 0x98, 0x52, 0x54, 0xd2, 0x2e, 0x4a, 0x93, 0x5b, 0x90, 0x3c, 0x67, 0xe4, 0x3b, 0x2d, 0x69, 0x47, 0xbb, 0x10, 0xe1, 0xe9, 0xe5, 0x69, 0x2d, 0x3d, 0x3b, 0x06, /* (2^133)P */ 0xeb, 0x7d, 0xa5, 0xdd, 0xee, 0x26, 0x27, 0x47, 0x91, 0x18, 0xf4, 0x10, 0xae, 0xc4, 0xb6, 0xef, 0x14, 0x76, 0x30, 0x7b, 0x91, 0x41, 0x16, 0x2b, 0x7c, 0x5b, 0xf4, 0xc4, 0x4f, 0x55, 0x7c, 0x11, /* (2^134)P */ 0x12, 0x88, 0x9d, 0x8f, 0x11, 0xf3, 0x7c, 0xc0, 0x39, 0x79, 0x01, 0x50, 0x20, 0xd8, 0xdb, 0x01, 0x27, 0x28, 0x1b, 0x17, 0xf4, 0x03, 0xe8, 0xd7, 0xea, 0x25, 0xd2, 0x87, 0x74, 0xe8, 0x15, 0x10, /* (2^135)P */ 0x4d, 0xcc, 0x3a, 0xd2, 0xfe, 0xe3, 0x8d, 0xc5, 0x2d, 0xbe, 0xa7, 0x94, 0xc2, 0x91, 0xdb, 0x50, 0x57, 0xf4, 0x9c, 0x1c, 0x3d, 0xd4, 0x94, 0x0b, 0x4a, 0x52, 0x37, 0x6e, 0xfa, 0x40, 0x16, 0x6b, /* (2^136)P */ 0x09, 0x0d, 0xda, 0x5f, 0x6c, 0x34, 0x2f, 0x69, 0x51, 0x31, 0x4d, 0xfa, 0x59, 0x1c, 0x0b, 0x20, 0x96, 0xa2, 0x77, 0x07, 0x76, 0x6f, 0xc4, 0xb8, 0xcf, 0xfb, 0xfd, 0x3f, 0x5f, 0x39, 0x38, 0x4b, /* (2^137)P */ 0x71, 0xd6, 0x54, 0xbe, 0x00, 0x5e, 0xd2, 0x18, 0xa6, 0xab, 0xc8, 0xbe, 0x82, 0x05, 0xd5, 0x60, 0x82, 0xb9, 0x78, 0x3b, 0x26, 0x8f, 0xad, 0x87, 0x32, 0x04, 0xda, 0x9c, 0x4e, 0xf6, 0x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0x1f, 0x8c, 0x69, 0x55, 0x3f, 0x29, 0xf9, 0xc3, 0x5a, 0xed, 0x50, 0x33, 0xbe, 0xeb, 0x7e, 0x47, 0xca, 0x06, 0xf8, 0x9b, 0x5e, /* (2^144)P */ 0x68, 0x9f, 0x30, 0x3c, 0xb6, 0x8f, 0xce, 0xe9, 0xf4, 0xf9, 0xe1, 0x65, 0x35, 0xf6, 0x76, 0x53, 0xf1, 0x93, 0x63, 0x5a, 0xb3, 0xcf, 0xaf, 0xd1, 0x06, 0x35, 0x62, 0xe5, 0xed, 0xa1, 0x32, 0x66, /* (2^145)P */ 0x4c, 0xed, 0x2d, 0x0c, 0x39, 0x6c, 0x7d, 0x0b, 0x1f, 0xcb, 0x04, 0xdf, 0x81, 0x32, 0xcb, 0x56, 0xc7, 0xc3, 0xec, 0x49, 0x12, 0x5a, 0x30, 0x66, 0x2a, 0xa7, 0x8c, 0xa3, 0x60, 0x8b, 0x58, 0x5d, /* (2^146)P */ 0x2d, 0xf4, 0xe5, 0xe8, 0x78, 0xbf, 0xec, 0xa6, 0xec, 0x3e, 0x8a, 0x3c, 0x4b, 0xb4, 0xee, 0x86, 0x04, 0x16, 0xd2, 0xfb, 0x48, 0x9c, 0x21, 0xec, 0x31, 0x67, 0xc3, 0x17, 0xf5, 0x1a, 0xaf, 0x1a, /* (2^147)P */ 0xe7, 0xbd, 0x69, 0x67, 0x83, 0xa2, 0x06, 0xc3, 0xdb, 0x2a, 0x1e, 0x2b, 0x62, 0x80, 0x82, 0x20, 0xa6, 0x94, 0xff, 0xfb, 0x1f, 0xf5, 0x27, 0x80, 0x6b, 0xf2, 0x24, 0x11, 0xce, 0xa1, 0xcf, 0x76, /* (2^148)P */ 0xb6, 0xab, 0x22, 0x24, 0x56, 0x00, 0xeb, 0x18, 0xc3, 0x29, 0x8c, 0x8f, 0xd5, 0xc4, 0x77, 0xf3, 0x1a, 0x56, 0x31, 0xf5, 0x07, 0xc2, 0xbb, 0x4d, 0x27, 0x8a, 0x12, 0x82, 0xf0, 0xb7, 0x53, 0x02, /* (2^149)P */ 0xe0, 0x17, 0x2c, 0xb6, 0x1c, 0x09, 0x1f, 0x3d, 0xa9, 0x28, 0x46, 0xd6, 0xab, 0xe1, 0x60, 0x48, 0x53, 0x42, 0x9d, 0x30, 0x36, 0x74, 0xd1, 0x52, 0x76, 0xe5, 0xfa, 0x3e, 0xe1, 0x97, 0x6f, 0x35, /* (2^150)P */ 0x5b, 0x53, 0x50, 0xa1, 0x1a, 0xe1, 0x51, 0xd3, 0xcc, 0x78, 0xd8, 0x1d, 0xbb, 0x45, 0x6b, 0x3e, 0x98, 0x2c, 0xd9, 0xbe, 0x28, 0x61, 0x77, 0x0c, 0xb8, 0x85, 0x28, 0x03, 0x93, 0xae, 0x34, 0x1d, /* (2^151)P */ 0xc3, 0xa4, 0x5b, 0xa8, 0x8c, 0x48, 0xa0, 0x4b, 0xce, 0xe6, 0x9c, 0x3c, 0xc3, 0x48, 0x53, 0x98, 0x70, 0xa7, 0xbd, 0x97, 0x6f, 0x4c, 0x12, 0x66, 0x4a, 0x12, 0x54, 0x06, 0x29, 0xa0, 0x81, 0x0f, /* (2^152)P */ 0xfd, 0x86, 0x9b, 0x56, 0xa6, 0x9c, 0xd0, 0x9e, 0x2d, 0x9a, 0xaf, 0x18, 0xfd, 0x09, 0x10, 0x81, 0x0a, 0xc2, 0xd8, 0x93, 0x3f, 0xd0, 0x08, 0xff, 0x6b, 0xf2, 0xae, 0x9f, 0x19, 0x48, 0xa1, 0x52, /* (2^153)P */ 0x73, 0x1b, 0x8d, 0x2d, 0xdc, 0xf9, 0x03, 0x3e, 0x70, 0x1a, 0x96, 0x73, 0x18, 0x80, 0x05, 0x42, 0x70, 0x59, 0xa3, 0x41, 0xf0, 0x87, 0xd9, 0xc0, 0x49, 0xd5, 0xc0, 0xa1, 0x15, 0x1f, 0xaa, 0x07, /* (2^154)P */ 0x24, 0x72, 0xd2, 0x8c, 0xe0, 0x6c, 0xd4, 0xdf, 0x39, 0x42, 0x4e, 0x93, 0x4f, 0x02, 0x0a, 0x6d, 0x59, 0x7b, 0x89, 0x99, 0x63, 0x7a, 0x8a, 0x80, 0xa2, 0x95, 0x3d, 0xe1, 0xe9, 0x56, 0x45, 0x0a, /* (2^155)P */ 0x45, 0x30, 0xc1, 0xe9, 0x1f, 0x99, 0x1a, 0xd2, 0xb8, 0x51, 0x77, 0xfe, 0x48, 0x85, 0x0e, 0x9b, 0x35, 0x00, 0xf3, 0x4b, 0xcb, 0x43, 0xa6, 0x5d, 0x21, 0xf7, 0x40, 0x39, 0xd6, 0x28, 0xdb, 0x77,
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
true
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x25519/curve_noasm.go
vendor/github.com/cloudflare/circl/dh/x25519/curve_noasm.go
//go:build !amd64 || purego // +build !amd64 purego package x25519 import fp "github.com/cloudflare/circl/math/fp25519" func double(x, z *fp.Elt) { doubleGeneric(x, z) } func diffAdd(w *[5]fp.Elt, b uint) { diffAddGeneric(w, b) } func ladderStep(w *[5]fp.Elt, b uint) { ladderStepGeneric(w, b) } func mulA24(z, x *fp.Elt) { mulA24Generic(z, x) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x25519/curve_amd64.go
vendor/github.com/cloudflare/circl/dh/x25519/curve_amd64.go
//go:build amd64 && !purego // +build amd64,!purego package x25519 import ( fp "github.com/cloudflare/circl/math/fp25519" "golang.org/x/sys/cpu" ) var hasBmi2Adx = cpu.X86.HasBMI2 && cpu.X86.HasADX var _ = hasBmi2Adx func double(x, z *fp.Elt) { doubleAmd64(x, z) } func diffAdd(w *[5]fp.Elt, b uint) { diffAddAmd64(w, b) } func ladderStep(w *[5]fp.Elt, b uint) { ladderStepAmd64(w, b) } func mulA24(z, x *fp.Elt) { mulA24Amd64(z, x) } //go:noescape func ladderStepAmd64(w *[5]fp.Elt, b uint) //go:noescape func diffAddAmd64(w *[5]fp.Elt, b uint) //go:noescape func doubleAmd64(x, z *fp.Elt) //go:noescape func mulA24Amd64(z, x *fp.Elt)
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x25519/doc.go
vendor/github.com/cloudflare/circl/dh/x25519/doc.go
/* Package x25519 provides Diffie-Hellman functions as specified in RFC-7748. Validation of public keys. The Diffie-Hellman function, as described in RFC-7748 [1], works for any public key. However, if a different protocol requires contributory behaviour [2,3], then the public keys must be validated against low-order points [3,4]. To do that, the Shared function performs this validation internally and returns false when the public key is invalid (i.e., it is a low-order point). References: - [1] RFC7748 by Langley, Hamburg, Turner (https://rfc-editor.org/rfc/rfc7748.txt) - [2] Curve25519 by Bernstein (https://cr.yp.to/ecdh.html) - [3] Bernstein (https://cr.yp.to/ecdh.html#validate) - [4] Cremers&Jackson (https://eprint.iacr.org/2019/526) */ package x25519
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x25519/key.go
vendor/github.com/cloudflare/circl/dh/x25519/key.go
package x25519 import ( "crypto/subtle" fp "github.com/cloudflare/circl/math/fp25519" ) // Size is the length in bytes of a X25519 key. const Size = 32 // Key represents a X25519 key. type Key [Size]byte func (k *Key) clamp(in *Key) *Key { *k = *in k[0] &= 248 k[31] = (k[31] & 127) | 64 return k } // isValidPubKey verifies if the public key is not a low-order point. func (k *Key) isValidPubKey() bool { fp.Modp((*fp.Elt)(k)) var isLowOrder int for _, P := range lowOrderPoints { isLowOrder |= subtle.ConstantTimeCompare(P[:], k[:]) } return isLowOrder == 0 } // KeyGen obtains a public key given a secret key. func KeyGen(public, secret *Key) { ladderJoye(public.clamp(secret)) } // Shared calculates Alice's shared key from Alice's secret key and Bob's // public key returning true on success. A failure case happens when the public // key is a low-order point, thus the shared key is all-zeros and the function // returns false. func Shared(shared, secret, public *Key) bool { validPk := *public validPk[31] &= (1 << (255 % 8)) - 1 ok := validPk.isValidPubKey() ladderMontgomery(shared.clamp(secret), &validPk) return ok }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x25519/curve_generic.go
vendor/github.com/cloudflare/circl/dh/x25519/curve_generic.go
package x25519 import ( "encoding/binary" "math/bits" fp "github.com/cloudflare/circl/math/fp25519" ) func doubleGeneric(x, z *fp.Elt) { t0, t1 := &fp.Elt{}, &fp.Elt{} fp.AddSub(x, z) fp.Sqr(x, x) fp.Sqr(z, z) fp.Sub(t0, x, z) mulA24Generic(t1, t0) fp.Add(t1, t1, z) fp.Mul(x, x, z) fp.Mul(z, t0, t1) } func diffAddGeneric(w *[5]fp.Elt, b uint) { mu, x1, z1, x2, z2 := &w[0], &w[1], &w[2], &w[3], &w[4] fp.Cswap(x1, x2, b) fp.Cswap(z1, z2, b) fp.AddSub(x1, z1) fp.Mul(z1, z1, mu) fp.AddSub(x1, z1) fp.Sqr(x1, x1) fp.Sqr(z1, z1) fp.Mul(x1, x1, z2) fp.Mul(z1, z1, x2) } func ladderStepGeneric(w *[5]fp.Elt, b uint) { x1, x2, z2, x3, z3 := &w[0], &w[1], &w[2], &w[3], &w[4] t0 := &fp.Elt{} t1 := &fp.Elt{} fp.AddSub(x2, z2) fp.AddSub(x3, z3) fp.Mul(t0, x2, z3) fp.Mul(t1, x3, z2) fp.AddSub(t0, t1) fp.Cmov(x2, x3, b) fp.Cmov(z2, z3, b) fp.Sqr(x3, t0) fp.Sqr(z3, t1) fp.Mul(z3, x1, z3) fp.Sqr(x2, x2) fp.Sqr(z2, z2) fp.Sub(t0, x2, z2) mulA24Generic(t1, t0) fp.Add(t1, t1, z2) fp.Mul(x2, x2, z2) fp.Mul(z2, t0, t1) } func mulA24Generic(z, x *fp.Elt) { const A24 = 121666 const n = 8 var xx [4]uint64 for i := range xx { xx[i] = binary.LittleEndian.Uint64(x[i*n : (i+1)*n]) } h0, l0 := bits.Mul64(xx[0], A24) h1, l1 := bits.Mul64(xx[1], A24) h2, l2 := bits.Mul64(xx[2], A24) h3, l3 := bits.Mul64(xx[3], A24) var c3 uint64 l1, c0 := bits.Add64(h0, l1, 0) l2, c1 := bits.Add64(h1, l2, c0) l3, c2 := bits.Add64(h2, l3, c1) l4, _ := bits.Add64(h3, 0, c2) _, l4 = bits.Mul64(l4, 38) l0, c0 = bits.Add64(l0, l4, 0) xx[1], c1 = bits.Add64(l1, 0, c0) xx[2], c2 = bits.Add64(l2, 0, c1) xx[3], c3 = bits.Add64(l3, 0, c2) xx[0], _ = bits.Add64(l0, (-c3)&38, 0) for i := range xx { binary.LittleEndian.PutUint64(z[i*n:(i+1)*n], xx[i]) } }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x448/curve.go
vendor/github.com/cloudflare/circl/dh/x448/curve.go
package x448 import ( fp "github.com/cloudflare/circl/math/fp448" ) // ladderJoye calculates a fixed-point multiplication with the generator point. // The algorithm is the right-to-left Joye's ladder as described // in "How to precompute a ladder" in SAC'2017. func ladderJoye(k *Key) { w := [5]fp.Elt{} // [mu,x1,z1,x2,z2] order must be preserved. w[1] = fp.Elt{ // x1 = S 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, } fp.SetOne(&w[2]) // z1 = 1 w[3] = fp.Elt{ // x2 = G-S 0x20, 0x27, 0x9d, 0xc9, 0x7d, 0x19, 0xb1, 0xac, 0xf8, 0xba, 0x69, 0x1c, 0xff, 0x33, 0xac, 0x23, 0x51, 0x1b, 0xce, 0x3a, 0x64, 0x65, 0xbd, 0xf1, 0x23, 0xf8, 0xc1, 0x84, 0x9d, 0x45, 0x54, 0x29, 0x67, 0xb9, 0x81, 0x1c, 0x03, 0xd1, 0xcd, 0xda, 0x7b, 0xeb, 0xff, 0x1a, 0x88, 0x03, 0xcf, 0x3a, 0x42, 0x44, 0x32, 0x01, 0x25, 0xb7, 0xfa, 0xf0, } fp.SetOne(&w[4]) // z2 = 1 const n = 448 const h = 2 swap := uint(1) for s := 0; s < n-h; s++ { i := (s + h) / 8 j := (s + h) % 8 bit := uint((k[i] >> uint(j)) & 1) copy(w[0][:], tableGenerator[s*Size:(s+1)*Size]) diffAdd(&w, swap^bit) swap = bit } for s := 0; s < h; s++ { double(&w[1], &w[2]) } toAffine((*[fp.Size]byte)(k), &w[1], &w[2]) } // ladderMontgomery calculates a generic scalar point multiplication // The algorithm implemented is the left-to-right Montgomery's ladder. func ladderMontgomery(k, xP *Key) { w := [5]fp.Elt{} // [x1, x2, z2, x3, z3] order must be preserved. w[0] = *(*fp.Elt)(xP) // x1 = xP fp.SetOne(&w[1]) // x2 = 1 w[3] = *(*fp.Elt)(xP) // x3 = xP fp.SetOne(&w[4]) // z3 = 1 move := uint(0) for s := 448 - 1; s >= 0; s-- { i := s / 8 j := s % 8 bit := uint((k[i] >> uint(j)) & 1) ladderStep(&w, move^bit) move = bit } toAffine((*[fp.Size]byte)(k), &w[1], &w[2]) } func toAffine(k *[fp.Size]byte, x, z *fp.Elt) { fp.Inv(z, z) fp.Mul(x, x, z) _ = fp.ToBytes(k[:], x) } var lowOrderPoints = [3]fp.Elt{ { /* (0,_,1) point of order 2 on Curve448 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, { /* (1,_,1) a point of order 4 on the twist of Curve448 */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, { /* (-1,_,1) point of order 4 on Curve448 */ 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }, }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x448/table.go
vendor/github.com/cloudflare/circl/dh/x448/table.go
package x448 import fp "github.com/cloudflare/circl/math/fp448" // tableGenerator contains the set of points: // // t[i] = (xi+1)/(xi-1), // // where (xi,yi) = 2^iG and G is the generator point // Size = (448)*(448/8) = 25088 bytes. var tableGenerator = [448 * fp.Size]byte{ /* (2^ 0)P */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, /* (2^ 1)P */ 0x37, 0xfa, 0xaa, 0x0d, 0x86, 0xa6, 0x24, 0xe9, 0x6c, 0x95, 0x08, 0x34, 0xba, 0x1a, 0x81, 0x3a, 0xae, 0x01, 0xa5, 0xa7, 0x05, 0x85, 0x96, 0x00, 0x06, 0x5a, 0xd7, 0xff, 0xee, 0x8e, 0x8f, 0x94, 0xd2, 0xdc, 0xd7, 0xfc, 0xe7, 0xe5, 0x99, 0x1d, 0x05, 0x46, 0x43, 0xe8, 0xbc, 0x12, 0xb7, 0xeb, 0x30, 0x5e, 0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b, 0x11, 0x47, 0xd0, 0xcf, 0xb6, 0x54, /* (2^ 91)P */ 0x26, 0x45, 0xa2, 0x10, 0xd4, 0x2d, 0xae, 0xc0, 0xb0, 0xe8, 0x86, 0xb3, 0xc7, 0xea, 0x70, 0x87, 0x61, 0xb5, 0xa5, 0x55, 0xbe, 0x88, 0x1d, 0x7a, 0xd9, 0x6f, 0xeb, 0x83, 0xe2, 0x44, 0x7f, 0x98, 0x04, 0xd6, 0x50, 0x9d, 0xa7, 0x86, 0x66, 0x09, 0x63, 0xe1, 0xed, 0x72, 0xb1, 0xe4, 0x1d, 0x3a, 0xfd, 0x47, 0xce, 0x1c, 0xaa, 0x3b, 0x8f, 0x1b,
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
true
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x448/curve_noasm.go
vendor/github.com/cloudflare/circl/dh/x448/curve_noasm.go
//go:build !amd64 || purego // +build !amd64 purego package x448 import fp "github.com/cloudflare/circl/math/fp448" func double(x, z *fp.Elt) { doubleGeneric(x, z) } func diffAdd(w *[5]fp.Elt, b uint) { diffAddGeneric(w, b) } func ladderStep(w *[5]fp.Elt, b uint) { ladderStepGeneric(w, b) } func mulA24(z, x *fp.Elt) { mulA24Generic(z, x) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x448/curve_amd64.go
vendor/github.com/cloudflare/circl/dh/x448/curve_amd64.go
//go:build amd64 && !purego // +build amd64,!purego package x448 import ( fp "github.com/cloudflare/circl/math/fp448" "golang.org/x/sys/cpu" ) var hasBmi2Adx = cpu.X86.HasBMI2 && cpu.X86.HasADX var _ = hasBmi2Adx func double(x, z *fp.Elt) { doubleAmd64(x, z) } func diffAdd(w *[5]fp.Elt, b uint) { diffAddAmd64(w, b) } func ladderStep(w *[5]fp.Elt, b uint) { ladderStepAmd64(w, b) } func mulA24(z, x *fp.Elt) { mulA24Amd64(z, x) } //go:noescape func doubleAmd64(x, z *fp.Elt) //go:noescape func diffAddAmd64(w *[5]fp.Elt, b uint) //go:noescape func ladderStepAmd64(w *[5]fp.Elt, b uint) //go:noescape func mulA24Amd64(z, x *fp.Elt)
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x448/doc.go
vendor/github.com/cloudflare/circl/dh/x448/doc.go
/* Package x448 provides Diffie-Hellman functions as specified in RFC-7748. Validation of public keys. The Diffie-Hellman function, as described in RFC-7748 [1], works for any public key. However, if a different protocol requires contributory behaviour [2,3], then the public keys must be validated against low-order points [3,4]. To do that, the Shared function performs this validation internally and returns false when the public key is invalid (i.e., it is a low-order point). References: - [1] RFC7748 by Langley, Hamburg, Turner (https://rfc-editor.org/rfc/rfc7748.txt) - [2] Curve25519 by Bernstein (https://cr.yp.to/ecdh.html) - [3] Bernstein (https://cr.yp.to/ecdh.html#validate) - [4] Cremers&Jackson (https://eprint.iacr.org/2019/526) */ package x448
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x448/key.go
vendor/github.com/cloudflare/circl/dh/x448/key.go
package x448 import ( "crypto/subtle" fp "github.com/cloudflare/circl/math/fp448" ) // Size is the length in bytes of a X448 key. const Size = 56 // Key represents a X448 key. type Key [Size]byte func (k *Key) clamp(in *Key) *Key { *k = *in k[0] &= 252 k[55] |= 128 return k } // isValidPubKey verifies if the public key is not a low-order point. func (k *Key) isValidPubKey() bool { fp.Modp((*fp.Elt)(k)) var isLowOrder int for _, P := range lowOrderPoints { isLowOrder |= subtle.ConstantTimeCompare(P[:], k[:]) } return isLowOrder == 0 } // KeyGen obtains a public key given a secret key. func KeyGen(public, secret *Key) { ladderJoye(public.clamp(secret)) } // Shared calculates Alice's shared key from Alice's secret key and Bob's // public key returning true on success. A failure case happens when the public // key is a low-order point, thus the shared key is all-zeros and the function // returns false. func Shared(shared, secret, public *Key) bool { validPk := *public ok := validPk.isValidPubKey() ladderMontgomery(shared.clamp(secret), &validPk) return ok }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/dh/x448/curve_generic.go
vendor/github.com/cloudflare/circl/dh/x448/curve_generic.go
package x448 import ( "encoding/binary" "math/bits" "github.com/cloudflare/circl/math/fp448" ) func doubleGeneric(x, z *fp448.Elt) { t0, t1 := &fp448.Elt{}, &fp448.Elt{} fp448.AddSub(x, z) fp448.Sqr(x, x) fp448.Sqr(z, z) fp448.Sub(t0, x, z) mulA24Generic(t1, t0) fp448.Add(t1, t1, z) fp448.Mul(x, x, z) fp448.Mul(z, t0, t1) } func diffAddGeneric(w *[5]fp448.Elt, b uint) { mu, x1, z1, x2, z2 := &w[0], &w[1], &w[2], &w[3], &w[4] fp448.Cswap(x1, x2, b) fp448.Cswap(z1, z2, b) fp448.AddSub(x1, z1) fp448.Mul(z1, z1, mu) fp448.AddSub(x1, z1) fp448.Sqr(x1, x1) fp448.Sqr(z1, z1) fp448.Mul(x1, x1, z2) fp448.Mul(z1, z1, x2) } func ladderStepGeneric(w *[5]fp448.Elt, b uint) { x1, x2, z2, x3, z3 := &w[0], &w[1], &w[2], &w[3], &w[4] t0 := &fp448.Elt{} t1 := &fp448.Elt{} fp448.AddSub(x2, z2) fp448.AddSub(x3, z3) fp448.Mul(t0, x2, z3) fp448.Mul(t1, x3, z2) fp448.AddSub(t0, t1) fp448.Cmov(x2, x3, b) fp448.Cmov(z2, z3, b) fp448.Sqr(x3, t0) fp448.Sqr(z3, t1) fp448.Mul(z3, x1, z3) fp448.Sqr(x2, x2) fp448.Sqr(z2, z2) fp448.Sub(t0, x2, z2) mulA24Generic(t1, t0) fp448.Add(t1, t1, z2) fp448.Mul(x2, x2, z2) fp448.Mul(z2, t0, t1) } func mulA24Generic(z, x *fp448.Elt) { const A24 = 39082 const n = 8 var xx [7]uint64 for i := range xx { xx[i] = binary.LittleEndian.Uint64(x[i*n : (i+1)*n]) } h0, l0 := bits.Mul64(xx[0], A24) h1, l1 := bits.Mul64(xx[1], A24) h2, l2 := bits.Mul64(xx[2], A24) h3, l3 := bits.Mul64(xx[3], A24) h4, l4 := bits.Mul64(xx[4], A24) h5, l5 := bits.Mul64(xx[5], A24) h6, l6 := bits.Mul64(xx[6], A24) l1, c0 := bits.Add64(h0, l1, 0) l2, c1 := bits.Add64(h1, l2, c0) l3, c2 := bits.Add64(h2, l3, c1) l4, c3 := bits.Add64(h3, l4, c2) l5, c4 := bits.Add64(h4, l5, c3) l6, c5 := bits.Add64(h5, l6, c4) l7, _ := bits.Add64(h6, 0, c5) l0, c0 = bits.Add64(l0, l7, 0) l1, c1 = bits.Add64(l1, 0, c0) l2, c2 = bits.Add64(l2, 0, c1) l3, c3 = bits.Add64(l3, l7<<32, c2) l4, c4 = bits.Add64(l4, 0, c3) l5, c5 = bits.Add64(l5, 0, c4) l6, l7 = bits.Add64(l6, 0, c5) xx[0], c0 = bits.Add64(l0, l7, 0) xx[1], c1 = bits.Add64(l1, 0, c0) xx[2], c2 = bits.Add64(l2, 0, c1) xx[3], c3 = bits.Add64(l3, l7<<32, c2) xx[4], c4 = bits.Add64(l4, 0, c3) xx[5], c5 = bits.Add64(l5, 0, c4) xx[6], _ = bits.Add64(l6, 0, c5) for i := range xx { binary.LittleEndian.PutUint64(z[i*n:(i+1)*n], xx[i]) } }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/internal/conv/conv.go
vendor/github.com/cloudflare/circl/internal/conv/conv.go
package conv import ( "encoding/binary" "fmt" "math/big" "strings" "golang.org/x/crypto/cryptobyte" ) // BytesLe2Hex returns an hexadecimal string of a number stored in a // little-endian order slice x. func BytesLe2Hex(x []byte) string { b := &strings.Builder{} b.Grow(2*len(x) + 2) fmt.Fprint(b, "0x") if len(x) == 0 { fmt.Fprint(b, "00") } for i := len(x) - 1; i >= 0; i-- { fmt.Fprintf(b, "%02x", x[i]) } return b.String() } // BytesLe2BigInt converts a little-endian slice x into a big-endian // math/big.Int. func BytesLe2BigInt(x []byte) *big.Int { n := len(x) b := new(big.Int) if len(x) > 0 { y := make([]byte, n) for i := 0; i < n; i++ { y[n-1-i] = x[i] } b.SetBytes(y) } return b } // BytesBe2Uint64Le converts a big-endian slice x to a little-endian slice of uint64. func BytesBe2Uint64Le(x []byte) []uint64 { l := len(x) z := make([]uint64, (l+7)/8) blocks := l / 8 for i := 0; i < blocks; i++ { z[i] = binary.BigEndian.Uint64(x[l-8*(i+1):]) } remBytes := l % 8 for i := 0; i < remBytes; i++ { z[blocks] |= uint64(x[l-1-8*blocks-i]) << uint(8*i) } return z } // BigInt2BytesLe stores a positive big.Int number x into a little-endian slice z. // The slice is modified if the bitlength of x <= 8*len(z) (padding with zeros). // If x does not fit in the slice or is negative, z is not modified. func BigInt2BytesLe(z []byte, x *big.Int) { xLen := (x.BitLen() + 7) >> 3 zLen := len(z) if zLen >= xLen && x.Sign() >= 0 { y := x.Bytes() for i := 0; i < xLen; i++ { z[i] = y[xLen-1-i] } for i := xLen; i < zLen; i++ { z[i] = 0 } } } // Uint64Le2BigInt converts a little-endian slice x into a big number. func Uint64Le2BigInt(x []uint64) *big.Int { n := len(x) b := new(big.Int) var bi big.Int for i := n - 1; i >= 0; i-- { bi.SetUint64(x[i]) b.Lsh(b, 64) b.Add(b, &bi) } return b } // Uint64Le2BytesLe converts a little-endian slice x to a little-endian slice of bytes. func Uint64Le2BytesLe(x []uint64) []byte { b := make([]byte, 8*len(x)) n := len(x) for i := 0; i < n; i++ { binary.LittleEndian.PutUint64(b[i*8:], x[i]) } return b } // Uint64Le2BytesBe converts a little-endian slice x to a big-endian slice of bytes. func Uint64Le2BytesBe(x []uint64) []byte { b := make([]byte, 8*len(x)) n := len(x) for i := 0; i < n; i++ { binary.BigEndian.PutUint64(b[i*8:], x[n-1-i]) } return b } // Uint64Le2Hex returns an hexadecimal string of a number stored in a // little-endian order slice x. func Uint64Le2Hex(x []uint64) string { b := new(strings.Builder) b.Grow(16*len(x) + 2) fmt.Fprint(b, "0x") if len(x) == 0 { fmt.Fprint(b, "00") } for i := len(x) - 1; i >= 0; i-- { fmt.Fprintf(b, "%016x", x[i]) } return b.String() } // BigInt2Uint64Le stores a positive big.Int number x into a little-endian slice z. // The slice is modified if the bitlength of x <= 8*len(z) (padding with zeros). // If x does not fit in the slice or is negative, z is not modified. func BigInt2Uint64Le(z []uint64, x *big.Int) { xLen := (x.BitLen() + 63) >> 6 // number of 64-bit words zLen := len(z) if zLen >= xLen && x.Sign() > 0 { var y, yi big.Int y.Set(x) two64 := big.NewInt(1) two64.Lsh(two64, 64).Sub(two64, big.NewInt(1)) for i := 0; i < xLen; i++ { yi.And(&y, two64) z[i] = yi.Uint64() y.Rsh(&y, 64) } } for i := xLen; i < zLen; i++ { z[i] = 0 } } // MarshalBinary encodes a value into a byte array in a format readable by UnmarshalBinary. func MarshalBinary(v cryptobyte.MarshalingValue) ([]byte, error) { const DefaultSize = 32 b := cryptobyte.NewBuilder(make([]byte, 0, DefaultSize)) b.AddValue(v) return b.Bytes() } // MarshalBinaryLen encodes a value into an array of n bytes in a format readable by UnmarshalBinary. func MarshalBinaryLen(v cryptobyte.MarshalingValue, length uint) ([]byte, error) { b := cryptobyte.NewFixedBuilder(make([]byte, 0, length)) b.AddValue(v) return b.Bytes() } // A UnmarshalingValue decodes itself from a cryptobyte.String and advances the pointer. // It reports whether the read was successful. type UnmarshalingValue interface { Unmarshal(*cryptobyte.String) bool } // UnmarshalBinary recovers a value from a byte array. // It returns an error if the read was unsuccessful. func UnmarshalBinary(v UnmarshalingValue, data []byte) (err error) { s := cryptobyte.String(data) if data == nil || !v.Unmarshal(&s) || !s.Empty() { err = fmt.Errorf("cannot read %T from input string", v) } return }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/internal/sha3/shake.go
vendor/github.com/cloudflare/circl/internal/sha3/shake.go
// Copyright 2014 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 sha3 // This file defines the ShakeHash interface, and provides // functions for creating SHAKE and cSHAKE instances, as well as utility // functions for hashing bytes to arbitrary-length output. // // // SHAKE implementation is based on FIPS PUB 202 [1] // cSHAKE implementations is based on NIST SP 800-185 [2] // // [1] https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf // [2] https://doi.org/10.6028/NIST.SP.800-185 import ( "io" ) // ShakeHash defines the interface to hash functions that // support arbitrary-length output. type ShakeHash interface { // Write absorbs more data into the hash's state. It panics if input is // written to it after output has been read from it. io.Writer // Read reads more output from the hash; reading affects the hash's // state. (ShakeHash.Read is thus very different from Hash.Sum) // It never returns an error. io.Reader // Clone returns a copy of the ShakeHash in its current state. Clone() ShakeHash // Reset resets the ShakeHash to its initial state. Reset() } // Consts for configuring initial SHA-3 state const ( dsbyteShake = 0x1f rate128 = 168 rate256 = 136 ) // Clone returns copy of SHAKE context within its current state. func (d *State) Clone() ShakeHash { return d.clone() } // NewShake128 creates a new SHAKE128 variable-output-length ShakeHash. // Its generic security strength is 128 bits against all attacks if at // least 32 bytes of its output are used. func NewShake128() State { return State{rate: rate128, dsbyte: dsbyteShake} } // NewTurboShake128 creates a new TurboSHAKE128 variable-output-length ShakeHash. // Its generic security strength is 128 bits against all attacks if at // least 32 bytes of its output are used. // D is the domain separation byte and must be between 0x01 and 0x7f inclusive. func NewTurboShake128(D byte) State { if D == 0 || D > 0x7f { panic("turboshake: D out of range") } return State{rate: rate128, dsbyte: D, turbo: true} } // NewShake256 creates a new SHAKE256 variable-output-length ShakeHash. // Its generic security strength is 256 bits against all attacks if // at least 64 bytes of its output are used. func NewShake256() State { return State{rate: rate256, dsbyte: dsbyteShake} } // NewTurboShake256 creates a new TurboSHAKE256 variable-output-length ShakeHash. // Its generic security strength is 256 bits against all attacks if // at least 64 bytes of its output are used. // D is the domain separation byte and must be between 0x01 and 0x7f inclusive. func NewTurboShake256(D byte) State { if D == 0 || D > 0x7f { panic("turboshake: D out of range") } return State{rate: rate256, dsbyte: D, turbo: true} } // ShakeSum128 writes an arbitrary-length digest of data into hash. func ShakeSum128(hash, data []byte) { h := NewShake128() _, _ = h.Write(data) _, _ = h.Read(hash) } // ShakeSum256 writes an arbitrary-length digest of data into hash. func ShakeSum256(hash, data []byte) { h := NewShake256() _, _ = h.Write(data) _, _ = h.Read(hash) } // TurboShakeSum128 writes an arbitrary-length digest of data into hash. func TurboShakeSum128(hash, data []byte, D byte) { h := NewTurboShake128(D) _, _ = h.Write(data) _, _ = h.Read(hash) } // TurboShakeSum256 writes an arbitrary-length digest of data into hash. func TurboShakeSum256(hash, data []byte, D byte) { h := NewTurboShake256(D) _, _ = h.Write(data) _, _ = h.Read(hash) } func (d *State) SwitchDS(D byte) { d.dsbyte = D }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/internal/sha3/rc.go
vendor/github.com/cloudflare/circl/internal/sha3/rc.go
package sha3 // RC stores the round constants for use in the ι step. var RC = [24]uint64{ 0x0000000000000001, 0x0000000000008082, 0x800000000000808A, 0x8000000080008000, 0x000000000000808B, 0x0000000080000001, 0x8000000080008081, 0x8000000000008009, 0x000000000000008A, 0x0000000000000088, 0x0000000080008009, 0x000000008000000A, 0x000000008000808B, 0x800000000000008B, 0x8000000000008089, 0x8000000000008003, 0x8000000000008002, 0x8000000000000080, 0x000000000000800A, 0x800000008000000A, 0x8000000080008081, 0x8000000000008080, 0x0000000080000001, 0x8000000080008008, }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/internal/sha3/xor_unaligned.go
vendor/github.com/cloudflare/circl/internal/sha3/xor_unaligned.go
// Copyright 2015 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 || 386 || ppc64le) && !appengine // +build amd64 386 ppc64le // +build !appengine package sha3 import "unsafe" // A storageBuf is an aligned array of maxRate bytes. type storageBuf [maxRate / 8]uint64 func (b *storageBuf) asBytes() *[maxRate]byte { return (*[maxRate]byte)(unsafe.Pointer(b)) } // xorInuses unaligned reads and writes to update d.a to contain d.a // XOR buf. func xorIn(d *State, buf []byte) { n := len(buf) bw := (*[maxRate / 8]uint64)(unsafe.Pointer(&buf[0]))[: n/8 : n/8] if n >= 72 { d.a[0] ^= bw[0] d.a[1] ^= bw[1] d.a[2] ^= bw[2] d.a[3] ^= bw[3] d.a[4] ^= bw[4] d.a[5] ^= bw[5] d.a[6] ^= bw[6] d.a[7] ^= bw[7] d.a[8] ^= bw[8] } if n >= 104 { d.a[9] ^= bw[9] d.a[10] ^= bw[10] d.a[11] ^= bw[11] d.a[12] ^= bw[12] } if n >= 136 { d.a[13] ^= bw[13] d.a[14] ^= bw[14] d.a[15] ^= bw[15] d.a[16] ^= bw[16] } if n >= 144 { d.a[17] ^= bw[17] } if n >= 168 { d.a[18] ^= bw[18] d.a[19] ^= bw[19] d.a[20] ^= bw[20] } } func copyOut(d *State, buf []byte) { ab := (*[maxRate]uint8)(unsafe.Pointer(&d.a[0])) copy(buf, ab[:]) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/internal/sha3/xor_generic.go
vendor/github.com/cloudflare/circl/internal/sha3/xor_generic.go
// Copyright 2015 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 || appengine) && (!386 || appengine) && (!ppc64le || appengine) // +build !amd64 appengine // +build !386 appengine // +build !ppc64le appengine package sha3 import "encoding/binary" // xorIn xors the bytes in buf into the state; it // makes no non-portable assumptions about memory layout // or alignment. func xorIn(d *State, buf []byte) { n := len(buf) / 8 for i := 0; i < n; i++ { a := binary.LittleEndian.Uint64(buf) d.a[i] ^= a buf = buf[8:] } } // copyOut copies ulint64s to a byte buffer. func copyOut(d *State, b []byte) { for i := 0; len(b) >= 8; i++ { binary.LittleEndian.PutUint64(b, d.a[i]) b = b[8:] } }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/internal/sha3/hashes.go
vendor/github.com/cloudflare/circl/internal/sha3/hashes.go
// Copyright 2014 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 sha3 // This file provides functions for creating instances of the SHA-3 // and SHAKE hash functions, as well as utility functions for hashing // bytes. // New224 creates a new SHA3-224 hash. // Its generic security strength is 224 bits against preimage attacks, // and 112 bits against collision attacks. func New224() State { return State{rate: 144, outputLen: 28, dsbyte: 0x06} } // New256 creates a new SHA3-256 hash. // Its generic security strength is 256 bits against preimage attacks, // and 128 bits against collision attacks. func New256() State { return State{rate: 136, outputLen: 32, dsbyte: 0x06} } // New384 creates a new SHA3-384 hash. // Its generic security strength is 384 bits against preimage attacks, // and 192 bits against collision attacks. func New384() State { return State{rate: 104, outputLen: 48, dsbyte: 0x06} } // New512 creates a new SHA3-512 hash. // Its generic security strength is 512 bits against preimage attacks, // and 256 bits against collision attacks. func New512() State { return State{rate: 72, outputLen: 64, dsbyte: 0x06} } // Sum224 returns the SHA3-224 digest of the data. func Sum224(data []byte) (digest [28]byte) { h := New224() _, _ = h.Write(data) h.Sum(digest[:0]) return } // Sum256 returns the SHA3-256 digest of the data. func Sum256(data []byte) (digest [32]byte) { h := New256() _, _ = h.Write(data) h.Sum(digest[:0]) return } // Sum384 returns the SHA3-384 digest of the data. func Sum384(data []byte) (digest [48]byte) { h := New384() _, _ = h.Write(data) h.Sum(digest[:0]) return } // Sum512 returns the SHA3-512 digest of the data. func Sum512(data []byte) (digest [64]byte) { h := New512() _, _ = h.Write(data) h.Sum(digest[:0]) return }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/internal/sha3/sha3.go
vendor/github.com/cloudflare/circl/internal/sha3/sha3.go
// Copyright 2014 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 sha3 // spongeDirection indicates the direction bytes are flowing through the sponge. type spongeDirection int const ( // spongeAbsorbing indicates that the sponge is absorbing input. spongeAbsorbing spongeDirection = iota // spongeSqueezing indicates that the sponge is being squeezed. spongeSqueezing ) const ( // maxRate is the maximum size of the internal buffer. SHAKE-256 // currently needs the largest buffer. maxRate = 168 ) func (d *State) buf() []byte { return d.storage.asBytes()[d.bufo:d.bufe] } type State struct { // Generic sponge components. a [25]uint64 // main state of the hash rate int // the number of bytes of state to use bufo int // offset of buffer in storage bufe int // end of buffer in storage // dsbyte contains the "domain separation" bits and the first bit of // the padding. Sections 6.1 and 6.2 of [1] separate the outputs of the // SHA-3 and SHAKE functions by appending bitstrings to the message. // Using a little-endian bit-ordering convention, these are "01" for SHA-3 // and "1111" for SHAKE, or 00000010b and 00001111b, respectively. Then the // padding rule from section 5.1 is applied to pad the message to a multiple // of the rate, which involves adding a "1" bit, zero or more "0" bits, and // a final "1" bit. We merge the first "1" bit from the padding into dsbyte, // giving 00000110b (0x06) and 00011111b (0x1f). // [1] http://csrc.nist.gov/publications/drafts/fips-202/fips_202_draft.pdf // "Draft FIPS 202: SHA-3 Standard: Permutation-Based Hash and // Extendable-Output Functions (May 2014)" dsbyte byte storage storageBuf // Specific to SHA-3 and SHAKE. outputLen int // the default output size in bytes state spongeDirection // whether the sponge is absorbing or squeezing turbo bool // Whether we're using 12 rounds instead of 24 } // BlockSize returns the rate of sponge underlying this hash function. func (d *State) BlockSize() int { return d.rate } // Size returns the output size of the hash function in bytes. func (d *State) Size() int { return d.outputLen } // Reset clears the internal state by zeroing the sponge state and // the byte buffer, and setting Sponge.state to absorbing. func (d *State) Reset() { // Zero the permutation's state. for i := range d.a { d.a[i] = 0 } d.state = spongeAbsorbing d.bufo = 0 d.bufe = 0 } func (d *State) clone() *State { ret := *d return &ret } // permute applies the KeccakF-1600 permutation. It handles // any input-output buffering. func (d *State) permute() { switch d.state { case spongeAbsorbing: // If we're absorbing, we need to xor the input into the state // before applying the permutation. xorIn(d, d.buf()) d.bufe = 0 d.bufo = 0 KeccakF1600(&d.a, d.turbo) case spongeSqueezing: // If we're squeezing, we need to apply the permutation before // copying more output. KeccakF1600(&d.a, d.turbo) d.bufe = d.rate d.bufo = 0 copyOut(d, d.buf()) } } // pads appends the domain separation bits in dsbyte, applies // the multi-bitrate 10..1 padding rule, and permutes the state. func (d *State) padAndPermute(dsbyte byte) { // Pad with this instance's domain-separator bits. We know that there's // at least one byte of space in d.buf() because, if it were full, // permute would have been called to empty it. dsbyte also contains the // first one bit for the padding. See the comment in the state struct. zerosStart := d.bufe + 1 d.bufe = d.rate buf := d.buf() buf[zerosStart-1] = dsbyte for i := zerosStart; i < d.rate; i++ { buf[i] = 0 } // This adds the final one bit for the padding. Because of the way that // bits are numbered from the LSB upwards, the final bit is the MSB of // the last byte. buf[d.rate-1] ^= 0x80 // Apply the permutation d.permute() d.state = spongeSqueezing d.bufe = d.rate copyOut(d, buf) } // Write absorbs more data into the hash's state. It produces an error // if more data is written to the ShakeHash after writing func (d *State) Write(p []byte) (written int, err error) { if d.state != spongeAbsorbing { panic("sha3: write to sponge after read") } written = len(p) for len(p) > 0 { bufl := d.bufe - d.bufo if bufl == 0 && len(p) >= d.rate { // The fast path; absorb a full "rate" bytes of input and apply the permutation. xorIn(d, p[:d.rate]) p = p[d.rate:] KeccakF1600(&d.a, d.turbo) } else { // The slow path; buffer the input until we can fill the sponge, and then xor it in. todo := d.rate - bufl if todo > len(p) { todo = len(p) } d.bufe += todo buf := d.buf() copy(buf[bufl:], p[:todo]) p = p[todo:] // If the sponge is full, apply the permutation. if d.bufe == d.rate { d.permute() } } } return written, nil } // Read squeezes an arbitrary number of bytes from the sponge. func (d *State) Read(out []byte) (n int, err error) { // If we're still absorbing, pad and apply the permutation. if d.state == spongeAbsorbing { d.padAndPermute(d.dsbyte) } n = len(out) // Now, do the squeezing. for len(out) > 0 { buf := d.buf() n := copy(out, buf) d.bufo += n out = out[n:] // Apply the permutation if we've squeezed the sponge dry. if d.bufo == d.bufe { d.permute() } } return } // Sum applies padding to the hash state and then squeezes out the desired // number of output bytes. func (d *State) Sum(in []byte) []byte { // Make a copy of the original hash so that caller can keep writing // and summing. dup := d.clone() hash := make([]byte, dup.outputLen) _, _ = dup.Read(hash) return append(in, hash...) } func (d *State) IsAbsorbing() bool { return d.state == spongeAbsorbing }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/internal/sha3/doc.go
vendor/github.com/cloudflare/circl/internal/sha3/doc.go
// Copyright 2014 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 sha3 implements the SHA-3 fixed-output-length hash functions and // the SHAKE variable-output-length hash functions defined by FIPS-202. // // Both types of hash function use the "sponge" construction and the Keccak // permutation. For a detailed specification see http://keccak.noekeon.org/ // // # Guidance // // If you aren't sure what function you need, use SHAKE256 with at least 64 // bytes of output. The SHAKE instances are faster than the SHA3 instances; // the latter have to allocate memory to conform to the hash.Hash interface. // // If you need a secret-key MAC (message authentication code), prepend the // secret key to the input, hash with SHAKE256 and read at least 32 bytes of // output. // // # Security strengths // // The SHA3-x (x equals 224, 256, 384, or 512) functions have a security // strength against preimage attacks of x bits. Since they only produce "x" // bits of output, their collision-resistance is only "x/2" bits. // // The SHAKE-256 and -128 functions have a generic security strength of 256 and // 128 bits against all attacks, provided that at least 2x bits of their output // is used. Requesting more than 64 or 32 bytes of output, respectively, does // not increase the collision-resistance of the SHAKE functions. // // # The sponge construction // // A sponge builds a pseudo-random function from a public pseudo-random // permutation, by applying the permutation to a state of "rate + capacity" // bytes, but hiding "capacity" of the bytes. // // A sponge starts out with a zero state. To hash an input using a sponge, up // to "rate" bytes of the input are XORed into the sponge's state. The sponge // is then "full" and the permutation is applied to "empty" it. This process is // repeated until all the input has been "absorbed". The input is then padded. // The digest is "squeezed" from the sponge in the same way, except that output // is copied out instead of input being XORed in. // // A sponge is parameterized by its generic security strength, which is equal // to half its capacity; capacity + rate is equal to the permutation's width. // Since the KeccakF-1600 permutation is 1600 bits (200 bytes) wide, this means // that the security strength of a sponge instance is equal to (1600 - bitrate) / 2. // // # Recommendations // // The SHAKE functions are recommended for most new uses. They can produce // output of arbitrary length. SHAKE256, with an output length of at least // 64 bytes, provides 256-bit security against all attacks. The Keccak team // recommends it for most applications upgrading from SHA2-512. (NIST chose a // much stronger, but much slower, sponge instance for SHA3-512.) // // The SHA-3 functions are "drop-in" replacements for the SHA-2 functions. // They produce output of the same length, with the same security strengths // against all attacks. This means, in particular, that SHA3-256 only has // 128-bit collision resistance, because its output length is 32 bytes. package sha3
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/internal/sha3/xor.go
vendor/github.com/cloudflare/circl/internal/sha3/xor.go
// Copyright 2015 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 && !386 && !ppc64le) || appengine // +build !amd64,!386,!ppc64le appengine package sha3 // A storageBuf is an aligned array of maxRate bytes. type storageBuf [maxRate]byte func (b *storageBuf) asBytes() *[maxRate]byte { return (*[maxRate]byte)(b) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/cloudflare/circl/internal/sha3/keccakf.go
vendor/github.com/cloudflare/circl/internal/sha3/keccakf.go
// Copyright 2014 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 sha3 // KeccakF1600 applies the Keccak permutation to a 1600b-wide // state represented as a slice of 25 uint64s. // If turbo is true, applies the 12-round variant instead of the // regular 24-round variant. // nolint:funlen func KeccakF1600(a *[25]uint64, turbo bool) { // Implementation translated from Keccak-inplace.c // in the keccak reference code. var t, bc0, bc1, bc2, bc3, bc4, d0, d1, d2, d3, d4 uint64 i := 0 if turbo { i = 12 } for ; i < 24; i += 4 { // Combines the 5 steps in each round into 2 steps. // Unrolls 4 rounds per loop and spreads some steps across rounds. // Round 1 bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20] bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21] bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22] bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23] bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24] d0 = bc4 ^ (bc1<<1 | bc1>>63) d1 = bc0 ^ (bc2<<1 | bc2>>63) d2 = bc1 ^ (bc3<<1 | bc3>>63) d3 = bc2 ^ (bc4<<1 | bc4>>63) d4 = bc3 ^ (bc0<<1 | bc0>>63) bc0 = a[0] ^ d0 t = a[6] ^ d1 bc1 = t<<44 | t>>(64-44) t = a[12] ^ d2 bc2 = t<<43 | t>>(64-43) t = a[18] ^ d3 bc3 = t<<21 | t>>(64-21) t = a[24] ^ d4 bc4 = t<<14 | t>>(64-14) a[0] = bc0 ^ (bc2 &^ bc1) ^ RC[i] a[6] = bc1 ^ (bc3 &^ bc2) a[12] = bc2 ^ (bc4 &^ bc3) a[18] = bc3 ^ (bc0 &^ bc4) a[24] = bc4 ^ (bc1 &^ bc0) t = a[10] ^ d0 bc2 = t<<3 | t>>(64-3) t = a[16] ^ d1 bc3 = t<<45 | t>>(64-45) t = a[22] ^ d2 bc4 = t<<61 | t>>(64-61) t = a[3] ^ d3 bc0 = t<<28 | t>>(64-28) t = a[9] ^ d4 bc1 = t<<20 | t>>(64-20) a[10] = bc0 ^ (bc2 &^ bc1) a[16] = bc1 ^ (bc3 &^ bc2) a[22] = bc2 ^ (bc4 &^ bc3) a[3] = bc3 ^ (bc0 &^ bc4) a[9] = bc4 ^ (bc1 &^ bc0) t = a[20] ^ d0 bc4 = t<<18 | t>>(64-18) t = a[1] ^ d1 bc0 = t<<1 | t>>(64-1) t = a[7] ^ d2 bc1 = t<<6 | t>>(64-6) t = a[13] ^ d3 bc2 = t<<25 | t>>(64-25) t = a[19] ^ d4 bc3 = t<<8 | t>>(64-8) a[20] = bc0 ^ (bc2 &^ bc1) a[1] = bc1 ^ (bc3 &^ bc2) a[7] = bc2 ^ (bc4 &^ bc3) a[13] = bc3 ^ (bc0 &^ bc4) a[19] = bc4 ^ (bc1 &^ bc0) t = a[5] ^ d0 bc1 = t<<36 | t>>(64-36) t = a[11] ^ d1 bc2 = t<<10 | t>>(64-10) t = a[17] ^ d2 bc3 = t<<15 | t>>(64-15) t = a[23] ^ d3 bc4 = t<<56 | t>>(64-56) t = a[4] ^ d4 bc0 = t<<27 | t>>(64-27) a[5] = bc0 ^ (bc2 &^ bc1) a[11] = bc1 ^ (bc3 &^ bc2) a[17] = bc2 ^ (bc4 &^ bc3) a[23] = bc3 ^ (bc0 &^ bc4) a[4] = bc4 ^ (bc1 &^ bc0) t = a[15] ^ d0 bc3 = t<<41 | t>>(64-41) t = a[21] ^ d1 bc4 = t<<2 | t>>(64-2) t = a[2] ^ d2 bc0 = t<<62 | t>>(64-62) t = a[8] ^ d3 bc1 = t<<55 | t>>(64-55) t = a[14] ^ d4 bc2 = t<<39 | t>>(64-39) a[15] = bc0 ^ (bc2 &^ bc1) a[21] = bc1 ^ (bc3 &^ bc2) a[2] = bc2 ^ (bc4 &^ bc3) a[8] = bc3 ^ (bc0 &^ bc4) a[14] = bc4 ^ (bc1 &^ bc0) // Round 2 bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20] bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21] bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22] bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23] bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24] d0 = bc4 ^ (bc1<<1 | bc1>>63) d1 = bc0 ^ (bc2<<1 | bc2>>63) d2 = bc1 ^ (bc3<<1 | bc3>>63) d3 = bc2 ^ (bc4<<1 | bc4>>63) d4 = bc3 ^ (bc0<<1 | bc0>>63) bc0 = a[0] ^ d0 t = a[16] ^ d1 bc1 = t<<44 | t>>(64-44) t = a[7] ^ d2 bc2 = t<<43 | t>>(64-43) t = a[23] ^ d3 bc3 = t<<21 | t>>(64-21) t = a[14] ^ d4 bc4 = t<<14 | t>>(64-14) a[0] = bc0 ^ (bc2 &^ bc1) ^ RC[i+1] a[16] = bc1 ^ (bc3 &^ bc2) a[7] = bc2 ^ (bc4 &^ bc3) a[23] = bc3 ^ (bc0 &^ bc4) a[14] = bc4 ^ (bc1 &^ bc0) t = a[20] ^ d0 bc2 = t<<3 | t>>(64-3) t = a[11] ^ d1 bc3 = t<<45 | t>>(64-45) t = a[2] ^ d2 bc4 = t<<61 | t>>(64-61) t = a[18] ^ d3 bc0 = t<<28 | t>>(64-28) t = a[9] ^ d4 bc1 = t<<20 | t>>(64-20) a[20] = bc0 ^ (bc2 &^ bc1) a[11] = bc1 ^ (bc3 &^ bc2) a[2] = bc2 ^ (bc4 &^ bc3) a[18] = bc3 ^ (bc0 &^ bc4) a[9] = bc4 ^ (bc1 &^ bc0) t = a[15] ^ d0 bc4 = t<<18 | t>>(64-18) t = a[6] ^ d1 bc0 = t<<1 | t>>(64-1) t = a[22] ^ d2 bc1 = t<<6 | t>>(64-6) t = a[13] ^ d3 bc2 = t<<25 | t>>(64-25) t = a[4] ^ d4 bc3 = t<<8 | t>>(64-8) a[15] = bc0 ^ (bc2 &^ bc1) a[6] = bc1 ^ (bc3 &^ bc2) a[22] = bc2 ^ (bc4 &^ bc3) a[13] = bc3 ^ (bc0 &^ bc4) a[4] = bc4 ^ (bc1 &^ bc0) t = a[10] ^ d0 bc1 = t<<36 | t>>(64-36) t = a[1] ^ d1 bc2 = t<<10 | t>>(64-10) t = a[17] ^ d2 bc3 = t<<15 | t>>(64-15) t = a[8] ^ d3 bc4 = t<<56 | t>>(64-56) t = a[24] ^ d4 bc0 = t<<27 | t>>(64-27) a[10] = bc0 ^ (bc2 &^ bc1) a[1] = bc1 ^ (bc3 &^ bc2) a[17] = bc2 ^ (bc4 &^ bc3) a[8] = bc3 ^ (bc0 &^ bc4) a[24] = bc4 ^ (bc1 &^ bc0) t = a[5] ^ d0 bc3 = t<<41 | t>>(64-41) t = a[21] ^ d1 bc4 = t<<2 | t>>(64-2) t = a[12] ^ d2 bc0 = t<<62 | t>>(64-62) t = a[3] ^ d3 bc1 = t<<55 | t>>(64-55) t = a[19] ^ d4 bc2 = t<<39 | t>>(64-39) a[5] = bc0 ^ (bc2 &^ bc1) a[21] = bc1 ^ (bc3 &^ bc2) a[12] = bc2 ^ (bc4 &^ bc3) a[3] = bc3 ^ (bc0 &^ bc4) a[19] = bc4 ^ (bc1 &^ bc0) // Round 3 bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20] bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21] bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22] bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23] bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24] d0 = bc4 ^ (bc1<<1 | bc1>>63) d1 = bc0 ^ (bc2<<1 | bc2>>63) d2 = bc1 ^ (bc3<<1 | bc3>>63) d3 = bc2 ^ (bc4<<1 | bc4>>63) d4 = bc3 ^ (bc0<<1 | bc0>>63) bc0 = a[0] ^ d0 t = a[11] ^ d1 bc1 = t<<44 | t>>(64-44) t = a[22] ^ d2 bc2 = t<<43 | t>>(64-43) t = a[8] ^ d3 bc3 = t<<21 | t>>(64-21) t = a[19] ^ d4 bc4 = t<<14 | t>>(64-14) a[0] = bc0 ^ (bc2 &^ bc1) ^ RC[i+2] a[11] = bc1 ^ (bc3 &^ bc2) a[22] = bc2 ^ (bc4 &^ bc3) a[8] = bc3 ^ (bc0 &^ bc4) a[19] = bc4 ^ (bc1 &^ bc0) t = a[15] ^ d0 bc2 = t<<3 | t>>(64-3) t = a[1] ^ d1 bc3 = t<<45 | t>>(64-45) t = a[12] ^ d2 bc4 = t<<61 | t>>(64-61) t = a[23] ^ d3 bc0 = t<<28 | t>>(64-28) t = a[9] ^ d4 bc1 = t<<20 | t>>(64-20) a[15] = bc0 ^ (bc2 &^ bc1) a[1] = bc1 ^ (bc3 &^ bc2) a[12] = bc2 ^ (bc4 &^ bc3) a[23] = bc3 ^ (bc0 &^ bc4) a[9] = bc4 ^ (bc1 &^ bc0) t = a[5] ^ d0 bc4 = t<<18 | t>>(64-18) t = a[16] ^ d1 bc0 = t<<1 | t>>(64-1) t = a[2] ^ d2 bc1 = t<<6 | t>>(64-6) t = a[13] ^ d3 bc2 = t<<25 | t>>(64-25) t = a[24] ^ d4 bc3 = t<<8 | t>>(64-8) a[5] = bc0 ^ (bc2 &^ bc1) a[16] = bc1 ^ (bc3 &^ bc2) a[2] = bc2 ^ (bc4 &^ bc3) a[13] = bc3 ^ (bc0 &^ bc4) a[24] = bc4 ^ (bc1 &^ bc0) t = a[20] ^ d0 bc1 = t<<36 | t>>(64-36) t = a[6] ^ d1 bc2 = t<<10 | t>>(64-10) t = a[17] ^ d2 bc3 = t<<15 | t>>(64-15) t = a[3] ^ d3 bc4 = t<<56 | t>>(64-56) t = a[14] ^ d4 bc0 = t<<27 | t>>(64-27) a[20] = bc0 ^ (bc2 &^ bc1) a[6] = bc1 ^ (bc3 &^ bc2) a[17] = bc2 ^ (bc4 &^ bc3) a[3] = bc3 ^ (bc0 &^ bc4) a[14] = bc4 ^ (bc1 &^ bc0) t = a[10] ^ d0 bc3 = t<<41 | t>>(64-41) t = a[21] ^ d1 bc4 = t<<2 | t>>(64-2) t = a[7] ^ d2 bc0 = t<<62 | t>>(64-62) t = a[18] ^ d3 bc1 = t<<55 | t>>(64-55) t = a[4] ^ d4 bc2 = t<<39 | t>>(64-39) a[10] = bc0 ^ (bc2 &^ bc1) a[21] = bc1 ^ (bc3 &^ bc2) a[7] = bc2 ^ (bc4 &^ bc3) a[18] = bc3 ^ (bc0 &^ bc4) a[4] = bc4 ^ (bc1 &^ bc0) // Round 4 bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20] bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21] bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22] bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23] bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24] d0 = bc4 ^ (bc1<<1 | bc1>>63) d1 = bc0 ^ (bc2<<1 | bc2>>63) d2 = bc1 ^ (bc3<<1 | bc3>>63) d3 = bc2 ^ (bc4<<1 | bc4>>63) d4 = bc3 ^ (bc0<<1 | bc0>>63) bc0 = a[0] ^ d0 t = a[1] ^ d1 bc1 = t<<44 | t>>(64-44) t = a[2] ^ d2 bc2 = t<<43 | t>>(64-43) t = a[3] ^ d3 bc3 = t<<21 | t>>(64-21) t = a[4] ^ d4 bc4 = t<<14 | t>>(64-14) a[0] = bc0 ^ (bc2 &^ bc1) ^ RC[i+3] a[1] = bc1 ^ (bc3 &^ bc2) a[2] = bc2 ^ (bc4 &^ bc3) a[3] = bc3 ^ (bc0 &^ bc4) a[4] = bc4 ^ (bc1 &^ bc0) t = a[5] ^ d0 bc2 = t<<3 | t>>(64-3) t = a[6] ^ d1 bc3 = t<<45 | t>>(64-45) t = a[7] ^ d2 bc4 = t<<61 | t>>(64-61) t = a[8] ^ d3 bc0 = t<<28 | t>>(64-28) t = a[9] ^ d4 bc1 = t<<20 | t>>(64-20) a[5] = bc0 ^ (bc2 &^ bc1) a[6] = bc1 ^ (bc3 &^ bc2) a[7] = bc2 ^ (bc4 &^ bc3) a[8] = bc3 ^ (bc0 &^ bc4) a[9] = bc4 ^ (bc1 &^ bc0) t = a[10] ^ d0 bc4 = t<<18 | t>>(64-18) t = a[11] ^ d1 bc0 = t<<1 | t>>(64-1) t = a[12] ^ d2 bc1 = t<<6 | t>>(64-6) t = a[13] ^ d3 bc2 = t<<25 | t>>(64-25) t = a[14] ^ d4 bc3 = t<<8 | t>>(64-8) a[10] = bc0 ^ (bc2 &^ bc1) a[11] = bc1 ^ (bc3 &^ bc2) a[12] = bc2 ^ (bc4 &^ bc3) a[13] = bc3 ^ (bc0 &^ bc4) a[14] = bc4 ^ (bc1 &^ bc0) t = a[15] ^ d0 bc1 = t<<36 | t>>(64-36) t = a[16] ^ d1 bc2 = t<<10 | t>>(64-10) t = a[17] ^ d2 bc3 = t<<15 | t>>(64-15) t = a[18] ^ d3 bc4 = t<<56 | t>>(64-56) t = a[19] ^ d4 bc0 = t<<27 | t>>(64-27) a[15] = bc0 ^ (bc2 &^ bc1) a[16] = bc1 ^ (bc3 &^ bc2) a[17] = bc2 ^ (bc4 &^ bc3) a[18] = bc3 ^ (bc0 &^ bc4) a[19] = bc4 ^ (bc1 &^ bc0) t = a[20] ^ d0 bc3 = t<<41 | t>>(64-41) t = a[21] ^ d1 bc4 = t<<2 | t>>(64-2) t = a[22] ^ d2 bc0 = t<<62 | t>>(64-62) t = a[23] ^ d3 bc1 = t<<55 | t>>(64-55) t = a[24] ^ d4 bc2 = t<<39 | t>>(64-39) a[20] = bc0 ^ (bc2 &^ bc1) a[21] = bc1 ^ (bc3 &^ bc2) a[22] = bc2 ^ (bc4 &^ bc3) a[23] = bc3 ^ (bc0 &^ bc4) a[24] = bc4 ^ (bc1 &^ bc0) } }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/pmezard/go-difflib/difflib/difflib.go
vendor/github.com/pmezard/go-difflib/difflib/difflib.go
// Package difflib is a partial port of Python difflib module. // // It provides tools to compare sequences of strings and generate textual diffs. // // The following class and functions have been ported: // // - SequenceMatcher // // - unified_diff // // - context_diff // // Getting unified diffs was the main goal of the port. Keep in mind this code // is mostly suitable to output text differences in a human friendly way, there // are no guarantees generated diffs are consumable by patch(1). package difflib import ( "bufio" "bytes" "fmt" "io" "strings" ) func min(a, b int) int { if a < b { return a } return b } func max(a, b int) int { if a > b { return a } return b } func calculateRatio(matches, length int) float64 { if length > 0 { return 2.0 * float64(matches) / float64(length) } return 1.0 } type Match struct { A int B int Size int } type OpCode struct { Tag byte I1 int I2 int J1 int J2 int } // SequenceMatcher compares sequence of strings. The basic // algorithm predates, and is a little fancier than, an algorithm // published in the late 1980's by Ratcliff and Obershelp under the // hyperbolic name "gestalt pattern matching". The basic idea is to find // the longest contiguous matching subsequence that contains no "junk" // elements (R-O doesn't address junk). The same idea is then applied // recursively to the pieces of the sequences to the left and to the right // of the matching subsequence. This does not yield minimal edit // sequences, but does tend to yield matches that "look right" to people. // // SequenceMatcher tries to compute a "human-friendly diff" between two // sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the // longest *contiguous* & junk-free matching subsequence. That's what // catches peoples' eyes. The Windows(tm) windiff has another interesting // notion, pairing up elements that appear uniquely in each sequence. // That, and the method here, appear to yield more intuitive difference // reports than does diff. This method appears to be the least vulnerable // to synching up on blocks of "junk lines", though (like blank lines in // ordinary text files, or maybe "<P>" lines in HTML files). That may be // because this is the only method of the 3 that has a *concept* of // "junk" <wink>. // // Timing: Basic R-O is cubic time worst case and quadratic time expected // case. SequenceMatcher is quadratic time for the worst case and has // expected-case behavior dependent in a complicated way on how many // elements the sequences have in common; best case time is linear. type SequenceMatcher struct { a []string b []string b2j map[string][]int IsJunk func(string) bool autoJunk bool bJunk map[string]struct{} matchingBlocks []Match fullBCount map[string]int bPopular map[string]struct{} opCodes []OpCode } func NewMatcher(a, b []string) *SequenceMatcher { m := SequenceMatcher{autoJunk: true} m.SetSeqs(a, b) return &m } func NewMatcherWithJunk(a, b []string, autoJunk bool, isJunk func(string) bool) *SequenceMatcher { m := SequenceMatcher{IsJunk: isJunk, autoJunk: autoJunk} m.SetSeqs(a, b) return &m } // Set two sequences to be compared. func (m *SequenceMatcher) SetSeqs(a, b []string) { m.SetSeq1(a) m.SetSeq2(b) } // Set the first sequence to be compared. The second sequence to be compared is // not changed. // // SequenceMatcher computes and caches detailed information about the second // sequence, so if you want to compare one sequence S against many sequences, // use .SetSeq2(s) once and call .SetSeq1(x) repeatedly for each of the other // sequences. // // See also SetSeqs() and SetSeq2(). func (m *SequenceMatcher) SetSeq1(a []string) { if &a == &m.a { return } m.a = a m.matchingBlocks = nil m.opCodes = nil } // Set the second sequence to be compared. The first sequence to be compared is // not changed. func (m *SequenceMatcher) SetSeq2(b []string) { if &b == &m.b { return } m.b = b m.matchingBlocks = nil m.opCodes = nil m.fullBCount = nil m.chainB() } func (m *SequenceMatcher) chainB() { // Populate line -> index mapping b2j := map[string][]int{} for i, s := range m.b { indices := b2j[s] indices = append(indices, i) b2j[s] = indices } // Purge junk elements m.bJunk = map[string]struct{}{} if m.IsJunk != nil { junk := m.bJunk for s, _ := range b2j { if m.IsJunk(s) { junk[s] = struct{}{} } } for s, _ := range junk { delete(b2j, s) } } // Purge remaining popular elements popular := map[string]struct{}{} n := len(m.b) if m.autoJunk && n >= 200 { ntest := n/100 + 1 for s, indices := range b2j { if len(indices) > ntest { popular[s] = struct{}{} } } for s, _ := range popular { delete(b2j, s) } } m.bPopular = popular m.b2j = b2j } func (m *SequenceMatcher) isBJunk(s string) bool { _, ok := m.bJunk[s] return ok } // Find longest matching block in a[alo:ahi] and b[blo:bhi]. // // If IsJunk is not defined: // // Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where // alo <= i <= i+k <= ahi // blo <= j <= j+k <= bhi // and for all (i',j',k') meeting those conditions, // k >= k' // i <= i' // and if i == i', j <= j' // // In other words, of all maximal matching blocks, return one that // starts earliest in a, and of all those maximal matching blocks that // start earliest in a, return the one that starts earliest in b. // // If IsJunk is defined, first the longest matching block is // determined as above, but with the additional restriction that no // junk element appears in the block. Then that block is extended as // far as possible by matching (only) junk elements on both sides. So // the resulting block never matches on junk except as identical junk // happens to be adjacent to an "interesting" match. // // If no blocks match, return (alo, blo, 0). func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Match { // CAUTION: stripping common prefix or suffix would be incorrect. // E.g., // ab // acab // Longest matching block is "ab", but if common prefix is // stripped, it's "a" (tied with "b"). UNIX(tm) diff does so // strip, so ends up claiming that ab is changed to acab by // inserting "ca" in the middle. That's minimal but unintuitive: // "it's obvious" that someone inserted "ac" at the front. // Windiff ends up at the same place as diff, but by pairing up // the unique 'b's and then matching the first two 'a's. besti, bestj, bestsize := alo, blo, 0 // find longest junk-free match // during an iteration of the loop, j2len[j] = length of longest // junk-free match ending with a[i-1] and b[j] j2len := map[int]int{} for i := alo; i != ahi; i++ { // look at all instances of a[i] in b; note that because // b2j has no junk keys, the loop is skipped if a[i] is junk newj2len := map[int]int{} for _, j := range m.b2j[m.a[i]] { // a[i] matches b[j] if j < blo { continue } if j >= bhi { break } k := j2len[j-1] + 1 newj2len[j] = k if k > bestsize { besti, bestj, bestsize = i-k+1, j-k+1, k } } j2len = newj2len } // Extend the best by non-junk elements on each end. In particular, // "popular" non-junk elements aren't in b2j, which greatly speeds // the inner loop above, but also means "the best" match so far // doesn't contain any junk *or* popular non-junk elements. for besti > alo && bestj > blo && !m.isBJunk(m.b[bestj-1]) && m.a[besti-1] == m.b[bestj-1] { besti, bestj, bestsize = besti-1, bestj-1, bestsize+1 } for besti+bestsize < ahi && bestj+bestsize < bhi && !m.isBJunk(m.b[bestj+bestsize]) && m.a[besti+bestsize] == m.b[bestj+bestsize] { bestsize += 1 } // Now that we have a wholly interesting match (albeit possibly // empty!), we may as well suck up the matching junk on each // side of it too. Can't think of a good reason not to, and it // saves post-processing the (possibly considerable) expense of // figuring out what to do with it. In the case of an empty // interesting match, this is clearly the right thing to do, // because no other kind of match is possible in the regions. for besti > alo && bestj > blo && m.isBJunk(m.b[bestj-1]) && m.a[besti-1] == m.b[bestj-1] { besti, bestj, bestsize = besti-1, bestj-1, bestsize+1 } for besti+bestsize < ahi && bestj+bestsize < bhi && m.isBJunk(m.b[bestj+bestsize]) && m.a[besti+bestsize] == m.b[bestj+bestsize] { bestsize += 1 } return Match{A: besti, B: bestj, Size: bestsize} } // Return list of triples describing matching subsequences. // // Each triple is of the form (i, j, n), and means that // a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in // i and in j. It's also guaranteed that if (i, j, n) and (i', j', n') are // adjacent triples in the list, and the second is not the last triple in the // list, then i+n != i' or j+n != j'. IOW, adjacent triples never describe // adjacent equal blocks. // // The last triple is a dummy, (len(a), len(b), 0), and is the only // triple with n==0. func (m *SequenceMatcher) GetMatchingBlocks() []Match { if m.matchingBlocks != nil { return m.matchingBlocks } var matchBlocks func(alo, ahi, blo, bhi int, matched []Match) []Match matchBlocks = func(alo, ahi, blo, bhi int, matched []Match) []Match { match := m.findLongestMatch(alo, ahi, blo, bhi) i, j, k := match.A, match.B, match.Size if match.Size > 0 { if alo < i && blo < j { matched = matchBlocks(alo, i, blo, j, matched) } matched = append(matched, match) if i+k < ahi && j+k < bhi { matched = matchBlocks(i+k, ahi, j+k, bhi, matched) } } return matched } matched := matchBlocks(0, len(m.a), 0, len(m.b), nil) // It's possible that we have adjacent equal blocks in the // matching_blocks list now. nonAdjacent := []Match{} i1, j1, k1 := 0, 0, 0 for _, b := range matched { // Is this block adjacent to i1, j1, k1? i2, j2, k2 := b.A, b.B, b.Size if i1+k1 == i2 && j1+k1 == j2 { // Yes, so collapse them -- this just increases the length of // the first block by the length of the second, and the first // block so lengthened remains the block to compare against. k1 += k2 } else { // Not adjacent. Remember the first block (k1==0 means it's // the dummy we started with), and make the second block the // new block to compare against. if k1 > 0 { nonAdjacent = append(nonAdjacent, Match{i1, j1, k1}) } i1, j1, k1 = i2, j2, k2 } } if k1 > 0 { nonAdjacent = append(nonAdjacent, Match{i1, j1, k1}) } nonAdjacent = append(nonAdjacent, Match{len(m.a), len(m.b), 0}) m.matchingBlocks = nonAdjacent return m.matchingBlocks } // Return list of 5-tuples describing how to turn a into b. // // Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple // has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the // tuple preceding it, and likewise for j1 == the previous j2. // // The tags are characters, with these meanings: // // 'r' (replace): a[i1:i2] should be replaced by b[j1:j2] // // 'd' (delete): a[i1:i2] should be deleted, j1==j2 in this case. // // 'i' (insert): b[j1:j2] should be inserted at a[i1:i1], i1==i2 in this case. // // 'e' (equal): a[i1:i2] == b[j1:j2] func (m *SequenceMatcher) GetOpCodes() []OpCode { if m.opCodes != nil { return m.opCodes } i, j := 0, 0 matching := m.GetMatchingBlocks() opCodes := make([]OpCode, 0, len(matching)) for _, m := range matching { // invariant: we've pumped out correct diffs to change // a[:i] into b[:j], and the next matching block is // a[ai:ai+size] == b[bj:bj+size]. So we need to pump // out a diff to change a[i:ai] into b[j:bj], pump out // the matching block, and move (i,j) beyond the match ai, bj, size := m.A, m.B, m.Size tag := byte(0) if i < ai && j < bj { tag = 'r' } else if i < ai { tag = 'd' } else if j < bj { tag = 'i' } if tag > 0 { opCodes = append(opCodes, OpCode{tag, i, ai, j, bj}) } i, j = ai+size, bj+size // the list of matching blocks is terminated by a // sentinel with size 0 if size > 0 { opCodes = append(opCodes, OpCode{'e', ai, i, bj, j}) } } m.opCodes = opCodes return m.opCodes } // Isolate change clusters by eliminating ranges with no changes. // // Return a generator of groups with up to n lines of context. // Each group is in the same format as returned by GetOpCodes(). func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode { if n < 0 { n = 3 } codes := m.GetOpCodes() if len(codes) == 0 { codes = []OpCode{OpCode{'e', 0, 1, 0, 1}} } // Fixup leading and trailing groups if they show no changes. if codes[0].Tag == 'e' { c := codes[0] i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 codes[0] = OpCode{c.Tag, max(i1, i2-n), i2, max(j1, j2-n), j2} } if codes[len(codes)-1].Tag == 'e' { c := codes[len(codes)-1] i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 codes[len(codes)-1] = OpCode{c.Tag, i1, min(i2, i1+n), j1, min(j2, j1+n)} } nn := n + n groups := [][]OpCode{} group := []OpCode{} for _, c := range codes { i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 // End the current group and start a new one whenever // there is a large range with no changes. if c.Tag == 'e' && i2-i1 > nn { group = append(group, OpCode{c.Tag, i1, min(i2, i1+n), j1, min(j2, j1+n)}) groups = append(groups, group) group = []OpCode{} i1, j1 = max(i1, i2-n), max(j1, j2-n) } group = append(group, OpCode{c.Tag, i1, i2, j1, j2}) } if len(group) > 0 && !(len(group) == 1 && group[0].Tag == 'e') { groups = append(groups, group) } return groups } // Return a measure of the sequences' similarity (float in [0,1]). // // Where T is the total number of elements in both sequences, and // M is the number of matches, this is 2.0*M / T. // Note that this is 1 if the sequences are identical, and 0 if // they have nothing in common. // // .Ratio() is expensive to compute if you haven't already computed // .GetMatchingBlocks() or .GetOpCodes(), in which case you may // want to try .QuickRatio() or .RealQuickRation() first to get an // upper bound. func (m *SequenceMatcher) Ratio() float64 { matches := 0 for _, m := range m.GetMatchingBlocks() { matches += m.Size } return calculateRatio(matches, len(m.a)+len(m.b)) } // Return an upper bound on ratio() relatively quickly. // // This isn't defined beyond that it is an upper bound on .Ratio(), and // is faster to compute. func (m *SequenceMatcher) QuickRatio() float64 { // viewing a and b as multisets, set matches to the cardinality // of their intersection; this counts the number of matches // without regard to order, so is clearly an upper bound if m.fullBCount == nil { m.fullBCount = map[string]int{} for _, s := range m.b { m.fullBCount[s] = m.fullBCount[s] + 1 } } // avail[x] is the number of times x appears in 'b' less the // number of times we've seen it in 'a' so far ... kinda avail := map[string]int{} matches := 0 for _, s := range m.a { n, ok := avail[s] if !ok { n = m.fullBCount[s] } avail[s] = n - 1 if n > 0 { matches += 1 } } return calculateRatio(matches, len(m.a)+len(m.b)) } // Return an upper bound on ratio() very quickly. // // This isn't defined beyond that it is an upper bound on .Ratio(), and // is faster to compute than either .Ratio() or .QuickRatio(). func (m *SequenceMatcher) RealQuickRatio() float64 { la, lb := len(m.a), len(m.b) return calculateRatio(min(la, lb), la+lb) } // Convert range to the "ed" format func formatRangeUnified(start, stop int) string { // Per the diff spec at http://www.unix.org/single_unix_specification/ beginning := start + 1 // lines start numbering with one length := stop - start if length == 1 { return fmt.Sprintf("%d", beginning) } if length == 0 { beginning -= 1 // empty ranges begin at line just before the range } return fmt.Sprintf("%d,%d", beginning, length) } // Unified diff parameters type UnifiedDiff struct { A []string // First sequence lines FromFile string // First file name FromDate string // First file time B []string // Second sequence lines ToFile string // Second file name ToDate string // Second file time Eol string // Headers end of line, defaults to LF Context int // Number of context lines } // Compare two sequences of lines; generate the delta as a unified diff. // // Unified diffs are a compact way of showing line changes and a few // lines of context. The number of context lines is set by 'n' which // defaults to three. // // By default, the diff control lines (those with ---, +++, or @@) are // created with a trailing newline. This is helpful so that inputs // created from file.readlines() result in diffs that are suitable for // file.writelines() since both the inputs and outputs have trailing // newlines. // // For inputs that do not have trailing newlines, set the lineterm // argument to "" so that the output will be uniformly newline free. // // The unidiff format normally has a header for filenames and modification // times. Any or all of these may be specified using strings for // 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. // The modification times are normally expressed in the ISO 8601 format. func WriteUnifiedDiff(writer io.Writer, diff UnifiedDiff) error { buf := bufio.NewWriter(writer) defer buf.Flush() wf := func(format string, args ...interface{}) error { _, err := buf.WriteString(fmt.Sprintf(format, args...)) return err } ws := func(s string) error { _, err := buf.WriteString(s) return err } if len(diff.Eol) == 0 { diff.Eol = "\n" } started := false m := NewMatcher(diff.A, diff.B) for _, g := range m.GetGroupedOpCodes(diff.Context) { if !started { started = true fromDate := "" if len(diff.FromDate) > 0 { fromDate = "\t" + diff.FromDate } toDate := "" if len(diff.ToDate) > 0 { toDate = "\t" + diff.ToDate } if diff.FromFile != "" || diff.ToFile != "" { err := wf("--- %s%s%s", diff.FromFile, fromDate, diff.Eol) if err != nil { return err } err = wf("+++ %s%s%s", diff.ToFile, toDate, diff.Eol) if err != nil { return err } } } first, last := g[0], g[len(g)-1] range1 := formatRangeUnified(first.I1, last.I2) range2 := formatRangeUnified(first.J1, last.J2) if err := wf("@@ -%s +%s @@%s", range1, range2, diff.Eol); err != nil { return err } for _, c := range g { i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 if c.Tag == 'e' { for _, line := range diff.A[i1:i2] { if err := ws(" " + line); err != nil { return err } } continue } if c.Tag == 'r' || c.Tag == 'd' { for _, line := range diff.A[i1:i2] { if err := ws("-" + line); err != nil { return err } } } if c.Tag == 'r' || c.Tag == 'i' { for _, line := range diff.B[j1:j2] { if err := ws("+" + line); err != nil { return err } } } } } return nil } // Like WriteUnifiedDiff but returns the diff a string. func GetUnifiedDiffString(diff UnifiedDiff) (string, error) { w := &bytes.Buffer{} err := WriteUnifiedDiff(w, diff) return string(w.Bytes()), err } // Convert range to the "ed" format. func formatRangeContext(start, stop int) string { // Per the diff spec at http://www.unix.org/single_unix_specification/ beginning := start + 1 // lines start numbering with one length := stop - start if length == 0 { beginning -= 1 // empty ranges begin at line just before the range } if length <= 1 { return fmt.Sprintf("%d", beginning) } return fmt.Sprintf("%d,%d", beginning, beginning+length-1) } type ContextDiff UnifiedDiff // Compare two sequences of lines; generate the delta as a context diff. // // Context diffs are a compact way of showing line changes and a few // lines of context. The number of context lines is set by diff.Context // which defaults to three. // // By default, the diff control lines (those with *** or ---) are // created with a trailing newline. // // For inputs that do not have trailing newlines, set the diff.Eol // argument to "" so that the output will be uniformly newline free. // // The context diff format normally has a header for filenames and // modification times. Any or all of these may be specified using // strings for diff.FromFile, diff.ToFile, diff.FromDate, diff.ToDate. // The modification times are normally expressed in the ISO 8601 format. // If not specified, the strings default to blanks. func WriteContextDiff(writer io.Writer, diff ContextDiff) error { buf := bufio.NewWriter(writer) defer buf.Flush() var diffErr error wf := func(format string, args ...interface{}) { _, err := buf.WriteString(fmt.Sprintf(format, args...)) if diffErr == nil && err != nil { diffErr = err } } ws := func(s string) { _, err := buf.WriteString(s) if diffErr == nil && err != nil { diffErr = err } } if len(diff.Eol) == 0 { diff.Eol = "\n" } prefix := map[byte]string{ 'i': "+ ", 'd': "- ", 'r': "! ", 'e': " ", } started := false m := NewMatcher(diff.A, diff.B) for _, g := range m.GetGroupedOpCodes(diff.Context) { if !started { started = true fromDate := "" if len(diff.FromDate) > 0 { fromDate = "\t" + diff.FromDate } toDate := "" if len(diff.ToDate) > 0 { toDate = "\t" + diff.ToDate } if diff.FromFile != "" || diff.ToFile != "" { wf("*** %s%s%s", diff.FromFile, fromDate, diff.Eol) wf("--- %s%s%s", diff.ToFile, toDate, diff.Eol) } } first, last := g[0], g[len(g)-1] ws("***************" + diff.Eol) range1 := formatRangeContext(first.I1, last.I2) wf("*** %s ****%s", range1, diff.Eol) for _, c := range g { if c.Tag == 'r' || c.Tag == 'd' { for _, cc := range g { if cc.Tag == 'i' { continue } for _, line := range diff.A[cc.I1:cc.I2] { ws(prefix[cc.Tag] + line) } } break } } range2 := formatRangeContext(first.J1, last.J2) wf("--- %s ----%s", range2, diff.Eol) for _, c := range g { if c.Tag == 'r' || c.Tag == 'i' { for _, cc := range g { if cc.Tag == 'd' { continue } for _, line := range diff.B[cc.J1:cc.J2] { ws(prefix[cc.Tag] + line) } } break } } } return diffErr } // Like WriteContextDiff but returns the diff a string. func GetContextDiffString(diff ContextDiff) (string, error) { w := &bytes.Buffer{} err := WriteContextDiff(w, diff) return string(w.Bytes()), err } // Split a string on "\n" while preserving them. The output can be used // as input for UnifiedDiff and ContextDiff structures. func SplitLines(s string) []string { lines := strings.SplitAfter(s, "\n") lines[len(lines)-1] += "\n" return lines }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/concurrency.go
vendor/github.com/samber/lo/concurrency.go
package lo import "sync" type synchronize struct { locker sync.Locker } func (s *synchronize) Do(cb func()) { s.locker.Lock() Try0(cb) s.locker.Unlock() } // Synchronize wraps the underlying callback in a mutex. It receives an optional mutex. func Synchronize(opt ...sync.Locker) *synchronize { if len(opt) > 1 { panic("unexpected arguments") } else if len(opt) == 0 { opt = append(opt, &sync.Mutex{}) } return &synchronize{ locker: opt[0], } } // Async executes a function in a goroutine and returns the result in a channel. func Async[A any](f func() A) chan A { ch := make(chan A) go func() { ch <- f() }() return ch } // Async0 executes a function in a goroutine and returns a channel set once the function finishes. func Async0(f func()) chan struct{} { ch := make(chan struct{}) go func() { f() ch <- struct{}{} }() return ch } // Async1 is an alias to Async. func Async1[A any](f func() A) chan A { return Async(f) } // Async2 has the same behavior as Async, but returns the 2 results as a tuple inside the channel. func Async2[A any, B any](f func() (A, B)) chan Tuple2[A, B] { ch := make(chan Tuple2[A, B]) go func() { ch <- T2(f()) }() return ch } // Async3 has the same behavior as Async, but returns the 3 results as a tuple inside the channel. func Async3[A any, B any, C any](f func() (A, B, C)) chan Tuple3[A, B, C] { ch := make(chan Tuple3[A, B, C]) go func() { ch <- T3(f()) }() return ch } // Async4 has the same behavior as Async, but returns the 4 results as a tuple inside the channel. func Async4[A any, B any, C any, D any](f func() (A, B, C, D)) chan Tuple4[A, B, C, D] { ch := make(chan Tuple4[A, B, C, D]) go func() { ch <- T4(f()) }() return ch } // Async5 has the same behavior as Async, but returns the 5 results as a tuple inside the channel. func Async5[A any, B any, C any, D any, E any](f func() (A, B, C, D, E)) chan Tuple5[A, B, C, D, E] { ch := make(chan Tuple5[A, B, C, D, E]) go func() { ch <- T5(f()) }() return ch } // Async6 has the same behavior as Async, but returns the 6 results as a tuple inside the channel. func Async6[A any, B any, C any, D any, E any, F any](f func() (A, B, C, D, E, F)) chan Tuple6[A, B, C, D, E, F] { ch := make(chan Tuple6[A, B, C, D, E, F]) go func() { ch <- T6(f()) }() return ch }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/types.go
vendor/github.com/samber/lo/types.go
package lo // Entry defines a key/value pairs. type Entry[K comparable, V any] struct { Key K Value V } // Tuple2 is a group of 2 elements (pair). type Tuple2[A any, B any] struct { A A B B } // Tuple3 is a group of 3 elements. type Tuple3[A any, B any, C any] struct { A A B B C C } // Tuple4 is a group of 4 elements. type Tuple4[A any, B any, C any, D any] struct { A A B B C C D D } // Tuple5 is a group of 5 elements. type Tuple5[A any, B any, C any, D any, E any] struct { A A B B C C D D E E } // Tuple6 is a group of 6 elements. type Tuple6[A any, B any, C any, D any, E any, F any] struct { A A B B C C D D E E F F } // Tuple7 is a group of 7 elements. type Tuple7[A any, B any, C any, D any, E any, F any, G any] struct { A A B B C C D D E E F F G G } // Tuple8 is a group of 8 elements. type Tuple8[A any, B any, C any, D any, E any, F any, G any, H any] struct { A A B B C C D D E E F F G G H H } // Tuple9 is a group of 9 elements. type Tuple9[A any, B any, C any, D any, E any, F any, G any, H any, I any] struct { A A B B C C D D E E F F G G H H I I }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/errors.go
vendor/github.com/samber/lo/errors.go
package lo import ( "errors" "fmt" "reflect" ) // Validate is a helper that creates an error when a condition is not met. // Play: https://go.dev/play/p/vPyh51XpCBt func Validate(ok bool, format string, args ...any) error { if !ok { return fmt.Errorf(fmt.Sprintf(format, args...)) } return nil } func messageFromMsgAndArgs(msgAndArgs ...interface{}) string { if len(msgAndArgs) == 1 { if msgAsStr, ok := msgAndArgs[0].(string); ok { return msgAsStr } return fmt.Sprintf("%+v", msgAndArgs[0]) } if len(msgAndArgs) > 1 { return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...) } return "" } // must panics if err is error or false. func must(err any, messageArgs ...interface{}) { if err == nil { return } switch e := err.(type) { case bool: if !e { message := messageFromMsgAndArgs(messageArgs...) if message == "" { message = "not ok" } panic(message) } case error: message := messageFromMsgAndArgs(messageArgs...) if message != "" { panic(message + ": " + e.Error()) } else { panic(e.Error()) } default: panic("must: invalid err type '" + reflect.TypeOf(err).Name() + "', should either be a bool or an error") } } // Must is a helper that wraps a call to a function returning a value and an error // and panics if err is error or false. // Play: https://go.dev/play/p/TMoWrRp3DyC func Must[T any](val T, err any, messageArgs ...interface{}) T { must(err, messageArgs...) return val } // Must0 has the same behavior than Must, but callback returns no variable. // Play: https://go.dev/play/p/TMoWrRp3DyC func Must0(err any, messageArgs ...interface{}) { must(err, messageArgs...) } // Must1 is an alias to Must // Play: https://go.dev/play/p/TMoWrRp3DyC func Must1[T any](val T, err any, messageArgs ...interface{}) T { return Must(val, err, messageArgs...) } // Must2 has the same behavior than Must, but callback returns 2 variables. // Play: https://go.dev/play/p/TMoWrRp3DyC func Must2[T1 any, T2 any](val1 T1, val2 T2, err any, messageArgs ...interface{}) (T1, T2) { must(err, messageArgs...) return val1, val2 } // Must3 has the same behavior than Must, but callback returns 3 variables. // Play: https://go.dev/play/p/TMoWrRp3DyC func Must3[T1 any, T2 any, T3 any](val1 T1, val2 T2, val3 T3, err any, messageArgs ...interface{}) (T1, T2, T3) { must(err, messageArgs...) return val1, val2, val3 } // Must4 has the same behavior than Must, but callback returns 4 variables. // Play: https://go.dev/play/p/TMoWrRp3DyC func Must4[T1 any, T2 any, T3 any, T4 any](val1 T1, val2 T2, val3 T3, val4 T4, err any, messageArgs ...interface{}) (T1, T2, T3, T4) { must(err, messageArgs...) return val1, val2, val3, val4 } // Must5 has the same behavior than Must, but callback returns 5 variables. // Play: https://go.dev/play/p/TMoWrRp3DyC func Must5[T1 any, T2 any, T3 any, T4 any, T5 any](val1 T1, val2 T2, val3 T3, val4 T4, val5 T5, err any, messageArgs ...interface{}) (T1, T2, T3, T4, T5) { must(err, messageArgs...) return val1, val2, val3, val4, val5 } // Must6 has the same behavior than Must, but callback returns 6 variables. // Play: https://go.dev/play/p/TMoWrRp3DyC func Must6[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any](val1 T1, val2 T2, val3 T3, val4 T4, val5 T5, val6 T6, err any, messageArgs ...interface{}) (T1, T2, T3, T4, T5, T6) { must(err, messageArgs...) return val1, val2, val3, val4, val5, val6 } // Try calls the function and return false in case of error. func Try(callback func() error) (ok bool) { ok = true defer func() { if r := recover(); r != nil { ok = false } }() err := callback() if err != nil { ok = false } return } // Try0 has the same behavior than Try, but callback returns no variable. // Play: https://go.dev/play/p/mTyyWUvn9u4 func Try0(callback func()) bool { return Try(func() error { callback() return nil }) } // Try1 is an alias to Try. // Play: https://go.dev/play/p/mTyyWUvn9u4 func Try1(callback func() error) bool { return Try(callback) } // Try2 has the same behavior than Try, but callback returns 2 variables. // Play: https://go.dev/play/p/mTyyWUvn9u4 func Try2[T any](callback func() (T, error)) bool { return Try(func() error { _, err := callback() return err }) } // Try3 has the same behavior than Try, but callback returns 3 variables. // Play: https://go.dev/play/p/mTyyWUvn9u4 func Try3[T, R any](callback func() (T, R, error)) bool { return Try(func() error { _, _, err := callback() return err }) } // Try4 has the same behavior than Try, but callback returns 4 variables. // Play: https://go.dev/play/p/mTyyWUvn9u4 func Try4[T, R, S any](callback func() (T, R, S, error)) bool { return Try(func() error { _, _, _, err := callback() return err }) } // Try5 has the same behavior than Try, but callback returns 5 variables. // Play: https://go.dev/play/p/mTyyWUvn9u4 func Try5[T, R, S, Q any](callback func() (T, R, S, Q, error)) bool { return Try(func() error { _, _, _, _, err := callback() return err }) } // Try6 has the same behavior than Try, but callback returns 6 variables. // Play: https://go.dev/play/p/mTyyWUvn9u4 func Try6[T, R, S, Q, U any](callback func() (T, R, S, Q, U, error)) bool { return Try(func() error { _, _, _, _, _, err := callback() return err }) } // TryOr has the same behavior than Must, but returns a default value in case of error. // Play: https://go.dev/play/p/B4F7Wg2Zh9X func TryOr[A any](callback func() (A, error), fallbackA A) (A, bool) { return TryOr1(callback, fallbackA) } // TryOr1 has the same behavior than Must, but returns a default value in case of error. // Play: https://go.dev/play/p/B4F7Wg2Zh9X func TryOr1[A any](callback func() (A, error), fallbackA A) (A, bool) { ok := false Try0(func() { a, err := callback() if err == nil { fallbackA = a ok = true } }) return fallbackA, ok } // TryOr2 has the same behavior than Must, but returns a default value in case of error. // Play: https://go.dev/play/p/B4F7Wg2Zh9X func TryOr2[A any, B any](callback func() (A, B, error), fallbackA A, fallbackB B) (A, B, bool) { ok := false Try0(func() { a, b, err := callback() if err == nil { fallbackA = a fallbackB = b ok = true } }) return fallbackA, fallbackB, ok } // TryOr3 has the same behavior than Must, but returns a default value in case of error. // Play: https://go.dev/play/p/B4F7Wg2Zh9X func TryOr3[A any, B any, C any](callback func() (A, B, C, error), fallbackA A, fallbackB B, fallbackC C) (A, B, C, bool) { ok := false Try0(func() { a, b, c, err := callback() if err == nil { fallbackA = a fallbackB = b fallbackC = c ok = true } }) return fallbackA, fallbackB, fallbackC, ok } // TryOr4 has the same behavior than Must, but returns a default value in case of error. // Play: https://go.dev/play/p/B4F7Wg2Zh9X func TryOr4[A any, B any, C any, D any](callback func() (A, B, C, D, error), fallbackA A, fallbackB B, fallbackC C, fallbackD D) (A, B, C, D, bool) { ok := false Try0(func() { a, b, c, d, err := callback() if err == nil { fallbackA = a fallbackB = b fallbackC = c fallbackD = d ok = true } }) return fallbackA, fallbackB, fallbackC, fallbackD, ok } // TryOr5 has the same behavior than Must, but returns a default value in case of error. // Play: https://go.dev/play/p/B4F7Wg2Zh9X func TryOr5[A any, B any, C any, D any, E any](callback func() (A, B, C, D, E, error), fallbackA A, fallbackB B, fallbackC C, fallbackD D, fallbackE E) (A, B, C, D, E, bool) { ok := false Try0(func() { a, b, c, d, e, err := callback() if err == nil { fallbackA = a fallbackB = b fallbackC = c fallbackD = d fallbackE = e ok = true } }) return fallbackA, fallbackB, fallbackC, fallbackD, fallbackE, ok } // TryOr6 has the same behavior than Must, but returns a default value in case of error. // Play: https://go.dev/play/p/B4F7Wg2Zh9X func TryOr6[A any, B any, C any, D any, E any, F any](callback func() (A, B, C, D, E, F, error), fallbackA A, fallbackB B, fallbackC C, fallbackD D, fallbackE E, fallbackF F) (A, B, C, D, E, F, bool) { ok := false Try0(func() { a, b, c, d, e, f, err := callback() if err == nil { fallbackA = a fallbackB = b fallbackC = c fallbackD = d fallbackE = e fallbackF = f ok = true } }) return fallbackA, fallbackB, fallbackC, fallbackD, fallbackE, fallbackF, ok } // TryWithErrorValue has the same behavior than Try, but also returns value passed to panic. // Play: https://go.dev/play/p/Kc7afQIT2Fs func TryWithErrorValue(callback func() error) (errorValue any, ok bool) { ok = true defer func() { if r := recover(); r != nil { ok = false errorValue = r } }() err := callback() if err != nil { ok = false errorValue = err } return } // TryCatch has the same behavior than Try, but calls the catch function in case of error. // Play: https://go.dev/play/p/PnOON-EqBiU func TryCatch(callback func() error, catch func()) { if !Try(callback) { catch() } } // TryCatchWithErrorValue has the same behavior than TryWithErrorValue, but calls the catch function in case of error. // Play: https://go.dev/play/p/8Pc9gwX_GZO func TryCatchWithErrorValue(callback func() error, catch func(any)) { if err, ok := TryWithErrorValue(callback); !ok { catch(err) } } // ErrorsAs is a shortcut for errors.As(err, &&T). // Play: https://go.dev/play/p/8wk5rH8UfrE func ErrorsAs[T error](err error) (T, bool) { var t T ok := errors.As(err, &t) return t, ok }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/type_manipulation.go
vendor/github.com/samber/lo/type_manipulation.go
package lo // ToPtr returns a pointer copy of value. func ToPtr[T any](x T) *T { return &x } // FromPtr returns the pointer value or empty. func FromPtr[T any](x *T) T { if x == nil { return Empty[T]() } return *x } // FromPtrOr returns the pointer value or the fallback value. func FromPtrOr[T any](x *T, fallback T) T { if x == nil { return fallback } return *x } // ToSlicePtr returns a slice of pointer copy of value. func ToSlicePtr[T any](collection []T) []*T { return Map(collection, func(x T, _ int) *T { return &x }) } // ToAnySlice returns a slice with all elements mapped to `any` type func ToAnySlice[T any](collection []T) []any { result := make([]any, len(collection)) for i, item := range collection { result[i] = item } return result } // FromAnySlice returns an `any` slice with all elements mapped to a type. // Returns false in case of type conversion failure. func FromAnySlice[T any](in []any) (out []T, ok bool) { defer func() { if r := recover(); r != nil { out = []T{} ok = false } }() result := make([]T, len(in)) for i, item := range in { result[i] = item.(T) } return result, true } // Empty returns an empty value. func Empty[T any]() T { var zero T return zero } // IsEmpty returns true if argument is a zero value. func IsEmpty[T comparable](v T) bool { var zero T return zero == v } // IsNotEmpty returns true if argument is not a zero value. func IsNotEmpty[T comparable](v T) bool { var zero T return zero != v } // Coalesce returns the first non-empty arguments. Arguments must be comparable. func Coalesce[T comparable](v ...T) (result T, ok bool) { for _, e := range v { if e != result { result = e ok = true return } } return }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/retry.go
vendor/github.com/samber/lo/retry.go
package lo import ( "sync" "time" ) type debounce struct { after time.Duration mu *sync.Mutex timer *time.Timer done bool callbacks []func() } func (d *debounce) reset() *debounce { d.mu.Lock() defer d.mu.Unlock() if d.done { return d } if d.timer != nil { d.timer.Stop() } d.timer = time.AfterFunc(d.after, func() { for _, f := range d.callbacks { f() } }) return d } func (d *debounce) cancel() { d.mu.Lock() defer d.mu.Unlock() if d.timer != nil { d.timer.Stop() d.timer = nil } d.done = true } // NewDebounce creates a debounced instance that delays invoking functions given until after wait milliseconds have elapsed. // Play: https://go.dev/play/p/mz32VMK2nqe func NewDebounce(duration time.Duration, f ...func()) (func(), func()) { d := &debounce{ after: duration, mu: new(sync.Mutex), timer: nil, done: false, callbacks: f, } return func() { d.reset() }, d.cancel } // Attempt invokes a function N times until it returns valid output. Returning either the caught error or nil. When first argument is less than `1`, the function runs until a successful response is returned. // Play: https://go.dev/play/p/3ggJZ2ZKcMj func Attempt(maxIteration int, f func(int) error) (int, error) { var err error for i := 0; maxIteration <= 0 || i < maxIteration; i++ { // for retries >= 0 { err = f(i) if err == nil { return i + 1, nil } } return maxIteration, err } // AttemptWithDelay invokes a function N times until it returns valid output, // with a pause between each call. Returning either the caught error or nil. // When first argument is less than `1`, the function runs until a successful // response is returned. // Play: https://go.dev/play/p/tVs6CygC7m1 func AttemptWithDelay(maxIteration int, delay time.Duration, f func(int, time.Duration) error) (int, time.Duration, error) { var err error start := time.Now() for i := 0; maxIteration <= 0 || i < maxIteration; i++ { err = f(i, time.Since(start)) if err == nil { return i + 1, time.Since(start), nil } if maxIteration <= 0 || i+1 < maxIteration { time.Sleep(delay) } } return maxIteration, time.Since(start), err } // throttle ?
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/intersect.go
vendor/github.com/samber/lo/intersect.go
package lo // Contains returns true if an element is present in a collection. func Contains[T comparable](collection []T, element T) bool { for _, item := range collection { if item == element { return true } } return false } // ContainsBy returns true if predicate function return true. func ContainsBy[T any](collection []T, predicate func(T) bool) bool { for _, item := range collection { if predicate(item) { return true } } return false } // Every returns true if all elements of a subset are contained into a collection or if the subset is empty. func Every[T comparable](collection []T, subset []T) bool { for _, elem := range subset { if !Contains(collection, elem) { return false } } return true } // EveryBy returns true if the predicate returns true for all of the elements in the collection or if the collection is empty. func EveryBy[V any](collection []V, predicate func(V) bool) bool { for _, v := range collection { if !predicate(v) { return false } } return true } // Some returns true if at least 1 element of a subset is contained into a collection. // If the subset is empty Some returns false. func Some[T comparable](collection []T, subset []T) bool { for _, elem := range subset { if Contains(collection, elem) { return true } } return false } // SomeBy returns true if the predicate returns true for any of the elements in the collection. // If the collection is empty SomeBy returns false. func SomeBy[V any](collection []V, predicate func(V) bool) bool { for _, v := range collection { if predicate(v) { return true } } return false } // None returns true if no element of a subset are contained into a collection or if the subset is empty. func None[V comparable](collection []V, subset []V) bool { for _, elem := range subset { if Contains(collection, elem) { return false } } return true } // NoneBy returns true if the predicate returns true for none of the elements in the collection or if the collection is empty. func NoneBy[V any](collection []V, predicate func(V) bool) bool { for _, v := range collection { if predicate(v) { return false } } return true } // Intersect returns the intersection between two collections. func Intersect[T comparable](list1 []T, list2 []T) []T { result := []T{} seen := map[T]struct{}{} for _, elem := range list1 { seen[elem] = struct{}{} } for _, elem := range list2 { if _, ok := seen[elem]; ok { result = append(result, elem) } } return result } // Difference returns the difference between two collections. // The first value is the collection of element absent of list2. // The second value is the collection of element absent of list1. func Difference[T comparable](list1 []T, list2 []T) ([]T, []T) { left := []T{} right := []T{} seenLeft := map[T]struct{}{} seenRight := map[T]struct{}{} for _, elem := range list1 { seenLeft[elem] = struct{}{} } for _, elem := range list2 { seenRight[elem] = struct{}{} } for _, elem := range list1 { if _, ok := seenRight[elem]; !ok { left = append(left, elem) } } for _, elem := range list2 { if _, ok := seenLeft[elem]; !ok { right = append(right, elem) } } return left, right } // Union returns all distinct elements from both collections. // result returns will not change the order of elements relatively. func Union[T comparable](list1 []T, list2 []T) []T { result := []T{} seen := map[T]struct{}{} hasAdd := map[T]struct{}{} for _, e := range list1 { seen[e] = struct{}{} } for _, e := range list2 { seen[e] = struct{}{} } for _, e := range list1 { if _, ok := seen[e]; ok { result = append(result, e) hasAdd[e] = struct{}{} } } for _, e := range list2 { if _, ok := hasAdd[e]; ok { continue } if _, ok := seen[e]; ok { result = append(result, e) } } return result } // Without returns slice excluding all given values. func Without[T comparable](collection []T, exclude ...T) []T { result := make([]T, 0, len(collection)) for _, e := range collection { if !Contains(exclude, e) { result = append(result, e) } } return result } // WithoutEmpty returns slice excluding empty values. func WithoutEmpty[T comparable](collection []T) []T { var empty T result := make([]T, 0, len(collection)) for _, e := range collection { if e != empty { result = append(result, e) } } return result }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/map.go
vendor/github.com/samber/lo/map.go
package lo // Keys creates an array of the map keys. // Play: https://go.dev/play/p/Uu11fHASqrU func Keys[K comparable, V any](in map[K]V) []K { result := make([]K, 0, len(in)) for k := range in { result = append(result, k) } return result } // Values creates an array of the map values. // Play: https://go.dev/play/p/nnRTQkzQfF6 func Values[K comparable, V any](in map[K]V) []V { result := make([]V, 0, len(in)) for _, v := range in { result = append(result, v) } return result } // PickBy returns same map type filtered by given predicate. // Play: https://go.dev/play/p/kdg8GR_QMmf func PickBy[K comparable, V any](in map[K]V, predicate func(K, V) bool) map[K]V { r := map[K]V{} for k, v := range in { if predicate(k, v) { r[k] = v } } return r } // PickByKeys returns same map type filtered by given keys. // Play: https://go.dev/play/p/R1imbuci9qU func PickByKeys[K comparable, V any](in map[K]V, keys []K) map[K]V { r := map[K]V{} for k, v := range in { if Contains(keys, k) { r[k] = v } } return r } // PickByValues returns same map type filtered by given values. // Play: https://go.dev/play/p/1zdzSvbfsJc func PickByValues[K comparable, V comparable](in map[K]V, values []V) map[K]V { r := map[K]V{} for k, v := range in { if Contains(values, v) { r[k] = v } } return r } // OmitBy returns same map type filtered by given predicate. // Play: https://go.dev/play/p/EtBsR43bdsd func OmitBy[K comparable, V any](in map[K]V, predicate func(K, V) bool) map[K]V { r := map[K]V{} for k, v := range in { if !predicate(k, v) { r[k] = v } } return r } // OmitByKeys returns same map type filtered by given keys. // Play: https://go.dev/play/p/t1QjCrs-ysk func OmitByKeys[K comparable, V any](in map[K]V, keys []K) map[K]V { r := map[K]V{} for k, v := range in { if !Contains(keys, k) { r[k] = v } } return r } // OmitByValues returns same map type filtered by given values. // Play: https://go.dev/play/p/9UYZi-hrs8j func OmitByValues[K comparable, V comparable](in map[K]V, values []V) map[K]V { r := map[K]V{} for k, v := range in { if !Contains(values, v) { r[k] = v } } return r } // Entries transforms a map into array of key/value pairs. // Play: func Entries[K comparable, V any](in map[K]V) []Entry[K, V] { entries := make([]Entry[K, V], 0, len(in)) for k, v := range in { entries = append(entries, Entry[K, V]{ Key: k, Value: v, }) } return entries } // ToPairs transforms a map into array of key/value pairs. // Alias of Entries(). // Play: https://go.dev/play/p/3Dhgx46gawJ func ToPairs[K comparable, V any](in map[K]V) []Entry[K, V] { return Entries(in) } // FromEntries transforms an array of key/value pairs into a map. // Play: https://go.dev/play/p/oIr5KHFGCEN func FromEntries[K comparable, V any](entries []Entry[K, V]) map[K]V { out := map[K]V{} for _, v := range entries { out[v.Key] = v.Value } return out } // FromPairs transforms an array of key/value pairs into a map. // Alias of FromEntries(). // Play: https://go.dev/play/p/oIr5KHFGCEN func FromPairs[K comparable, V any](entries []Entry[K, V]) map[K]V { return FromEntries(entries) } // Invert creates a map composed of the inverted keys and values. If map // contains duplicate values, subsequent values overwrite property assignments // of previous values. // Play: https://go.dev/play/p/rFQ4rak6iA1 func Invert[K comparable, V comparable](in map[K]V) map[V]K { out := map[V]K{} for k, v := range in { out[v] = k } return out } // Assign merges multiple maps from left to right. // Play: https://go.dev/play/p/VhwfJOyxf5o func Assign[K comparable, V any](maps ...map[K]V) map[K]V { out := map[K]V{} for _, m := range maps { for k, v := range m { out[k] = v } } return out } // MapKeys manipulates a map keys and transforms it to a map of another type. // Play: https://go.dev/play/p/9_4WPIqOetJ func MapKeys[K comparable, V any, R comparable](in map[K]V, iteratee func(V, K) R) map[R]V { result := map[R]V{} for k, v := range in { result[iteratee(v, k)] = v } return result } // MapValues manipulates a map values and transforms it to a map of another type. // Play: https://go.dev/play/p/T_8xAfvcf0W func MapValues[K comparable, V any, R any](in map[K]V, iteratee func(V, K) R) map[K]R { result := map[K]R{} for k, v := range in { result[k] = iteratee(v, k) } return result } // MapToSlice transforms a map into a slice based on specific iteratee // Play: https://go.dev/play/p/ZuiCZpDt6LD func MapToSlice[K comparable, V any, R any](in map[K]V, iteratee func(K, V) R) []R { result := make([]R, 0, len(in)) for k, v := range in { result = append(result, iteratee(k, v)) } return result }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/find.go
vendor/github.com/samber/lo/find.go
package lo import ( "fmt" "math/rand" "golang.org/x/exp/constraints" ) // import "golang.org/x/exp/constraints" // IndexOf returns the index at which the first occurrence of a value is found in an array or return -1 // if the value cannot be found. func IndexOf[T comparable](collection []T, element T) int { for i, item := range collection { if item == element { return i } } return -1 } // LastIndexOf returns the index at which the last occurrence of a value is found in an array or return -1 // if the value cannot be found. func LastIndexOf[T comparable](collection []T, element T) int { length := len(collection) for i := length - 1; i >= 0; i-- { if collection[i] == element { return i } } return -1 } // Find search an element in a slice based on a predicate. It returns element and true if element was found. func Find[T any](collection []T, predicate func(T) bool) (T, bool) { for _, item := range collection { if predicate(item) { return item, true } } var result T return result, false } // FindIndexOf searches an element in a slice based on a predicate and returns the index and true. // It returns -1 and false if the element is not found. func FindIndexOf[T any](collection []T, predicate func(T) bool) (T, int, bool) { for i, item := range collection { if predicate(item) { return item, i, true } } var result T return result, -1, false } // FindLastIndexOf searches last element in a slice based on a predicate and returns the index and true. // It returns -1 and false if the element is not found. func FindLastIndexOf[T any](collection []T, predicate func(T) bool) (T, int, bool) { length := len(collection) for i := length - 1; i >= 0; i-- { if predicate(collection[i]) { return collection[i], i, true } } var result T return result, -1, false } // FindOrElse search an element in a slice based on a predicate. It returns the element if found or a given fallback value otherwise. func FindOrElse[T any](collection []T, fallback T, predicate func(T) bool) T { for _, item := range collection { if predicate(item) { return item } } return fallback } // FindKey returns the key of the first value matching. func FindKey[K comparable, V comparable](object map[K]V, value V) (K, bool) { for k, v := range object { if v == value { return k, true } } return Empty[K](), false } // FindKeyBy returns the key of the first element predicate returns truthy for. func FindKeyBy[K comparable, V any](object map[K]V, predicate func(K, V) bool) (K, bool) { for k, v := range object { if predicate(k, v) { return k, true } } return Empty[K](), false } // FindUniques returns a slice with all the unique elements of the collection. // The order of result values is determined by the order they occur in the collection. func FindUniques[T comparable](collection []T) []T { isDupl := make(map[T]bool, len(collection)) for _, item := range collection { duplicated, ok := isDupl[item] if !ok { isDupl[item] = false } else if !duplicated { isDupl[item] = true } } result := make([]T, 0, len(collection)-len(isDupl)) for _, item := range collection { if duplicated := isDupl[item]; !duplicated { result = append(result, item) } } return result } // FindUniquesBy returns a slice with all the unique elements of the collection. // The order of result values is determined by the order they occur in the array. It accepts `iteratee` which is // invoked for each element in array to generate the criterion by which uniqueness is computed. func FindUniquesBy[T any, U comparable](collection []T, iteratee func(T) U) []T { isDupl := make(map[U]bool, len(collection)) for _, item := range collection { key := iteratee(item) duplicated, ok := isDupl[key] if !ok { isDupl[key] = false } else if !duplicated { isDupl[key] = true } } result := make([]T, 0, len(collection)-len(isDupl)) for _, item := range collection { key := iteratee(item) if duplicated := isDupl[key]; !duplicated { result = append(result, item) } } return result } // FindDuplicates returns a slice with the first occurence of each duplicated elements of the collection. // The order of result values is determined by the order they occur in the collection. func FindDuplicates[T comparable](collection []T) []T { isDupl := make(map[T]bool, len(collection)) for _, item := range collection { duplicated, ok := isDupl[item] if !ok { isDupl[item] = false } else if !duplicated { isDupl[item] = true } } result := make([]T, 0, len(collection)-len(isDupl)) for _, item := range collection { if duplicated := isDupl[item]; duplicated { result = append(result, item) isDupl[item] = false } } return result } // FindDuplicatesBy returns a slice with the first occurence of each duplicated elements of the collection. // The order of result values is determined by the order they occur in the array. It accepts `iteratee` which is // invoked for each element in array to generate the criterion by which uniqueness is computed. func FindDuplicatesBy[T any, U comparable](collection []T, iteratee func(T) U) []T { isDupl := make(map[U]bool, len(collection)) for _, item := range collection { key := iteratee(item) duplicated, ok := isDupl[key] if !ok { isDupl[key] = false } else if !duplicated { isDupl[key] = true } } result := make([]T, 0, len(collection)-len(isDupl)) for _, item := range collection { key := iteratee(item) if duplicated := isDupl[key]; duplicated { result = append(result, item) isDupl[key] = false } } return result } // Min search the minimum value of a collection. func Min[T constraints.Ordered](collection []T) T { var min T if len(collection) == 0 { return min } min = collection[0] for i := 1; i < len(collection); i++ { item := collection[i] if item < min { min = item } } return min } // MinBy search the minimum value of a collection using the given comparison function. // If several values of the collection are equal to the smallest value, returns the first such value. func MinBy[T any](collection []T, comparison func(T, T) bool) T { var min T if len(collection) == 0 { return min } min = collection[0] for i := 1; i < len(collection); i++ { item := collection[i] if comparison(item, min) { min = item } } return min } // Max searches the maximum value of a collection. func Max[T constraints.Ordered](collection []T) T { var max T if len(collection) == 0 { return max } max = collection[0] for i := 1; i < len(collection); i++ { item := collection[i] if item > max { max = item } } return max } // MaxBy search the maximum value of a collection using the given comparison function. // If several values of the collection are equal to the greatest value, returns the first such value. func MaxBy[T any](collection []T, comparison func(T, T) bool) T { var max T if len(collection) == 0 { return max } max = collection[0] for i := 1; i < len(collection); i++ { item := collection[i] if comparison(item, max) { max = item } } return max } // Last returns the last element of a collection or error if empty. func Last[T any](collection []T) (T, error) { length := len(collection) if length == 0 { var t T return t, fmt.Errorf("last: cannot extract the last element of an empty slice") } return collection[length-1], nil } // Nth returns the element at index `nth` of collection. If `nth` is negative, the nth element // from the end is returned. An error is returned when nth is out of slice bounds. func Nth[T any, N constraints.Integer](collection []T, nth N) (T, error) { n := int(nth) l := len(collection) if n >= l || -n > l { var t T return t, fmt.Errorf("nth: %d out of slice bounds", n) } if n >= 0 { return collection[n], nil } return collection[l+n], nil } // Sample returns a random item from collection. func Sample[T any](collection []T) T { size := len(collection) if size == 0 { return Empty[T]() } return collection[rand.Intn(size)] } // Samples returns N random unique items from collection. func Samples[T any](collection []T, count int) []T { size := len(collection) cOpy := append([]T{}, collection...) results := []T{} for i := 0; i < size && i < count; i++ { copyLength := size - i index := rand.Intn(size - i) results = append(results, cOpy[index]) // Removes element. // It is faster to swap with last element and remove it. cOpy[index] = cOpy[copyLength-1] cOpy = cOpy[:copyLength-1] } return results }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/slice.go
vendor/github.com/samber/lo/slice.go
package lo import ( "math/rand" "golang.org/x/exp/constraints" ) // Filter iterates over elements of collection, returning an array of all elements predicate returns truthy for. // Play: https://go.dev/play/p/Apjg3WeSi7K func Filter[V any](collection []V, predicate func(V, int) bool) []V { result := []V{} for i, item := range collection { if predicate(item, i) { result = append(result, item) } } return result } // Map manipulates a slice and transforms it to a slice of another type. // Play: https://go.dev/play/p/OkPcYAhBo0D func Map[T any, R any](collection []T, iteratee func(T, int) R) []R { result := make([]R, len(collection)) for i, item := range collection { result[i] = iteratee(item, i) } return result } // FilterMap returns a slice which obtained after both filtering and mapping using the given callback function. // The callback function should return two values: // - the result of the mapping operation and // - whether the result element should be included or not. // // Play: https://go.dev/play/p/-AuYXfy7opz func FilterMap[T any, R any](collection []T, callback func(T, int) (R, bool)) []R { result := []R{} for i, item := range collection { if r, ok := callback(item, i); ok { result = append(result, r) } } return result } // FlatMap manipulates a slice and transforms and flattens it to a slice of another type. // Play: https://go.dev/play/p/YSoYmQTA8-U func FlatMap[T any, R any](collection []T, iteratee func(T, int) []R) []R { result := []R{} for i, item := range collection { result = append(result, iteratee(item, i)...) } return result } // Reduce reduces collection to a value which is the accumulated result of running each element in collection // through accumulator, where each successive invocation is supplied the return value of the previous. // Play: https://go.dev/play/p/R4UHXZNaaUG func Reduce[T any, R any](collection []T, accumulator func(R, T, int) R, initial R) R { for i, item := range collection { initial = accumulator(initial, item, i) } return initial } // ReduceRight helper is like Reduce except that it iterates over elements of collection from right to left. // Play: https://go.dev/play/p/Fq3W70l7wXF func ReduceRight[T any, R any](collection []T, accumulator func(R, T, int) R, initial R) R { for i := len(collection) - 1; i >= 0; i-- { initial = accumulator(initial, collection[i], i) } return initial } // ForEach iterates over elements of collection and invokes iteratee for each element. // Play: https://go.dev/play/p/oofyiUPRf8t func ForEach[T any](collection []T, iteratee func(T, int)) { for i, item := range collection { iteratee(item, i) } } // Times invokes the iteratee n times, returning an array of the results of each invocation. // The iteratee is invoked with index as argument. // Play: https://go.dev/play/p/vgQj3Glr6lT func Times[T any](count int, iteratee func(int) T) []T { result := make([]T, count) for i := 0; i < count; i++ { result[i] = iteratee(i) } return result } // Uniq returns a duplicate-free version of an array, in which only the first occurrence of each element is kept. // The order of result values is determined by the order they occur in the array. // Play: https://go.dev/play/p/DTzbeXZ6iEN func Uniq[T comparable](collection []T) []T { result := make([]T, 0, len(collection)) seen := make(map[T]struct{}, len(collection)) for _, item := range collection { if _, ok := seen[item]; ok { continue } seen[item] = struct{}{} result = append(result, item) } return result } // UniqBy returns a duplicate-free version of an array, in which only the first occurrence of each element is kept. // The order of result values is determined by the order they occur in the array. It accepts `iteratee` which is // invoked for each element in array to generate the criterion by which uniqueness is computed. // Play: https://go.dev/play/p/g42Z3QSb53u func UniqBy[T any, U comparable](collection []T, iteratee func(T) U) []T { result := make([]T, 0, len(collection)) seen := make(map[U]struct{}, len(collection)) for _, item := range collection { key := iteratee(item) if _, ok := seen[key]; ok { continue } seen[key] = struct{}{} result = append(result, item) } return result } // GroupBy returns an object composed of keys generated from the results of running each element of collection through iteratee. // Play: https://go.dev/play/p/XnQBd_v6brd func GroupBy[T any, U comparable](collection []T, iteratee func(T) U) map[U][]T { result := map[U][]T{} for _, item := range collection { key := iteratee(item) result[key] = append(result[key], item) } return result } // Chunk returns an array of elements split into groups the length of size. If array can't be split evenly, // the final chunk will be the remaining elements. // Play: https://go.dev/play/p/EeKl0AuTehH func Chunk[T any](collection []T, size int) [][]T { if size <= 0 { panic("Second parameter must be greater than 0") } chunksNum := len(collection) / size if len(collection)%size != 0 { chunksNum += 1 } result := make([][]T, 0, chunksNum) for i := 0; i < chunksNum; i++ { last := (i + 1) * size if last > len(collection) { last = len(collection) } result = append(result, collection[i*size:last]) } return result } // PartitionBy returns an array of elements split into groups. The order of grouped values is // determined by the order they occur in collection. The grouping is generated from the results // of running each element of collection through iteratee. // Play: https://go.dev/play/p/NfQ_nGjkgXW func PartitionBy[T any, K comparable](collection []T, iteratee func(x T) K) [][]T { result := [][]T{} seen := map[K]int{} for _, item := range collection { key := iteratee(item) resultIndex, ok := seen[key] if !ok { resultIndex = len(result) seen[key] = resultIndex result = append(result, []T{}) } result[resultIndex] = append(result[resultIndex], item) } return result // unordered: // groups := GroupBy[T, K](collection, iteratee) // return Values[K, []T](groups) } // Flatten returns an array a single level deep. // Play: https://go.dev/play/p/rbp9ORaMpjw func Flatten[T any](collection [][]T) []T { totalLen := 0 for i := range collection { totalLen += len(collection[i]) } result := make([]T, 0, totalLen) for i := range collection { result = append(result, collection[i]...) } return result } // Shuffle returns an array of shuffled values. Uses the Fisher-Yates shuffle algorithm. // Play: https://go.dev/play/p/Qp73bnTDnc7 func Shuffle[T any](collection []T) []T { rand.Shuffle(len(collection), func(i, j int) { collection[i], collection[j] = collection[j], collection[i] }) return collection } // Reverse reverses array so that the first element becomes the last, the second element becomes the second to last, and so on. // Play: https://go.dev/play/p/fhUMLvZ7vS6 func Reverse[T any](collection []T) []T { length := len(collection) half := length / 2 for i := 0; i < half; i = i + 1 { j := length - 1 - i collection[i], collection[j] = collection[j], collection[i] } return collection } // Fill fills elements of array with `initial` value. // Play: https://go.dev/play/p/VwR34GzqEub func Fill[T Clonable[T]](collection []T, initial T) []T { result := make([]T, 0, len(collection)) for range collection { result = append(result, initial.Clone()) } return result } // Repeat builds a slice with N copies of initial value. // Play: https://go.dev/play/p/g3uHXbmc3b6 func Repeat[T Clonable[T]](count int, initial T) []T { result := make([]T, 0, count) for i := 0; i < count; i++ { result = append(result, initial.Clone()) } return result } // RepeatBy builds a slice with values returned by N calls of callback. // Play: https://go.dev/play/p/ozZLCtX_hNU func RepeatBy[T any](count int, predicate func(int) T) []T { result := make([]T, 0, count) for i := 0; i < count; i++ { result = append(result, predicate(i)) } return result } // KeyBy transforms a slice or an array of structs to a map based on a pivot callback. // Play: https://go.dev/play/p/mdaClUAT-zZ func KeyBy[K comparable, V any](collection []V, iteratee func(V) K) map[K]V { result := make(map[K]V, len(collection)) for _, v := range collection { k := iteratee(v) result[k] = v } return result } // Associate returns a map containing key-value pairs provided by transform function applied to elements of the given slice. // If any of two pairs would have the same key the last one gets added to the map. // The order of keys in returned map is not specified and is not guaranteed to be the same from the original array. // Play: https://go.dev/play/p/WHa2CfMO3Lr func Associate[T any, K comparable, V any](collection []T, transform func(T) (K, V)) map[K]V { result := make(map[K]V) for _, t := range collection { k, v := transform(t) result[k] = v } return result } // SliceToMap returns a map containing key-value pairs provided by transform function applied to elements of the given slice. // If any of two pairs would have the same key the last one gets added to the map. // The order of keys in returned map is not specified and is not guaranteed to be the same from the original array. // Alias of Associate(). // Play: https://go.dev/play/p/WHa2CfMO3Lr func SliceToMap[T any, K comparable, V any](collection []T, transform func(T) (K, V)) map[K]V { return Associate(collection, transform) } // Drop drops n elements from the beginning of a slice or array. // Play: https://go.dev/play/p/JswS7vXRJP2 func Drop[T any](collection []T, n int) []T { if len(collection) <= n { return make([]T, 0) } result := make([]T, 0, len(collection)-n) return append(result, collection[n:]...) } // DropRight drops n elements from the end of a slice or array. // Play: https://go.dev/play/p/GG0nXkSJJa3 func DropRight[T any](collection []T, n int) []T { if len(collection) <= n { return []T{} } result := make([]T, 0, len(collection)-n) return append(result, collection[:len(collection)-n]...) } // DropWhile drops elements from the beginning of a slice or array while the predicate returns true. // Play: https://go.dev/play/p/7gBPYw2IK16 func DropWhile[T any](collection []T, predicate func(T) bool) []T { i := 0 for ; i < len(collection); i++ { if !predicate(collection[i]) { break } } result := make([]T, 0, len(collection)-i) return append(result, collection[i:]...) } // DropRightWhile drops elements from the end of a slice or array while the predicate returns true. // Play: https://go.dev/play/p/3-n71oEC0Hz func DropRightWhile[T any](collection []T, predicate func(T) bool) []T { i := len(collection) - 1 for ; i >= 0; i-- { if !predicate(collection[i]) { break } } result := make([]T, 0, i+1) return append(result, collection[:i+1]...) } // Reject is the opposite of Filter, this method returns the elements of collection that predicate does not return truthy for. // Play: https://go.dev/play/p/YkLMODy1WEL func Reject[V any](collection []V, predicate func(V, int) bool) []V { result := []V{} for i, item := range collection { if !predicate(item, i) { result = append(result, item) } } return result } // Count counts the number of elements in the collection that compare equal to value. // Play: https://go.dev/play/p/Y3FlK54yveC func Count[T comparable](collection []T, value T) (count int) { for _, item := range collection { if item == value { count++ } } return count } // CountBy counts the number of elements in the collection for which predicate is true. // Play: https://go.dev/play/p/ByQbNYQQi4X func CountBy[T any](collection []T, predicate func(T) bool) (count int) { for _, item := range collection { if predicate(item) { count++ } } return count } // Subset returns a copy of a slice from `offset` up to `length` elements. Like `slice[start:start+length]`, but does not panic on overflow. // Play: https://go.dev/play/p/tOQu1GhFcog func Subset[T any](collection []T, offset int, length uint) []T { size := len(collection) if offset < 0 { offset = size + offset if offset < 0 { offset = 0 } } if offset > size { return []T{} } if length > uint(size)-uint(offset) { length = uint(size - offset) } return collection[offset : offset+int(length)] } // Slice returns a copy of a slice from `start` up to, but not including `end`. Like `slice[start:end]`, but does not panic on overflow. // Play: https://go.dev/play/p/8XWYhfMMA1h func Slice[T any](collection []T, start int, end int) []T { size := len(collection) if start >= end { return []T{} } if start > size { start = size } if end > size { end = size } return collection[start:end] } // Replace returns a copy of the slice with the first n non-overlapping instances of old replaced by new. // Play: https://go.dev/play/p/XfPzmf9gql6 func Replace[T comparable](collection []T, old T, new T, n int) []T { result := make([]T, len(collection)) copy(result, collection) for i := range result { if result[i] == old && n != 0 { result[i] = new n-- } } return result } // ReplaceAll returns a copy of the slice with all non-overlapping instances of old replaced by new. // Play: https://go.dev/play/p/a9xZFUHfYcV func ReplaceAll[T comparable](collection []T, old T, new T) []T { return Replace(collection, old, new, -1) } // Compact returns a slice of all non-zero elements. // Play: https://go.dev/play/p/tXiy-iK6PAc func Compact[T comparable](collection []T) []T { var zero T result := []T{} for _, item := range collection { if item != zero { result = append(result, item) } } return result } // IsSorted checks if a slice is sorted. // Play: https://go.dev/play/p/mc3qR-t4mcx func IsSorted[T constraints.Ordered](collection []T) bool { for i := 1; i < len(collection); i++ { if collection[i-1] > collection[i] { return false } } return true } // IsSortedByKey checks if a slice is sorted by iteratee. // Play: https://go.dev/play/p/wiG6XyBBu49 func IsSortedByKey[T any, K constraints.Ordered](collection []T, iteratee func(T) K) bool { size := len(collection) for i := 0; i < size-1; i++ { if iteratee(collection[i]) > iteratee(collection[i+1]) { return false } } return true }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/string.go
vendor/github.com/samber/lo/string.go
package lo import ( "unicode/utf8" ) // Substring return part of a string. // Play: https://go.dev/play/p/TQlxQi82Lu1 func Substring[T ~string](str T, offset int, length uint) T { size := len(str) if offset < 0 { offset = size + offset if offset < 0 { offset = 0 } } if offset > size { return Empty[T]() } if length > uint(size)-uint(offset) { length = uint(size - offset) } return str[offset : offset+int(length)] } // ChunkString returns an array of strings split into groups the length of size. If array can't be split evenly, // the final chunk will be the remaining elements. // Play: https://go.dev/play/p/__FLTuJVz54 func ChunkString[T ~string](str T, size int) []T { if size <= 0 { panic("lo.ChunkString: Size parameter must be greater than 0") } if len(str) == 0 { return []T{""} } if size >= len(str) { return []T{str} } var chunks []T = make([]T, 0, ((len(str)-1)/size)+1) currentLen := 0 currentStart := 0 for i := range str { if currentLen == size { chunks = append(chunks, str[currentStart:i]) currentLen = 0 currentStart = i } currentLen++ } chunks = append(chunks, str[currentStart:]) return chunks } // RuneLength is an alias to utf8.RuneCountInString which returns the number of runes in string. // Play: https://go.dev/play/p/tuhgW_lWY8l func RuneLength(str string) int { return utf8.RuneCountInString(str) }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/math.go
vendor/github.com/samber/lo/math.go
package lo import "golang.org/x/exp/constraints" // Range creates an array of numbers (positive and/or negative) with given length. // Play: https://go.dev/play/p/0r6VimXAi9H func Range(elementNum int) []int { length := If(elementNum < 0, -elementNum).Else(elementNum) result := make([]int, length) step := If(elementNum < 0, -1).Else(1) for i, j := 0, 0; i < length; i, j = i+1, j+step { result[i] = j } return result } // RangeFrom creates an array of numbers from start with specified length. // Play: https://go.dev/play/p/0r6VimXAi9H func RangeFrom[T constraints.Integer | constraints.Float](start T, elementNum int) []T { length := If(elementNum < 0, -elementNum).Else(elementNum) result := make([]T, length) step := If(elementNum < 0, -1).Else(1) for i, j := 0, start; i < length; i, j = i+1, j+T(step) { result[i] = j } return result } // RangeWithSteps creates an array of numbers (positive and/or negative) progressing from start up to, but not including end. // step set to zero will return empty array. // Play: https://go.dev/play/p/0r6VimXAi9H func RangeWithSteps[T constraints.Integer | constraints.Float](start, end, step T) []T { result := []T{} if start == end || step == 0 { return result } if start < end { if step < 0 { return result } for i := start; i < end; i += step { result = append(result, i) } return result } if step > 0 { return result } for i := start; i > end; i += step { result = append(result, i) } return result } // Clamp clamps number within the inclusive lower and upper bounds. // Play: https://go.dev/play/p/RU4lJNC2hlI func Clamp[T constraints.Ordered](value T, min T, max T) T { if value < min { return min } else if value > max { return max } return value } // SumBy summarizes the values in a collection using the given return value from the iteration function. If collection is empty 0 is returned. // Play: https://go.dev/play/p/Dz_a_7jN_ca func SumBy[T any, R constraints.Float | constraints.Integer](collection []T, iteratee func(T) R) R { var sum R = 0 for _, item := range collection { sum = sum + iteratee(item) } return sum }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/constraints.go
vendor/github.com/samber/lo/constraints.go
package lo // Clonable defines a constraint of types having Clone() T method. type Clonable[T any] interface { Clone() T }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/condition.go
vendor/github.com/samber/lo/condition.go
package lo // Ternary is a 1 line if/else statement. // Play: https://go.dev/play/p/t-D7WBL44h2 func Ternary[T any](condition bool, ifOutput T, elseOutput T) T { if condition { return ifOutput } return elseOutput } // TernaryF is a 1 line if/else statement whose options are functions // Play: https://go.dev/play/p/AO4VW20JoqM func TernaryF[T any](condition bool, ifFunc func() T, elseFunc func() T) T { if condition { return ifFunc() } return elseFunc() } type ifElse[T any] struct { result T done bool } // If. // Play: https://go.dev/play/p/WSw3ApMxhyW func If[T any](condition bool, result T) *ifElse[T] { if condition { return &ifElse[T]{result, true} } var t T return &ifElse[T]{t, false} } // IfF. // Play: https://go.dev/play/p/WSw3ApMxhyW func IfF[T any](condition bool, resultF func() T) *ifElse[T] { if condition { return &ifElse[T]{resultF(), true} } var t T return &ifElse[T]{t, false} } // ElseIf. // Play: https://go.dev/play/p/WSw3ApMxhyW func (i *ifElse[T]) ElseIf(condition bool, result T) *ifElse[T] { if !i.done && condition { i.result = result i.done = true } return i } // ElseIfF. // Play: https://go.dev/play/p/WSw3ApMxhyW func (i *ifElse[T]) ElseIfF(condition bool, resultF func() T) *ifElse[T] { if !i.done && condition { i.result = resultF() i.done = true } return i } // Else. // Play: https://go.dev/play/p/WSw3ApMxhyW func (i *ifElse[T]) Else(result T) T { if i.done { return i.result } return result } // ElseF. // Play: https://go.dev/play/p/WSw3ApMxhyW func (i *ifElse[T]) ElseF(resultF func() T) T { if i.done { return i.result } return resultF() } type switchCase[T comparable, R any] struct { predicate T result R done bool } // Switch is a pure functional switch/case/default statement. // Play: https://go.dev/play/p/TGbKUMAeRUd func Switch[T comparable, R any](predicate T) *switchCase[T, R] { var result R return &switchCase[T, R]{ predicate, result, false, } } // Case. // Play: https://go.dev/play/p/TGbKUMAeRUd func (s *switchCase[T, R]) Case(val T, result R) *switchCase[T, R] { if !s.done && s.predicate == val { s.result = result s.done = true } return s } // CaseF. // Play: https://go.dev/play/p/TGbKUMAeRUd func (s *switchCase[T, R]) CaseF(val T, cb func() R) *switchCase[T, R] { if !s.done && s.predicate == val { s.result = cb() s.done = true } return s } // Default. // Play: https://go.dev/play/p/TGbKUMAeRUd func (s *switchCase[T, R]) Default(result R) R { if !s.done { s.result = result } return s.result } // DefaultF. // Play: https://go.dev/play/p/TGbKUMAeRUd func (s *switchCase[T, R]) DefaultF(cb func() R) R { if !s.done { s.result = cb() } return s.result }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/test.go
vendor/github.com/samber/lo/test.go
package lo import ( "os" "testing" "time" ) // https://github.com/stretchr/testify/issues/1101 func testWithTimeout(t *testing.T, timeout time.Duration) { t.Helper() testFinished := make(chan struct{}) t.Cleanup(func() { close(testFinished) }) go func() { select { case <-testFinished: case <-time.After(timeout): t.Errorf("test timed out after %s", timeout) os.Exit(1) } }() } type foo struct { bar string } func (f foo) Clone() foo { return foo{f.bar} }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false
jesseduffield/lazygit
https://github.com/jesseduffield/lazygit/blob/80dd695d7a8d32714603f5a6307f26f589802b1d/vendor/github.com/samber/lo/tuples.go
vendor/github.com/samber/lo/tuples.go
package lo // T2 creates a tuple from a list of values. // Play: https://go.dev/play/p/IllL3ZO4BQm func T2[A any, B any](a A, b B) Tuple2[A, B] { return Tuple2[A, B]{A: a, B: b} } // T3 creates a tuple from a list of values. // Play: https://go.dev/play/p/IllL3ZO4BQm func T3[A any, B any, C any](a A, b B, c C) Tuple3[A, B, C] { return Tuple3[A, B, C]{A: a, B: b, C: c} } // T4 creates a tuple from a list of values. // Play: https://go.dev/play/p/IllL3ZO4BQm func T4[A any, B any, C any, D any](a A, b B, c C, d D) Tuple4[A, B, C, D] { return Tuple4[A, B, C, D]{A: a, B: b, C: c, D: d} } // T5 creates a tuple from a list of values. // Play: https://go.dev/play/p/IllL3ZO4BQm func T5[A any, B any, C any, D any, E any](a A, b B, c C, d D, e E) Tuple5[A, B, C, D, E] { return Tuple5[A, B, C, D, E]{A: a, B: b, C: c, D: d, E: e} } // T6 creates a tuple from a list of values. // Play: https://go.dev/play/p/IllL3ZO4BQm func T6[A any, B any, C any, D any, E any, F any](a A, b B, c C, d D, e E, f F) Tuple6[A, B, C, D, E, F] { return Tuple6[A, B, C, D, E, F]{A: a, B: b, C: c, D: d, E: e, F: f} } // T7 creates a tuple from a list of values. // Play: https://go.dev/play/p/IllL3ZO4BQm func T7[A any, B any, C any, D any, E any, F any, G any](a A, b B, c C, d D, e E, f F, g G) Tuple7[A, B, C, D, E, F, G] { return Tuple7[A, B, C, D, E, F, G]{A: a, B: b, C: c, D: d, E: e, F: f, G: g} } // T8 creates a tuple from a list of values. // Play: https://go.dev/play/p/IllL3ZO4BQm func T8[A any, B any, C any, D any, E any, F any, G any, H any](a A, b B, c C, d D, e E, f F, g G, h H) Tuple8[A, B, C, D, E, F, G, H] { return Tuple8[A, B, C, D, E, F, G, H]{A: a, B: b, C: c, D: d, E: e, F: f, G: g, H: h} } // T8 creates a tuple from a list of values. // Play: https://go.dev/play/p/IllL3ZO4BQm func T9[A any, B any, C any, D any, E any, F any, G any, H any, I any](a A, b B, c C, d D, e E, f F, g G, h H, i I) Tuple9[A, B, C, D, E, F, G, H, I] { return Tuple9[A, B, C, D, E, F, G, H, I]{A: a, B: b, C: c, D: d, E: e, F: f, G: g, H: h, I: i} } // Unpack2 returns values contained in tuple. // Play: https://go.dev/play/p/xVP_k0kJ96W func Unpack2[A any, B any](tuple Tuple2[A, B]) (A, B) { return tuple.A, tuple.B } // Unpack3 returns values contained in tuple. // Play: https://go.dev/play/p/xVP_k0kJ96W func Unpack3[A any, B any, C any](tuple Tuple3[A, B, C]) (A, B, C) { return tuple.A, tuple.B, tuple.C } // Unpack4 returns values contained in tuple. // Play: https://go.dev/play/p/xVP_k0kJ96W func Unpack4[A any, B any, C any, D any](tuple Tuple4[A, B, C, D]) (A, B, C, D) { return tuple.A, tuple.B, tuple.C, tuple.D } // Unpack5 returns values contained in tuple. // Play: https://go.dev/play/p/xVP_k0kJ96W func Unpack5[A any, B any, C any, D any, E any](tuple Tuple5[A, B, C, D, E]) (A, B, C, D, E) { return tuple.A, tuple.B, tuple.C, tuple.D, tuple.E } // Unpack6 returns values contained in tuple. // Play: https://go.dev/play/p/xVP_k0kJ96W func Unpack6[A any, B any, C any, D any, E any, F any](tuple Tuple6[A, B, C, D, E, F]) (A, B, C, D, E, F) { return tuple.A, tuple.B, tuple.C, tuple.D, tuple.E, tuple.F } // Unpack7 returns values contained in tuple. // Play: https://go.dev/play/p/xVP_k0kJ96W func Unpack7[A any, B any, C any, D any, E any, F any, G any](tuple Tuple7[A, B, C, D, E, F, G]) (A, B, C, D, E, F, G) { return tuple.A, tuple.B, tuple.C, tuple.D, tuple.E, tuple.F, tuple.G } // Unpack8 returns values contained in tuple. // Play: https://go.dev/play/p/xVP_k0kJ96W func Unpack8[A any, B any, C any, D any, E any, F any, G any, H any](tuple Tuple8[A, B, C, D, E, F, G, H]) (A, B, C, D, E, F, G, H) { return tuple.A, tuple.B, tuple.C, tuple.D, tuple.E, tuple.F, tuple.G, tuple.H } // Unpack9 returns values contained in tuple. // Play: https://go.dev/play/p/xVP_k0kJ96W func Unpack9[A any, B any, C any, D any, E any, F any, G any, H any, I any](tuple Tuple9[A, B, C, D, E, F, G, H, I]) (A, B, C, D, E, F, G, H, I) { return tuple.A, tuple.B, tuple.C, tuple.D, tuple.E, tuple.F, tuple.G, tuple.H, tuple.I } // Zip2 creates a slice of grouped elements, the first of which contains the first elements // of the given arrays, the second of which contains the second elements of the given arrays, and so on. // When collections have different size, the Tuple attributes are filled with zero value. // Play: https://go.dev/play/p/jujaA6GaJTp func Zip2[A any, B any](a []A, b []B) []Tuple2[A, B] { size := Max([]int{len(a), len(b)}) result := make([]Tuple2[A, B], 0, size) for index := 0; index < size; index++ { _a, _ := Nth(a, index) _b, _ := Nth(b, index) result = append(result, Tuple2[A, B]{ A: _a, B: _b, }) } return result } // Zip3 creates a slice of grouped elements, the first of which contains the first elements // of the given arrays, the second of which contains the second elements of the given arrays, and so on. // When collections have different size, the Tuple attributes are filled with zero value. // Play: https://go.dev/play/p/jujaA6GaJTp func Zip3[A any, B any, C any](a []A, b []B, c []C) []Tuple3[A, B, C] { size := Max([]int{len(a), len(b), len(c)}) result := make([]Tuple3[A, B, C], 0, size) for index := 0; index < size; index++ { _a, _ := Nth(a, index) _b, _ := Nth(b, index) _c, _ := Nth(c, index) result = append(result, Tuple3[A, B, C]{ A: _a, B: _b, C: _c, }) } return result } // Zip4 creates a slice of grouped elements, the first of which contains the first elements // of the given arrays, the second of which contains the second elements of the given arrays, and so on. // When collections have different size, the Tuple attributes are filled with zero value. // Play: https://go.dev/play/p/jujaA6GaJTp func Zip4[A any, B any, C any, D any](a []A, b []B, c []C, d []D) []Tuple4[A, B, C, D] { size := Max([]int{len(a), len(b), len(c), len(d)}) result := make([]Tuple4[A, B, C, D], 0, size) for index := 0; index < size; index++ { _a, _ := Nth(a, index) _b, _ := Nth(b, index) _c, _ := Nth(c, index) _d, _ := Nth(d, index) result = append(result, Tuple4[A, B, C, D]{ A: _a, B: _b, C: _c, D: _d, }) } return result } // Zip5 creates a slice of grouped elements, the first of which contains the first elements // of the given arrays, the second of which contains the second elements of the given arrays, and so on. // When collections have different size, the Tuple attributes are filled with zero value. // Play: https://go.dev/play/p/jujaA6GaJTp func Zip5[A any, B any, C any, D any, E any](a []A, b []B, c []C, d []D, e []E) []Tuple5[A, B, C, D, E] { size := Max([]int{len(a), len(b), len(c), len(d), len(e)}) result := make([]Tuple5[A, B, C, D, E], 0, size) for index := 0; index < size; index++ { _a, _ := Nth(a, index) _b, _ := Nth(b, index) _c, _ := Nth(c, index) _d, _ := Nth(d, index) _e, _ := Nth(e, index) result = append(result, Tuple5[A, B, C, D, E]{ A: _a, B: _b, C: _c, D: _d, E: _e, }) } return result } // Zip6 creates a slice of grouped elements, the first of which contains the first elements // of the given arrays, the second of which contains the second elements of the given arrays, and so on. // When collections have different size, the Tuple attributes are filled with zero value. // Play: https://go.dev/play/p/jujaA6GaJTp func Zip6[A any, B any, C any, D any, E any, F any](a []A, b []B, c []C, d []D, e []E, f []F) []Tuple6[A, B, C, D, E, F] { size := Max([]int{len(a), len(b), len(c), len(d), len(e), len(f)}) result := make([]Tuple6[A, B, C, D, E, F], 0, size) for index := 0; index < size; index++ { _a, _ := Nth(a, index) _b, _ := Nth(b, index) _c, _ := Nth(c, index) _d, _ := Nth(d, index) _e, _ := Nth(e, index) _f, _ := Nth(f, index) result = append(result, Tuple6[A, B, C, D, E, F]{ A: _a, B: _b, C: _c, D: _d, E: _e, F: _f, }) } return result } // Zip7 creates a slice of grouped elements, the first of which contains the first elements // of the given arrays, the second of which contains the second elements of the given arrays, and so on. // When collections have different size, the Tuple attributes are filled with zero value. // Play: https://go.dev/play/p/jujaA6GaJTp func Zip7[A any, B any, C any, D any, E any, F any, G any](a []A, b []B, c []C, d []D, e []E, f []F, g []G) []Tuple7[A, B, C, D, E, F, G] { size := Max([]int{len(a), len(b), len(c), len(d), len(e), len(f), len(g)}) result := make([]Tuple7[A, B, C, D, E, F, G], 0, size) for index := 0; index < size; index++ { _a, _ := Nth(a, index) _b, _ := Nth(b, index) _c, _ := Nth(c, index) _d, _ := Nth(d, index) _e, _ := Nth(e, index) _f, _ := Nth(f, index) _g, _ := Nth(g, index) result = append(result, Tuple7[A, B, C, D, E, F, G]{ A: _a, B: _b, C: _c, D: _d, E: _e, F: _f, G: _g, }) } return result } // Zip8 creates a slice of grouped elements, the first of which contains the first elements // of the given arrays, the second of which contains the second elements of the given arrays, and so on. // When collections have different size, the Tuple attributes are filled with zero value. // Play: https://go.dev/play/p/jujaA6GaJTp func Zip8[A any, B any, C any, D any, E any, F any, G any, H any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H) []Tuple8[A, B, C, D, E, F, G, H] { size := Max([]int{len(a), len(b), len(c), len(d), len(e), len(f), len(g), len(h)}) result := make([]Tuple8[A, B, C, D, E, F, G, H], 0, size) for index := 0; index < size; index++ { _a, _ := Nth(a, index) _b, _ := Nth(b, index) _c, _ := Nth(c, index) _d, _ := Nth(d, index) _e, _ := Nth(e, index) _f, _ := Nth(f, index) _g, _ := Nth(g, index) _h, _ := Nth(h, index) result = append(result, Tuple8[A, B, C, D, E, F, G, H]{ A: _a, B: _b, C: _c, D: _d, E: _e, F: _f, G: _g, H: _h, }) } return result } // Zip9 creates a slice of grouped elements, the first of which contains the first elements // of the given arrays, the second of which contains the second elements of the given arrays, and so on. // When collections have different size, the Tuple attributes are filled with zero value. // Play: https://go.dev/play/p/jujaA6GaJTp func Zip9[A any, B any, C any, D any, E any, F any, G any, H any, I any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H, i []I) []Tuple9[A, B, C, D, E, F, G, H, I] { size := Max([]int{len(a), len(b), len(c), len(d), len(e), len(f), len(g), len(h), len(i)}) result := make([]Tuple9[A, B, C, D, E, F, G, H, I], 0, size) for index := 0; index < size; index++ { _a, _ := Nth(a, index) _b, _ := Nth(b, index) _c, _ := Nth(c, index) _d, _ := Nth(d, index) _e, _ := Nth(e, index) _f, _ := Nth(f, index) _g, _ := Nth(g, index) _h, _ := Nth(h, index) _i, _ := Nth(i, index) result = append(result, Tuple9[A, B, C, D, E, F, G, H, I]{ A: _a, B: _b, C: _c, D: _d, E: _e, F: _f, G: _g, H: _h, I: _i, }) } return result } // Unzip2 accepts an array of grouped elements and creates an array regrouping the elements // to their pre-zip configuration. // Play: https://go.dev/play/p/ciHugugvaAW func Unzip2[A any, B any](tuples []Tuple2[A, B]) ([]A, []B) { size := len(tuples) r1 := make([]A, 0, size) r2 := make([]B, 0, size) for _, tuple := range tuples { r1 = append(r1, tuple.A) r2 = append(r2, tuple.B) } return r1, r2 } // Unzip3 accepts an array of grouped elements and creates an array regrouping the elements // to their pre-zip configuration. // Play: https://go.dev/play/p/ciHugugvaAW func Unzip3[A any, B any, C any](tuples []Tuple3[A, B, C]) ([]A, []B, []C) { size := len(tuples) r1 := make([]A, 0, size) r2 := make([]B, 0, size) r3 := make([]C, 0, size) for _, tuple := range tuples { r1 = append(r1, tuple.A) r2 = append(r2, tuple.B) r3 = append(r3, tuple.C) } return r1, r2, r3 } // Unzip4 accepts an array of grouped elements and creates an array regrouping the elements // to their pre-zip configuration. // Play: https://go.dev/play/p/ciHugugvaAW func Unzip4[A any, B any, C any, D any](tuples []Tuple4[A, B, C, D]) ([]A, []B, []C, []D) { size := len(tuples) r1 := make([]A, 0, size) r2 := make([]B, 0, size) r3 := make([]C, 0, size) r4 := make([]D, 0, size) for _, tuple := range tuples { r1 = append(r1, tuple.A) r2 = append(r2, tuple.B) r3 = append(r3, tuple.C) r4 = append(r4, tuple.D) } return r1, r2, r3, r4 } // Unzip5 accepts an array of grouped elements and creates an array regrouping the elements // to their pre-zip configuration. // Play: https://go.dev/play/p/ciHugugvaAW func Unzip5[A any, B any, C any, D any, E any](tuples []Tuple5[A, B, C, D, E]) ([]A, []B, []C, []D, []E) { size := len(tuples) r1 := make([]A, 0, size) r2 := make([]B, 0, size) r3 := make([]C, 0, size) r4 := make([]D, 0, size) r5 := make([]E, 0, size) for _, tuple := range tuples { r1 = append(r1, tuple.A) r2 = append(r2, tuple.B) r3 = append(r3, tuple.C) r4 = append(r4, tuple.D) r5 = append(r5, tuple.E) } return r1, r2, r3, r4, r5 } // Unzip6 accepts an array of grouped elements and creates an array regrouping the elements // to their pre-zip configuration. // Play: https://go.dev/play/p/ciHugugvaAW func Unzip6[A any, B any, C any, D any, E any, F any](tuples []Tuple6[A, B, C, D, E, F]) ([]A, []B, []C, []D, []E, []F) { size := len(tuples) r1 := make([]A, 0, size) r2 := make([]B, 0, size) r3 := make([]C, 0, size) r4 := make([]D, 0, size) r5 := make([]E, 0, size) r6 := make([]F, 0, size) for _, tuple := range tuples { r1 = append(r1, tuple.A) r2 = append(r2, tuple.B) r3 = append(r3, tuple.C) r4 = append(r4, tuple.D) r5 = append(r5, tuple.E) r6 = append(r6, tuple.F) } return r1, r2, r3, r4, r5, r6 } // Unzip7 accepts an array of grouped elements and creates an array regrouping the elements // to their pre-zip configuration. // Play: https://go.dev/play/p/ciHugugvaAW func Unzip7[A any, B any, C any, D any, E any, F any, G any](tuples []Tuple7[A, B, C, D, E, F, G]) ([]A, []B, []C, []D, []E, []F, []G) { size := len(tuples) r1 := make([]A, 0, size) r2 := make([]B, 0, size) r3 := make([]C, 0, size) r4 := make([]D, 0, size) r5 := make([]E, 0, size) r6 := make([]F, 0, size) r7 := make([]G, 0, size) for _, tuple := range tuples { r1 = append(r1, tuple.A) r2 = append(r2, tuple.B) r3 = append(r3, tuple.C) r4 = append(r4, tuple.D) r5 = append(r5, tuple.E) r6 = append(r6, tuple.F) r7 = append(r7, tuple.G) } return r1, r2, r3, r4, r5, r6, r7 } // Unzip8 accepts an array of grouped elements and creates an array regrouping the elements // to their pre-zip configuration. // Play: https://go.dev/play/p/ciHugugvaAW func Unzip8[A any, B any, C any, D any, E any, F any, G any, H any](tuples []Tuple8[A, B, C, D, E, F, G, H]) ([]A, []B, []C, []D, []E, []F, []G, []H) { size := len(tuples) r1 := make([]A, 0, size) r2 := make([]B, 0, size) r3 := make([]C, 0, size) r4 := make([]D, 0, size) r5 := make([]E, 0, size) r6 := make([]F, 0, size) r7 := make([]G, 0, size) r8 := make([]H, 0, size) for _, tuple := range tuples { r1 = append(r1, tuple.A) r2 = append(r2, tuple.B) r3 = append(r3, tuple.C) r4 = append(r4, tuple.D) r5 = append(r5, tuple.E) r6 = append(r6, tuple.F) r7 = append(r7, tuple.G) r8 = append(r8, tuple.H) } return r1, r2, r3, r4, r5, r6, r7, r8 } // Unzip9 accepts an array of grouped elements and creates an array regrouping the elements // to their pre-zip configuration. // Play: https://go.dev/play/p/ciHugugvaAW func Unzip9[A any, B any, C any, D any, E any, F any, G any, H any, I any](tuples []Tuple9[A, B, C, D, E, F, G, H, I]) ([]A, []B, []C, []D, []E, []F, []G, []H, []I) { size := len(tuples) r1 := make([]A, 0, size) r2 := make([]B, 0, size) r3 := make([]C, 0, size) r4 := make([]D, 0, size) r5 := make([]E, 0, size) r6 := make([]F, 0, size) r7 := make([]G, 0, size) r8 := make([]H, 0, size) r9 := make([]I, 0, size) for _, tuple := range tuples { r1 = append(r1, tuple.A) r2 = append(r2, tuple.B) r3 = append(r3, tuple.C) r4 = append(r4, tuple.D) r5 = append(r5, tuple.E) r6 = append(r6, tuple.F) r7 = append(r7, tuple.G) r8 = append(r8, tuple.H) r9 = append(r9, tuple.I) } return r1, r2, r3, r4, r5, r6, r7, r8, r9 }
go
MIT
80dd695d7a8d32714603f5a6307f26f589802b1d
2026-01-07T08:35:43.445894Z
false