forked from Consensys/gnark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commitment.go
33 lines (29 loc) · 1011 Bytes
/
commitment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package cs
import (
"crypto/rand"
"fmt"
"math/big"
"os"
"strings"
"github.com/airchains-network/gnark/constraint/solver"
"github.com/airchains-network/gnark/debug"
"github.com/airchains-network/gnark/logger"
)
func Bsb22CommitmentComputePlaceholder(mod *big.Int, _ []*big.Int, output []*big.Int) (err error) {
if (len(os.Args) > 0 && (strings.HasSuffix(os.Args[0], ".test") || strings.HasSuffix(os.Args[0], ".test.exe"))) || debug.Debug {
// usually we only run solver without prover during testing
log := logger.Logger()
log.Error().Msg("Augmented commitment hint not replaced. Proof will not be sound and verification will fail!")
output[0], err = rand.Int(rand.Reader, mod)
if output[0].Sign() == 0 {
// a commit == 0 is unlikely; happens quite often in tests
// with tinyfield
output[0].SetUint64(1)
}
return
}
return fmt.Errorf("placeholder function: to be replaced by commitment computation")
}
func init() {
solver.RegisterHint(Bsb22CommitmentComputePlaceholder)
}