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

bumps constantine, updates curves #21

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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*
!*/
!*.*
.nimble
poseidon2.out
16 changes: 16 additions & 0 deletions nimble.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": 2,
"packages": {
"constantine": {
"version": "0.1.0",
"vcsRevision": "bc3845aa492b52f7fef047503b1592e830d1a774",
"url": "https://github.com/mratsim/constantine",
"downloadMethod": "git",
"dependencies": [],
"checksums": {
"sha1": "09594d4ce93e83ae377a7a9cb8fd4472b104ca4b"
}
}
},
"tasks": {}
}
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#bc3845aa492b52f7fef047503b1592e830d1a774"
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
Loading