diff --git a/core/felt/felt.go b/core/felt/felt.go index 84fa3c2f3f..284e7a064b 100644 --- a/core/felt/felt.go +++ b/core/felt/felt.go @@ -144,6 +144,11 @@ func (z *Felt) Marshal() []byte { return z.val.Marshal() } +// Unmarshal forwards the call to underlying field element implementation +func (z *Felt) Unmarshal(e []byte) { + z.val.Unmarshal(e) +} + // Bytes forwards the call to underlying field element implementation func (z *Felt) Bytes() [32]byte { return z.val.Bytes() diff --git a/core/felt/felt_test.go b/core/felt/felt_test.go index 6a7c40afc9..e497dc6a1e 100644 --- a/core/felt/felt_test.go +++ b/core/felt/felt_test.go @@ -65,3 +65,14 @@ func TestShortString(t *testing.T) { assert.Equal(t, "0x1234...6789", f.ShortString()) }) } + +func TestFeltMarshalAndUnmarshal(t *testing.T) { + f := new(felt.Felt).SetBytes([]byte("somebytes")) + + fBytes := f.Marshal() + + f2 := new(felt.Felt) + f2.Unmarshal(fBytes) + + assert.True(t, f2.Equal(f)) +}