 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package hash provides an interface that hash functions (as gadget) should implement.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BuilderRegistry = make(map[string]func(api frontend.API) (FieldHasher, error))
    Functions ¶
This section is empty.
Types ¶
type BinaryFixedLengthHasher ¶ added in v0.9.0
type BinaryFixedLengthHasher interface {
	BinaryHasher
	// FixedLengthSum returns digest of the first length bytes.
	FixedLengthSum(length frontend.Variable) []uints.U8
}
    BinaryFixedLengthHasher is like BinaryHasher, but assumes the length of the input is not full length as defined during compile time. This allows to compute digest of variable-length input, unlike BinaryHasher which assumes the length of the input is the total number of bytes written.
type BinaryHasher ¶ added in v0.9.0
type BinaryHasher interface {
	// Sum finalises the current hash and returns the digest.
	Sum() []uints.U8
	// Write writes more bytes into the current hash state.
	Write([]uints.U8)
	// Size returns the number of bytes this hash function returns in a call to
	// [BinaryHasher.Sum].
	Size() int
}
    BinaryHasher hashes inputs into a short digest. It takes as inputs bytes and outputs byte array whose length depends on the underlying hash function. For SNARK-native hash functions use FieldHasher.
type FieldHasher ¶ added in v0.9.0
type FieldHasher interface {
	// Sum computes the hash of the internal state of the hash function.
	Sum() frontend.Variable
	// Write populate the internal state of the hash function with data. The inputs are native field elements.
	Write(data ...frontend.Variable)
	// Reset empty the internal state and put the intermediate state to zero.
	Reset()
}
    FieldHasher hashes inputs into a short digest. This interface mocks BinaryHasher, but is more suitable in-circuit by assuming the inputs are scalar field elements and outputs digest as a field element. Such hash functions are for examle Poseidon, MiMC etc.
       Directories
      ¶
      Directories
      ¶
    
    | Path | Synopsis | 
|---|---|
| Package mimc provides a ZKP-circuit function to compute a MiMC hash. | Package mimc provides a ZKP-circuit function to compute a MiMC hash. | 
| Package sha2 implements SHA2 hash computation. | Package sha2 implements SHA2 hash computation. | 
| Package sha3 provides ZKP circuits for SHA3 hash algorithms applying sponge construction over Keccak f-[1600] permutation function. | Package sha3 provides ZKP circuits for SHA3 hash algorithms applying sponge construction over Keccak f-[1600] permutation function. |