{.used.} import std/[streams, strutils], unittest2, stew/byteutils, ../kzg_abi, ./types proc readSetup(): KzgSettings = var s = newFileStream(trustedSetupFile) g1Bytes: array[FIELD_ELEMENTS_PER_BLOB * 48, byte] g2Bytes: array[65 * 96, byte] doAssert(s.isNil.not, "FAILED TO OPEN: " & trustedSetupFile) let fieldElems = s.readLine().parseInt() doAssert fieldElems == FIELD_ELEMENTS_PER_BLOB let numG2 = s.readLine().parseInt() doAssert numG2 == 65 for i in 0 ..< FIELD_ELEMENTS_PER_BLOB: let z = hexToByteArray[48](s.readLine()) g1Bytes[i*48 ..< i*48+48] = z[0..<48] for i in 0 ..< 65: let z = hexToByteArray[96](s.readLine()) g2Bytes[i*96 ..< i*96+96] = z[0..<96] let res = load_trusted_setup(result, g1Bytes[0].addr, FIELD_ELEMENTS_PER_BLOB, g2Bytes[0].addr, 65) doAssert(res == KZG_OK, "ERROR: " & $res) proc readSetup(filename: string): KzgSettings = var file = open(filename) let ret = load_trusted_setup_file(result, file) doAssert ret == KZG_OK file.close() proc createKateBlobs(s: KzgSettings, n: int): KateBlobs = for i in 0.. MAX_TOP_BYTE and i %% BYTES_PER_FIELD_ELEMENT == 31: blob[i] = MAX_TOP_BYTE result.blobs.add(blob) for i in 0..