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

Update Constantine to version 0.1.0 #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
nim: [1.6.14]
nim: [stable, 1.6.20]
steps:
- uses: actions/checkout@v2
- uses: iffy/install-nim@v3
- uses: iffy/install-nim@v5
with:
version: ${{ matrix.nim }}
- name: Build
Expand Down
6 changes: 3 additions & 3 deletions poseidon2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export toF
export elements
export types

# workaround for "undeclared identifier: 'getCurveOrder'"
import constantine/math/config/curves
export curves
# workaround for "undeclared identifier: 'getModulus'"
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 == 0.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would prefer to pin it to a concrete commit, it's not stable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is stable now, constantine version 0.1.0 was tagged last week: https://github.com/mratsim/constantine/releases/tag/v0.1.0

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
2 changes: 1 addition & 1 deletion poseidon2/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import
constantine/math/arithmetic,
constantine/math/io/io_fields,
constantine/math/io/io_bigints,
constantine/math/config/curves
constantine/named/algebras

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

Expand Down
1 change: 0 additions & 1 deletion tests/poseidon2/testSponge.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import std/unittest
import std/sequtils

import constantine/math/io/io_fields
import constantine/math/arithmetic

import poseidon2/types
import poseidon2/io
Expand Down
Loading