funchash(ingest []byte, cfg *blake2b.Config) []byte { hasher, err := blake2b.New(cfg) if err != nil { // If this happens sth is very wrong. panic(fmt.Sprintf("invalid address hash configuration: %v", err)) // ok } if _, err := hasher.Write(ingest); err != nil { // blake2bs Write implementation never returns an error in its current // setup. So if this happens sth went very wrong. panic(fmt.Sprintf("blake2b is unable to process hashes: %v", err)) // ok } return hasher.Sum(nil) }
对公钥进行一次哈希运算:
1
hash(pub, &blake2b.Config{Size: 20})
原文注释里是这样说的:
PayloadHashLength defines the hash length taken over addresses using the Actor and SECP256K1 protocols.
// Sign signs the given message, which must be 32 bytes long. funcSign(sk, msg []byte) ([]byte, error) { // secp256k1 就是最终的椭圆曲线签名,这个签名可以替换成secp256k1不同语言版本的实现 return secp256k1.Sign(msg, sk) }