crypto

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 9 modules, 12 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStarknetKeccakState added in v0.16.1

func NewStarknetKeccakState() hash.Hash

NewStarknetKeccakState returns a fresh Keccak-256 state that callers can stream bytes into. Finalize with StarknetKeccakSum to obtain the felt.

func Pedersen

func Pedersen[R, A, B felt.FeltLike](a *A, b *B) R

Pedersen implements the Pedersen hash.

func PedersenArray

func PedersenArray[R, F felt.FeltLike](elems []F) R

PedersenArray implements Pedersen array hashing.

func PedersenElems added in v0.16.6

func PedersenElems[R, F felt.FeltLike](elems ...*F) R

PedersenElems is the pointer-element variant of PedersenArray.

func Poseidon added in v0.2.1

func Poseidon[R, A, B felt.FeltLike](x *A, y *B) R

Poseidon implements the Poseidon hash.

func PoseidonArray added in v0.2.1

func PoseidonArray[R, F felt.FeltLike](elems []F) R

PoseidonArray calculates Poseidon hash over elems If len(elems) is odd, pads with [1] If len(elems) is even, pads with [1, 0]

PoseidonArray implements Poseidon array hashing.

func PoseidonElems added in v0.16.6

func PoseidonElems[R, F felt.FeltLike](elems ...*F) R

PoseidonElems is the pointer-element variant of PoseidonArray, for callers that already hold a []*felt.Felt (e.g. transaction hashing) and would otherwise pay a copy to convert into a value slice.

func StarknetKeccak

func StarknetKeccak(b []byte) felt.Felt

StarknetKeccak implements Starknet keccak

func StarknetKeccakSum added in v0.16.1

func StarknetKeccakSum(h hash.Hash) felt.Felt

StarknetKeccakSum finalizes a Keccak-256 state into a Starknet felt by masking the top 6 bits of the digest and reducing modulo the felt prime.

Types

type HashFn added in v0.13.0

type HashFn func(*felt.Felt, *felt.Felt) felt.Felt

type PedersenDigest added in v0.6.2

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

func (*PedersenDigest) Finish added in v0.6.2

func (d *PedersenDigest) Finish[R felt.FeltLike]() R

Finish completes the digest and returns it as felt type R.

func (*PedersenDigest) Update added in v0.6.2

func (d *PedersenDigest) Update[F felt.FeltLike](elem *F) *PedersenDigest

Update adds one element of any felt type to the digest.

func (*PedersenDigest) UpdateArray added in v0.16.6

func (d *PedersenDigest) UpdateArray[F felt.FeltLike](elems []F) *PedersenDigest

UpdateArray adds every element of elems to the digest.

type PoseidonDigest added in v0.6.2

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

func (*PoseidonDigest) Finish added in v0.6.2

func (d *PoseidonDigest) Finish[R felt.FeltLike]() R

Finish completes the digest and returns it as felt type R.

func (*PoseidonDigest) Update added in v0.6.2

func (d *PoseidonDigest) Update[F felt.FeltLike](elem *F) *PoseidonDigest

Update adds one element of any felt type to the digest.

func (*PoseidonDigest) UpdateArray added in v0.16.6

func (d *PoseidonDigest) UpdateArray[F felt.FeltLike](elems []F) *PoseidonDigest

UpdateArray adds every element of elems to the digest.

type PublicKey added in v0.9.3

type PublicKey ecdsa.PublicKey

func NewPublicKey added in v0.9.3

func NewPublicKey(x *felt.Felt) PublicKey

func (*PublicKey) Verify added in v0.9.3

func (k *PublicKey) Verify(sig *Signature, msg *felt.Felt) (bool, error)

type Signature added in v0.9.3

type Signature struct {
	R, S felt.Felt
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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