diff --git a/execution/evm/evm_test.go b/execution/evm/evm_test.go index e643f6b4a..b4497b36c 100644 --- a/execution/evm/evm_test.go +++ b/execution/evm/evm_test.go @@ -6,6 +6,7 @@ package evm import ( "bytes" "encoding/binary" + "fmt" "math/big" "reflect" "testing" @@ -1443,6 +1444,48 @@ func TestEVM(t *testing.T) { } } }) + + t.Run("SnarkProof", func(t *testing.T) { + st := acmstate.NewMemoryState() + blockchain := new(blockchain) + eventSink := exec.NewNoopEventSink() + txe := new(exec.TxExecution) + success := "0000000000000000000000000000000000000000000000000000000000000001" + + account1 := newAccount(t, st, "1") + + var gas uint64 = 1000000 + /* + contract snark_proof.sol on execution/solidity + */ + + // This bytecode is compiled from Solidity contract above using remix.ethereum.org online compiler + code, err := hex.DecodeString("608060405234801561001057600080fd5b5061109c806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063dd12931314610030575b600080fd5b61018f600480360361012081101561004757600080fd5b8101908080604001906002806020026040519081016040528092919082600260200280828437600081840152601f19601f82011690508083019250505050505091929192908060800190600280602002604051908101604052809291906000905b828210156100fc578382604002016002806020026040519081016040528092919082600260200280828437600081840152601f19601f820116905080830192505050505050815260200190600101906100a8565b50505050919291929080604001906002806020026040519081016040528092919082600260200280828437600081840152601f19601f820116905080830192505050505050919291929080602001906001806020026040519081016040528092919082600160200280828437600081840152601f19601f82011690508083019250505050505091929192905050506101b9565b604051808267ffffffffffffffff1667ffffffffffffffff16815260200191505060405180910390f35b60006101c3610ee9565b6040518060400160405280876000600281106101db57fe5b60200201518152602001876001600281106101f257fe5b60200201518152508160000181905250604051806040016040528060405180604001604052808860006002811061022557fe5b602002015160006002811061023657fe5b602002015181526020018860006002811061024d57fe5b602002015160016002811061025e57fe5b6020020151815250815260200160405180604001604052808860016002811061028357fe5b602002015160006002811061029457fe5b60200201518152602001886001600281106102ab57fe5b60200201516001600281106102bc57fe5b602002015181525081525081602001819052506040518060400160405280856000600281106102e757fe5b60200201518152602001856001600281106102fe57fe5b60200201518152508160400181905250606060016040519080825280602002602001820160405280156103405781602001602082028038833980820191505090505b50905060008090505b60018110156103885784816001811061035e57fe5b602002015182828151811061036f57fe5b6020026020010181815250508080600101915050610349565b5060006103958284610400565b14156103f1577f3f3cfdb26fb5f9f1786ab4f1a1f9cd4c0b5e726cbdfc26e495261731aad44e396040518080602001828103825260228152602001806110466022913960400191505060405180910390a16001925050506103f8565b6000925050505b949350505050565b6000807f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001905061042e610f1c565b610436610572565b905080608001515160018651011461044d57600080fd5b610455610f63565b6040518060400160405280600081526020016000815250905060008090505b86518110156104eb578387828151811061048a57fe5b60200260200101511061049c57600080fd5b6104dc826104d7856080015160018501815181106104b657fe5b60200260200101518a85815181106104ca57fe5b602002602001015161094f565b6109e3565b91508080600101915050610474565b5061050e81836080015160008151811061050157fe5b60200260200101516109e3565b90506105548560000151866020015161052684610a96565b85604001516105388a60400151610a96565b876060015161054a8960000151610a96565b8960200151610b30565b610564576001935050505061056c565b600093505050505b92915050565b61057a610f1c565b60405180604001604052807f0e418100f073ea28e62635436dfef6662084b9806ce0ad27b3613c937547afaf81526020017f2715cf4a1ab651aa12224d4d89ff7b6c7d52de41d685a8e3f858dbf7cf4bb86c8152508160000181905250604051806040016040528060405180604001604052807f2c45036fa487081f7dceff7fc25f21ecb503280d6709afeb2ef267062a17bfaa81526020017f2bfdb5e21864c4dd66403e22e27b177159a41d8d6083d242316f279cb402a6af815250815260200160405180604001604052807f19130dbec8ab7a1e680dfb30b1095362ac90bda4cc286b02f6dcf066814374ba81526020017f0fb951bad964841c50f4959173906e4ab9dcdb1e3d8ce23a608ce62dffc627b98152508152508160200181905250604051806040016040528060405180604001604052807f1b406529320c585cd88fc96b447bd4d2b2628684924d3308fe5a3da3fa7ef3b281526020017f2c610b42fc4ef3486859cf17c701911614d1ea8835766cc1c7b6b10105b9a91a815250815260200160405180604001604052807f1aebcf6a745eb8e2619df8459519a62585a525e9eb2e0d21a7860ab295dc83af81526020017f169479ce2e165fa60f74d9b2c9dbef898693bbd057d65a3dc71393bb267f4f538152508152508160400181905250604051806040016040528060405180604001604052807f117693772d6758fa5c40fb20e7da8014a16787a51dae05c9ce84eeaecc562d4781526020017f28cde745918425d0ff0aee33d9d9c40b0c55e17b3eb8f9349a535b854b6986e7815250815260200160405180604001604052807f1d3789e7c9fe3aa18efd584b0788dd6a6c9e096e6feefb17a3074ccb4603693581526020017f29ca1920396f97ba9604a61627e7c871d7784b8cfb05548e861d08cb3faa3c5d8152508152508160600181905250600260405190808252806020026020018201604052801561086157816020015b61084e610f7d565b8152602001906001900390816108465790505b50816080018190525060405180604001604052807f15069c841ae9a81471054e59a0f8368742cdb9e868f90697e25801f6919ba09c81526020017f14f48d7ef7fc76b76e45f96041c01a6d86a4f0ae1aa3811ddf97e73a483883da81525081608001516000815181106108d057fe5b602002602001018190525060405180604001604052807f2ca7396acba421c38c761d240608f70f49c28340c9fe8ae415767f10ddbf0f5d81526020017f09d0792a0b5f5242c6b39dd102d3a4fd5858cd8c93ce2d337f310a5c23f28862815250816080015160018151811061094157fe5b602002602001018190525090565b610957610f63565b61095f610f97565b83600001518160006003811061097157fe5b60200201818152505083602001518160016003811061098c57fe5b60200201818152505082816002600381106109a357fe5b6020020181815250506000606083608084600060076107d05a03f1905080600081146109ce576109d0565bfe5b50806109db57600080fd5b505092915050565b6109eb610f63565b6109f3610fb9565b836000015181600060048110610a0557fe5b602002018181525050836020015181600160048110610a2057fe5b602002018181525050826000015181600260048110610a3b57fe5b602002018181525050826020015181600360048110610a5657fe5b602002018181525050600060608360c084600060066107d05a03f190508060008114610a8157610a83565bfe5b5080610a8e57600080fd5b505092915050565b610a9e610f63565b60007f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47905060008360000151148015610adb575060008360200151145b15610aff576040518060400160405280600081526020016000815250915050610b2b565b60405180604001604052808460000151815260200182856020015181610b2157fe5b0683038152509150505b919050565b600060606004604051908082528060200260200182016040528015610b6f57816020015b610b5c610f7d565b815260200190600190039081610b545790505b50905060606004604051908082528060200260200182016040528015610baf57816020015b610b9c610fdb565b815260200190600190039081610b945790505b5090508a82600081518110610bc057fe5b60200260200101819052508882600181518110610bd957fe5b60200260200101819052508682600281518110610bf257fe5b60200260200101819052508482600381518110610c0b57fe5b60200260200101819052508981600081518110610c2457fe5b60200260200101819052508781600181518110610c3d57fe5b60200260200101819052508581600281518110610c5657fe5b60200260200101819052508381600381518110610c6f57fe5b6020026020010181905250610c848282610c94565b9250505098975050505050505050565b60008151835114610ca457600080fd5b6000835190506000600682029050606081604051908082528060200260200182016040528015610ce35781602001602082028038833980820191505090505b50905060008090505b83811015610e8957868181518110610d0057fe5b602002602001015160000151826000600684020181518110610d1e57fe5b602002602001018181525050868181518110610d3657fe5b602002602001015160200151826001600684020181518110610d5457fe5b602002602001018181525050858181518110610d6c57fe5b602002602001015160000151600060028110610d8457fe5b6020020151826002600684020181518110610d9b57fe5b602002602001018181525050858181518110610db357fe5b602002602001015160000151600160028110610dcb57fe5b6020020151826003600684020181518110610de257fe5b602002602001018181525050858181518110610dfa57fe5b602002602001015160200151600060028110610e1257fe5b6020020151826004600684020181518110610e2957fe5b602002602001018181525050858181518110610e4157fe5b602002602001015160200151600160028110610e5957fe5b6020020151826005600684020181518110610e7057fe5b6020026020010181815250508080600101915050610cec565b50610e92611001565b60006020826020860260208601600060086107d05a03f190508060008114610eb957610ebb565bfe5b5080610ec657600080fd5b600082600060018110610ed557fe5b602002015114159550505050505092915050565b6040518060600160405280610efc610f7d565b8152602001610f09610fdb565b8152602001610f16610f7d565b81525090565b6040518060a00160405280610f2f610f7d565b8152602001610f3c610fdb565b8152602001610f49610fdb565b8152602001610f56610fdb565b8152602001606081525090565b604051806040016040528060008152602001600081525090565b604051806040016040528060008152602001600081525090565b6040518060600160405280600390602082028038833980820191505090505090565b6040518060800160405280600490602082028038833980820191505090505090565b6040518060400160405280610fee611023565b8152602001610ffb611023565b81525090565b6040518060200160405280600190602082028038833980820191505090505090565b604051806040016040528060029060208202803883398082019150509050509056fe5472616e73616374696f6e207375636365737366756c6c792076657269666965642ea265627a7a72315820370d27c03786385e17679581219c564d5cab475959d2258e687395be7135499764736f6c634300050b0032") + require.NoError(t, err) + + params := engine.CallParams{ + Caller: account1, + Input: code, + Gas: &gas, + } + + vm := New(Options{}) + // Run the contract + contractCode, err := vm.Execute(st, blockchain, eventSink, params, code) + require.NoError(t, err) + + err = native.InitCode(st, account1, contractCode) + require.NoError(t, err) + // proof of the knowledge of 2 int x,y that satisfies x+y == 7, you never will know which ones ;) + params.Input, err = hex.DecodeString("dd1293131f2ccd45a0b09042eb57d4450d7a7c29756a6fa15d90b4be6a1b6137dfa74b3d04fe23902ce8eafcfd08575d543cd6d90a8fb4cee612cb7595fca4f27e1e59a821404670659770738d45c4e0ebde16e3a92cde672a183910b2842f04437d059c0aac54431da98c9a4b5ed1f0748f09a2786410cb72ec504de60c8348e950c7630cb1c9d20bc1e2d4a50b732c3254f10b1c103e242c71bd4ee957de8233f31f8818e4e54e2440cf16f062e358737f97a69850edab4dcf6fcc0624718b2b1c2f2425b8c5ecf1280d9e8643a1ea8cb31a174816dfd070d4b9498f51467705d0963c0e145c31d12be80bc23ab2431ed4d307c7d1bc9df33090c2c766cdb15ca539580000000000000000000000000000000000000000000000000000000000000001") + require.NoError(t, err) + + out, errx := vm.Execute(st, blockchain, txe, params, contractCode) + // out must be solidity uint64(1) + assert.NoError(t, errx) + assert.Equal(t, success, fmt.Sprintf("%x", out)) + + }) } type blockchain struct { diff --git a/execution/native/gas.go b/execution/native/gas.go index cf50672dc..6c6b16f58 100644 --- a/execution/native/gas.go +++ b/execution/native/gas.go @@ -21,4 +21,8 @@ const ( GasExpModBase uint64 = 1 GasIdentityWord uint64 = 1 GasIdentityBase uint64 = 1 + + GasBn256Add uint64 = 1 + GasBn256ScalarMul uint64 = 1 + GasBn256Pairing uint64 = 1 ) diff --git a/execution/native/precompiles.go b/execution/native/precompiles.go index ff14fb283..a2f36a1e1 100644 --- a/execution/native/precompiles.go +++ b/execution/native/precompiles.go @@ -5,6 +5,7 @@ import ( "fmt" "math/big" + "github.com/clearmatics/bn256" "github.com/hyperledger/burrow/binary" "github.com/hyperledger/burrow/crypto" "github.com/hyperledger/burrow/execution/errors" @@ -28,7 +29,19 @@ var Precompiles = New(). MustFunction(`Compute the operation base**exp % mod where the values are big ints`, leftPadAddress(5), permission.None, - expModFunc) + expModFunc). + MustFunction(`Return the add of two points on a bn256 curve`, + leftPadAddress(6), + permission.None, + bn256Add). + MustFunction(`Return the scalar multiplication of a big int and a point on a bn256 curve`, + leftPadAddress(7), + permission.None, + bn256ScalarMul). + MustFunction(`Check the pairing of a set of points on a bn256 curve `, + leftPadAddress(8), + permission.None, + bn256Pairing) func leftPadAddress(bs ...byte) crypto.Address { return crypto.AddressFromWord256(binary.LeftPadWord256(bs)) @@ -131,9 +144,10 @@ func expModFunc(ctx Context) (output []byte, err error) { } // get the values of base, exp and mod - base := getBigInt(segments[0], baseLength) - exp := getBigInt(segments[1], expLength) - mod := getBigInt(segments[2], modLength) + + base := new(big.Int).SetBytes(segments[0]) + exp := new(big.Int).SetBytes(segments[1]) + mod := new(big.Int).SetBytes(segments[2]) // handle mod 0 if mod.Sign() == 0 { @@ -144,6 +158,99 @@ func expModFunc(ctx Context) (output []byte, err error) { return binary.LeftPadBytes(new(big.Int).Exp(base, exp, mod).Bytes(), int(modLength)), nil } +// bn256Add implements the EIP-196 for add pairs in a bn256 curve https://github.com/ethereum/EIPs/blob/master/EIPS/eip-196.md +func bn256Add(ctx Context) (output []byte, err error) { + + if *ctx.Gas < GasBn256Add { + return nil, errors.Codes.InsufficientGas + } + *ctx.Gas -= GasBn256Add + // retrieve the points from the input + x := new(bn256.G1) + y := new(bn256.G1) + + _, sgmnt, errs := cut(ctx.Input, binary.Word256Bytes*2, binary.Word256Bytes*2) + if errs != nil { + return nil, errs + } + + _, errx := x.Unmarshal(sgmnt[0]) + if errx != nil { + return nil, fmt.Errorf("error x: " + errx.Error()) + } + + _, erry := y.Unmarshal(sgmnt[1]) + if erry != nil { + return nil, fmt.Errorf("error y: " + erry.Error()) + } + //add them + res := new(bn256.G1) + res.Add(x, y) + return res.Marshal(), nil +} + +//bn256bn256ScalarMul implements the EIP-196 for scalar multiplication in a bn256 curve https://github.com/ethereum/EIPs/blob/master/EIPS/eip-196.md +func bn256ScalarMul(ctx Context) ([]byte, error) { + if *ctx.Gas < GasBn256ScalarMul { + return nil, errors.Codes.InsufficientGas + } + *ctx.Gas -= GasBn256ScalarMul + + //retrieve the point from the input + _, sgmnt, errs := cut(ctx.Input, binary.Word256Bytes*2, binary.Word256Bytes) + + if errs != nil { + return nil, errs + } + + bnp := new(bn256.G1) + _, errp := bnp.Unmarshal(sgmnt[0]) + if errp != nil { + return nil, errp + } + //make the scalar multiplication + res := new(bn256.G1) + res.ScalarMult(bnp, new(big.Int).SetBytes(sgmnt[1])) + return res.Marshal(), nil +} + +// bn256Pairing implements the EIP-197 https://github.com/ethereum/EIPs/blob/master/EIPS/eip-197.md +func bn256Pairing(ctx Context) ([]byte, error) { + if *ctx.Gas < GasBn256Pairing { + return nil, errors.Codes.InsufficientGas + } + + *ctx.Gas -= GasBn256Pairing + + // Handle some corner cases cheaply + + if len(ctx.Input)%192 > 0 { + + return nil, fmt.Errorf("bad elliptic curve pairing size") + } + // auxiliars for parse the inputs + var ( + cs []*bn256.G1 + ts []*bn256.G2 + ) + // retrieving the inputs into the curve points + for i := 0; i < len(ctx.Input); i += 192 { + c, errc := newCurvePoint(ctx.Input[i : i+64]) + if errc != nil { + return nil, errc + } + cs = append(cs, c) + + t, errt := newTwistPoint(ctx.Input[i+64 : i+192]) + if errt != nil { + return nil, errt + } + ts = append(ts, t) + } + // check the parity + return pairingCheckByte(cs, ts), nil +} + // Partition the head of input into segments for each length in lengths. The first return value is the unconsumed tail // of input and the seconds is the segments. Returns an error if input is of insufficient length to establish each segment. func cut(input []byte, lengths ...uint64) ([]byte, [][]byte, error) { @@ -158,10 +265,31 @@ func cut(input []byte, lengths ...uint64) ([]byte, [][]byte, error) { return input, segments, nil } -func getBigInt(bs []byte, numBytes uint64) *big.Int { - bits := uint(numBytes) * 8 - // Push bytes into big.Int and interpret as twos complement encoding with of bits width - return binary.FromTwosComplement(new(big.Int).SetBytes(bs), bits) +//represent bools as byte arrays of size 32. 1 for true, 0 for false +func pairingCheckByte(a []*bn256.G1, b []*bn256.G2) []byte { + if bn256.PairingCheck(a, b) { + return []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} + + } + return make([]byte, binary.Word256Bytes) +} + +func newCurvePoint(blob []byte) (*bn256.G1, error) { + p := new(bn256.G1) + if _, err := p.Unmarshal(blob); err != nil { + return nil, err + } + return p, nil +} + +// newTwistPoint unmarshals a binary blob into a bn256 elliptic curve point, +// returning it, or an error if the point is invalid. +func newTwistPoint(blob []byte) (*bn256.G2, error) { + p := new(bn256.G2) + if _, err := p.Unmarshal(blob); err != nil { + return nil, err + } + return p, nil } func getUint64(bs []byte) uint64 { diff --git a/execution/native/precompiles_test.go b/execution/native/precompiles_test.go new file mode 100644 index 000000000..603c6d0d7 --- /dev/null +++ b/execution/native/precompiles_test.go @@ -0,0 +1,71 @@ +package native + +import ( + "encoding/hex" + "fmt" + "log" + "testing" + + "github.com/stretchr/testify/require" +) + +// TODO: Add more test for each precompile +const ( + bigModExpInput = "000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040e09ad9675465c53a109fac66a445c91b292d2bb2c5268addb30cd82f80fcb0033ff97c80a5fc6f39193ae969c6ede6710a6b7ac27078a06d90ef1c72e5c85fb502fc9e1f6beb81516545975218075ec2af118cd8798df6e08a147c60fd6095ac2bb02c2908cf4dd7c81f11c289e4bce98f3553768f392a80ce22bf5c4f4a248c6b" + bigModExpExpected = "60008f1614cc01dcfb6bfb09c625cf90b47d4468db81b5f8b7a39d42f332eab9b2da8f2d95311648a8f243f4bb13cfb3d8f7f2a3c014122ebb3ed41b02783adc" + + bn256AddInput = "000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + bn256AddExpected = "030644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd315ed738c0e0a7c92e7845f96b2ae9c0a68a6a449e3538fc7ff3ebf7a5a18a2c4" + + bn256ScaMulInput = "2bd3e6d0f3b142924f5ca7b49ce5b9d54c4703d7ae5648e61d02268b1a0a9fb721611ce0a6af85915e2f1d70300909ce2e49dfad4a4619c8390cae66cefdb20400000000000000000000000000000000000000000000000011138ce750fa15c2" + bn256ScaMulExpected = "070a8d6a982153cae4be29d434e8faef8a47b274a053f5a4ee2a6c9c13c31e5c031b8ce914eba3a9ffb989f9cdd5b0f01943074bf4f0f315690ec3cec6981afc" + + bn256PairingInput = "1c76476f4def4bb94541d57ebba1193381ffa7aa76ada664dd31c16024c43f593034dd2920f673e204fee2811c678745fc819b55d3e9d294e45c9b03a76aef41209dd15ebff5d46c4bd888e51a93cf99a7329636c63514396b4a452003a35bf704bf11ca01483bfa8b34b43561848d28905960114c8ac04049af4b6315a416782bb8324af6cfc93537a2ad1a445cfd0ca2a71acd7ac41fadbf933c2a51be344d120a2a4cf30c1bf9845f20c6fe39e07ea2cce61f0c9bb048165fe5e4de877550111e129f1cf1097710d41c4ac70fcdfa5ba2023c6ff1cbeac322de49d1b6df7c2032c61a830e3c17286de9462bf242fca2883585b93870a73853face6a6bf411198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa" + bn256PairingExpected = "0000000000000000000000000000000000000000000000000000000000000001" +) + +type precompile func(Context) ([]byte, error) + +func TestBigModExp(t *testing.T) { + testPrecompile(t, expModFunc, bigModExpInput, bigModExpExpected) +} + +func TestBn256Add(t *testing.T) { + + testPrecompile(t, bn256Add, bn256AddInput, bn256AddExpected) + +} + +func TestBn256ScalarMul(t *testing.T) { + + testPrecompile(t, bn256ScalarMul, bn256ScaMulInput, bn256ScaMulExpected) + +} + +func TestBn256Pairing(t *testing.T) { + testPrecompile(t, bn256Pairing, bn256PairingInput, bn256PairingExpected) + +} + +func testPrecompile(t *testing.T, pr precompile, input, success string) { + inputb, _ := hex.DecodeString(input) + + ctx := setContext(inputb) + out, err := pr(*ctx) + if err != nil { + log.Println(err.Error()) + t.Logf(err.Error()) + t.Fail() + } + fmt.Printf("%x", out) + require.Equal(t, success, fmt.Sprintf("%x", out)) + +} + +func setContext(input []byte) *Context { + gas := uint64(1000000) + ctx := Context{} + ctx.Input = input + ctx.Gas = &gas + return &ctx +} diff --git a/execution/solidity/snark_proof.sol b/execution/solidity/snark_proof.sol new file mode 100644 index 000000000..113ffd6c6 --- /dev/null +++ b/execution/solidity/snark_proof.sol @@ -0,0 +1,623 @@ +// This file is LGPL3 Licensed + +/* +This contract tests the 5th, 6th, 7th and 8th eth precompile. + +It verifies a zk-snark proof of the knowledge of two integer that satisfies the computation: + +--------------------------------------------------------- + + def main(private field x, private field y) -> (field): + x+y == 7 + return 1 + +--------------------------------------------------------- + +This contract and libaries were generated with ZoKrates https://zokrates.github.io/ + +*/ + + +/** + * @title Elliptic curve operations on twist points for alt_bn128 + * @author Mustafa Al-Bassam (mus@musalbas.com) + * @dev Homepage: https://github.com/musalbas/solidity-BN256G2 + */ + +library BN256G2 { + uint256 internal constant FIELD_MODULUS = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47; + uint256 internal constant TWISTBX = 0x2b149d40ceb8aaae81be18991be06ac3b5b4c5e559dbefa33267e6dc24a138e5; + uint256 internal constant TWISTBY = 0x9713b03af0fed4cd2cafadeed8fdf4a74fa084e52d1852e4a2bd0685c315d2; + uint internal constant PTXX = 0; + uint internal constant PTXY = 1; + uint internal constant PTYX = 2; + uint internal constant PTYY = 3; + uint internal constant PTZX = 4; + uint internal constant PTZY = 5; + + /** + * @notice Add two twist points + * @param pt1xx Coefficient 1 of x on point 1 + * @param pt1xy Coefficient 2 of x on point 1 + * @param pt1yx Coefficient 1 of y on point 1 + * @param pt1yy Coefficient 2 of y on point 1 + * @param pt2xx Coefficient 1 of x on point 2 + * @param pt2xy Coefficient 2 of x on point 2 + * @param pt2yx Coefficient 1 of y on point 2 + * @param pt2yy Coefficient 2 of y on point 2 + * @return (pt3xx, pt3xy, pt3yx, pt3yy) + */ + function ECTwistAdd( + uint256 pt1xx, uint256 pt1xy, + uint256 pt1yx, uint256 pt1yy, + uint256 pt2xx, uint256 pt2xy, + uint256 pt2yx, uint256 pt2yy + ) public view returns ( + uint256, uint256, + uint256, uint256 + ) { + if ( + pt1xx == 0 && pt1xy == 0 && + pt1yx == 0 && pt1yy == 0 + ) { + if (!( + pt2xx == 0 && pt2xy == 0 && + pt2yx == 0 && pt2yy == 0 + )) { + assert(_isOnCurve( + pt2xx, pt2xy, + pt2yx, pt2yy + )); + } + return ( + pt2xx, pt2xy, + pt2yx, pt2yy + ); + } else if ( + pt2xx == 0 && pt2xy == 0 && + pt2yx == 0 && pt2yy == 0 + ) { + assert(_isOnCurve( + pt1xx, pt1xy, + pt1yx, pt1yy + )); + return ( + pt1xx, pt1xy, + pt1yx, pt1yy + ); + } + + assert(_isOnCurve( + pt1xx, pt1xy, + pt1yx, pt1yy + )); + assert(_isOnCurve( + pt2xx, pt2xy, + pt2yx, pt2yy + )); + + uint256[6] memory pt3 = _ECTwistAddJacobian( + pt1xx, pt1xy, + pt1yx, pt1yy, + 1, 0, + pt2xx, pt2xy, + pt2yx, pt2yy, + 1, 0 + ); + + return _fromJacobian( + pt3[PTXX], pt3[PTXY], + pt3[PTYX], pt3[PTYY], + pt3[PTZX], pt3[PTZY] + ); + } + + /** + * @notice Multiply a twist point by a scalar + * @param s Scalar to multiply by + * @param pt1xx Coefficient 1 of x + * @param pt1xy Coefficient 2 of x + * @param pt1yx Coefficient 1 of y + * @param pt1yy Coefficient 2 of y + * @return (pt2xx, pt2xy, pt2yx, pt2yy) + */ + function ECTwistMul( + uint256 s, + uint256 pt1xx, uint256 pt1xy, + uint256 pt1yx, uint256 pt1yy + ) public view returns ( + uint256, uint256, + uint256, uint256 + ) { + uint256 pt1zx = 1; + if ( + pt1xx == 0 && pt1xy == 0 && + pt1yx == 0 && pt1yy == 0 + ) { + pt1xx = 1; + pt1yx = 1; + pt1zx = 0; + } else { + assert(_isOnCurve( + pt1xx, pt1xy, + pt1yx, pt1yy + )); + } + + uint256[6] memory pt2 = _ECTwistMulJacobian( + s, + pt1xx, pt1xy, + pt1yx, pt1yy, + pt1zx, 0 + ); + + return _fromJacobian( + pt2[PTXX], pt2[PTXY], + pt2[PTYX], pt2[PTYY], + pt2[PTZX], pt2[PTZY] + ); + } + + /** + * @notice Get the field modulus + * @return The field modulus + */ + function GetFieldModulus() public pure returns (uint256) { + return FIELD_MODULUS; + } + + function submod(uint256 a, uint256 b, uint256 n) internal pure returns (uint256) { + return addmod(a, n - b, n); + } + + function _FQ2Mul( + uint256 xx, uint256 xy, + uint256 yx, uint256 yy + ) internal pure returns (uint256, uint256) { + return ( + submod(mulmod(xx, yx, FIELD_MODULUS), mulmod(xy, yy, FIELD_MODULUS), FIELD_MODULUS), + addmod(mulmod(xx, yy, FIELD_MODULUS), mulmod(xy, yx, FIELD_MODULUS), FIELD_MODULUS) + ); + } + + function _FQ2Muc( + uint256 xx, uint256 xy, + uint256 c + ) internal pure returns (uint256, uint256) { + return ( + mulmod(xx, c, FIELD_MODULUS), + mulmod(xy, c, FIELD_MODULUS) + ); + } + + function _FQ2Add( + uint256 xx, uint256 xy, + uint256 yx, uint256 yy + ) internal pure returns (uint256, uint256) { + return ( + addmod(xx, yx, FIELD_MODULUS), + addmod(xy, yy, FIELD_MODULUS) + ); + } + + function _FQ2Sub( + uint256 xx, uint256 xy, + uint256 yx, uint256 yy + ) internal pure returns (uint256 rx, uint256 ry) { + return ( + submod(xx, yx, FIELD_MODULUS), + submod(xy, yy, FIELD_MODULUS) + ); + } + + function _FQ2Div( + uint256 xx, uint256 xy, + uint256 yx, uint256 yy + ) internal view returns (uint256, uint256) { + (yx, yy) = _FQ2Inv(yx, yy); + return _FQ2Mul(xx, xy, yx, yy); + } + + function _FQ2Inv(uint256 x, uint256 y) internal view returns (uint256, uint256) { + uint256 inv = _modInv(addmod(mulmod(y, y, FIELD_MODULUS), mulmod(x, x, FIELD_MODULUS), FIELD_MODULUS), FIELD_MODULUS); + return ( + mulmod(x, inv, FIELD_MODULUS), + FIELD_MODULUS - mulmod(y, inv, FIELD_MODULUS) + ); + } + + function _isOnCurve( + uint256 xx, uint256 xy, + uint256 yx, uint256 yy + ) internal pure returns (bool) { + uint256 yyx; + uint256 yyy; + uint256 xxxx; + uint256 xxxy; + (yyx, yyy) = _FQ2Mul(yx, yy, yx, yy); + (xxxx, xxxy) = _FQ2Mul(xx, xy, xx, xy); + (xxxx, xxxy) = _FQ2Mul(xxxx, xxxy, xx, xy); + (yyx, yyy) = _FQ2Sub(yyx, yyy, xxxx, xxxy); + (yyx, yyy) = _FQ2Sub(yyx, yyy, TWISTBX, TWISTBY); + return yyx == 0 && yyy == 0; + } + + function _modInv(uint256 a, uint256 n) internal view returns (uint256 result) { + bool success; + assembly { + let freemem := mload(0x40) + mstore(freemem, 0x20) + mstore(add(freemem,0x20), 0x20) + mstore(add(freemem,0x40), 0x20) + mstore(add(freemem,0x60), a) + mstore(add(freemem,0x80), sub(n, 2)) + mstore(add(freemem,0xA0), n) + success := staticcall(sub(gas, 2000), 5, freemem, 0xC0, freemem, 0x20) + result := mload(freemem) + } + require(success); + } + + function _fromJacobian( + uint256 pt1xx, uint256 pt1xy, + uint256 pt1yx, uint256 pt1yy, + uint256 pt1zx, uint256 pt1zy + ) internal view returns ( + uint256 pt2xx, uint256 pt2xy, + uint256 pt2yx, uint256 pt2yy + ) { + uint256 invzx; + uint256 invzy; + (invzx, invzy) = _FQ2Inv(pt1zx, pt1zy); + (pt2xx, pt2xy) = _FQ2Mul(pt1xx, pt1xy, invzx, invzy); + (pt2yx, pt2yy) = _FQ2Mul(pt1yx, pt1yy, invzx, invzy); + } + + function _ECTwistAddJacobian( + uint256 pt1xx, uint256 pt1xy, + uint256 pt1yx, uint256 pt1yy, + uint256 pt1zx, uint256 pt1zy, + uint256 pt2xx, uint256 pt2xy, + uint256 pt2yx, uint256 pt2yy, + uint256 pt2zx, uint256 pt2zy) internal pure returns (uint256[6] memory pt3) { + if (pt1zx == 0 && pt1zy == 0) { + ( + pt3[PTXX], pt3[PTXY], + pt3[PTYX], pt3[PTYY], + pt3[PTZX], pt3[PTZY] + ) = ( + pt2xx, pt2xy, + pt2yx, pt2yy, + pt2zx, pt2zy + ); + return pt3; + } else if (pt2zx == 0 && pt2zy == 0) { + ( + pt3[PTXX], pt3[PTXY], + pt3[PTYX], pt3[PTYY], + pt3[PTZX], pt3[PTZY] + ) = ( + pt1xx, pt1xy, + pt1yx, pt1yy, + pt1zx, pt1zy + ); + return pt3; + } + + (pt2yx, pt2yy) = _FQ2Mul(pt2yx, pt2yy, pt1zx, pt1zy); // U1 = y2 * z1 + (pt3[PTYX], pt3[PTYY]) = _FQ2Mul(pt1yx, pt1yy, pt2zx, pt2zy); // U2 = y1 * z2 + (pt2xx, pt2xy) = _FQ2Mul(pt2xx, pt2xy, pt1zx, pt1zy); // V1 = x2 * z1 + (pt3[PTZX], pt3[PTZY]) = _FQ2Mul(pt1xx, pt1xy, pt2zx, pt2zy); // V2 = x1 * z2 + + if (pt2xx == pt3[PTZX] && pt2xy == pt3[PTZY]) { + if (pt2yx == pt3[PTYX] && pt2yy == pt3[PTYY]) { + ( + pt3[PTXX], pt3[PTXY], + pt3[PTYX], pt3[PTYY], + pt3[PTZX], pt3[PTZY] + ) = _ECTwistDoubleJacobian(pt1xx, pt1xy, pt1yx, pt1yy, pt1zx, pt1zy); + return pt3; + } + ( + pt3[PTXX], pt3[PTXY], + pt3[PTYX], pt3[PTYY], + pt3[PTZX], pt3[PTZY] + ) = ( + 1, 0, + 1, 0, + 0, 0 + ); + return pt3; + } + + (pt2zx, pt2zy) = _FQ2Mul(pt1zx, pt1zy, pt2zx, pt2zy); // W = z1 * z2 + (pt1xx, pt1xy) = _FQ2Sub(pt2yx, pt2yy, pt3[PTYX], pt3[PTYY]); // U = U1 - U2 + (pt1yx, pt1yy) = _FQ2Sub(pt2xx, pt2xy, pt3[PTZX], pt3[PTZY]); // V = V1 - V2 + (pt1zx, pt1zy) = _FQ2Mul(pt1yx, pt1yy, pt1yx, pt1yy); // V_squared = V * V + (pt2yx, pt2yy) = _FQ2Mul(pt1zx, pt1zy, pt3[PTZX], pt3[PTZY]); // V_squared_times_V2 = V_squared * V2 + (pt1zx, pt1zy) = _FQ2Mul(pt1zx, pt1zy, pt1yx, pt1yy); // V_cubed = V * V_squared + (pt3[PTZX], pt3[PTZY]) = _FQ2Mul(pt1zx, pt1zy, pt2zx, pt2zy); // newz = V_cubed * W + (pt2xx, pt2xy) = _FQ2Mul(pt1xx, pt1xy, pt1xx, pt1xy); // U * U + (pt2xx, pt2xy) = _FQ2Mul(pt2xx, pt2xy, pt2zx, pt2zy); // U * U * W + (pt2xx, pt2xy) = _FQ2Sub(pt2xx, pt2xy, pt1zx, pt1zy); // U * U * W - V_cubed + (pt2zx, pt2zy) = _FQ2Muc(pt2yx, pt2yy, 2); // 2 * V_squared_times_V2 + (pt2xx, pt2xy) = _FQ2Sub(pt2xx, pt2xy, pt2zx, pt2zy); // A = U * U * W - V_cubed - 2 * V_squared_times_V2 + (pt3[PTXX], pt3[PTXY]) = _FQ2Mul(pt1yx, pt1yy, pt2xx, pt2xy); // newx = V * A + (pt1yx, pt1yy) = _FQ2Sub(pt2yx, pt2yy, pt2xx, pt2xy); // V_squared_times_V2 - A + (pt1yx, pt1yy) = _FQ2Mul(pt1xx, pt1xy, pt1yx, pt1yy); // U * (V_squared_times_V2 - A) + (pt1xx, pt1xy) = _FQ2Mul(pt1zx, pt1zy, pt3[PTYX], pt3[PTYY]); // V_cubed * U2 + (pt3[PTYX], pt3[PTYY]) = _FQ2Sub(pt1yx, pt1yy, pt1xx, pt1xy); // newy = U * (V_squared_times_V2 - A) - V_cubed * U2 + } + + function _ECTwistDoubleJacobian( + uint256 pt1xx, uint256 pt1xy, + uint256 pt1yx, uint256 pt1yy, + uint256 pt1zx, uint256 pt1zy + ) internal pure returns ( + uint256 pt2xx, uint256 pt2xy, + uint256 pt2yx, uint256 pt2yy, + uint256 pt2zx, uint256 pt2zy + ) { + (pt2xx, pt2xy) = _FQ2Muc(pt1xx, pt1xy, 3); // 3 * x + (pt2xx, pt2xy) = _FQ2Mul(pt2xx, pt2xy, pt1xx, pt1xy); // W = 3 * x * x + (pt1zx, pt1zy) = _FQ2Mul(pt1yx, pt1yy, pt1zx, pt1zy); // S = y * z + (pt2yx, pt2yy) = _FQ2Mul(pt1xx, pt1xy, pt1yx, pt1yy); // x * y + (pt2yx, pt2yy) = _FQ2Mul(pt2yx, pt2yy, pt1zx, pt1zy); // B = x * y * S + (pt1xx, pt1xy) = _FQ2Mul(pt2xx, pt2xy, pt2xx, pt2xy); // W * W + (pt2zx, pt2zy) = _FQ2Muc(pt2yx, pt2yy, 8); // 8 * B + (pt1xx, pt1xy) = _FQ2Sub(pt1xx, pt1xy, pt2zx, pt2zy); // H = W * W - 8 * B + (pt2zx, pt2zy) = _FQ2Mul(pt1zx, pt1zy, pt1zx, pt1zy); // S_squared = S * S + (pt2yx, pt2yy) = _FQ2Muc(pt2yx, pt2yy, 4); // 4 * B + (pt2yx, pt2yy) = _FQ2Sub(pt2yx, pt2yy, pt1xx, pt1xy); // 4 * B - H + (pt2yx, pt2yy) = _FQ2Mul(pt2yx, pt2yy, pt2xx, pt2xy); // W * (4 * B - H) + (pt2xx, pt2xy) = _FQ2Muc(pt1yx, pt1yy, 8); // 8 * y + (pt2xx, pt2xy) = _FQ2Mul(pt2xx, pt2xy, pt1yx, pt1yy); // 8 * y * y + (pt2xx, pt2xy) = _FQ2Mul(pt2xx, pt2xy, pt2zx, pt2zy); // 8 * y * y * S_squared + (pt2yx, pt2yy) = _FQ2Sub(pt2yx, pt2yy, pt2xx, pt2xy); // newy = W * (4 * B - H) - 8 * y * y * S_squared + (pt2xx, pt2xy) = _FQ2Muc(pt1xx, pt1xy, 2); // 2 * H + (pt2xx, pt2xy) = _FQ2Mul(pt2xx, pt2xy, pt1zx, pt1zy); // newx = 2 * H * S + (pt2zx, pt2zy) = _FQ2Mul(pt1zx, pt1zy, pt2zx, pt2zy); // S * S_squared + (pt2zx, pt2zy) = _FQ2Muc(pt2zx, pt2zy, 8); // newz = 8 * S * S_squared + } + + function _ECTwistMulJacobian( + uint256 d, + uint256 pt1xx, uint256 pt1xy, + uint256 pt1yx, uint256 pt1yy, + uint256 pt1zx, uint256 pt1zy + ) internal pure returns (uint256[6] memory pt2) { + while (d != 0) { + if ((d & 1) != 0) { + pt2 = _ECTwistAddJacobian( + pt2[PTXX], pt2[PTXY], + pt2[PTYX], pt2[PTYY], + pt2[PTZX], pt2[PTZY], + pt1xx, pt1xy, + pt1yx, pt1yy, + pt1zx, pt1zy); + } + ( + pt1xx, pt1xy, + pt1yx, pt1yy, + pt1zx, pt1zy + ) = _ECTwistDoubleJacobian( + pt1xx, pt1xy, + pt1yx, pt1yy, + pt1zx, pt1zy + ); + + d = d / 2; + } + } +} +// This file is MIT Licensed. +// +// Copyright 2017 Christian Reitwiessner +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +pragma solidity ^0.5.0; +library Pairing { + struct G1Point { + uint X; + uint Y; + } + // Encoding of field elements is: X[0] * z + X[1] + struct G2Point { + uint[2] X; + uint[2] Y; + } + /// @return the generator of G1 + function P1() pure internal returns (G1Point memory) { + return G1Point(1, 2); + } + /// @return the generator of G2 + function P2() pure internal returns (G2Point memory) { + return G2Point( + [11559732032986387107991004021392285783925812861821192530917403151452391805634, + 10857046999023057135944570762232829481370756359578518086990519993285655852781], + [4082367875863433681332203403145435568316851327593401208105741076214120093531, + 8495653923123431417604973247489272438418190587263600148770280649306958101930] + ); + } + /// @return the negation of p, i.e. p.addition(p.negate()) should be zero. + function negate(G1Point memory p) pure internal returns (G1Point memory) { + // The prime q in the base field F_q for G1 + uint q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; + if (p.X == 0 && p.Y == 0) + return G1Point(0, 0); + return G1Point(p.X, q - (p.Y % q)); + } + /// @return the sum of two points of G1 + function addition(G1Point memory p1, G1Point memory p2) internal returns (G1Point memory r) { + uint[4] memory input; + input[0] = p1.X; + input[1] = p1.Y; + input[2] = p2.X; + input[3] = p2.Y; + bool success; + assembly { + success := call(sub(gas, 2000), 6, 0, input, 0xc0, r, 0x60) + // Use "invalid" to make gas estimation work + switch success case 0 { invalid() } + } + require(success); + } + /// @return the sum of two points of G2 + function addition(G2Point memory p1, G2Point memory p2) internal returns (G2Point memory r) { + (r.X[1], r.X[0], r.Y[1], r.Y[0]) = BN256G2.ECTwistAdd(p1.X[1],p1.X[0],p1.Y[1],p1.Y[0],p2.X[1],p2.X[0],p2.Y[1],p2.Y[0]); + } + /// @return the product of a point on G1 and a scalar, i.e. + /// p == p.scalar_mul(1) and p.addition(p) == p.scalar_mul(2) for all points p. + function scalar_mul(G1Point memory p, uint s) internal returns (G1Point memory r) { + uint[3] memory input; + input[0] = p.X; + input[1] = p.Y; + input[2] = s; + bool success; + assembly { + success := call(sub(gas, 2000), 7, 0, input, 0x80, r, 0x60) + // Use "invalid" to make gas estimation work + switch success case 0 { invalid() } + } + require (success); + } + /// @return the result of computing the pairing check + /// e(p1[0], p2[0]) * .... * e(p1[n], p2[n]) == 1 + /// For example pairing([P1(), P1().negate()], [P2(), P2()]) should + /// return true. + function pairing(G1Point[] memory p1, G2Point[] memory p2) internal returns (bool) { + require(p1.length == p2.length); + uint elements = p1.length; + uint inputSize = elements * 6; + uint[] memory input = new uint[](inputSize); + for (uint i = 0; i < elements; i++) + { + input[i * 6 + 0] = p1[i].X; + input[i * 6 + 1] = p1[i].Y; + input[i * 6 + 2] = p2[i].X[0]; + input[i * 6 + 3] = p2[i].X[1]; + input[i * 6 + 4] = p2[i].Y[0]; + input[i * 6 + 5] = p2[i].Y[1]; + } + uint[1] memory out; + bool success; + assembly { + success := call(sub(gas, 2000), 8, 0, add(input, 0x20), mul(inputSize, 0x20), out, 0x20) + // Use "invalid" to make gas estimation work + switch success case 0 { invalid() } + } + require(success); + return out[0] != 0; + } + /// Convenience method for a pairing check for two pairs. + function pairingProd2(G1Point memory a1, G2Point memory a2, G1Point memory b1, G2Point memory b2) internal returns (bool) { + G1Point[] memory p1 = new G1Point[](2); + G2Point[] memory p2 = new G2Point[](2); + p1[0] = a1; + p1[1] = b1; + p2[0] = a2; + p2[1] = b2; + return pairing(p1, p2); + } + /// Convenience method for a pairing check for three pairs. + function pairingProd3( + G1Point memory a1, G2Point memory a2, + G1Point memory b1, G2Point memory b2, + G1Point memory c1, G2Point memory c2 + ) internal returns (bool) { + G1Point[] memory p1 = new G1Point[](3); + G2Point[] memory p2 = new G2Point[](3); + p1[0] = a1; + p1[1] = b1; + p1[2] = c1; + p2[0] = a2; + p2[1] = b2; + p2[2] = c2; + return pairing(p1, p2); + } + /// Convenience method for a pairing check for four pairs. + function pairingProd4( + G1Point memory a1, G2Point memory a2, + G1Point memory b1, G2Point memory b2, + G1Point memory c1, G2Point memory c2, + G1Point memory d1, G2Point memory d2 + ) internal returns (bool) { + G1Point[] memory p1 = new G1Point[](4); + G2Point[] memory p2 = new G2Point[](4); + p1[0] = a1; + p1[1] = b1; + p1[2] = c1; + p1[3] = d1; + p2[0] = a2; + p2[1] = b2; + p2[2] = c2; + p2[3] = d2; + return pairing(p1, p2); + } +} + +contract Verifier { + using Pairing for *; + struct VerifyingKey { + Pairing.G1Point a; + Pairing.G2Point b; + Pairing.G2Point gamma; + Pairing.G2Point delta; + Pairing.G1Point[] gamma_abc; + } + struct Proof { + Pairing.G1Point a; + Pairing.G2Point b; + Pairing.G1Point c; + } + function verifyingKey() pure internal returns (VerifyingKey memory vk) { + vk.a = Pairing.G1Point(uint256(0x0e418100f073ea28e62635436dfef6662084b9806ce0ad27b3613c937547afaf), uint256(0x2715cf4a1ab651aa12224d4d89ff7b6c7d52de41d685a8e3f858dbf7cf4bb86c)); + vk.b = Pairing.G2Point([uint256(0x2c45036fa487081f7dceff7fc25f21ecb503280d6709afeb2ef267062a17bfaa), uint256(0x2bfdb5e21864c4dd66403e22e27b177159a41d8d6083d242316f279cb402a6af)], [uint256(0x19130dbec8ab7a1e680dfb30b1095362ac90bda4cc286b02f6dcf066814374ba), uint256(0x0fb951bad964841c50f4959173906e4ab9dcdb1e3d8ce23a608ce62dffc627b9)]); + vk.gamma = Pairing.G2Point([uint256(0x1b406529320c585cd88fc96b447bd4d2b2628684924d3308fe5a3da3fa7ef3b2), uint256(0x2c610b42fc4ef3486859cf17c701911614d1ea8835766cc1c7b6b10105b9a91a)], [uint256(0x1aebcf6a745eb8e2619df8459519a62585a525e9eb2e0d21a7860ab295dc83af), uint256(0x169479ce2e165fa60f74d9b2c9dbef898693bbd057d65a3dc71393bb267f4f53)]); + vk.delta = Pairing.G2Point([uint256(0x117693772d6758fa5c40fb20e7da8014a16787a51dae05c9ce84eeaecc562d47), uint256(0x28cde745918425d0ff0aee33d9d9c40b0c55e17b3eb8f9349a535b854b6986e7)], [uint256(0x1d3789e7c9fe3aa18efd584b0788dd6a6c9e096e6feefb17a3074ccb46036935), uint256(0x29ca1920396f97ba9604a61627e7c871d7784b8cfb05548e861d08cb3faa3c5d)]); + vk.gamma_abc = new Pairing.G1Point[](2); + vk.gamma_abc[0] = Pairing.G1Point(uint256(0x15069c841ae9a81471054e59a0f8368742cdb9e868f90697e25801f6919ba09c), uint256(0x14f48d7ef7fc76b76e45f96041c01a6d86a4f0ae1aa3811ddf97e73a483883da)); + vk.gamma_abc[1] = Pairing.G1Point(uint256(0x2ca7396acba421c38c761d240608f70f49c28340c9fe8ae415767f10ddbf0f5d), uint256(0x09d0792a0b5f5242c6b39dd102d3a4fd5858cd8c93ce2d337f310a5c23f28862)); + } + function verify(uint[] memory input, Proof memory proof) internal returns (uint) { + uint256 snark_scalar_field = 21888242871839275222246405745257275088548364400416034343698204186575808495617; + VerifyingKey memory vk = verifyingKey(); + require(input.length + 1 == vk.gamma_abc.length); + // Compute the linear combination vk_x + Pairing.G1Point memory vk_x = Pairing.G1Point(0, 0); + for (uint i = 0; i < input.length; i++) { + require(input[i] < snark_scalar_field); + vk_x = Pairing.addition(vk_x, Pairing.scalar_mul(vk.gamma_abc[i + 1], input[i])); + } + vk_x = Pairing.addition(vk_x, vk.gamma_abc[0]); + if(!Pairing.pairingProd4( + proof.a, proof.b, + Pairing.negate(vk_x), vk.gamma, + Pairing.negate(proof.c), vk.delta, + Pairing.negate(vk.a), vk.b)) return 1; + return 0; + } + event Verified(string s); + function verifyTx( + uint[2] memory a, + uint[2][2] memory b, + uint[2] memory c, + uint[1] memory input + ) public returns (uint64) { + Proof memory proof; + proof.a = Pairing.G1Point(a[0], a[1]); + proof.b = Pairing.G2Point([b[0][0], b[0][1]], [b[1][0], b[1][1]]); + proof.c = Pairing.G1Point(c[0], c[1]); + uint[] memory inputValues = new uint[](input.length); + for(uint i = 0; i < input.length; i++){ + inputValues[i] = input[i]; + } + if (verify(inputValues, proof) == 0) { + emit Verified("Transaction successfully verified."); + return 1; + } else { + return 0; + } + } +} diff --git a/execution/solidity/snark_proof.sol.go b/execution/solidity/snark_proof.sol.go new file mode 100644 index 000000000..a373ce04c --- /dev/null +++ b/execution/solidity/snark_proof.sol.go @@ -0,0 +1,57 @@ +package solidity + +import hex "github.com/tmthrgd/go-hex" + +var Bytecode_SnarkProof = hex.MustDecodeString("608060405234801561001057600080fd5b5061109c806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063dd12931314610030575b600080fd5b61018f600480360361012081101561004757600080fd5b8101908080604001906002806020026040519081016040528092919082600260200280828437600081840152601f19601f82011690508083019250505050505091929192908060800190600280602002604051908101604052809291906000905b828210156100fc578382604002016002806020026040519081016040528092919082600260200280828437600081840152601f19601f820116905080830192505050505050815260200190600101906100a8565b50505050919291929080604001906002806020026040519081016040528092919082600260200280828437600081840152601f19601f820116905080830192505050505050919291929080602001906001806020026040519081016040528092919082600160200280828437600081840152601f19601f82011690508083019250505050505091929192905050506101b9565b604051808267ffffffffffffffff1667ffffffffffffffff16815260200191505060405180910390f35b60006101c3610ee9565b6040518060400160405280876000600281106101db57fe5b60200201518152602001876001600281106101f257fe5b60200201518152508160000181905250604051806040016040528060405180604001604052808860006002811061022557fe5b602002015160006002811061023657fe5b602002015181526020018860006002811061024d57fe5b602002015160016002811061025e57fe5b6020020151815250815260200160405180604001604052808860016002811061028357fe5b602002015160006002811061029457fe5b60200201518152602001886001600281106102ab57fe5b60200201516001600281106102bc57fe5b602002015181525081525081602001819052506040518060400160405280856000600281106102e757fe5b60200201518152602001856001600281106102fe57fe5b60200201518152508160400181905250606060016040519080825280602002602001820160405280156103405781602001602082028038833980820191505090505b50905060008090505b60018110156103885784816001811061035e57fe5b602002015182828151811061036f57fe5b6020026020010181815250508080600101915050610349565b5060006103958284610400565b14156103f1577f3f3cfdb26fb5f9f1786ab4f1a1f9cd4c0b5e726cbdfc26e495261731aad44e396040518080602001828103825260228152602001806110466022913960400191505060405180910390a16001925050506103f8565b6000925050505b949350505050565b6000807f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001905061042e610f1c565b610436610572565b905080608001515160018651011461044d57600080fd5b610455610f63565b6040518060400160405280600081526020016000815250905060008090505b86518110156104eb578387828151811061048a57fe5b60200260200101511061049c57600080fd5b6104dc826104d7856080015160018501815181106104b657fe5b60200260200101518a85815181106104ca57fe5b602002602001015161094f565b6109e3565b91508080600101915050610474565b5061050e81836080015160008151811061050157fe5b60200260200101516109e3565b90506105548560000151866020015161052684610a96565b85604001516105388a60400151610a96565b876060015161054a8960000151610a96565b8960200151610b30565b610564576001935050505061056c565b600093505050505b92915050565b61057a610f1c565b60405180604001604052807f0e418100f073ea28e62635436dfef6662084b9806ce0ad27b3613c937547afaf81526020017f2715cf4a1ab651aa12224d4d89ff7b6c7d52de41d685a8e3f858dbf7cf4bb86c8152508160000181905250604051806040016040528060405180604001604052807f2c45036fa487081f7dceff7fc25f21ecb503280d6709afeb2ef267062a17bfaa81526020017f2bfdb5e21864c4dd66403e22e27b177159a41d8d6083d242316f279cb402a6af815250815260200160405180604001604052807f19130dbec8ab7a1e680dfb30b1095362ac90bda4cc286b02f6dcf066814374ba81526020017f0fb951bad964841c50f4959173906e4ab9dcdb1e3d8ce23a608ce62dffc627b98152508152508160200181905250604051806040016040528060405180604001604052807f1b406529320c585cd88fc96b447bd4d2b2628684924d3308fe5a3da3fa7ef3b281526020017f2c610b42fc4ef3486859cf17c701911614d1ea8835766cc1c7b6b10105b9a91a815250815260200160405180604001604052807f1aebcf6a745eb8e2619df8459519a62585a525e9eb2e0d21a7860ab295dc83af81526020017f169479ce2e165fa60f74d9b2c9dbef898693bbd057d65a3dc71393bb267f4f538152508152508160400181905250604051806040016040528060405180604001604052807f117693772d6758fa5c40fb20e7da8014a16787a51dae05c9ce84eeaecc562d4781526020017f28cde745918425d0ff0aee33d9d9c40b0c55e17b3eb8f9349a535b854b6986e7815250815260200160405180604001604052807f1d3789e7c9fe3aa18efd584b0788dd6a6c9e096e6feefb17a3074ccb4603693581526020017f29ca1920396f97ba9604a61627e7c871d7784b8cfb05548e861d08cb3faa3c5d8152508152508160600181905250600260405190808252806020026020018201604052801561086157816020015b61084e610f7d565b8152602001906001900390816108465790505b50816080018190525060405180604001604052807f15069c841ae9a81471054e59a0f8368742cdb9e868f90697e25801f6919ba09c81526020017f14f48d7ef7fc76b76e45f96041c01a6d86a4f0ae1aa3811ddf97e73a483883da81525081608001516000815181106108d057fe5b602002602001018190525060405180604001604052807f2ca7396acba421c38c761d240608f70f49c28340c9fe8ae415767f10ddbf0f5d81526020017f09d0792a0b5f5242c6b39dd102d3a4fd5858cd8c93ce2d337f310a5c23f28862815250816080015160018151811061094157fe5b602002602001018190525090565b610957610f63565b61095f610f97565b83600001518160006003811061097157fe5b60200201818152505083602001518160016003811061098c57fe5b60200201818152505082816002600381106109a357fe5b6020020181815250506000606083608084600060076107d05a03f1905080600081146109ce576109d0565bfe5b50806109db57600080fd5b505092915050565b6109eb610f63565b6109f3610fb9565b836000015181600060048110610a0557fe5b602002018181525050836020015181600160048110610a2057fe5b602002018181525050826000015181600260048110610a3b57fe5b602002018181525050826020015181600360048110610a5657fe5b602002018181525050600060608360c084600060066107d05a03f190508060008114610a8157610a83565bfe5b5080610a8e57600080fd5b505092915050565b610a9e610f63565b60007f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47905060008360000151148015610adb575060008360200151145b15610aff576040518060400160405280600081526020016000815250915050610b2b565b60405180604001604052808460000151815260200182856020015181610b2157fe5b0683038152509150505b919050565b600060606004604051908082528060200260200182016040528015610b6f57816020015b610b5c610f7d565b815260200190600190039081610b545790505b50905060606004604051908082528060200260200182016040528015610baf57816020015b610b9c610fdb565b815260200190600190039081610b945790505b5090508a82600081518110610bc057fe5b60200260200101819052508882600181518110610bd957fe5b60200260200101819052508682600281518110610bf257fe5b60200260200101819052508482600381518110610c0b57fe5b60200260200101819052508981600081518110610c2457fe5b60200260200101819052508781600181518110610c3d57fe5b60200260200101819052508581600281518110610c5657fe5b60200260200101819052508381600381518110610c6f57fe5b6020026020010181905250610c848282610c94565b9250505098975050505050505050565b60008151835114610ca457600080fd5b6000835190506000600682029050606081604051908082528060200260200182016040528015610ce35781602001602082028038833980820191505090505b50905060008090505b83811015610e8957868181518110610d0057fe5b602002602001015160000151826000600684020181518110610d1e57fe5b602002602001018181525050868181518110610d3657fe5b602002602001015160200151826001600684020181518110610d5457fe5b602002602001018181525050858181518110610d6c57fe5b602002602001015160000151600060028110610d8457fe5b6020020151826002600684020181518110610d9b57fe5b602002602001018181525050858181518110610db357fe5b602002602001015160000151600160028110610dcb57fe5b6020020151826003600684020181518110610de257fe5b602002602001018181525050858181518110610dfa57fe5b602002602001015160200151600060028110610e1257fe5b6020020151826004600684020181518110610e2957fe5b602002602001018181525050858181518110610e4157fe5b602002602001015160200151600160028110610e5957fe5b6020020151826005600684020181518110610e7057fe5b6020026020010181815250508080600101915050610cec565b50610e92611001565b60006020826020860260208601600060086107d05a03f190508060008114610eb957610ebb565bfe5b5080610ec657600080fd5b600082600060018110610ed557fe5b602002015114159550505050505092915050565b6040518060600160405280610efc610f7d565b8152602001610f09610fdb565b8152602001610f16610f7d565b81525090565b6040518060a00160405280610f2f610f7d565b8152602001610f3c610fdb565b8152602001610f49610fdb565b8152602001610f56610fdb565b8152602001606081525090565b604051806040016040528060008152602001600081525090565b604051806040016040528060008152602001600081525090565b6040518060600160405280600390602082028038833980820191505090505090565b6040518060800160405280600490602082028038833980820191505090505090565b6040518060400160405280610fee611023565b8152602001610ffb611023565b81525090565b6040518060200160405280600190602082028038833980820191505090505090565b604051806040016040528060029060208202803883398082019150509050509056fe5472616e73616374696f6e207375636365737366756c6c792076657269666965642ea265627a7a72315820370d27c03786385e17679581219c564d5cab475959d2258e687395be7135499764736f6c634300050b0032") +var DeployedBytecode_SnarkProof = hex.MustDecodeString("608060405234801561001057600080fd5b506004361061002b5760003560e01c8063dd12931314610030575b600080fd5b61018f600480360361012081101561004757600080fd5b8101908080604001906002806020026040519081016040528092919082600260200280828437600081840152601f19601f82011690508083019250505050505091929192908060800190600280602002604051908101604052809291906000905b828210156100fc578382604002016002806020026040519081016040528092919082600260200280828437600081840152601f19601f820116905080830192505050505050815260200190600101906100a8565b50505050919291929080604001906002806020026040519081016040528092919082600260200280828437600081840152601f19601f820116905080830192505050505050919291929080602001906001806020026040519081016040528092919082600160200280828437600081840152601f19601f82011690508083019250505050505091929192905050506101b9565b604051808267ffffffffffffffff1667ffffffffffffffff16815260200191505060405180910390f35b60006101c3610ee9565b6040518060400160405280876000600281106101db57fe5b60200201518152602001876001600281106101f257fe5b60200201518152508160000181905250604051806040016040528060405180604001604052808860006002811061022557fe5b602002015160006002811061023657fe5b602002015181526020018860006002811061024d57fe5b602002015160016002811061025e57fe5b6020020151815250815260200160405180604001604052808860016002811061028357fe5b602002015160006002811061029457fe5b60200201518152602001886001600281106102ab57fe5b60200201516001600281106102bc57fe5b602002015181525081525081602001819052506040518060400160405280856000600281106102e757fe5b60200201518152602001856001600281106102fe57fe5b60200201518152508160400181905250606060016040519080825280602002602001820160405280156103405781602001602082028038833980820191505090505b50905060008090505b60018110156103885784816001811061035e57fe5b602002015182828151811061036f57fe5b6020026020010181815250508080600101915050610349565b5060006103958284610400565b14156103f1577f3f3cfdb26fb5f9f1786ab4f1a1f9cd4c0b5e726cbdfc26e495261731aad44e396040518080602001828103825260228152602001806110466022913960400191505060405180910390a16001925050506103f8565b6000925050505b949350505050565b6000807f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001905061042e610f1c565b610436610572565b905080608001515160018651011461044d57600080fd5b610455610f63565b6040518060400160405280600081526020016000815250905060008090505b86518110156104eb578387828151811061048a57fe5b60200260200101511061049c57600080fd5b6104dc826104d7856080015160018501815181106104b657fe5b60200260200101518a85815181106104ca57fe5b602002602001015161094f565b6109e3565b91508080600101915050610474565b5061050e81836080015160008151811061050157fe5b60200260200101516109e3565b90506105548560000151866020015161052684610a96565b85604001516105388a60400151610a96565b876060015161054a8960000151610a96565b8960200151610b30565b610564576001935050505061056c565b600093505050505b92915050565b61057a610f1c565b60405180604001604052807f0e418100f073ea28e62635436dfef6662084b9806ce0ad27b3613c937547afaf81526020017f2715cf4a1ab651aa12224d4d89ff7b6c7d52de41d685a8e3f858dbf7cf4bb86c8152508160000181905250604051806040016040528060405180604001604052807f2c45036fa487081f7dceff7fc25f21ecb503280d6709afeb2ef267062a17bfaa81526020017f2bfdb5e21864c4dd66403e22e27b177159a41d8d6083d242316f279cb402a6af815250815260200160405180604001604052807f19130dbec8ab7a1e680dfb30b1095362ac90bda4cc286b02f6dcf066814374ba81526020017f0fb951bad964841c50f4959173906e4ab9dcdb1e3d8ce23a608ce62dffc627b98152508152508160200181905250604051806040016040528060405180604001604052807f1b406529320c585cd88fc96b447bd4d2b2628684924d3308fe5a3da3fa7ef3b281526020017f2c610b42fc4ef3486859cf17c701911614d1ea8835766cc1c7b6b10105b9a91a815250815260200160405180604001604052807f1aebcf6a745eb8e2619df8459519a62585a525e9eb2e0d21a7860ab295dc83af81526020017f169479ce2e165fa60f74d9b2c9dbef898693bbd057d65a3dc71393bb267f4f538152508152508160400181905250604051806040016040528060405180604001604052807f117693772d6758fa5c40fb20e7da8014a16787a51dae05c9ce84eeaecc562d4781526020017f28cde745918425d0ff0aee33d9d9c40b0c55e17b3eb8f9349a535b854b6986e7815250815260200160405180604001604052807f1d3789e7c9fe3aa18efd584b0788dd6a6c9e096e6feefb17a3074ccb4603693581526020017f29ca1920396f97ba9604a61627e7c871d7784b8cfb05548e861d08cb3faa3c5d8152508152508160600181905250600260405190808252806020026020018201604052801561086157816020015b61084e610f7d565b8152602001906001900390816108465790505b50816080018190525060405180604001604052807f15069c841ae9a81471054e59a0f8368742cdb9e868f90697e25801f6919ba09c81526020017f14f48d7ef7fc76b76e45f96041c01a6d86a4f0ae1aa3811ddf97e73a483883da81525081608001516000815181106108d057fe5b602002602001018190525060405180604001604052807f2ca7396acba421c38c761d240608f70f49c28340c9fe8ae415767f10ddbf0f5d81526020017f09d0792a0b5f5242c6b39dd102d3a4fd5858cd8c93ce2d337f310a5c23f28862815250816080015160018151811061094157fe5b602002602001018190525090565b610957610f63565b61095f610f97565b83600001518160006003811061097157fe5b60200201818152505083602001518160016003811061098c57fe5b60200201818152505082816002600381106109a357fe5b6020020181815250506000606083608084600060076107d05a03f1905080600081146109ce576109d0565bfe5b50806109db57600080fd5b505092915050565b6109eb610f63565b6109f3610fb9565b836000015181600060048110610a0557fe5b602002018181525050836020015181600160048110610a2057fe5b602002018181525050826000015181600260048110610a3b57fe5b602002018181525050826020015181600360048110610a5657fe5b602002018181525050600060608360c084600060066107d05a03f190508060008114610a8157610a83565bfe5b5080610a8e57600080fd5b505092915050565b610a9e610f63565b60007f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47905060008360000151148015610adb575060008360200151145b15610aff576040518060400160405280600081526020016000815250915050610b2b565b60405180604001604052808460000151815260200182856020015181610b2157fe5b0683038152509150505b919050565b600060606004604051908082528060200260200182016040528015610b6f57816020015b610b5c610f7d565b815260200190600190039081610b545790505b50905060606004604051908082528060200260200182016040528015610baf57816020015b610b9c610fdb565b815260200190600190039081610b945790505b5090508a82600081518110610bc057fe5b60200260200101819052508882600181518110610bd957fe5b60200260200101819052508682600281518110610bf257fe5b60200260200101819052508482600381518110610c0b57fe5b60200260200101819052508981600081518110610c2457fe5b60200260200101819052508781600181518110610c3d57fe5b60200260200101819052508581600281518110610c5657fe5b60200260200101819052508381600381518110610c6f57fe5b6020026020010181905250610c848282610c94565b9250505098975050505050505050565b60008151835114610ca457600080fd5b6000835190506000600682029050606081604051908082528060200260200182016040528015610ce35781602001602082028038833980820191505090505b50905060008090505b83811015610e8957868181518110610d0057fe5b602002602001015160000151826000600684020181518110610d1e57fe5b602002602001018181525050868181518110610d3657fe5b602002602001015160200151826001600684020181518110610d5457fe5b602002602001018181525050858181518110610d6c57fe5b602002602001015160000151600060028110610d8457fe5b6020020151826002600684020181518110610d9b57fe5b602002602001018181525050858181518110610db357fe5b602002602001015160000151600160028110610dcb57fe5b6020020151826003600684020181518110610de257fe5b602002602001018181525050858181518110610dfa57fe5b602002602001015160200151600060028110610e1257fe5b6020020151826004600684020181518110610e2957fe5b602002602001018181525050858181518110610e4157fe5b602002602001015160200151600160028110610e5957fe5b6020020151826005600684020181518110610e7057fe5b6020026020010181815250508080600101915050610cec565b50610e92611001565b60006020826020860260208601600060086107d05a03f190508060008114610eb957610ebb565bfe5b5080610ec657600080fd5b600082600060018110610ed557fe5b602002015114159550505050505092915050565b6040518060600160405280610efc610f7d565b8152602001610f09610fdb565b8152602001610f16610f7d565b81525090565b6040518060a00160405280610f2f610f7d565b8152602001610f3c610fdb565b8152602001610f49610fdb565b8152602001610f56610fdb565b8152602001606081525090565b604051806040016040528060008152602001600081525090565b604051806040016040528060008152602001600081525090565b6040518060600160405280600390602082028038833980820191505090505090565b6040518060800160405280600490602082028038833980820191505090505090565b6040518060400160405280610fee611023565b8152602001610ffb611023565b81525090565b6040518060200160405280600190602082028038833980820191505090505090565b604051806040016040528060029060208202803883398082019150509050509056fe5472616e73616374696f6e207375636365737366756c6c792076657269666965642ea265627a7a72315820370d27c03786385e17679581219c564d5cab475959d2258e687395be7135499764736f6c634300050b0032") +var Abi_SnarkProof = []byte(`[ + { + "constant": false, + "inputs": [ + { + "internalType": "uint256[2]", + "name": "a", + "type": "uint256[2]" + }, + { + "internalType": "uint256[2][2]", + "name": "b", + "type": "uint256[2][2]" + }, + { + "internalType": "uint256[2]", + "name": "c", + "type": "uint256[2]" + }, + { + "internalType": "uint256[1]", + "name": "input", + "type": "uint256[1]" + } + ], + "name": "verifyTx", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "s", + "type": "string" + } + ], + "name": "Verified", + "type": "event" + } +]`) diff --git a/go.mod b/go.mod index a8569314a..03f3a8f09 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf // indirect github.com/btcsuite/btcd v0.0.0-20190523000118-16327141da8c github.com/cep21/xdgbasedir v0.0.0-20170329171747-21470bfc93b9 + github.com/clearmatics/bn256 v0.0.0-20190516154049-c6c2a2b131e6 github.com/eapache/channels v1.1.0 github.com/eapache/queue v1.1.0 // indirect github.com/elgs/gojq v0.0.0-20160421194050-81fa9a608a13 diff --git a/go.sum b/go.sum index 4faf39984..ca3cd84d4 100644 --- a/go.sum +++ b/go.sum @@ -35,6 +35,8 @@ github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46f github.com/cep21/xdgbasedir v0.0.0-20170329171747-21470bfc93b9 h1:Iy/9yf1PnKnwH8V0phEnqKE6aSIaqIZ+yn4PQgHF84E= github.com/cep21/xdgbasedir v0.0.0-20170329171747-21470bfc93b9/go.mod h1:6R3C29d3JonDKVjnlzFv5BGL/bfZP+0I7rKHKwiqKP8= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/clearmatics/bn256 v0.0.0-20190516154049-c6c2a2b131e6 h1:GcPwuT8CSZB1uGmNPGHefp/C1NwlcmnbhRBDniwFpTI= +github.com/clearmatics/bn256 v0.0.0-20190516154049-c6c2a2b131e6/go.mod h1:Vg/LC6++mrS0u5RhoUKUyP4B+0PuFvy/s8BjSL1PSwM= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= @@ -311,6 +313,7 @@ golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190306220234-b354f8bf4d9e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190516110030-61b9204099cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190825160603-fb81701db80f h1:LCxigP8q3fPRGNVYndYsyHnF0zRrvcoVwZMfb8iQZe4= golang.org/x/sys v0.0.0-20190825160603-fb81701db80f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=