https://github.com/yacovm/ZKAT-VDP
Tip revision: 721f52b1b74f8e0aa60799bd1436865f8020258e authored by yacovm on 14 August 2023, 13:43:45 UTC
Create README.md
Create README.md
Tip revision: 721f52b
ldp.go
package ldp
import (
fr "github.com/consensys/gnark-crypto/ecc/bn254/fr"
"math/big"
)
func GetCoinsFromRho(rho fr.Element) (c0, c1 int) {
rhoB := rho.Text(2)
l := len(rhoB)
c0 = int(rhoB[l-1] - '0')
c1 = int(rhoB[l-2] - '0')
return
}
func RandomResponse(rho fr.Element, msg *big.Int) (res big.Int, c0, c1 int) {
c0, c1 = GetCoinsFromRho(rho)
if c0 == 0 {
res = *msg
} else {
if c1 == 0 {
res.SetInt64(int64(1))
} else {
res.SetInt64(int64(0))
}
}
return
}
