Rename back

This commit is contained in:
Uma Roy
2023-10-11 11:37:45 -07:00
parent d8b919a403
commit 3b8611c6ac
16 changed files with 80 additions and 80 deletions

View File

@@ -39,7 +39,7 @@ func (c *BN254Chip) Poseidon(state BN254State) BN254State {
return state
}
func (c *BN254Chip) HashNoPad(input []gl.GoldilocksVariable) BN254HashOut {
func (c *BN254Chip) HashNoPad(input []gl.Variable) BN254HashOut {
state := BN254State{
frontend.Variable(0),
frontend.Variable(0),
@@ -69,7 +69,7 @@ func (c *BN254Chip) HashNoPad(input []gl.GoldilocksVariable) BN254HashOut {
return BN254HashOut(state[0])
}
func (c *BN254Chip) HashOrNoop(input []gl.GoldilocksVariable) BN254HashOut {
func (c *BN254Chip) HashOrNoop(input []gl.Variable) BN254HashOut {
if len(input) <= 3 {
returnVal := frontend.Variable(0)
@@ -94,10 +94,10 @@ func (c *BN254Chip) TwoToOne(left BN254HashOut, right BN254HashOut) BN254HashOut
return state[0]
}
func (c *BN254Chip) ToVec(hash BN254HashOut) []gl.GoldilocksVariable {
func (c *BN254Chip) ToVec(hash BN254HashOut) []gl.Variable {
bits := c.api.ToBinary(hash)
returnElements := []gl.GoldilocksVariable{}
returnElements := []gl.Variable{}
// Split into 7 byte chunks, since 8 byte chunks can result in collisions
chunkSize := 56

View File

@@ -11,9 +11,9 @@ const MAX_WIDTH = 12
const SPONGE_WIDTH = 12
const SPONGE_RATE = 8
type GoldilocksState = [SPONGE_WIDTH]gl.GoldilocksVariable
type GoldilocksState = [SPONGE_WIDTH]gl.Variable
type GoldilocksStateExtension = [SPONGE_WIDTH]gl.QuadraticExtensionVariable
type GoldilocksHashOut = [4]gl.GoldilocksVariable
type GoldilocksHashOut = [4]gl.Variable
type GoldilocksChip struct {
api frontend.API `gnark:"-"`
@@ -38,7 +38,7 @@ func (c *GoldilocksChip) Poseidon(input GoldilocksState) GoldilocksState {
// The input elements MUST have all it's elements be within Goldilocks field.
// The returned slice's elements will all be within Goldilocks field.
func (c *GoldilocksChip) HashNToMNoPad(input []gl.GoldilocksVariable, nbOutputs int) []gl.GoldilocksVariable {
func (c *GoldilocksChip) HashNToMNoPad(input []gl.Variable, nbOutputs int) []gl.Variable {
var state GoldilocksState
for i := 0; i < SPONGE_WIDTH; i++ {
@@ -54,7 +54,7 @@ func (c *GoldilocksChip) HashNToMNoPad(input []gl.GoldilocksVariable, nbOutputs
state = c.Poseidon(state)
}
var outputs []gl.GoldilocksVariable
var outputs []gl.Variable
for {
for i := 0; i < SPONGE_RATE; i++ {
@@ -69,9 +69,9 @@ func (c *GoldilocksChip) HashNToMNoPad(input []gl.GoldilocksVariable, nbOutputs
// The input elements can be outside of the Goldilocks field.
// The returned slice's elements will all be within Goldilocks field.
func (c *GoldilocksChip) HashNoPad(input []gl.GoldilocksVariable) GoldilocksHashOut {
func (c *GoldilocksChip) HashNoPad(input []gl.Variable) GoldilocksHashOut {
var hash GoldilocksHashOut
inputVars := []gl.GoldilocksVariable{}
inputVars := []gl.Variable{}
for i := 0; i < len(input); i++ {
inputVars = append(inputVars, c.gl.Reduce(input[i]))
@@ -85,7 +85,7 @@ func (c *GoldilocksChip) HashNoPad(input []gl.GoldilocksVariable) GoldilocksHash
return hash
}
func (c *GoldilocksChip) ToVec(hash GoldilocksHashOut) []gl.GoldilocksVariable {
func (c *GoldilocksChip) ToVec(hash GoldilocksHashOut) []gl.Variable {
return hash[:]
}
@@ -135,7 +135,7 @@ func (c *GoldilocksChip) ConstantLayerExtension(state GoldilocksStateExtension,
return state
}
func (c *GoldilocksChip) sBoxMonomial(x gl.GoldilocksVariable) gl.GoldilocksVariable {
func (c *GoldilocksChip) sBoxMonomial(x gl.Variable) gl.Variable {
x2 := c.gl.MulNoReduce(x, x)
x3 := c.gl.MulNoReduce(x, x2)
x3 = c.gl.ReduceWithMaxBits(x3, 192)
@@ -169,7 +169,7 @@ func (c *GoldilocksChip) SBoxLayerExtension(state GoldilocksStateExtension) Gold
return state
}
func (c *GoldilocksChip) mdsRowShf(r int, v [SPONGE_WIDTH]gl.GoldilocksVariable) gl.GoldilocksVariable {
func (c *GoldilocksChip) mdsRowShf(r int, v [SPONGE_WIDTH]gl.Variable) gl.Variable {
res := gl.Zero()
for i := 0; i < 12; i++ {

View File

@@ -21,7 +21,7 @@ func (circuit *TestPublicInputsHashCircuit) Define(api frontend.API) error {
glAPI := gl.NewGoldilocksApi(api)
// BN254 -> Binary(64) -> F
var input [3]gl.GoldilocksVariable
var input [3]gl.Variable
for i := 0; i < 3; i++ {
input[i] = gl.NewVariable(api.FromBinary(api.ToBinary(circuit.In[i], 64)...))
}