Documentation
¶
Index ¶
- func ComputeHashOnElements(elems []*big.Int) (hash *big.Int)
- func GetRandomKeys() (privKey, x, y *big.Int, err error)
- func GetYCoordinate(starkX *felt.Felt) *felt.Felt
- func HashPedersenElements(elems []*big.Int) (hash *big.Int)
- func Pedersen(a, b *felt.Felt) *felt.Felt
- func PedersenArray(felts ...*felt.Felt) *felt.Felt
- func Poseidon(a, b *felt.Felt) *felt.Felt
- func PoseidonArray(felts ...*felt.Felt) *felt.Felt
- func PrivateKeyToPoint(privKey *big.Int) (x, y *big.Int)
- func Sign(msgHash, privKey *big.Int) (r, s *big.Int, err error)
- func StarknetKeccak(b []byte) *felt.Felt
- func Verify(msgHash, r, s, pubX *big.Int) (bool, error)
- func VerifyFelts(msgHash, r, s, pubX *felt.Felt) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeHashOnElements ¶ added in v0.7.1
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
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
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
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
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
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
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
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
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
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
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
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
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.