mirror of
https://github.com/arnaucube/gnark-plonky2-verifier.git
synced 2026-01-12 00:51:33 +01:00
fix: Support range checking non aligned bitwidth values (#47)
* initial commit * most of the code done * made global poseidon chip * changed decompSize and added some panics * made all gl chip as pointers * working code * revert go.mod and go.sum * cleanup and comments * cleaned up range checker selection * renamed gnarkRangeCheckSelector to gnarkRangeCheckerSelector * addressed PR comment * addressed overflow issue identified by Veridise * added some comments * fixed some comment typos * restore change made from commit hash85d20ceand9617141
This commit is contained in:
@@ -22,7 +22,7 @@ const BN254_SPONGE_RATE int = 3
|
||||
|
||||
type BN254Chip struct {
|
||||
api frontend.API `gnark:"-"`
|
||||
gl gl.Chip `gnark:"-"`
|
||||
gl *gl.Chip `gnark:"-"`
|
||||
}
|
||||
|
||||
type BN254State = [BN254_SPONGE_WIDTH]frontend.Variable
|
||||
@@ -33,7 +33,7 @@ func NewBN254Chip(api frontend.API) *BN254Chip {
|
||||
panic("Gnark compiler not set to BN254 scalar field")
|
||||
}
|
||||
|
||||
return &BN254Chip{api: api, gl: *gl.New(api)}
|
||||
return &BN254Chip{api: api, gl: gl.New(api)}
|
||||
}
|
||||
|
||||
func (c *BN254Chip) Poseidon(state BN254State) BN254State {
|
||||
|
||||
@@ -17,11 +17,11 @@ type GoldilocksHashOut = [POSEIDON_GL_HASH_SIZE]gl.Variable
|
||||
|
||||
type GoldilocksChip struct {
|
||||
api frontend.API `gnark:"-"`
|
||||
gl gl.Chip `gnark:"-"`
|
||||
gl *gl.Chip `gnark:"-"`
|
||||
}
|
||||
|
||||
func NewGoldilocksChip(api frontend.API) *GoldilocksChip {
|
||||
return &GoldilocksChip{api: api, gl: *gl.New(api)}
|
||||
return &GoldilocksChip{api: api, gl: gl.New(api)}
|
||||
}
|
||||
|
||||
// The permutation function.
|
||||
|
||||
@@ -26,7 +26,7 @@ func (circuit *TestPublicInputsHashCircuit) Define(api frontend.API) error {
|
||||
input[i] = gl.NewVariable(api.FromBinary(api.ToBinary(circuit.In[i], 64)...))
|
||||
}
|
||||
|
||||
poseidonChip := &GoldilocksChip{api: api, gl: *glAPI}
|
||||
poseidonChip := &GoldilocksChip{api: api, gl: glAPI}
|
||||
output := poseidonChip.HashNoPad(input[:])
|
||||
|
||||
// Check that output is correct
|
||||
|
||||
Reference in New Issue
Block a user