mirror of
https://github.com/luxfi/gpu.git
synced 2026-10-30 16:23:49 +00:00
Empty/nil input now returns (nil, nil) on no-CGO builds so callers can skip empty blocks without distinguishing build modes. Non-empty input returns the new exported ErrEcrecoverNoCGO sentinel for fallback paths. Pin the Signature and EcrecoverResult layouts (R/S/MsgHash 32 bytes, Address 20 bytes, V/Valid scalar) and the empty-batch contract for both build paths.
22 lines
689 B
Go
22 lines
689 B
Go
//go:build !cgo
|
|
|
|
package gpu
|
|
|
|
import "errors"
|
|
|
|
// BatchEcrecover recovers Ethereum addresses for a batch of signatures.
|
|
//
|
|
// Without CGO the GPU/native backend is unavailable. Empty and nil inputs
|
|
// short-circuit (callers use this to skip empty blocks without paying the
|
|
// cost of an FFI hop). A non-empty input returns ErrEcrecoverNoCGO so the
|
|
// caller can fall back to a pure-Go ecrecover path.
|
|
func BatchEcrecover(sigs []Signature) ([]EcrecoverResult, error) {
|
|
if len(sigs) == 0 {
|
|
return nil, nil
|
|
}
|
|
return nil, ErrEcrecoverNoCGO
|
|
}
|
|
|
|
// ErrEcrecoverNoCGO is returned by BatchEcrecover on builds without CGO.
|
|
var ErrEcrecoverNoCGO = errors.New("gpu: BatchEcrecover requires CGO")
|