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

jam and cue in core are wrong #3245

Open
mariari opened this issue Dec 10, 2024 · 2 comments
Open

jam and cue in core are wrong #3245

mariari opened this issue Dec 10, 2024 · 2 comments

Comments

@mariari
Copy link
Member

mariari commented Dec 10, 2024

I was looking over some anoma encoded data via the repl and saw very strange data

Swap> 1 |> anomaEncode
18014398509482168
Swap> 0 |> anomaEncode
184
Swap> 2 |> anomaEncode
36028797018964152
Swap> 3 |> anomaEncode
54043195528446136
Swap> 4 |> anomaEncode
72057594037928120

consumedMagic : Nat := anomaEncode "hello";

Swap> consumedMagic
148107274127321517247825720839002784496

These with the naieve cue implementation all give 5.

iex(anoma@YU-NO)14> 72057594037928120 |> Noun.atom_integer_to_binary |> Nock.Cue.cue
{:ok, 5}
iex(anoma@YU-NO)15> 148107274127321517247825720839002784496 |> Nock.Cue.cue
{:ok, 5}

however on a real implementation this doesn't use all the bytes, and thus is invalid with a proper implementation

iex(anoma@YU-NO)20> 184 |> Noun.atom_integer_to_binary |> Noun.Jam.cue
{:ok, <<5>>}
iex(anoma@YU-NO)21> 18014398509482168 |> Noun.atom_integer_to_binary |> Noun.Jam.cue
:error
iex(anoma@YU-NO)22> 18014398509482168  |> Noun.Jam.cue
:error

The jam and cue seem to work via the Juvix repl

foo : Nat :=  1 |> anomaEncode |> anomaDecode;
Swap> foo
1

so I assume the jam and cue implementation on Juvix core terms is wrong?

@mariari
Copy link
Member Author

mariari commented Dec 10, 2024

Further the encoding is insanely large for what it is. (encoding a resource takes 22 KB!)

@lukaszcz
Copy link
Collaborator

lukaszcz commented Dec 10, 2024

I don't think the encoding in the Core evaluator is meant to correspond to the "real" jam and cue. It's just automatically derived default serialization/deserialization with cereal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants