Skip to content

Commit

Permalink
Feat: added constructor for Identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
hmoog committed Apr 2, 2022
1 parent 5b334ed commit 4ddbaf9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/refactored/types/identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ import (
"github.com/iotaledger/hive.go/cerrors"
"github.com/iotaledger/hive.go/marshalutil"
"github.com/mr-tron/base58"
"golang.org/x/crypto/blake2b"
)

// region Identifier ///////////////////////////////////////////////////////////////////////////////////////////////////

// Identifier is the type that represents the identifier of a Transaction.
type Identifier [IdentifierLength]byte

// NewIdentifier returns a new Identifier for the given data.
func NewIdentifier(data []byte) (new Identifier) {
return blake2b.Sum256(data)
}

// FromRandomness fills the Identifier with random information.
func (t *Identifier) FromRandomness() (err error) {
_, err = rand.Read((*t)[:])
Expand Down

0 comments on commit 4ddbaf9

Please sign in to comment.