func New(c *Config) (hash.Hash, error) {
	if c == nil {
		c = defaultConfig
	} else {
		if c.Size == 0 {
			c.Size = Size
		}
		if err := verifyConfig(c); err != nil {
			return nil, err
		}
	}
	d := new(digest)
	d.initialize(c)
	return d, nil
}
New returns a new hash.Hash configured with the given Config.
Config can be nil, in which case the default one is used, calculating 64-byte digest.
Returns non-nil error if Config contains invalid parameters.
package blake2b
import (
	"encoding/binary"
	"errors"
	"hash"
)
const (
	BlockSize  = 128  
	Size       = 64   
	SaltSize   = 16   
	PersonSize = 16   
	KeySize    = 64   
)
type digest struct {
	h  [8]uint64        
	t  [2]uint64        
	f  [2]uint64        
	x  [BlockSize]byte  
	nx int              
	ih         [8]uint64        
	paddedKey  [BlockSize]byte  
	isKeyed    bool             
	size       uint8            
	isLastNode bool             
}
var iv = [8]uint64{
	0x6a09e667f3bcc908, 0xbb67ae8584caa73b,
	0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1,
	0x510e527fade682d1, 0x9b05688c2b3e6c1f,
	0x1f83d9abfb41bd6b, 0x5be0cd19137e2179,
}
type Config struct {
	Size   uint8   
	Key    []byte  
	Salt   []byte  
	Person []byte  
	Tree   *Tree   
}
type Tree struct {
	Fanout        uint8   
	MaxDepth      uint8   
	LeafSize      uint32  
	NodeOffset    uint64  
	NodeDepth     uint8   
	InnerHashSize uint8   
	IsLastNode    bool    
}
var (
	defaultConfig = &Config{Size: Size}
	config256     = &Config{Size: 32}
)
func verifyConfig(c *Config) error {
	if c.Size > Size {
		return errors.New("digest size is too large")
	}
	if len(c.Key) > KeySize {
		return errors.New("key is too large")
	}
	if len(c.Salt) > SaltSize {
		return errors.New("salt is too large")
	}
	if len(c.Person) > PersonSize {
		return errors.New("personalization is too large")
	}
	if c.Tree != nil {
		if c.Tree.Fanout == 1 {
			return errors.New("fanout of 1 is not allowed in tree mode")
		}
		if c.Tree.MaxDepth < 2 {
			return errors.New("incorrect tree depth")
		}
		if c.Tree.InnerHashSize < 1 || c.Tree.InnerHashSize > Size {
			return errors.New("incorrect tree inner hash size")
		}
	}
	return nil
}