Documentation
¶
Overview ¶
Package legacymimc 提供 gnark-crypto v0.5.3 的旧版 MiMC 实现。 chain33 升级 go-ethereum v1.14.8 后 gnark-crypto 升至 v0.12.1, 其 MiMC round constants 从 sha3.Sum256 改为 keccak256,导致 hash 输出变化。 为保持 zksync/mix 链上已有数据兼容,保留旧实现。
Index ¶
Constants ¶
const BlockSize = fr.Bytes
BlockSize size that mimc consumes
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CircuitMiMC ¶
type CircuitMiMC struct {
// contains filtered or unexported fields
}
CircuitMiMC 电路内 MiMC 实现,使用旧版 round constants(sha3.Sum256 推导)。 参考 gnark v0.9.0 std/hash/mimc,但允许注入自定义 params 以保持链上协议兼容。
func NewCircuitMiMC ¶
func NewCircuitMiMC(api frontend.API, seed string) (CircuitMiMC, error)
NewCircuitMiMC returns a CircuitMiMC instance with given seed's old constants. 返回 (CircuitMiMC, error) 以对齐 gnark 上游 NewMiMC 的签名风格;本实现参数派生不会失败,error 恒为 nil。
func (*CircuitMiMC) Reset ¶
func (h *CircuitMiMC) Reset()
Reset resets the Hash to its initial state.
func (*CircuitMiMC) Sum ¶
func (h *CircuitMiMC) Sum() frontend.Variable
Sum hash (in r1cs form) using Miyaguchi–Preneel: https://en.wikipedia.org/wiki/One-way_compression_function 与 gnark v0.5.2 电路实现保持一致:h = E(stream, h.h) + stream
func (*CircuitMiMC) Write ¶
func (h *CircuitMiMC) Write(data ...frontend.Variable)
Write adds more data to the running hash.