curve

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: MIT Imports: 10 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeHashOnElements added in v0.7.1

func ComputeHashOnElements(elems []*big.Int) (hash *big.Int)

ComputeHashOnElements computes the hash on the given elements using a golang Pedersen Hash implementation.

The function appends the length of `elems` to the slice and then calls the `HashPedersenElements` method passing in `elems` as an argument. The resulting hash is returned.

Parameters:

  • elems: slice of big.Int pointers to be hashed

Returns:

  • hash: The hash of the list of elements

func GetRandomKeys added in v0.12.0

func GetRandomKeys() (privKey, x, y *big.Int, err error)

GetRandomKeys generates a random private key and its corresponding public key.

Returns:

  • privKey: The private key
  • x: The x-coordinate of the public key (the Starknet public key)
  • y: The y-coordinate of the public key
  • err: An error if any occurred during the key generation process

func GetYCoordinate added in v0.12.0

func GetYCoordinate(starkX *felt.Felt) *felt.Felt

GetYCoordinate returns the y-coordinate of a point on the curve given the x-coordinate.

Parameters:

  • starkX: The x-coordinate of the point

Returns:

  • *big.Int: The y-coordinate of the point

func HashPedersenElements added in v0.7.1

func HashPedersenElements(elems []*big.Int) (hash *big.Int)

HashPedersenElements calculates the hash of a list of elements using a golang Pedersen Hash. Parameters:

  • elems: slice of big.Int pointers to be hashed

Returns:

  • hash: The hash of the list of elements

func Pedersen added in v0.7.1

func Pedersen(a, b *felt.Felt) *felt.Felt

Pedersen is a function that implements the Pedersen hash.

Parameters:

  • a: a pointers to felt.Felt to be hashed.
  • b: a pointers to felt.Felt to be hashed.

Returns:

  • *felt.Felt: a pointer to a felt.Felt storing the resulting hash.

func PedersenArray added in v0.7.1

func PedersenArray(felts ...*felt.Felt) *felt.Felt

PedersenArray is a function that takes a variadic number of felt.Felt pointers as parameters and calls the PedersenArray function from the junoCrypto package with the provided parameters.

Parameters:

  • felts: A variadic number of pointers to felt.Felt

Returns:

  • *felt.Felt: pointer to a felt.Felt

func Poseidon added in v0.7.3

func Poseidon(a, b *felt.Felt) *felt.Felt

Poseidon is a function that implements the Poseidon hash.

Parameters:

  • a: a pointers to felt.Felt to be hashed.
  • b: a pointers to felt.Felt to be hashed.

Returns:

  • *felt.Felt: a pointer to a felt.Felt storing the resulting hash.

func PoseidonArray added in v0.7.3

func PoseidonArray(felts ...*felt.Felt) *felt.Felt

PoseidonArray is a function that takes a variadic number of felt.Felt pointers as parameters and calls the PoseidonArray function from the junoCrypto package with the provided parameters.

Parameters:

  • felts: A variadic number of pointers to felt.Felt

Returns:

  • *felt.Felt: pointer to a felt.Felt

func PrivateKeyToPoint added in v0.12.0

func PrivateKeyToPoint(privKey *big.Int) (x, y *big.Int)

PrivateKeyToPoint generates a point on the StarkCurve from a private key.

It takes a private key as a parameter and returns the x and y coordinates of the generated point on the curve.

Parameters:

  • privKey: The private key

Returns:

  • x: The x-coordinate of the point on the curve
  • y: The y-coordinate of the point on the curve

func Sign added in v0.12.0

func Sign(msgHash, privKey *big.Int) (r, s *big.Int, err error)

Sign calculates the signature of a message using the StarkCurve algorithm.

Parameters:

  • msgHash: The message hash to be signed
  • privKey: The private key used for signing

Returns:

  • r: The r component of the signature
  • s: The s component of the signature
  • error: An error if any occurred during the signing process

func StarknetKeccak added in v0.7.3

func StarknetKeccak(b []byte) *felt.Felt

StarknetKeccak computes the Starknet Keccak hash of the given byte slice.

Parameters:

  • b: The byte slice to hash

Returns:

  • *felt.Felt: pointer to a felt.Felt
  • error: An error if any

func Verify added in v0.12.0

func Verify(msgHash, r, s, pubX *big.Int) (bool, error)

Verify verifies the validity of the signature for a given message hash using the StarkCurve.

Parameters:

  • msgHash: The message hash to be verified
  • r: The r component of the signature
  • s: The s component of the signature
  • pubX: The x-coordinate of the public key used for verification, usually used as the account public key.

Returns:

  • bool: true if the signature is valid, false otherwise
  • error: An error if any occurred during the verification process

func VerifyFelts added in v0.12.0

func VerifyFelts(msgHash, r, s, pubX *felt.Felt) (bool, error)

VerifyFelts verifies the validity of the signature for a given message hash using the StarkCurve. It does the same as Verify, but with felt.Felt parameters.

Parameters:

  • msgHash: The message hash to be verified
  • r: The r component of the signature
  • s: The s component of the signature
  • pubX: The x-coordinate of the public key used for verification, usually used as the account public key.

Returns:

  • bool: true if the signature is valid, false otherwise
  • error: An error if any occurred during the verification process

Types

This section is empty.

Jump to

Keyboard shortcuts

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