Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ZKSigma in stead of built in crypto.go #2

Merged
merged 5 commits into from Mar 8, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

Fixed comments

  • Loading branch information...
gertjaap committed Mar 8, 2019
commit ce1193908e9d80f51648bb4766451c0905df5d05
@@ -185,6 +185,7 @@ func (a *Auditor) computeSum(bank_i int) (*big.Int, bool) {
a.mu.Unlock()
gv := ZKLedgerCurve.Neg(ZKLedgerCurve.Mult(ZKLedgerCurve.G, rep.Sum)) // 1 / g^\sum{v_i}
T := ZKLedgerCurve.Add(comms, gv)
// TODO: Error handling
verifies, _ := rep.Eproof.Verify(ZKLedgerCurve, T, rtokens, ZKLedgerCurve.H, a.pki.Get(bank_i))

This comment has been minimized.

Copy link
@narula

narula Mar 7, 2019

Member

add a TODO for checking the error

if !verifies {
Dprintf("[A] Bank %v proof didn't verify! Their total: %v\n", bank_i, rep.Sum)
@@ -219,6 +220,7 @@ func (a *Auditor) sumOneBank(wg *sync.WaitGroup, bank_i int, totals []*big.Int,
}
gv := ZKLedgerCurve.Neg(ZKLedgerCurve.Mult(ZKLedgerCurve.G, rep.Sum)) // 1 / g^\sum{v_i}
T := ZKLedgerCurve.Add(comms, gv)
// TODO: Error handling
verifies, _ := rep.Eproof.Verify(ZKLedgerCurve, T, rtokens, ZKLedgerCurve.H, a.pki.Get(bank_i))
if !verifies {
Dprintf("[A] Bank %v proof didn't verify! Their total: %v\n", bank_i, rep.Sum)
@@ -109,8 +109,8 @@ func MakeBank(id int, num int, l LedgerClient, pki *PKI) *Bank {
close(c)

for i := 0; i < num; i++ {
b.CommsCache[i] = zksigma.ECPoint{big.NewInt(0), big.NewInt(0)}
b.RTokenCache[i] = zksigma.ECPoint{big.NewInt(0), big.NewInt(0)}
b.CommsCache[i] = zksigma.Zero
b.RTokenCache[i] = zksigma.Zero
}
go b.start()
return b
@@ -392,7 +392,6 @@ func generateRangeProofs(num int, etx *EncryptedTransaction, bank_j int, id int,
etx.Entries[i].RP, etx.Entries[i].BAuxR, _ = zksigma.NewRangeProof(ZKLedgerCurve, value)
} else {
// TODO: Error handling

etx.Entries[i].RP, etx.Entries[i].BAuxR, _ = zksigma.NewRangeProof(ZKLedgerCurve, big.NewInt(0))
}
}
@@ -398,6 +398,7 @@ func benchmarkCreateLocalTxn(bnum int, b *testing.B) {

func BenchmarkUpdateCommCache(b *testing.B) {
value := new(big.Int).SetInt64(50)
// TODO: Error handling
comm, _, _ := zksigma.PedCommit(ZKLedgerCurve, value)
b.ResetTimer()
for n := 0; n < b.N; n++ {
@@ -141,6 +141,7 @@ func main() {
if *testName == "h" {
for i := 0; i < 20; i++ {
start = time.Now()
// TODO: Error handling
x, _ := auditor.Herfindahl(true, nil)
times[i] = time.Since(start)
total += times[i]
@@ -183,6 +184,7 @@ func main() {
total = 0
for i := 0; i < 20; i++ {
start = time.Now()
// TODO: Error handling
x, _ := auditor.Herfindahl(false, nil)
times[i] = time.Since(start)
total += times[i]
@@ -131,16 +131,15 @@ func (e *EncryptedTransaction) Verify(pks []zksigma.ECPoint, CommCache []zksigma
// Issuance
if e.Type == Issuance {
en := &e.Entries[e.Sender]
e.print_decrypted()
if en.V.Cmp(big.NewInt(0)) <= 0 {
Dprintf(" [%v] ETX %v Failed verify; issuance transaction values must be positive\n",
debug, e.Index)
return false
}
// Check proof of knowledge of sk_{asset issuer}
// TODO: Error handling
ok := false
if en.SKProof != nil {
// TODO: Error handling
ok, _ = en.SKProof.Verify(ZKLedgerCurve, pks[len(pks)-1])
}
if !ok {
@@ -158,6 +157,7 @@ func (e *EncryptedTransaction) Verify(pks []zksigma.ECPoint, CommCache []zksigma
return false
}
// Check proof of knowledge of sk_{bank}
// TODO: Error handling
ok, _ := en.SKProof.Verify(ZKLedgerCurve, pks[e.Sender])
if !ok {
Dprintf(" [%v] ETX %v Failed withdrawal: proof of knowledge of SK\n", debug, e.Index)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.