Skip to content

Commit 020005b

Browse files
Feat: add column linear combination check (#731)
1 parent cf9761b commit 020005b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

field/koalabear/vortex/verifier.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ func (p *Params) Verify(input VerifierInput) error {
5656
return fmt.Errorf("invalid proof: uAlpha is not a reed-solomon codeword")
5757
}
5858

59+
// This checks linear combination of the opened columns matches the requested position of the UAlpha
60+
if p.checkColLinCombination(input) != nil {
61+
return fmt.Errorf("invalid proof: uAlpha is not a correct linear combination")
62+
}
63+
5964
// This checks the consistency between the proof and the selected columns
6065
// to the input matrix.
6166
for i, c := range input.SelectedColumns {
@@ -75,3 +80,24 @@ func (p *Params) Verify(input VerifierInput) error {
7580
return nil
7681

7782
}
83+
84+
// Check linear combination of the opened columns matches the requested position of the UAlpha
85+
func (p *Params) checkColLinCombination(input VerifierInput) error {
86+
uAlpha := input.Proof.UAlpha
87+
88+
for i, selectedColID := range input.SelectedColumns {
89+
if selectedColID < 0 || selectedColID >= len(uAlpha) {
90+
return fmt.Errorf("column index %d is out of bounds for the linear combination array of size %d", selectedColID, len(uAlpha))
91+
}
92+
93+
// Compute the linear combination of the opened column
94+
y := EvalBasePolyHorner(input.Proof.OpenedColumns[i], input.Alpha)
95+
96+
// Check the consistency
97+
if y != uAlpha[selectedColID] {
98+
return fmt.Errorf("inconsistent linear combination at index %d (selected column ID %d): expected uAlpha[selectedColID] %s, got %s", i, selectedColID, uAlpha[selectedColID].String(), y.String())
99+
}
100+
}
101+
102+
return nil
103+
}

0 commit comments

Comments
 (0)