pedersen

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package pedersen implements the StarkNet variant of the Pedersen hash function.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayDigest

func ArrayDigest(data ...*felt.Felt) *felt.Felt

ArrayDigest returns a field element that is the result of hashing an array of field elements. This is generally used to overcome the limitation of the Digest function which has an upper bound on the amount of field elements that can be hashed. See the [array hashing] section of the StarkNet documentation for more details.

- [array hashing]: https://github.com/golang/proposal/blob/master/design/51082-godocfmt.md

func Digest

func Digest(data ...*felt.Felt) *felt.Felt

Digest returns a field element that is the result of hashing an input (a, b) ∈ 𝔽²ₚ where p = 2²⁵¹ + 17·2¹⁹² + 1. This function will panic if len(data) > 2. In order to hash n > 2 items, use ArrayDigest.

Example
a := new(felt.Felt).SetHex("3d937c035c878245caf64531a5756109c53068da139362728feb561405371cb")
b := new(felt.Felt).SetHex("208a0a10250e382e1e4bbe2880906c2791bf6275695e02fbbc6aeff9cd8b31a")
fmt.Printf("%s\n", Digest(a, b).Hex())
Output:

30e480bed5fe53fa909cc0f8c4d99b8f9f2c016be4c41e13a4848797979c662

Types

This section is empty.

Jump to

Keyboard shortcuts

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