diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index fe81380..dc11bf2 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -9,15 +9,11 @@ on: jobs: lint: runs-on: ubuntu-20.04 - container: golangci/golangci-lint:v1.43.0 steps: - uses: actions/checkout@v2 - - uses: actions/cache@v2 + - uses: actions/setup-go@v2 with: - path: | - ~/.cache/go-build - /go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - run: golangci-lint run + go-version: 1.18.0 + - uses: golangci/golangci-lint-action@v2 + with: + version: v1.45.0 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0a75424..ccf7e73 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,7 +11,8 @@ jobs: strategy: matrix: containers: - - 1.17.2-bullseye + - 1.17.8-bullseye + - 1.18.0-bullseye runs-on: ubuntu-20.04 container: golang:${{matrix.containers}} steps: diff --git a/claim.go b/claim.go index 11075d9..58897f8 100644 --- a/claim.go +++ b/claim.go @@ -9,7 +9,6 @@ import ( "time" "github.com/iden3/go-iden3-crypto/utils" - "github.com/iden3/go-merkletree-sql" ) /* @@ -57,7 +56,7 @@ var ErrIncorrectIDPosition = errors.New("incorrect ID position") // ErrNoID returns when ID not found in the Claim. var ErrNoID = errors.New("ID is not set") -// ErrSlotOverflow means some DataSlot overflows Q Field. And wraps the name +// ErrSlotOverflow means some ElemBytes overflows Q Field. And wraps the name // of overflowed slot. type ErrSlotOverflow struct { Field SlotName @@ -91,50 +90,9 @@ func (sc SchemaHash) MarshalText() ([]byte, error) { return dst, nil } -// DataSlot length is 32 bytes. But not all 32-byte values are valid. -// The value should be not greater than Q constant -// 21888242871839275222246405745257275088548364400416034343698204186575808495617 -type DataSlot [32]byte - -// ToInt returns *big.Int representation of DataSlot. -func (ds DataSlot) ToInt() *big.Int { - return new(big.Int).SetBytes(utils.SwapEndianness(ds[:])) -} - -// SetInt sets data slot to serialized value of *big.Int. And checks that the -// value is valid (fills in Field Q). -// Returns ErrDataOverflow if the value is too large -func (ds *DataSlot) SetInt(value *big.Int) error { - if !utils.CheckBigIntInField(value) { - return ErrDataOverflow - } - - val := utils.SwapEndianness(value.Bytes()) - copy((*ds)[:], val) - memset((*ds)[len(val):], 0) - return nil -} - -// NewDataSlotFromInt creates new DataSlot from *big.Int. -// Returns error ErrDataOverflow if value is too large to fill the Field Q. -func NewDataSlotFromInt(i *big.Int) (DataSlot, error) { - var s DataSlot - bs := i.Bytes() - // may be this check is redundant because of CheckBigIntInField, but just - // in case. - if len(bs) > len(s) { - return s, ErrDataOverflow - } - if !utils.CheckBigIntInField(i) { - return s, ErrDataOverflow - } - copy(s[:], utils.SwapEndianness(bs)) - return s, nil -} - type Claim struct { - index [4]DataSlot - value [4]DataSlot + index [4]ElemBytes + value [4]ElemBytes } // Subject for the time being describes the location of ID (in index or value @@ -236,7 +194,7 @@ func WithExpirationDate(dt time.Time) Option { // WithIndexData sets data to index slots A & B. // Returns ErrSlotOverflow if slotA or slotB value are too big. -func WithIndexData(slotA, slotB DataSlot) Option { +func WithIndexData(slotA, slotB ElemBytes) Option { return func(c *Claim) error { return c.SetIndexData(slotA, slotB) } @@ -260,7 +218,7 @@ func WithIndexDataInts(slotA, slotB *big.Int) Option { // WithValueData sets data to value slots A & B. // Returns ErrSlotOverflow if slotA or slotB value are too big. -func WithValueData(slotA, slotB DataSlot) Option { +func WithValueData(slotA, slotB ElemBytes) Option { return func(c *Claim) error { return c.SetValueData(slotA, slotB) } @@ -451,7 +409,7 @@ func (c *Claim) GetExpirationDate() (time.Time, bool) { // SetIndexData sets data to index slots A & B. // Returns ErrSlotOverflow if slotA or slotB value are too big. -func (c *Claim) SetIndexData(slotA, slotB DataSlot) error { +func (c *Claim) SetIndexData(slotA, slotB ElemBytes) error { slotsAsInts := []*big.Int{slotA.ToInt(), slotB.ToInt()} if !utils.CheckBigIntArrayInField(slotsAsInts) { return ErrDataOverflow @@ -484,7 +442,7 @@ func (c *Claim) SetIndexDataInts(slotA, slotB *big.Int) error { // SetValueData sets data to value slots A & B. // Returns ErrSlotOverflow if slotA or slotB value are too big. -func (c *Claim) SetValueData(slotA, slotB DataSlot) error { +func (c *Claim) SetValueData(slotA, slotB ElemBytes) error { slotsAsInts := []*big.Int{slotA.ToInt(), slotB.ToInt()} if !utils.CheckBigIntArrayInField(slotsAsInts) { return ErrDataOverflow @@ -515,7 +473,7 @@ func (c *Claim) SetValueDataInts(slotA, slotB *big.Int) error { return setSlotInt(&c.value[3], slotB, SlotNameValueB) } -func setSlotBytes(slot *DataSlot, value []byte, slotName SlotName) error { +func setSlotBytes(slot *ElemBytes, value []byte, slotName SlotName) error { if len(value) > len(*slot) { return ErrSlotOverflow{slotName} } @@ -527,8 +485,7 @@ func setSlotBytes(slot *DataSlot, value []byte, slotName SlotName) error { return nil } -func setSlotInt(slot *DataSlot, value *big.Int, slotName SlotName) error { - +func setSlotInt(slot *ElemBytes, value *big.Int, slotName SlotName) error { if value == nil { value = big.NewInt(0) } @@ -540,17 +497,9 @@ func setSlotInt(slot *DataSlot, value *big.Int, slotName SlotName) error { return err } -// TreeEntry creates new merkletree.Entry from the claim. Following changes to -// claim does not change returned merkletree.Entry. -func (c *Claim) TreeEntry() merkletree.Entry { - var e merkletree.Entry - for i := range c.index { - copy(e.Data[i][:], c.index[i][:]) - } - for i := range c.value { - copy(e.Data[i+len(c.index)][:], c.value[i][:]) - } - return e +// RawSlots returns raw bytes of claim's index and value +func (c *Claim) RawSlots() (index [4]ElemBytes, value [4]ElemBytes) { + return c.index, c.value } // Clone returns full deep copy of claim diff --git a/claim_test.go b/claim_test.go index 1fda1eb..7564c6c 100644 --- a/claim_test.go +++ b/claim_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" + "github.com/iden3/go-iden3-crypto/poseidon" "github.com/iden3/go-iden3-crypto/utils" - "github.com/stretchr/testify/require" ) @@ -37,34 +37,33 @@ func TestNewClaim(t *testing.T) { require.False(t, ok) } -func (ds DataSlot) String() string { +func (el ElemBytes) String() string { var b bytes.Buffer - for j := len(ds) - 1; j >= 0; j-- { - b.WriteString(fmt.Sprintf("% 08b", ds[j])) + for j := len(el) - 1; j >= 0; j-- { + b.WriteString(fmt.Sprintf("% 08b", el[j])) } return b.String() } -func TestMerketreeEntryHash(t *testing.T) { +func TestRawSlots(t *testing.T) { var schemaHash SchemaHash claim, err := NewClaim(schemaHash, WithFlagUpdatable(true)) require.NoError(t, err) - e := claim.TreeEntry() - - hi, hv, err := e.HiHv() + index, value := claim.RawSlots() + indexHash, err := poseidon.Hash([]*big.Int{ + index[0].ToInt(), index[1].ToInt(), index[2].ToInt(), index[3].ToInt()}) require.NoError(t, err) - - hit, err := hi.MarshalText() + valueHash, err := poseidon.Hash([]*big.Int{ + value[0].ToInt(), value[1].ToInt(), value[2].ToInt(), value[3].ToInt()}) require.NoError(t, err) + require.Equal(t, "19905260441950906049955646784794273651462264973332746773406911374272567544299", - string(hit)) + indexHash.Text(10)) - hvt, err := hv.MarshalText() - require.NoError(t, err) require.Equal(t, "2351654555892372227640888372176282444150254868378439619268573230312091195718", - string(hvt)) + valueHash.Text(10)) } func TestClaim_GetSchemaHash(t *testing.T) { @@ -74,7 +73,8 @@ func TestClaim_GetSchemaHash(t *testing.T) { require.Equal(t, schemaHashLn, n) claim, err := NewClaim(sc) require.NoError(t, err) - require.True(t, bytes.Equal(sc[:], utils.SwapEndianness(claim.index[0][:schemaHashLn]))) + require.True(t, + bytes.Equal(sc[:], utils.SwapEndianness(claim.index[0][:schemaHashLn]))) shFromClaim := claim.GetSchemaHash() shFromClaimHexBytes, err := shFromClaim.MarshalText() @@ -159,18 +159,22 @@ func toInt(t testing.TB, s string) *big.Int { } func TestIntSize(t *testing.T) { - iX := toInt(t, "16243864111864693853212588481963275789994876191154110553066821559749894481761") - iY := toInt(t, "7078462697308959301666117070269719819629678436794910510259518359026273676830") - vX := toInt(t, "12448278679517811784508557734102986855579744384337338465055621486538311281772") - vY := toInt(t, "9260608685281348956030279125705000716237952776955782848598673606545494194823") + iX := toInt(t, + "16243864111864693853212588481963275789994876191154110553066821559749894481761") + iY := toInt(t, + "7078462697308959301666117070269719819629678436794910510259518359026273676830") + vX := toInt(t, + "12448278679517811784508557734102986855579744384337338465055621486538311281772") + vY := toInt(t, + "9260608685281348956030279125705000716237952776955782848598673606545494194823") - ixSlot, err := NewDataSlotFromInt(iX) + ixSlot, err := NewElemBytesFromInt(iX) require.NoError(t, err) - iySlot, err := NewDataSlotFromInt(iY) + iySlot, err := NewElemBytesFromInt(iY) require.NoError(t, err) - vxSlot, err := NewDataSlotFromInt(vX) + vxSlot, err := NewElemBytesFromInt(vX) require.NoError(t, err) - vySlot, err := NewDataSlotFromInt(vY) + vySlot, err := NewElemBytesFromInt(vY) require.NoError(t, err) _, err = NewClaim(SchemaHash{}, WithIndexData(ixSlot, iySlot), @@ -179,10 +183,10 @@ func TestIntSize(t *testing.T) { } func TestNewDataSlotFromInt(t *testing.T) { - ds, err := NewDataSlotFromInt(toInt(t, + ds, err := NewElemBytesFromInt(toInt(t, "16243864111864693853212588481963275789994876191154110553066821559749894481761")) require.NoError(t, err) - expected := DataSlot{ + expected := ElemBytes{ 0x61, 0x27, 0xa0, 0xeb, 0x58, 0x7a, 0x6c, 0x2b, 0x4a, 0xa8, 0xc1, 0x2e, 0xf5, 0x01, 0xb2, 0xdb, 0xd0, 0x9c, 0xb1, 0xa5, 0x9c, 0x83, 0x42, 0x57, @@ -190,14 +194,14 @@ func TestNewDataSlotFromInt(t *testing.T) { } require.Equal(t, expected, ds) - _, err = NewDataSlotFromInt(toInt(t, + _, err = NewElemBytesFromInt(toInt(t, "9916243864111864693853212588481963275789994876191154110553066821559749894481761")) require.EqualError(t, err, ErrDataOverflow.Error()) } func TestClaim_WithIndexDataInts(t *testing.T) { - expSlot := DataSlot{} + expSlot := ElemBytes{} err := expSlot.SetInt(big.NewInt(0)) require.NoError(t, err) @@ -216,7 +220,7 @@ func TestClaim_WithIndexDataInts(t *testing.T) { func TestClaim_WithValueDataInts(t *testing.T) { - expSlot := DataSlot{} + expSlot := ElemBytes{} err := expSlot.SetInt(big.NewInt(0)) require.NoError(t, err) @@ -236,8 +240,9 @@ func TestClaim_WithValueDataInts(t *testing.T) { func TestClaim_WithIndexDataBytes(t *testing.T) { - iX := toInt(t, "124482786795178117845085577341029868555797443843373384650556214865383112817") - expSlot := DataSlot{} + iX := toInt(t, + "124482786795178117845085577341029868555797443843373384650556214865383112817") + expSlot := ElemBytes{} err := expSlot.SetInt(big.NewInt(0)) require.NoError(t, err) diff --git a/elem_bytes.go b/elem_bytes.go new file mode 100644 index 0000000..3079ac0 --- /dev/null +++ b/elem_bytes.go @@ -0,0 +1,63 @@ +package core + +import ( + "encoding/hex" + "math/big" + + "github.com/iden3/go-iden3-crypto/utils" +) + +// ElemBytes length is 32 bytes. But not all 32-byte values are valid. +// The value should be not greater than Q constant +// 21888242871839275222246405745257275088548364400416034343698204186575808495617 +type ElemBytes [32]byte + +// ToInt returns *big.Int representation of ElemBytes. +func (el ElemBytes) ToInt() *big.Int { + return new(big.Int).SetBytes(utils.SwapEndianness(el[:])) +} + +// SetInt sets element's data to serialized value of *big.Int in little-endian. +// And checks that the value is valid (fits in Field Q). +// Returns ErrDataOverflow if the value is too large +func (el *ElemBytes) SetInt(value *big.Int) error { + if !utils.CheckBigIntInField(value) { + return ErrDataOverflow + } + + val := utils.SwapEndianness(value.Bytes()) + copy((*el)[:], val) + memset((*el)[len(val):], 0) + return nil +} + +// Hex returns HEX representation of ElemBytes +func (el ElemBytes) Hex() string { + return hex.EncodeToString(el[:]) +} + +// NewElemBytesFromInt creates new ElemBytes from *big.Int. +// Returns error ErrDataOverflow if value is too large to fill the Field Q. +func NewElemBytesFromInt(i *big.Int) (ElemBytes, error) { + var s ElemBytes + bs := i.Bytes() + // may be this check is redundant because of CheckBigIntInField, but just + // in case. + if len(bs) > len(s) { + return s, ErrDataOverflow + } + if !utils.CheckBigIntInField(i) { + return s, ErrDataOverflow + } + copy(s[:], utils.SwapEndianness(bs)) + return s, nil +} + +// ElemBytesToInts converts slice of ElemBytes to slice of *big.Int +func ElemBytesToInts(elements []ElemBytes) []*big.Int { + result := make([]*big.Int, len(elements)) + for i := range elements { + result[i] = elements[i].ToInt() + } + return result +} diff --git a/example_test.go b/example_test.go index c992e15..39f1228 100644 --- a/example_test.go +++ b/example_test.go @@ -4,6 +4,8 @@ import ( "encoding/hex" "fmt" "time" + + "github.com/iden3/go-iden3-crypto/poseidon" ) func ExampleNewClaim() { @@ -21,13 +23,27 @@ func ExampleNewClaim() { fmt.Println(claim.GetVersion()) - entry := claim.TreeEntry() - indexHash, valueHash, err := entry.HiHv() + indexEntry, valueEntry := claim.RawSlots() + indexHash, err := poseidon.Hash(ElemBytesToInts(indexEntry[:])) + if err != nil { + panic(err) + } + valueHash, err := poseidon.Hash(ElemBytesToInts(valueEntry[:])) + if err != nil { + panic(err) + } + + indexSlot, err := NewElemBytesFromInt(indexHash) + if err != nil { + panic(err) + } + valueSlot, err := NewElemBytesFromInt(valueHash) if err != nil { panic(err) } - fmt.Println(hex.EncodeToString(indexHash[:])) - fmt.Println(hex.EncodeToString(valueHash[:])) + + fmt.Println(hex.EncodeToString(indexSlot[:])) + fmt.Println(hex.EncodeToString(valueSlot[:])) // Output: // true // 2021-01-10T20:30:00Z diff --git a/go.mod b/go.mod index 4c144fc..aae8cc9 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,7 @@ module github.com/iden3/go-iden3-core go 1.17 require ( - github.com/iden3/go-iden3-crypto v0.0.11 - github.com/iden3/go-merkletree-sql v1.0.0-pre8 + github.com/iden3/go-iden3-crypto v0.0.13 github.com/mr-tron/base58 v1.2.0 github.com/stretchr/testify v1.7.0 ) @@ -12,5 +11,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) diff --git a/go.sum b/go.sum index 0919e0a..7387980 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/blake512 v1.0.0/go.mod h1:FV1x7xPPLWukZlpDpWQ88rF/SFwZ5qbskrzhLMB92JI= -github.com/iden3/go-iden3-crypto v0.0.11 h1:5cFQ/BIqH9gjwe9Z68Hmc5jOTGqmMYnewIaTGCeO+6A= -github.com/iden3/go-iden3-crypto v0.0.11/go.mod h1:yUBWcXgAUDZxa1PvRl0zIT4Q4/rQO5PacE52Z06i8kw= -github.com/iden3/go-merkletree-sql v1.0.0-pre8 h1:ywL4VaBnpMGRLQUbSGgXXOjSHIo33KEEiBvrK2AnRa8= -github.com/iden3/go-merkletree-sql v1.0.0-pre8/go.mod h1:oYLAGBrr1/yNBZWhpE3JTxtbgDf6d56oRCbdjT1UX9A= +github.com/iden3/go-iden3-crypto v0.0.13 h1:ixWRiaqDULNyIDdOWz2QQJG5t4PpNHkQk2P6GV94cok= +github.com/iden3/go-iden3-crypto v0.0.13/go.mod h1:swXIv0HFbJKobbQBtsB50G7IHr6PbTowutSew/iBEoo= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -18,6 +18,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/id.go b/id.go index 91e2cfb..97a3da2 100644 --- a/id.go +++ b/id.go @@ -6,7 +6,6 @@ import ( "math/big" "github.com/iden3/go-iden3-crypto/poseidon" - "github.com/iden3/go-merkletree-sql" "github.com/mr-tron/base58" ) @@ -51,9 +50,9 @@ func (id *ID) Bytes() []byte { } func (id *ID) BigInt() *big.Int { - var idElem merkletree.ElemBytes - copy(idElem[:], id[:]) - return idElem.BigInt() + var s ElemBytes + copy(s[:], id[:]) + return s.ToInt() } func (id *ID) Equal(id2 *ID) bool { @@ -153,37 +152,37 @@ func CheckChecksum(id ID) bool { } // IdGenesisFromIdenState calculates the genesis Id from an Identity State. -func IdGenesisFromIdenState(hash *merkletree.Hash) *ID { //nolint:revive +func IdGenesisFromIdenState(state ElemBytes) *ID { //nolint:revive var idGenesisBytes [27]byte - rootBytes := hash.Bytes() - rootBytes = merkletree.SwapEndianness(rootBytes) // we take last 27 bytes, because of swapped endianness - copy(idGenesisBytes[:], rootBytes[len(rootBytes)-27:]) + copy(idGenesisBytes[:], state[len(state)-27:]) id := NewID(TypeDefault, idGenesisBytes) return &id } -// IdenState calculates the Identity State from the Claims Tree Root, Revocation Tree Root and Roots Tree Root. -func IdenState(clr *merkletree.Hash, - rer *merkletree.Hash, - ror *merkletree.Hash) *merkletree.Hash { - bi := merkletree.ElemBytesToBigInts([]merkletree.ElemBytes{ - merkletree.ElemBytes(*clr), - merkletree.ElemBytes(*rer), - merkletree.ElemBytes(*ror)}) - idenState, err := poseidon.Hash(bi) +// IdenState calculates the Identity State from the Claims Tree Root, +// Revocation Tree Root and Roots Tree Root. +func IdenState(clr ElemBytes, rer ElemBytes, + ror ElemBytes) (ElemBytes, error) { + + idenState, err := poseidon.Hash([]*big.Int{ + clr.ToInt(), rer.ToInt(), ror.ToInt()}) if err != nil { - panic(err) + return ElemBytes{}, err } - return merkletree.NewHashFromBigInt(idenState) + return NewElemBytesFromInt(idenState) } // CalculateGenesisID calculate genesis id based on provided claims tree root -func CalculateGenesisID(clr *merkletree.Hash) (*ID, error) { - idenState, err := merkletree.HashElems(clr.BigInt(), - merkletree.HashZero.BigInt(), merkletree.HashZero.BigInt()) +func CalculateGenesisID(clr ElemBytes) (*ID, error) { + idenState, err := poseidon.Hash([]*big.Int{ + clr.ToInt(), big.NewInt(0), big.NewInt(0)}) + if err != nil { + return nil, err + } + idenStateData, err := NewElemBytesFromInt(idenState) if err != nil { return nil, err } - return IdGenesisFromIdenState(idenState), nil + return IdGenesisFromIdenState(idenStateData), nil }