Skip to content

Commit

Permalink
add trusted setup constant (#36)
Browse files Browse the repository at this point in the history
This helps load the trusted setup whose location is relative to the kzg
module, which can be fluid
  • Loading branch information
arnetheduck authored Jan 8, 2025
1 parent abef457 commit 638835b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion kzg4844/kzg.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ import
./kzg_abi # compile sha256.c

export
kzg
kzg, kzg_abi.trustedSetup
20 changes: 10 additions & 10 deletions kzg4844/kzg_abi.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@

# Ensure "c_kzg_4844.h" in this directory takes precedence
import std/[os, strutils]
{.passc: "-I" & quoteShell(currentSourcePath.rsplit({DirSep, AltSep}, 1)[0]).}

import
./csources/bindings/nim/kzg_abi
const
currentDir = currentSourcePath.rsplit({DirSep, AltSep}, 1)[0]
trustedSetup* =
staticRead(currentDir & "/csources/src/trusted_setup.txt")

export
kzg_abi
{.passc: "-I" & quoteShell(currentDir).}

import ./csources/bindings/nim/kzg_abi

export kzg_abi

when defined(kzgExternalBlstNoSha256):
import std/strutils
from os import DirSep
const
kzgPath = currentSourcePath.rsplit(DirSep, 1)[0] & "/"
{.compile: kzgPath & "sha256.c"}
{.compile: currentDir & "/sha256.c".}
5 changes: 5 additions & 0 deletions tests/test_all.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
{.warning[UnusedImport]:off.}

import
unittest2,
../kzg4844/kzg,
../kzg4844/kzg_abi

# do nothing else, all tests are done in c-kzg-4844.
# we only need to make sure our imports are compileable

test "Check that trusted setup can be loaded":
check:
loadTrustedSetupFromString(trustedSetup, 0) == Result[void, string].ok()

0 comments on commit 638835b

Please sign in to comment.