Skip to content

Commit

Permalink
[R1CS] Fix parsing of R1CS files using readChars (#401)
Browse files Browse the repository at this point in the history
* remove duplicate comment

* use `readInto` and not stdlib `readChars`
  • Loading branch information
Vindaar authored Jun 26, 2024
1 parent 474fa04 commit 577af2c
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ proc parseConstraints(f: File, constraints: var seq[Constraint], sectionSize: ui
?f.parseConstraint(constraint, fieldSize)

proc parseMagicHeader(f: File, mh: var array[4, char]): bool =
let num = f.readChars(mh, 0, 4) # from start of file!
result = num == 4
result = f.readInto(mh)

proc parseSectionKind(f: File, v: var R1csSectionKind): bool =
var val: uint32
Expand Down Expand Up @@ -245,7 +244,7 @@ proc parseR1csFile*(path: string): R1csBin =
doAssert f.setFilePosition(np) == 0, "Failed to set file position to " & $np

# Sort the positions by the section type
pos = pos.sortedByIt(it[0]) # sort by the section kind
pos = pos.sortedByIt(it[0])
doAssert pos[0][0] == kHeader, "No header present in the file"

# 2. iterate the different kinds / positions & parse them
Expand Down

0 comments on commit 577af2c

Please sign in to comment.