Skip to content

Commit

Permalink
Record updates new syntax (#134)
Browse files Browse the repository at this point in the history
* Adapts to anoma/juvix#3138
  • Loading branch information
lukaszcz authored Nov 6, 2024
1 parent deaafbb commit 0080b11
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Stdlib/Cairo/Ec.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ add (point1 point2 : Point) : Point :=
in mkPoint r_x r_y;

--- Subtracts point2 from point1 on the EC.
sub (point1 point2 : Point) : Point := add point1 point2@Point{y := 0 - y};
sub (point1 point2 : Point) : Point :=
add point1 point2@Point{y := 0 - Point.y point2};

--- Computes point1 + alpha * point2 on the elliptic curve.
--- Because the EC operation builtin cannot handle inputs where additions of points with the same x
Expand Down
17 changes: 14 additions & 3 deletions Stdlib/Cairo/Poseidon.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,19 @@ poseidonHash2 (x y : Field) : Field :=
poseidonHashList (list : List Field) : Field :=
let
go (acc : PoseidonState) : List Field -> PoseidonState
| [] := poseidonHash acc@PoseidonState{s0 := s0 + 1}
| [x] := poseidonHash acc@PoseidonState{s0 := s0 + x; s1 := s1 + 1}
| [] := poseidonHash acc@PoseidonState{s0 := PoseidonState.s0 acc + 1}
| [x] :=
poseidonHash
acc@PoseidonState{
s0 := PoseidonState.s0 acc + x;
s1 := PoseidonState.s1 acc + 1;
}
| (x1 :: x2 :: xs) :=
go (poseidonHash acc@PoseidonState{s0 := s0 + x1; s1 := s1 + x2}) xs;
go
(poseidonHash
acc@PoseidonState{
s0 := PoseidonState.s0 acc + x1;
s1 := PoseidonState.s1 acc + x2;
})
xs;
in PoseidonState.s0 (go (mkPoseidonState 0 0 0) list);
2 changes: 1 addition & 1 deletion test/Package.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package : Package :=
github
"anoma"
"juvix-quickcheck"
"4242b864714f98947753544ea1b2cb435f6473d3";
"b28c74aeb181712e6a20a4371b09f3e9bea49702";
github "anoma" "juvix-test" "85811914324b082549cb1f500323884442fc793c";
];
};

0 comments on commit 0080b11

Please sign in to comment.