signature

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const BlsHashPrefix = "BLS"

BlsHashPrefix is the prefix used to verify a BLS scheme signature.

Variables

View Source
var (
	// ErrSignatureMismatch is returned when a verifier detect a wrong signature.
	ErrSignatureMismatch = errors.New("signature mismatch")
	// AllSchemes all the supported scheme.
	AllSchemes = []Scheme{
		NoScheme, Ecdsa, Bls, Eddsa,
	}
	// AllRealSchemes all supported real scheme (excluding NoScheme).
	AllRealSchemes = []Scheme{
		Ecdsa, Bls, Eddsa,
	}
)

Functions

func ASN1MarshalTxNamespace added in v0.1.4

func ASN1MarshalTxNamespace(tx *protoblocktx.Tx, nsIndex int) ([]byte, error)

ASN1MarshalTxNamespace marshals a transactions for a given namespace index. It uses the schema described in tx_schema.asn.

func AsnToProtoVersion added in v0.1.4

func AsnToProtoVersion(ver int64) *uint64

AsnToProtoVersion converts the ASN.1 version to proto version. ASN.1 uses -1 to encode nil version.

func DigestTxNamespace

func DigestTxNamespace(tx *protoblocktx.Tx, nsIndex int) ([]byte, error)

DigestTxNamespace digests a transactions for a given namespace index.

func ProtoToAsnVersion added in v0.1.4

func ProtoToAsnVersion(ver *uint64) int64

ProtoToAsnVersion converts the proto version to ASN.1 version. ASN.1 uses -1 to encode nil version.

Types

type BLSVerifier

type BLSVerifier struct {
	// contains filtered or unexported fields
}

BLSVerifier verifies using the BLS scheme.

func NewBLSVerifier

func NewBLSVerifier(key []byte) (*BLSVerifier, error)

NewBLSVerifier instantiate a new BLS scheme verifier.

func (*BLSVerifier) Verify

func (v *BLSVerifier) Verify(digest Digest, signature Signature) error

Verify a digest given a signature.

type Digest

type Digest = []byte

Digest of a message.

type DigestVerifier

type DigestVerifier interface {
	Verify(Digest, Signature) error
}

DigestVerifier verifies a digest.

type EcdsaTxVerifier

type EcdsaTxVerifier struct {
	// contains filtered or unexported fields
}

EcdsaTxVerifier verifies using the ECDSA scheme.

func NewEcdsaVerifier

func NewEcdsaVerifier(key []byte) (*EcdsaTxVerifier, error)

NewEcdsaVerifier instantiate a new ECDSA scheme verifier.

func (*EcdsaTxVerifier) Verify

func (v *EcdsaTxVerifier) Verify(digest Digest, signature Signature) error

Verify a digest given a signature.

type EdDSAVerifier

type EdDSAVerifier struct {
	PublicKey ed25519.PublicKey
}

EdDSAVerifier verifies using the EdDSA scheme.

func (*EdDSAVerifier) Verify

func (v *EdDSAVerifier) Verify(digest Digest, signature Signature) error

Verify a digest given a signature.

type NsVerifier

type NsVerifier struct {
	Scheme    Scheme
	PublicKey PublicKey
	// contains filtered or unexported fields
}

NsVerifier verifies a given namespace.

func NewNsVerifier

func NewNsVerifier(scheme Scheme, key PublicKey) (*NsVerifier, error)

NewNsVerifier creates a new namespace verifier according to the implementation scheme.

func (*NsVerifier) VerifyNs

func (v *NsVerifier) VerifyNs(tx *protoblocktx.Tx, nsIndex int) error

VerifyNs verifies a transaction's namespace signature.

type PrivateKey

type PrivateKey = []byte

PrivateKey to be used.

type PublicKey

type PublicKey = []byte

PublicKey to be used.

type Read

type Read struct {
	Key     []byte
	Version int64 `asn1:"optional,default:-1"`
}

Read is a stab for protoblocktx.Read. Any change to this protobuf requires a change to these structures.

type ReadWrite

type ReadWrite struct {
	Key     []byte
	Value   []byte
	Version int64 `asn1:"optional,default:-1"`
}

ReadWrite is a stab for protoblocktx.ReadWrite. Any change to this protobuf requires a change to these structures.

type Scheme

type Scheme = string

Scheme to be used.

const (
	// NoScheme does nothing.
	NoScheme Scheme = "NONE"
	// Ecdsa use the ECDSA scheme.
	Ecdsa Scheme = "ECDSA"
	// Bls use the BLS scheme.
	Bls Scheme = "BLS"
	// Eddsa use the EDDSA scheme.
	Eddsa Scheme = "EDDSA"
)

Supported schemes.

type Signature

type Signature = []byte

Signature of a message.

type TxWithNamespace added in v0.1.4

type TxWithNamespace struct {
	TxID             string `asn1:"utf8"`
	NamespaceID      string `asn1:"utf8"`
	NamespaceVersion int64
	ReadsOnly        []Read
	ReadWrites       []ReadWrite
	BlindWrites      []Write
}

TxWithNamespace is a stab for protoblocktx.Tx and protoblocktx.TxNamespace. Any change to these protobuf requires a change to these structures. It conforms with tx_schema.asn. We force the ASN.1 library to use UTF8 strings to avoid incompatibility with the schema. If not specified, the library choose to use ASCII (PrintableString) for simple strings, and UTF8 otherwise.

func TranslateTx added in v0.1.4

func TranslateTx(tx *protoblocktx.Tx, nsIndex int) (*TxWithNamespace, error)

TranslateTx translates a TX namespace to a stab struct for tx_schema.asn. Any change to *protoblocktx.Tx requires a change to this method.

type Write added in v0.1.4

type Write struct {
	Key   []byte
	Value []byte
}

Write is a stab for protoblocktx.Write. Any change to this protobuf requires a change to these structures.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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