本文整理匯總了Golang中github.com/dedis/crypto/abstract.Suite.HashLen方法的典型用法代碼示例。如果您正苦於以下問題:Golang Suite.HashLen方法的具體用法?Golang Suite.HashLen怎麽用?Golang Suite.HashLen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/dedis/crypto/abstract.Suite
的用法示例。
在下文中一共展示了Suite.HashLen方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: MerkleGet
// Retrieve an object in a Merkle tree,
// validating the entire path in the process.
// Returns a slice of a buffer obtained from HashGet.Get(),
// which might be shared and should be considered read-only.
func MerkleGet(suite abstract.Suite, root []byte, path MerklePath,
ctx HashGet) ([]byte, error) {
// Follow pointers through intermediate levels
blob := root
for i := range path.Ptr {
beg := path.Ptr[i]
end := beg + suite.HashLen()
if end > len(blob) {
return nil, errors.New("bad Merkle tree pointer offset")
}
id := HashId(blob[beg:end])
b, e := ctx.Get(id) // Lookup the next-level blob
if e != nil {
return nil, e
}
blob = b
}
// Validate and extract the actual object
beg := path.Ofs
end := beg + path.Len
if end > len(blob) {
return nil, errors.New("bad Merkle tree object offset/length")
}
return blob[beg:end], nil
}