Skip to content

Commit

Permalink
bumps constantine, updates curves
Browse files Browse the repository at this point in the history
  • Loading branch information
benbierens committed Aug 8, 2024
1 parent 8a54c69 commit e173dd8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions poseidon2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export elements
export types

# workaround for "undeclared identifier: 'getCurveOrder'"
import constantine/math/config/curves
export curves
import constantine/named/algebras
export algebras
2 changes: 1 addition & 1 deletion poseidon2.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ author = "nim-poseidon2 authors"
description = "Poseidon2 hash function"
license = "MIT"

requires "https://github.com/mratsim/constantine#ab6fa6ae1bbbd1b10071a92ec209b381b5d82511"
requires "https://github.com/mratsim/constantine#1e34ec22929eaba7bcf1681350ec21aed8f370f7"
6 changes: 3 additions & 3 deletions poseidon2/io.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import std/options
import constantine/math/arithmetic
import constantine/math/io/io_bigints
import constantine/math/io/io_fields
import constantine/math/config/curves
import constantine/named/algebras
import ./types

export curves
export algebras

func fromOpenArray(_: type F, bytes: openArray[byte]): F =
F.fromBig(B.unmarshal(bytes, littleEndian))
Expand All @@ -19,7 +19,7 @@ func fromBytes*(_: type F, bytes: array[32, byte]): Option[F] =
## Converts bytes into a field element. The byte array is interpreted as a
## canonical little-endian big integer.
let big = B.unmarshal(bytes, littleEndian)
if bool(big < F.fieldMod()):
if bool(big < F.getModulus()):
return some(F.fromBig(big))

func toBytes*(element: F): array[32, byte] =
Expand Down
2 changes: 1 addition & 1 deletion poseidon2/roundfun.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import
constantine/math/arithmetic,
constantine/math/config/curves
constantine/named/algebras

import ./types
import ./roundconst
Expand Down
4 changes: 2 additions & 2 deletions poseidon2/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import
constantine/math/arithmetic,
constantine/math/io/io_fields,
constantine/math/io/io_bigints,
constantine/math/config/curves
constantine/named/algebras

#-------------------------------------------------------------------------------

type B* = BigInt[254]
type F* = Fr[BN254Snarks]
type F* = Fr[BN254_Snarks]
type S* = (F,F,F)

#-------------------------------------------------------------------------------
Expand Down

0 comments on commit e173dd8

Please sign in to comment.