Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADR-28 derive address functions #9088

Merged
merged 9 commits into from
Apr 15, 2021
Prev Previous commit
Next Next commit
add noop error check
  • Loading branch information
robert-zaremba committed Apr 14, 2021
commit 7ee294b329febf3138fa4aa09b7cecacb247dbea
7 changes: 4 additions & 3 deletions types/address/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ type Addressable interface {
// Hash creates a new address from address type and key
func Hash(typ string, key []byte) []byte {
hasher := sha256.New()
hasher.Write(conv.UnsafeStrToBytes(typ))
_, err := hasher.Write(conv.UnsafeStrToBytes(typ))
// the error always nil, it's here only to satisfy the io.Writer interface
errors.AssertNil(err)
th := hasher.Sum(nil)

hasher.Reset()
_, err := hasher.Write(th)
// the error always nil, it's here only to satisfy the io.Writer interface
_, err = hasher.Write(th)
errors.AssertNil(err)
_, err = hasher.Write(key)
errors.AssertNil(err)
Expand Down