sigs

package
v1.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sigs dispatches Filecoin signature verification to the appropriate backend by signature type: BLS (BLS12-381), secp256k1, or delegated (Ethereum f4 addresses).

The interface mirrors Lotus' lib/sigs/sigs.go so wallet and chain validation code can be ported with minimal churn. Each backend lives in a subpackage (bls, secp, delegated) that registers itself via init() with the dispatcher.

Unlike Lotus, the BLS backend here is pure Go (gnark-crypto), so the entire crypto/sigs tree builds with CGO_ENABLED=0.

Copied from github.com/filecoin-project/lotus/lib/sigs/sigs.go at commit a0ecb8687f1c60d5e66040b6de364dbc9cc4d253. See LICENSE.

Modifications:

  • import path for chain/types updated to github.com/Reiers/lantern/chain/types
  • go.opencensus.io/trace usage stripped (we don't ship opencensus)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckBlockSignature

func CheckBlockSignature(ctx context.Context, blk *types.BlockHeader, worker address.Address) error

CheckBlockSignature verifies the BlockSig field of a BlockHeader against the expected worker address. Mirrors the Lotus helper of the same name (minus opencensus tracing, which Lantern does not ship).

func Generate

func Generate(sigType crypto.SigType) ([]byte, error)

Generate generates private key of given type

func RegisterSignature

func RegisterSignature(typ crypto.SigType, vs SigShim)

RegisterSignature should be only used during init

func Sign

func Sign(sigType crypto.SigType, privkey []byte, msg []byte) (*crypto.Signature, error)

Sign takes in signature type, private key and message. Returns a signature for that message. Valid sigTypes are: "secp256k1" and "bls"

func ToPublic

func ToPublic(sigType crypto.SigType, pk []byte) ([]byte, error)

ToPublic converts private key to public key

func Verify

func Verify(sig *crypto.Signature, addr address.Address, msg []byte) error

Verify verifies signatures

Types

type SigShim

type SigShim interface {
	GenPrivate() ([]byte, error)
	ToPublic(pk []byte) ([]byte, error)
	Sign(pk []byte, msg []byte) ([]byte, error)
	Verify(sig []byte, a address.Address, msg []byte) error
}

SigShim is used for introducing signature functions

Directories

Path Synopsis
Package bls implements Filecoin BLS12-381 signature verification using github.com/consensys/gnark-crypto/ecc/bls12-381.
Package bls implements Filecoin BLS12-381 signature verification using github.com/consensys/gnark-crypto/ecc/bls12-381.
Package delegated implements verification for Filecoin "delegated" (f4) signatures: Ethereum-style secp256k1 over Keccak-256 of an RLP-encoded payload.
Package delegated implements verification for Filecoin "delegated" (f4) signatures: Ethereum-style secp256k1 over Keccak-256 of an RLP-encoded payload.
Package secp implements Filecoin secp256k1 signature verification.
Package secp implements Filecoin secp256k1 signature verification.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL