diff --git a/Dockerfile b/Dockerfile index 481c1600..951d0e51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ ENV B 16 RUN apt-get update && apt-get -y install bison flex libgmp-dev libmpc-dev -RUN wget https://crypto.stanford.edu/pbc/files/pbc-0.5.14.tar.gz +RUN wget --no-check-certificate https://crypto.stanford.edu/pbc/files/pbc-0.5.14.tar.gz RUN tar -xvf pbc-0.5.14.tar.gz RUN cd pbc-0.5.14 && ./configure && make && make install diff --git a/honeybadgerbft/crypto/threshenc/go/main/client.go b/honeybadgerbft/crypto/threshenc/go/main/client.go new file mode 100644 index 00000000..2b4964db --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/go/main/client.go @@ -0,0 +1,83 @@ +package main + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "context" + "fmt" + + "github.com/apache/thrift/lib/go/thrift" + "github.com/vishalmohanty/encryption" +) + +var defaultCtx = context.Background() + +func handleClient(client *encryption.TPKEServiceClient) (err error) { +// client.Ping(defaultCtx) +// fmt.Println("ping()") + + ver_key := encryption.NewVerificationKeyThrift() + ver_key.Key = []byte{71, 111} + pub_key := encryption.NewTPKEPublicKeyThrift() + pub_key.L = 10 + pub_key.K = 5 + pub_key.VK = ver_key + pub_key.VKs = []*encryption.VerificationKeyThrift{ver_key} + +// val, err := client.Lagrange( +// defaultCtx, +// pub_key, +// []int32{0, 1}, +// 0, +// ) + val, err := client.Dealer(defaultCtx, 10, 5) + + if err != nil { +// switch v := err.(type) { +// case *tutorial.InvalidOperation: +// fmt.Println("Invalid operation:", v) +// default: + fmt.Println("Error during operation:", err) +// } + } else { + fmt.Println("Success! ", val) + } + return err +} + +func runClient(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, addr string, secure bool, cfg *thrift.TConfiguration) error { + var transport thrift.TTransport + if secure { + transport = thrift.NewTSSLSocketConf(addr, cfg) + } else { + transport = thrift.NewTSocketConf(addr, cfg) + } + transport, err := transportFactory.GetTransport(transport) + if err != nil { + return err + } + defer transport.Close() + if err := transport.Open(); err != nil { + return err + } + iprot := protocolFactory.GetProtocol(transport) + oprot := protocolFactory.GetProtocol(transport) + return handleClient(encryption.NewTPKEServiceClient(thrift.NewTStandardClient(iprot, oprot))) +} \ No newline at end of file diff --git a/honeybadgerbft/crypto/threshenc/go/main/go.mod b/honeybadgerbft/crypto/threshenc/go/main/go.mod new file mode 100644 index 00000000..43c242e9 --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/go/main/go.mod @@ -0,0 +1,7 @@ +module main + +go 1.17 + +require github.com/apache/thrift v0.16.0 +require "github.com/vishalmohanty/encryption" v0.0.0 +replace "github.com/vishalmohanty/encryption" v0.0.0 => "../../thrift/gen-go/encryption" diff --git a/honeybadgerbft/crypto/threshenc/go/main/go.sum b/honeybadgerbft/crypto/threshenc/go/main/go.sum new file mode 100644 index 00000000..d37f0dee --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/go/main/go.sum @@ -0,0 +1,15 @@ +github.com/apache/thrift v0.16.0 h1:qEy6UW60iVOlUy+b9ZR0d5WzUWYGOo4HfopoyBaNmoY= +github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= +github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/honeybadgerbft/crypto/threshenc/go/main/main b/honeybadgerbft/crypto/threshenc/go/main/main new file mode 100755 index 00000000..3d254183 Binary files /dev/null and b/honeybadgerbft/crypto/threshenc/go/main/main differ diff --git a/honeybadgerbft/crypto/threshenc/go/main/main.go b/honeybadgerbft/crypto/threshenc/go/main/main.go new file mode 100644 index 00000000..1175b9dd --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/go/main/main.go @@ -0,0 +1,83 @@ +package main + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "flag" + "fmt" + "os" + + "github.com/apache/thrift/lib/go/thrift" +) + +func Usage() { + fmt.Fprint(os.Stderr, "Usage of ", os.Args[0], ":\n") + flag.PrintDefaults() + fmt.Fprint(os.Stderr, "\n") +} + +func main() { + flag.Usage = Usage +// server := flag.Bool("server", false, "Run server") + protocol := flag.String("P", "binary", "Specify the protocol (binary, compact, json, simplejson)") + framed := flag.Bool("framed", false, "Use framed transport") + buffered := flag.Bool("buffered", false, "Use buffered transport") + addr := flag.String("addr", "localhost:9090", "Address to listen to") + secure := flag.Bool("secure", false, "Use tls secure transport") + + flag.Parse() + + var protocolFactory thrift.TProtocolFactory + switch *protocol { + case "compact": + protocolFactory = thrift.NewTCompactProtocolFactoryConf(nil) + case "simplejson": + protocolFactory = thrift.NewTSimpleJSONProtocolFactoryConf(nil) + case "json": + protocolFactory = thrift.NewTJSONProtocolFactory() + case "binary", "": + protocolFactory = thrift.NewTBinaryProtocolFactoryConf(nil) + default: + fmt.Fprint(os.Stderr, "Invalid protocol specified", protocol, "\n") + Usage() + os.Exit(1) + } + + var transportFactory thrift.TTransportFactory + cfg := &thrift.TConfiguration{ + TLSConfig: &tls.Config{ + InsecureSkipVerify: true, + }, + } + if *buffered { + transportFactory = thrift.NewTBufferedTransportFactory(8192) + } else { + transportFactory = thrift.NewTTransportFactory() + } + + if *framed { + transportFactory = thrift.NewTFramedTransportFactoryConf(transportFactory, cfg) + } + + if err := runClient(transportFactory, protocolFactory, *addr, *secure, cfg); err != nil { + fmt.Println("error running client:", err) + } +} diff --git a/honeybadgerbft/crypto/threshenc/py/python_encryption_handler.py b/honeybadgerbft/crypto/threshenc/py/python_encryption_handler.py new file mode 100644 index 00000000..97a5e680 --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/py/python_encryption_handler.py @@ -0,0 +1,116 @@ +import sys +sys.path.append('../../../crypto') + +import importlib +from python_encryption_helper import PythonEncryptionHelper +from threshenc.tpke import dealer, encrypt, decrypt + +encttypes = importlib.import_module("threshenc.thrift.gen-py.encryption.ttypes") + + +class PythonEncryptionHandler(PythonEncryptionHelper): + def __init__(self): + PythonEncryptionHelper.__init__(self) + + def lagrange(self, tpke_pub_key_thrift_info, S, j): + tpke_pub_key = \ + self.tpke_pub_key_from_thrift( + tpke_pub_key_thrift_info=tpke_pub_key_thrift_info, + ) + return tpke_pub_key.lagrange(S, j) + + def dealer(self, players, k): + public_key, private_keys = dealer( + players=players, + k=k + ) + return encttypes.DealerThrift( + PubKey=self.tpke_pub_key_to_thrift( + tpke_pub_key=public_key + ), + PrivKeys=[self.tpke_priv_key_to_thrift(priv_key) for priv_key in private_keys] + ) + + def encrypt(self, tpke_pub_key_thrift_info, m): + """ + Encrypt a 32 byte message. + + :return: (U,V,W) + """ + tpke_pub_key = \ + self.tpke_pub_key_from_thrift( + tpke_pub_key_thrift_info=tpke_pub_key_thrift_info, + ) + (U, V, W) = tpke_pub_key.encrypt(m) + return self.encryptedMessageToThrift( + U=U, + V=V, + W=W + ) + + def combineShares(self, tpke_pub_key_thrift_info, em, shares): + """ + Combine shares + tpke_pub_key_thrift_info: Public Key + em: Encrypted message + shares: map shares + + :rtype: binary + """ + tpke_pub_key = \ + self.tpke_pub_key_from_thrift( + tpke_pub_key_thrift_info=tpke_pub_key_thrift_info, + ) + U, V, W = self.encryptedMessageFromThrift(enc_msg_thrift_info=em) + return self.verification_key_to_thrift( + tpke_pub_key.combine_shares( + U=U, + V=V, + W=W, + shares=self.shares_from_thrift(shares=shares) + ) + ) + + def decryptShare(self, tpke_priv_key_thrift_info, em): + tpke_priv_key = \ + self.tpke_priv_key_from_thrift( + tpke_priv_key_thrift_info=tpke_priv_key_thrift_info + ) + U, V, W = self.encryptedMessageFromThrift(enc_msg_thrift_info=em) + return self.verification_key_to_thrift( + tpke_priv_key.decrypt_share(U, V, W) + ) + + def aesEncrypt(self, key, raw): + """AES Encrypt + key: public key + raw: message to be encrypted + + :return: encrypted binary bytes + """ + pub_key = self.aes_key_from_thrift( + aes_key_thrift_info=key + ) + message = self.aes_key_from_thrift( + aes_key_thrift_info=raw + ) + return self.aes_key_to_thrift( + aes_key=encrypt(key=pub_key, raw=message) + ) + + def aesDecrypt(self, key, enc): + """AES Decrypt + key: private key + raw: message to be decrypted + + :return: decrypted binary bytes + """ + priv_key = self.aes_key_from_thrift( + aes_key_thrift_info=key + ) + encrypted_message = self.aes_key_from_thrift( + aes_key_thrift_info=enc + ) + return self.aes_key_to_thrift( + aes_key=decrypt(key=priv_key, enc=encrypted_message) + ) diff --git a/honeybadgerbft/crypto/threshenc/py/python_encryption_helper.py b/honeybadgerbft/crypto/threshenc/py/python_encryption_helper.py new file mode 100644 index 00000000..9fafb8b2 --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/py/python_encryption_helper.py @@ -0,0 +1,103 @@ +"""Helper file to convert to and from thrift.""" +import sys +import importlib +from charm.toolbox.pairinggroup import PairingGroup +from base64 import encodestring, decodestring + +sys.path.append('../../../crypto') + + +from threshenc.tpke import TPKEPublicKey, TPKEPrivateKey + +encttypes = importlib.import_module("threshenc.thrift.gen-py.encryption.ttypes") +group = PairingGroup('SS512') + + +class PythonEncryptionHelper(object): + def __init__(self): + self.initialize = True + + def verification_key_from_thrift(self, ver_key_thrift_info): + return group.deserialize(encodestring(ver_key_thrift_info.key)) + + def verification_key_to_thrift(self, ver_key): + return encttypes.VerificationKeyThrift( + key=decodestring(group.serialize(ver_key)) + ) + + def aes_key_from_thrift(self, aes_key_thrift_info): + return decodestring(aes_key_thrift_info) + + def aes_key_to_thrift(self, aes_key): + return encodestring(aes_key) + + def tpke_pub_key_from_thrift(self, tpke_pub_key_thrift_info): + return TPKEPublicKey( + l=tpke_pub_key_thrift_info.l, + k=tpke_pub_key_thrift_info.k, + VK=self.verification_key_from_thrift(tpke_pub_key_thrift_info.VK), + VKs=[self.verification_key_from_thrift(x) for x in + tpke_pub_key_thrift_info.VKs] + ) + + def tpke_pub_key_to_thrift(self, tpke_pub_key): + return encttypes.TPKEPublicKeyThrift( + l=tpke_pub_key.l, + k=tpke_pub_key.k, + VK=self.verification_key_to_thrift(tpke_pub_key.VK), + VKs=[self.verification_key_to_thrift(x) for x in + tpke_pub_key.VKs] + ) + + def tpke_priv_key_from_thrift(self, tpke_priv_key_thrift_info): + return TPKEPrivateKey( + l=tpke_priv_key_thrift_info.PubKey.l, + k=tpke_priv_key_thrift_info.PubKey.k, + VK=self.verification_key_from_thrift(tpke_priv_key_thrift_info.PubKey.VK), + VKs=[self.verification_key_from_thrift(x) for x in + tpke_priv_key_thrift_info.PubKey.VKs], + SK=self.verification_key_from_thrift(tpke_priv_key_thrift_info.SK), + i=tpke_priv_key_thrift_info.i + ) + + def tpke_priv_key_to_thrift(self, tpke_priv_key): + return encttypes.TPKEPrivateKeyThrift( + PubKey=self.tpke_pub_key_to_thrift( + tpke_pub_key=TPKEPublicKey( + l=tpke_priv_key.l, + k=tpke_priv_key.k, + VK=tpke_priv_key.VK, + VKs=tpke_priv_key.VKs + ) + ), + SK=self.verification_key_to_thrift(tpke_priv_key.SK), + i=tpke_priv_key.i + ) + + def encryptedMessageFromThrift(self, enc_msg_thrift_info): + U = self.verification_key_from_thrift(enc_msg_thrift_info.U) + V = decodestring(enc_msg_thrift_info.V) + W = self.verification_key_from_thrift(enc_msg_thrift_info.W) + return U, V, W + + def encryptedMessageToThrift(self, U, V, W): + UThrift = self.verification_key_to_thrift(U) + VThrift = encodestring(V) + WThrift = self.verification_key_to_thrift(W) + return encttypes.EncryptedMessageThrift( + U=UThrift, + V=VThrift, + W=WThrift + ) + + def shares_from_thrift(self, shares): + shares_dict = {} + for idx, share in shares.items(): + shares_dict[idx] = self.verification_key_from_thrift(share) + return shares_dict + + def shares_to_thrift(self, shares): + shares_dict = {} + for idx, share in shares.items(): + shares_dict[idx] = self.verification_key_to_thrift(share) + return shares_dict diff --git a/honeybadgerbft/crypto/threshenc/py/python_encryption_server.py b/honeybadgerbft/crypto/threshenc/py/python_encryption_server.py new file mode 100644 index 00000000..5636ca47 --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/py/python_encryption_server.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +import sys +# your gen-py dir +sys.path.append('../thrift/gen-py') + +import argparse + +from thrift.protocol import TBinaryProtocol +from thrift.server import TServer +from thrift.transport import TSocket +from thrift.transport import TTransport + +from python_encryption_handler import PythonEncryptionHandler +from encryption import TPKEService + +PYTHON_ENCRYPTION_DEFAULT_PORT = 9090 + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Python encryption server') + parser.add_argument('--port', + type=int, + default=PYTHON_ENCRYPTION_DEFAULT_PORT, + help='Python Encryption Server port') + parsed_args = parser.parse_args() + port = parsed_args.port + + handler = PythonEncryptionHandler() + processor = TPKEService.Processor(handler) + transport = TSocket.TServerSocket(port=port) + tfactory = TTransport.TBufferedTransportFactory() + pfactory = TBinaryProtocol.TBinaryProtocolFactory() + + server = TServer.TSimpleServer(processor, transport, tfactory, pfactory) + + # You could do one of these for a multithreaded server + # server = TServer.TThreadedServer( + # processor, transport, tfactory, pfactory) + # server = TServer.TThreadPoolServer( + # processor, transport, tfactory, pfactory) + + print('Starting the server...') + server.serve() + print('done.') \ No newline at end of file diff --git a/honeybadgerbft/crypto/threshenc/thrift/encryption.thrift b/honeybadgerbft/crypto/threshenc/thrift/encryption.thrift new file mode 100644 index 00000000..1145e0e1 --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/thrift/encryption.thrift @@ -0,0 +1,72 @@ +namespace py encryption +namespace go encryption + +struct VerificationKeyThrift { + 1: required binary key +} + +struct PrivateKeyThrift { + 1: required binary key +} + +struct EncryptedMessageThrift { + 1: required binary U, + 2: required binary V, + 3: required binary W +} + +struct TPKEPublicKeyThrift { + 1: required i32 l, + 2: required i32 k, + 3: required VerificationKeyThrift VK, + 4: required list VKs, +} + +struct TPKEPrivateKeyThrift { + 1: required TPKEPublicKeyThrift PubKey, + 2: required PrivateKeyThrift SK, + 3: required i32 i +} + +struct DealerThrift { + 1: required TPKEPublicKeyThrift PubKey, + 2: required list PrivKeys +} + +struct AESKey { + 1: required binary key +} + +service TPKEService { + i32 lagrange( + 1: TPKEPublicKeyThrift PubKey, + 2: set S, + 3: i32 j + ), + EncryptedMessageThrift encrypt( + 1: TPKEPublicKeyThrift PubKey, + 2: string m + ), + binary combineShares( + 1: TPKEPublicKeyThrift PubKey, + 2: EncryptedMessageThrift em, + 3: map shares + ), + binary decryptShare( + 1: TPKEPrivateKeyThrift PrivKey, + 2: EncryptedMessageThrift em + ), + DealerThrift dealer( + 1: i32 players, + 2: i32 k + ), + binary aesEncrypt( + 1: AESKey key, + 2: binary raw + ), + binary aesDecrypt( + 1: AESKey key, + 2: binary encMes + ) +} + diff --git a/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/GoUnusedProtection__.go b/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/GoUnusedProtection__.go new file mode 100644 index 00000000..2ed9e388 --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/GoUnusedProtection__.go @@ -0,0 +1,6 @@ +// Code generated by Thrift Compiler (0.16.0). DO NOT EDIT. + +package encryption + +var GoUnusedProtection__ int; + diff --git a/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/encryption-consts.go b/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/encryption-consts.go new file mode 100644 index 00000000..dba6fbef --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/encryption-consts.go @@ -0,0 +1,23 @@ +// Code generated by Thrift Compiler (0.16.0). DO NOT EDIT. + +package encryption + +import ( + "bytes" + "context" + "fmt" + "time" + thrift "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = context.Background +var _ = time.Now +var _ = bytes.Equal + + +func init() { +} + diff --git a/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/encryption.go b/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/encryption.go new file mode 100644 index 00000000..932298bf --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/encryption.go @@ -0,0 +1,3744 @@ +// Code generated by Thrift Compiler (0.16.0). DO NOT EDIT. + +package encryption + +import ( + "bytes" + "context" + "fmt" + "time" + thrift "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = context.Background +var _ = time.Now +var _ = bytes.Equal + +// Attributes: +// - Key +type VerificationKeyThrift struct { + Key []byte `thrift:"key,1,required" db:"key" json:"key"` +} + +func NewVerificationKeyThrift() *VerificationKeyThrift { + return &VerificationKeyThrift{} +} + + +func (p *VerificationKeyThrift) GetKey() []byte { + return p.Key +} +func (p *VerificationKeyThrift) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + var issetKey bool = false; + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + issetKey = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + if !issetKey{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Key is not set")); + } + return nil +} + +func (p *VerificationKeyThrift) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Key = v +} + return nil +} + +func (p *VerificationKeyThrift) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "VerificationKeyThrift"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *VerificationKeyThrift) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := oprot.WriteBinary(ctx, p.Key); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.key (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *VerificationKeyThrift) Equals(other *VerificationKeyThrift) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if bytes.Compare(p.Key, other.Key) != 0 { return false } + return true +} + +func (p *VerificationKeyThrift) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("VerificationKeyThrift(%+v)", *p) +} + +// Attributes: +// - Key +type PrivateKeyThrift struct { + Key []byte `thrift:"key,1,required" db:"key" json:"key"` +} + +func NewPrivateKeyThrift() *PrivateKeyThrift { + return &PrivateKeyThrift{} +} + + +func (p *PrivateKeyThrift) GetKey() []byte { + return p.Key +} +func (p *PrivateKeyThrift) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + var issetKey bool = false; + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + issetKey = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + if !issetKey{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Key is not set")); + } + return nil +} + +func (p *PrivateKeyThrift) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Key = v +} + return nil +} + +func (p *PrivateKeyThrift) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "PrivateKeyThrift"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *PrivateKeyThrift) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := oprot.WriteBinary(ctx, p.Key); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.key (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *PrivateKeyThrift) Equals(other *PrivateKeyThrift) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if bytes.Compare(p.Key, other.Key) != 0 { return false } + return true +} + +func (p *PrivateKeyThrift) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PrivateKeyThrift(%+v)", *p) +} + +// Attributes: +// - U +// - V +// - W +type EncryptedMessageThrift struct { + U []byte `thrift:"U,1,required" db:"U" json:"U"` + V []byte `thrift:"V,2,required" db:"V" json:"V"` + W []byte `thrift:"W,3,required" db:"W" json:"W"` +} + +func NewEncryptedMessageThrift() *EncryptedMessageThrift { + return &EncryptedMessageThrift{} +} + + +func (p *EncryptedMessageThrift) GetU() []byte { + return p.U +} + +func (p *EncryptedMessageThrift) GetV() []byte { + return p.V +} + +func (p *EncryptedMessageThrift) GetW() []byte { + return p.W +} +func (p *EncryptedMessageThrift) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + var issetU bool = false; + var issetV bool = false; + var issetW bool = false; + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + issetU = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + issetV = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRING { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + issetW = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + if !issetU{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field U is not set")); + } + if !issetV{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field V is not set")); + } + if !issetW{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field W is not set")); + } + return nil +} + +func (p *EncryptedMessageThrift) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.U = v +} + return nil +} + +func (p *EncryptedMessageThrift) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.V = v +} + return nil +} + +func (p *EncryptedMessageThrift) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.W = v +} + return nil +} + +func (p *EncryptedMessageThrift) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "EncryptedMessageThrift"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *EncryptedMessageThrift) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "U", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:U: ", p), err) } + if err := oprot.WriteBinary(ctx, p.U); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.U (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:U: ", p), err) } + return err +} + +func (p *EncryptedMessageThrift) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "V", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:V: ", p), err) } + if err := oprot.WriteBinary(ctx, p.V); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.V (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:V: ", p), err) } + return err +} + +func (p *EncryptedMessageThrift) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "W", thrift.STRING, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:W: ", p), err) } + if err := oprot.WriteBinary(ctx, p.W); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.W (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:W: ", p), err) } + return err +} + +func (p *EncryptedMessageThrift) Equals(other *EncryptedMessageThrift) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if bytes.Compare(p.U, other.U) != 0 { return false } + if bytes.Compare(p.V, other.V) != 0 { return false } + if bytes.Compare(p.W, other.W) != 0 { return false } + return true +} + +func (p *EncryptedMessageThrift) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EncryptedMessageThrift(%+v)", *p) +} + +// Attributes: +// - L +// - K +// - VK +// - VKs +type TPKEPublicKeyThrift struct { + L int32 `thrift:"l,1,required" db:"l" json:"l"` + K int32 `thrift:"k,2,required" db:"k" json:"k"` + VK *VerificationKeyThrift `thrift:"VK,3,required" db:"VK" json:"VK"` + VKs []*VerificationKeyThrift `thrift:"VKs,4,required" db:"VKs" json:"VKs"` +} + +func NewTPKEPublicKeyThrift() *TPKEPublicKeyThrift { + return &TPKEPublicKeyThrift{} +} + + +func (p *TPKEPublicKeyThrift) GetL() int32 { + return p.L +} + +func (p *TPKEPublicKeyThrift) GetK() int32 { + return p.K +} +var TPKEPublicKeyThrift_VK_DEFAULT *VerificationKeyThrift +func (p *TPKEPublicKeyThrift) GetVK() *VerificationKeyThrift { + if !p.IsSetVK() { + return TPKEPublicKeyThrift_VK_DEFAULT + } +return p.VK +} + +func (p *TPKEPublicKeyThrift) GetVKs() []*VerificationKeyThrift { + return p.VKs +} +func (p *TPKEPublicKeyThrift) IsSetVK() bool { + return p.VK != nil +} + +func (p *TPKEPublicKeyThrift) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + var issetL bool = false; + var issetK bool = false; + var issetVK bool = false; + var issetVKs bool = false; + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + issetL = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I32 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + issetK = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + issetVK = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.LIST { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + issetVKs = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + if !issetL{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field L is not set")); + } + if !issetK{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field K is not set")); + } + if !issetVK{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field VK is not set")); + } + if !issetVKs{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field VKs is not set")); + } + return nil +} + +func (p *TPKEPublicKeyThrift) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.L = v +} + return nil +} + +func (p *TPKEPublicKeyThrift) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.K = v +} + return nil +} + +func (p *TPKEPublicKeyThrift) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + p.VK = &VerificationKeyThrift{} + if err := p.VK.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.VK), err) + } + return nil +} + +func (p *TPKEPublicKeyThrift) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]*VerificationKeyThrift, 0, size) + p.VKs = tSlice + for i := 0; i < size; i ++ { + _elem0 := &VerificationKeyThrift{} + if err := _elem0.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem0), err) + } + p.VKs = append(p.VKs, _elem0) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *TPKEPublicKeyThrift) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "TPKEPublicKeyThrift"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEPublicKeyThrift) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "l", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:l: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.L)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.l (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:l: ", p), err) } + return err +} + +func (p *TPKEPublicKeyThrift) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "k", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:k: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.K)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.k (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:k: ", p), err) } + return err +} + +func (p *TPKEPublicKeyThrift) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "VK", thrift.STRUCT, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:VK: ", p), err) } + if err := p.VK.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.VK), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:VK: ", p), err) } + return err +} + +func (p *TPKEPublicKeyThrift) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "VKs", thrift.LIST, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:VKs: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.VKs)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.VKs { + if err := v.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) + } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:VKs: ", p), err) } + return err +} + +func (p *TPKEPublicKeyThrift) Equals(other *TPKEPublicKeyThrift) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.L != other.L { return false } + if p.K != other.K { return false } + if !p.VK.Equals(other.VK) { return false } + if len(p.VKs) != len(other.VKs) { return false } + for i, _tgt := range p.VKs { + _src1 := other.VKs[i] + if !_tgt.Equals(_src1) { return false } + } + return true +} + +func (p *TPKEPublicKeyThrift) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEPublicKeyThrift(%+v)", *p) +} + +// Attributes: +// - PubKey +// - SK +// - I +type TPKEPrivateKeyThrift struct { + PubKey *TPKEPublicKeyThrift `thrift:"PubKey,1,required" db:"PubKey" json:"PubKey"` + SK *PrivateKeyThrift `thrift:"SK,2,required" db:"SK" json:"SK"` + I int32 `thrift:"i,3,required" db:"i" json:"i"` +} + +func NewTPKEPrivateKeyThrift() *TPKEPrivateKeyThrift { + return &TPKEPrivateKeyThrift{} +} + +var TPKEPrivateKeyThrift_PubKey_DEFAULT *TPKEPublicKeyThrift +func (p *TPKEPrivateKeyThrift) GetPubKey() *TPKEPublicKeyThrift { + if !p.IsSetPubKey() { + return TPKEPrivateKeyThrift_PubKey_DEFAULT + } +return p.PubKey +} +var TPKEPrivateKeyThrift_SK_DEFAULT *PrivateKeyThrift +func (p *TPKEPrivateKeyThrift) GetSK() *PrivateKeyThrift { + if !p.IsSetSK() { + return TPKEPrivateKeyThrift_SK_DEFAULT + } +return p.SK +} + +func (p *TPKEPrivateKeyThrift) GetI() int32 { + return p.I +} +func (p *TPKEPrivateKeyThrift) IsSetPubKey() bool { + return p.PubKey != nil +} + +func (p *TPKEPrivateKeyThrift) IsSetSK() bool { + return p.SK != nil +} + +func (p *TPKEPrivateKeyThrift) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + var issetPubKey bool = false; + var issetSK bool = false; + var issetI bool = false; + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + issetPubKey = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + issetSK = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I32 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + issetI = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + if !issetPubKey{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field PubKey is not set")); + } + if !issetSK{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field SK is not set")); + } + if !issetI{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field I is not set")); + } + return nil +} + +func (p *TPKEPrivateKeyThrift) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.PubKey = &TPKEPublicKeyThrift{} + if err := p.PubKey.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PubKey), err) + } + return nil +} + +func (p *TPKEPrivateKeyThrift) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.SK = &PrivateKeyThrift{} + if err := p.SK.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.SK), err) + } + return nil +} + +func (p *TPKEPrivateKeyThrift) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.I = v +} + return nil +} + +func (p *TPKEPrivateKeyThrift) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "TPKEPrivateKeyThrift"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEPrivateKeyThrift) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "PubKey", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:PubKey: ", p), err) } + if err := p.PubKey.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PubKey), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:PubKey: ", p), err) } + return err +} + +func (p *TPKEPrivateKeyThrift) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "SK", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:SK: ", p), err) } + if err := p.SK.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.SK), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:SK: ", p), err) } + return err +} + +func (p *TPKEPrivateKeyThrift) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "i", thrift.I32, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:i: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.I)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.i (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:i: ", p), err) } + return err +} + +func (p *TPKEPrivateKeyThrift) Equals(other *TPKEPrivateKeyThrift) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.PubKey.Equals(other.PubKey) { return false } + if !p.SK.Equals(other.SK) { return false } + if p.I != other.I { return false } + return true +} + +func (p *TPKEPrivateKeyThrift) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEPrivateKeyThrift(%+v)", *p) +} + +// Attributes: +// - PubKey +// - PrivKeys +type DealerThrift struct { + PubKey *TPKEPublicKeyThrift `thrift:"PubKey,1,required" db:"PubKey" json:"PubKey"` + PrivKeys []*TPKEPrivateKeyThrift `thrift:"PrivKeys,2,required" db:"PrivKeys" json:"PrivKeys"` +} + +func NewDealerThrift() *DealerThrift { + return &DealerThrift{} +} + +var DealerThrift_PubKey_DEFAULT *TPKEPublicKeyThrift +func (p *DealerThrift) GetPubKey() *TPKEPublicKeyThrift { + if !p.IsSetPubKey() { + return DealerThrift_PubKey_DEFAULT + } +return p.PubKey +} + +func (p *DealerThrift) GetPrivKeys() []*TPKEPrivateKeyThrift { + return p.PrivKeys +} +func (p *DealerThrift) IsSetPubKey() bool { + return p.PubKey != nil +} + +func (p *DealerThrift) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + var issetPubKey bool = false; + var issetPrivKeys bool = false; + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + issetPubKey = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.LIST { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + issetPrivKeys = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + if !issetPubKey{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field PubKey is not set")); + } + if !issetPrivKeys{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field PrivKeys is not set")); + } + return nil +} + +func (p *DealerThrift) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.PubKey = &TPKEPublicKeyThrift{} + if err := p.PubKey.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PubKey), err) + } + return nil +} + +func (p *DealerThrift) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]*TPKEPrivateKeyThrift, 0, size) + p.PrivKeys = tSlice + for i := 0; i < size; i ++ { + _elem2 := &TPKEPrivateKeyThrift{} + if err := _elem2.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem2), err) + } + p.PrivKeys = append(p.PrivKeys, _elem2) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *DealerThrift) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "DealerThrift"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *DealerThrift) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "PubKey", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:PubKey: ", p), err) } + if err := p.PubKey.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PubKey), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:PubKey: ", p), err) } + return err +} + +func (p *DealerThrift) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "PrivKeys", thrift.LIST, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:PrivKeys: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.PrivKeys)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.PrivKeys { + if err := v.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) + } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:PrivKeys: ", p), err) } + return err +} + +func (p *DealerThrift) Equals(other *DealerThrift) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.PubKey.Equals(other.PubKey) { return false } + if len(p.PrivKeys) != len(other.PrivKeys) { return false } + for i, _tgt := range p.PrivKeys { + _src3 := other.PrivKeys[i] + if !_tgt.Equals(_src3) { return false } + } + return true +} + +func (p *DealerThrift) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("DealerThrift(%+v)", *p) +} + +// Attributes: +// - Key +type AESKey struct { + Key []byte `thrift:"key,1,required" db:"key" json:"key"` +} + +func NewAESKey() *AESKey { + return &AESKey{} +} + + +func (p *AESKey) GetKey() []byte { + return p.Key +} +func (p *AESKey) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + var issetKey bool = false; + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + issetKey = true + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + if !issetKey{ + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Key is not set")); + } + return nil +} + +func (p *AESKey) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Key = v +} + return nil +} + +func (p *AESKey) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "AESKey"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AESKey) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := oprot.WriteBinary(ctx, p.Key); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.key (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *AESKey) Equals(other *AESKey) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if bytes.Compare(p.Key, other.Key) != 0 { return false } + return true +} + +func (p *AESKey) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AESKey(%+v)", *p) +} + +type TPKEService interface { + // Parameters: + // - PubKey + // - S + // - J + Lagrange(ctx context.Context, PubKey *TPKEPublicKeyThrift, S []int32, j int32) (_r int32, _err error) + // Parameters: + // - PubKey + // - M + Encrypt(ctx context.Context, PubKey *TPKEPublicKeyThrift, m string) (_r *EncryptedMessageThrift, _err error) + // Parameters: + // - PubKey + // - Em + // - Shares + CombineShares(ctx context.Context, PubKey *TPKEPublicKeyThrift, em *EncryptedMessageThrift, shares map[int32][]byte) (_r []byte, _err error) + // Parameters: + // - PrivKey + // - Em + DecryptShare(ctx context.Context, PrivKey *TPKEPrivateKeyThrift, em *EncryptedMessageThrift) (_r []byte, _err error) + // Parameters: + // - Players + // - K + Dealer(ctx context.Context, players int32, k int32) (_r *DealerThrift, _err error) + // Parameters: + // - Key + // - Raw + AesEncrypt(ctx context.Context, key *AESKey, raw []byte) (_r []byte, _err error) + // Parameters: + // - Key + // - EncMes + AesDecrypt(ctx context.Context, key *AESKey, encMes []byte) (_r []byte, _err error) +} + +type TPKEServiceClient struct { + c thrift.TClient + meta thrift.ResponseMeta +} + +func NewTPKEServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *TPKEServiceClient { + return &TPKEServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewTPKEServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *TPKEServiceClient { + return &TPKEServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewTPKEServiceClient(c thrift.TClient) *TPKEServiceClient { + return &TPKEServiceClient{ + c: c, + } +} + +func (p *TPKEServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *TPKEServiceClient) LastResponseMeta_() thrift.ResponseMeta { + return p.meta +} + +func (p *TPKEServiceClient) SetLastResponseMeta_(meta thrift.ResponseMeta) { + p.meta = meta +} + +// Parameters: +// - PubKey +// - S +// - J +func (p *TPKEServiceClient) Lagrange(ctx context.Context, PubKey *TPKEPublicKeyThrift, S []int32, j int32) (_r int32, _err error) { + var _args4 TPKEServiceLagrangeArgs + _args4.PubKey = PubKey + _args4.S = S + _args4.J = j + var _result6 TPKEServiceLagrangeResult + var _meta5 thrift.ResponseMeta + _meta5, _err = p.Client_().Call(ctx, "lagrange", &_args4, &_result6) + p.SetLastResponseMeta_(_meta5) + if _err != nil { + return + } + return _result6.GetSuccess(), nil +} + +// Parameters: +// - PubKey +// - M +func (p *TPKEServiceClient) Encrypt(ctx context.Context, PubKey *TPKEPublicKeyThrift, m string) (_r *EncryptedMessageThrift, _err error) { + var _args7 TPKEServiceEncryptArgs + _args7.PubKey = PubKey + _args7.M = m + var _result9 TPKEServiceEncryptResult + var _meta8 thrift.ResponseMeta + _meta8, _err = p.Client_().Call(ctx, "encrypt", &_args7, &_result9) + p.SetLastResponseMeta_(_meta8) + if _err != nil { + return + } + if _ret10 := _result9.GetSuccess(); _ret10 != nil { + return _ret10, nil + } + return nil, thrift.NewTApplicationException(thrift.MISSING_RESULT, "encrypt failed: unknown result") +} + +// Parameters: +// - PubKey +// - Em +// - Shares +func (p *TPKEServiceClient) CombineShares(ctx context.Context, PubKey *TPKEPublicKeyThrift, em *EncryptedMessageThrift, shares map[int32][]byte) (_r []byte, _err error) { + var _args11 TPKEServiceCombineSharesArgs + _args11.PubKey = PubKey + _args11.Em = em + _args11.Shares = shares + var _result13 TPKEServiceCombineSharesResult + var _meta12 thrift.ResponseMeta + _meta12, _err = p.Client_().Call(ctx, "combineShares", &_args11, &_result13) + p.SetLastResponseMeta_(_meta12) + if _err != nil { + return + } + return _result13.GetSuccess(), nil +} + +// Parameters: +// - PrivKey +// - Em +func (p *TPKEServiceClient) DecryptShare(ctx context.Context, PrivKey *TPKEPrivateKeyThrift, em *EncryptedMessageThrift) (_r []byte, _err error) { + var _args14 TPKEServiceDecryptShareArgs + _args14.PrivKey = PrivKey + _args14.Em = em + var _result16 TPKEServiceDecryptShareResult + var _meta15 thrift.ResponseMeta + _meta15, _err = p.Client_().Call(ctx, "decryptShare", &_args14, &_result16) + p.SetLastResponseMeta_(_meta15) + if _err != nil { + return + } + return _result16.GetSuccess(), nil +} + +// Parameters: +// - Players +// - K +func (p *TPKEServiceClient) Dealer(ctx context.Context, players int32, k int32) (_r *DealerThrift, _err error) { + var _args17 TPKEServiceDealerArgs + _args17.Players = players + _args17.K = k + var _result19 TPKEServiceDealerResult + var _meta18 thrift.ResponseMeta + _meta18, _err = p.Client_().Call(ctx, "dealer", &_args17, &_result19) + p.SetLastResponseMeta_(_meta18) + if _err != nil { + return + } + if _ret20 := _result19.GetSuccess(); _ret20 != nil { + return _ret20, nil + } + return nil, thrift.NewTApplicationException(thrift.MISSING_RESULT, "dealer failed: unknown result") +} + +// Parameters: +// - Key +// - Raw +func (p *TPKEServiceClient) AesEncrypt(ctx context.Context, key *AESKey, raw []byte) (_r []byte, _err error) { + var _args21 TPKEServiceAesEncryptArgs + _args21.Key = key + _args21.Raw = raw + var _result23 TPKEServiceAesEncryptResult + var _meta22 thrift.ResponseMeta + _meta22, _err = p.Client_().Call(ctx, "aesEncrypt", &_args21, &_result23) + p.SetLastResponseMeta_(_meta22) + if _err != nil { + return + } + return _result23.GetSuccess(), nil +} + +// Parameters: +// - Key +// - EncMes +func (p *TPKEServiceClient) AesDecrypt(ctx context.Context, key *AESKey, encMes []byte) (_r []byte, _err error) { + var _args24 TPKEServiceAesDecryptArgs + _args24.Key = key + _args24.EncMes = encMes + var _result26 TPKEServiceAesDecryptResult + var _meta25 thrift.ResponseMeta + _meta25, _err = p.Client_().Call(ctx, "aesDecrypt", &_args24, &_result26) + p.SetLastResponseMeta_(_meta25) + if _err != nil { + return + } + return _result26.GetSuccess(), nil +} + +type TPKEServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler TPKEService +} + +func (p *TPKEServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *TPKEServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *TPKEServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewTPKEServiceProcessor(handler TPKEService) *TPKEServiceProcessor { + + self27 := &TPKEServiceProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)} + self27.processorMap["lagrange"] = &tPKEServiceProcessorLagrange{handler:handler} + self27.processorMap["encrypt"] = &tPKEServiceProcessorEncrypt{handler:handler} + self27.processorMap["combineShares"] = &tPKEServiceProcessorCombineShares{handler:handler} + self27.processorMap["decryptShare"] = &tPKEServiceProcessorDecryptShare{handler:handler} + self27.processorMap["dealer"] = &tPKEServiceProcessorDealer{handler:handler} + self27.processorMap["aesEncrypt"] = &tPKEServiceProcessorAesEncrypt{handler:handler} + self27.processorMap["aesDecrypt"] = &tPKEServiceProcessorAesDecrypt{handler:handler} +return self27 +} + +func (p *TPKEServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err2 := iprot.ReadMessageBegin(ctx) + if err2 != nil { return false, thrift.WrapTException(err2) } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(ctx, thrift.STRUCT) + iprot.ReadMessageEnd(ctx) + x28 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name) + oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId) + x28.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, x28 + +} + +type tPKEServiceProcessorLagrange struct { + handler TPKEService +} + +func (p *tPKEServiceProcessorLagrange) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := TPKEServiceLagrangeArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "lagrange", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := TPKEServiceLagrangeResult{} + var retval int32 + if retval, err2 = p.handler.Lagrange(ctx, args.PubKey, args.S, args.J); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing lagrange: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "lagrange", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = &retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "lagrange", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type tPKEServiceProcessorEncrypt struct { + handler TPKEService +} + +func (p *tPKEServiceProcessorEncrypt) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := TPKEServiceEncryptArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "encrypt", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := TPKEServiceEncryptResult{} + var retval *EncryptedMessageThrift + if retval, err2 = p.handler.Encrypt(ctx, args.PubKey, args.M); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing encrypt: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "encrypt", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "encrypt", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type tPKEServiceProcessorCombineShares struct { + handler TPKEService +} + +func (p *tPKEServiceProcessorCombineShares) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := TPKEServiceCombineSharesArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "combineShares", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := TPKEServiceCombineSharesResult{} + var retval []byte + if retval, err2 = p.handler.CombineShares(ctx, args.PubKey, args.Em, args.Shares); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing combineShares: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "combineShares", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "combineShares", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type tPKEServiceProcessorDecryptShare struct { + handler TPKEService +} + +func (p *tPKEServiceProcessorDecryptShare) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := TPKEServiceDecryptShareArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "decryptShare", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := TPKEServiceDecryptShareResult{} + var retval []byte + if retval, err2 = p.handler.DecryptShare(ctx, args.PrivKey, args.Em); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing decryptShare: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "decryptShare", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "decryptShare", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type tPKEServiceProcessorDealer struct { + handler TPKEService +} + +func (p *tPKEServiceProcessorDealer) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := TPKEServiceDealerArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "dealer", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := TPKEServiceDealerResult{} + var retval *DealerThrift + if retval, err2 = p.handler.Dealer(ctx, args.Players, args.K); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing dealer: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "dealer", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "dealer", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type tPKEServiceProcessorAesEncrypt struct { + handler TPKEService +} + +func (p *tPKEServiceProcessorAesEncrypt) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := TPKEServiceAesEncryptArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "aesEncrypt", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := TPKEServiceAesEncryptResult{} + var retval []byte + if retval, err2 = p.handler.AesEncrypt(ctx, args.Key, args.Raw); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing aesEncrypt: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "aesEncrypt", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "aesEncrypt", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type tPKEServiceProcessorAesDecrypt struct { + handler TPKEService +} + +func (p *tPKEServiceProcessorAesDecrypt) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := TPKEServiceAesDecryptArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "aesDecrypt", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := TPKEServiceAesDecryptResult{} + var retval []byte + if retval, err2 = p.handler.AesDecrypt(ctx, args.Key, args.EncMes); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing aesDecrypt: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "aesDecrypt", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "aesDecrypt", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + + +// HELPER FUNCTIONS AND STRUCTURES + +// Attributes: +// - PubKey +// - S +// - J +type TPKEServiceLagrangeArgs struct { + PubKey *TPKEPublicKeyThrift `thrift:"PubKey,1" db:"PubKey" json:"PubKey"` + S []int32 `thrift:"S,2" db:"S" json:"S"` + J int32 `thrift:"j,3" db:"j" json:"j"` +} + +func NewTPKEServiceLagrangeArgs() *TPKEServiceLagrangeArgs { + return &TPKEServiceLagrangeArgs{} +} + +var TPKEServiceLagrangeArgs_PubKey_DEFAULT *TPKEPublicKeyThrift +func (p *TPKEServiceLagrangeArgs) GetPubKey() *TPKEPublicKeyThrift { + if !p.IsSetPubKey() { + return TPKEServiceLagrangeArgs_PubKey_DEFAULT + } +return p.PubKey +} + +func (p *TPKEServiceLagrangeArgs) GetS() []int32 { + return p.S +} + +func (p *TPKEServiceLagrangeArgs) GetJ() int32 { + return p.J +} +func (p *TPKEServiceLagrangeArgs) IsSetPubKey() bool { + return p.PubKey != nil +} + +func (p *TPKEServiceLagrangeArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.SET { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I32 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceLagrangeArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.PubKey = &TPKEPublicKeyThrift{} + if err := p.PubKey.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PubKey), err) + } + return nil +} + +func (p *TPKEServiceLagrangeArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]int32, 0, size) + p.S = tSet + for i := 0; i < size; i ++ { +var _elem29 int32 + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _elem29 = v +} + p.S = append(p.S, _elem29) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *TPKEServiceLagrangeArgs) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.J = v +} + return nil +} + +func (p *TPKEServiceLagrangeArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "lagrange_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceLagrangeArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "PubKey", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:PubKey: ", p), err) } + if err := p.PubKey.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PubKey), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:PubKey: ", p), err) } + return err +} + +func (p *TPKEServiceLagrangeArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "S", thrift.SET, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:S: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.I32, len(p.S)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("TPKEServiceLagrangeArgs(%+v)", *p) +} + +// Attributes: +// - Success +type TPKEServiceLagrangeResult struct { + Success *int32 `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewTPKEServiceLagrangeResult() *TPKEServiceLagrangeResult { + return &TPKEServiceLagrangeResult{} +} + +var TPKEServiceLagrangeResult_Success_DEFAULT int32 +func (p *TPKEServiceLagrangeResult) GetSuccess() int32 { + if !p.IsSetSuccess() { + return TPKEServiceLagrangeResult_Success_DEFAULT + } +return *p.Success +} +func (p *TPKEServiceLagrangeResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *TPKEServiceLagrangeResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.I32 { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceLagrangeResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + p.Success = &v +} + return nil +} + +func (p *TPKEServiceLagrangeResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "lagrange_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceLagrangeResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.I32, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := oprot.WriteI32(ctx, int32(*p.Success)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *TPKEServiceLagrangeResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceLagrangeResult(%+v)", *p) +} + +// Attributes: +// - PubKey +// - M +type TPKEServiceEncryptArgs struct { + PubKey *TPKEPublicKeyThrift `thrift:"PubKey,1" db:"PubKey" json:"PubKey"` + M string `thrift:"m,2" db:"m" json:"m"` +} + +func NewTPKEServiceEncryptArgs() *TPKEServiceEncryptArgs { + return &TPKEServiceEncryptArgs{} +} + +var TPKEServiceEncryptArgs_PubKey_DEFAULT *TPKEPublicKeyThrift +func (p *TPKEServiceEncryptArgs) GetPubKey() *TPKEPublicKeyThrift { + if !p.IsSetPubKey() { + return TPKEServiceEncryptArgs_PubKey_DEFAULT + } +return p.PubKey +} + +func (p *TPKEServiceEncryptArgs) GetM() string { + return p.M +} +func (p *TPKEServiceEncryptArgs) IsSetPubKey() bool { + return p.PubKey != nil +} + +func (p *TPKEServiceEncryptArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceEncryptArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.PubKey = &TPKEPublicKeyThrift{} + if err := p.PubKey.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PubKey), err) + } + return nil +} + +func (p *TPKEServiceEncryptArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.M = v +} + return nil +} + +func (p *TPKEServiceEncryptArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "encrypt_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceEncryptArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "PubKey", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:PubKey: ", p), err) } + if err := p.PubKey.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PubKey), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:PubKey: ", p), err) } + return err +} + +func (p *TPKEServiceEncryptArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "m", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:m: ", p), err) } + if err := oprot.WriteString(ctx, string(p.M)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.m (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:m: ", p), err) } + return err +} + +func (p *TPKEServiceEncryptArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceEncryptArgs(%+v)", *p) +} + +// Attributes: +// - Success +type TPKEServiceEncryptResult struct { + Success *EncryptedMessageThrift `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewTPKEServiceEncryptResult() *TPKEServiceEncryptResult { + return &TPKEServiceEncryptResult{} +} + +var TPKEServiceEncryptResult_Success_DEFAULT *EncryptedMessageThrift +func (p *TPKEServiceEncryptResult) GetSuccess() *EncryptedMessageThrift { + if !p.IsSetSuccess() { + return TPKEServiceEncryptResult_Success_DEFAULT + } +return p.Success +} +func (p *TPKEServiceEncryptResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *TPKEServiceEncryptResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceEncryptResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &EncryptedMessageThrift{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *TPKEServiceEncryptResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "encrypt_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceEncryptResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *TPKEServiceEncryptResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceEncryptResult(%+v)", *p) +} + +// Attributes: +// - PubKey +// - Em +// - Shares +type TPKEServiceCombineSharesArgs struct { + PubKey *TPKEPublicKeyThrift `thrift:"PubKey,1" db:"PubKey" json:"PubKey"` + Em *EncryptedMessageThrift `thrift:"em,2" db:"em" json:"em"` + Shares map[int32][]byte `thrift:"shares,3" db:"shares" json:"shares"` +} + +func NewTPKEServiceCombineSharesArgs() *TPKEServiceCombineSharesArgs { + return &TPKEServiceCombineSharesArgs{} +} + +var TPKEServiceCombineSharesArgs_PubKey_DEFAULT *TPKEPublicKeyThrift +func (p *TPKEServiceCombineSharesArgs) GetPubKey() *TPKEPublicKeyThrift { + if !p.IsSetPubKey() { + return TPKEServiceCombineSharesArgs_PubKey_DEFAULT + } +return p.PubKey +} +var TPKEServiceCombineSharesArgs_Em_DEFAULT *EncryptedMessageThrift +func (p *TPKEServiceCombineSharesArgs) GetEm() *EncryptedMessageThrift { + if !p.IsSetEm() { + return TPKEServiceCombineSharesArgs_Em_DEFAULT + } +return p.Em +} + +func (p *TPKEServiceCombineSharesArgs) GetShares() map[int32][]byte { + return p.Shares +} +func (p *TPKEServiceCombineSharesArgs) IsSetPubKey() bool { + return p.PubKey != nil +} + +func (p *TPKEServiceCombineSharesArgs) IsSetEm() bool { + return p.Em != nil +} + +func (p *TPKEServiceCombineSharesArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.MAP { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceCombineSharesArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.PubKey = &TPKEPublicKeyThrift{} + if err := p.PubKey.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PubKey), err) + } + return nil +} + +func (p *TPKEServiceCombineSharesArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.Em = &EncryptedMessageThrift{} + if err := p.Em.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Em), err) + } + return nil +} + +func (p *TPKEServiceCombineSharesArgs) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin(ctx) + if err != nil { + return thrift.PrependError("error reading map begin: ", err) + } + tMap := make(map[int32][]byte, size) + p.Shares = tMap + for i := 0; i < size; i ++ { +var _key30 int32 + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _key30 = v +} +var _val31 []byte + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _val31 = v +} + p.Shares[_key30] = _val31 + } + if err := iprot.ReadMapEnd(ctx); err != nil { + return thrift.PrependError("error reading map end: ", err) + } + return nil +} + +func (p *TPKEServiceCombineSharesArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "combineShares_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceCombineSharesArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "PubKey", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:PubKey: ", p), err) } + if err := p.PubKey.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PubKey), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:PubKey: ", p), err) } + return err +} + +func (p *TPKEServiceCombineSharesArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "em", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:em: ", p), err) } + if err := p.Em.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Em), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:em: ", p), err) } + return err +} + +func (p *TPKEServiceCombineSharesArgs) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "shares", thrift.MAP, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:shares: ", p), err) } + if err := oprot.WriteMapBegin(ctx, thrift.I32, thrift.STRING, len(p.Shares)); err != nil { + return thrift.PrependError("error writing map begin: ", err) + } + for k, v := range p.Shares { + if err := oprot.WriteI32(ctx, int32(k)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } + if err := oprot.WriteBinary(ctx, v); err != nil { + return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } + } + if err := oprot.WriteMapEnd(ctx); err != nil { + return thrift.PrependError("error writing map end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:shares: ", p), err) } + return err +} + +func (p *TPKEServiceCombineSharesArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceCombineSharesArgs(%+v)", *p) +} + +// Attributes: +// - Success +type TPKEServiceCombineSharesResult struct { + Success []byte `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewTPKEServiceCombineSharesResult() *TPKEServiceCombineSharesResult { + return &TPKEServiceCombineSharesResult{} +} + +var TPKEServiceCombineSharesResult_Success_DEFAULT []byte + +func (p *TPKEServiceCombineSharesResult) GetSuccess() []byte { + return p.Success +} +func (p *TPKEServiceCombineSharesResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *TPKEServiceCombineSharesResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRING { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceCombineSharesResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + p.Success = v +} + return nil +} + +func (p *TPKEServiceCombineSharesResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "combineShares_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceCombineSharesResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRING, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := oprot.WriteBinary(ctx, p.Success); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *TPKEServiceCombineSharesResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceCombineSharesResult(%+v)", *p) +} + +// Attributes: +// - PrivKey +// - Em +type TPKEServiceDecryptShareArgs struct { + PrivKey *TPKEPrivateKeyThrift `thrift:"PrivKey,1" db:"PrivKey" json:"PrivKey"` + Em *EncryptedMessageThrift `thrift:"em,2" db:"em" json:"em"` +} + +func NewTPKEServiceDecryptShareArgs() *TPKEServiceDecryptShareArgs { + return &TPKEServiceDecryptShareArgs{} +} + +var TPKEServiceDecryptShareArgs_PrivKey_DEFAULT *TPKEPrivateKeyThrift +func (p *TPKEServiceDecryptShareArgs) GetPrivKey() *TPKEPrivateKeyThrift { + if !p.IsSetPrivKey() { + return TPKEServiceDecryptShareArgs_PrivKey_DEFAULT + } +return p.PrivKey +} +var TPKEServiceDecryptShareArgs_Em_DEFAULT *EncryptedMessageThrift +func (p *TPKEServiceDecryptShareArgs) GetEm() *EncryptedMessageThrift { + if !p.IsSetEm() { + return TPKEServiceDecryptShareArgs_Em_DEFAULT + } +return p.Em +} +func (p *TPKEServiceDecryptShareArgs) IsSetPrivKey() bool { + return p.PrivKey != nil +} + +func (p *TPKEServiceDecryptShareArgs) IsSetEm() bool { + return p.Em != nil +} + +func (p *TPKEServiceDecryptShareArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceDecryptShareArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.PrivKey = &TPKEPrivateKeyThrift{} + if err := p.PrivKey.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PrivKey), err) + } + return nil +} + +func (p *TPKEServiceDecryptShareArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.Em = &EncryptedMessageThrift{} + if err := p.Em.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Em), err) + } + return nil +} + +func (p *TPKEServiceDecryptShareArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "decryptShare_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceDecryptShareArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "PrivKey", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:PrivKey: ", p), err) } + if err := p.PrivKey.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PrivKey), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:PrivKey: ", p), err) } + return err +} + +func (p *TPKEServiceDecryptShareArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "em", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:em: ", p), err) } + if err := p.Em.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Em), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:em: ", p), err) } + return err +} + +func (p *TPKEServiceDecryptShareArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceDecryptShareArgs(%+v)", *p) +} + +// Attributes: +// - Success +type TPKEServiceDecryptShareResult struct { + Success []byte `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewTPKEServiceDecryptShareResult() *TPKEServiceDecryptShareResult { + return &TPKEServiceDecryptShareResult{} +} + +var TPKEServiceDecryptShareResult_Success_DEFAULT []byte + +func (p *TPKEServiceDecryptShareResult) GetSuccess() []byte { + return p.Success +} +func (p *TPKEServiceDecryptShareResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *TPKEServiceDecryptShareResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRING { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceDecryptShareResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + p.Success = v +} + return nil +} + +func (p *TPKEServiceDecryptShareResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "decryptShare_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceDecryptShareResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRING, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := oprot.WriteBinary(ctx, p.Success); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *TPKEServiceDecryptShareResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceDecryptShareResult(%+v)", *p) +} + +// Attributes: +// - Players +// - K +type TPKEServiceDealerArgs struct { + Players int32 `thrift:"players,1" db:"players" json:"players"` + K int32 `thrift:"k,2" db:"k" json:"k"` +} + +func NewTPKEServiceDealerArgs() *TPKEServiceDealerArgs { + return &TPKEServiceDealerArgs{} +} + + +func (p *TPKEServiceDealerArgs) GetPlayers() int32 { + return p.Players +} + +func (p *TPKEServiceDealerArgs) GetK() int32 { + return p.K +} +func (p *TPKEServiceDealerArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I32 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceDealerArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Players = v +} + return nil +} + +func (p *TPKEServiceDealerArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.K = v +} + return nil +} + +func (p *TPKEServiceDealerArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "dealer_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceDealerArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "players", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:players: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Players)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.players (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:players: ", p), err) } + return err +} + +func (p *TPKEServiceDealerArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "k", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:k: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.K)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.k (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:k: ", p), err) } + return err +} + +func (p *TPKEServiceDealerArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceDealerArgs(%+v)", *p) +} + +// Attributes: +// - Success +type TPKEServiceDealerResult struct { + Success *DealerThrift `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewTPKEServiceDealerResult() *TPKEServiceDealerResult { + return &TPKEServiceDealerResult{} +} + +var TPKEServiceDealerResult_Success_DEFAULT *DealerThrift +func (p *TPKEServiceDealerResult) GetSuccess() *DealerThrift { + if !p.IsSetSuccess() { + return TPKEServiceDealerResult_Success_DEFAULT + } +return p.Success +} +func (p *TPKEServiceDealerResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *TPKEServiceDealerResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceDealerResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &DealerThrift{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *TPKEServiceDealerResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "dealer_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceDealerResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *TPKEServiceDealerResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceDealerResult(%+v)", *p) +} + +// Attributes: +// - Key +// - Raw +type TPKEServiceAesEncryptArgs struct { + Key *AESKey `thrift:"key,1" db:"key" json:"key"` + Raw []byte `thrift:"raw,2" db:"raw" json:"raw"` +} + +func NewTPKEServiceAesEncryptArgs() *TPKEServiceAesEncryptArgs { + return &TPKEServiceAesEncryptArgs{} +} + +var TPKEServiceAesEncryptArgs_Key_DEFAULT *AESKey +func (p *TPKEServiceAesEncryptArgs) GetKey() *AESKey { + if !p.IsSetKey() { + return TPKEServiceAesEncryptArgs_Key_DEFAULT + } +return p.Key +} + +func (p *TPKEServiceAesEncryptArgs) GetRaw() []byte { + return p.Raw +} +func (p *TPKEServiceAesEncryptArgs) IsSetKey() bool { + return p.Key != nil +} + +func (p *TPKEServiceAesEncryptArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceAesEncryptArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &AESKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *TPKEServiceAesEncryptArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Raw = v +} + return nil +} + +func (p *TPKEServiceAesEncryptArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "aesEncrypt_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceAesEncryptArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *TPKEServiceAesEncryptArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "raw", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:raw: ", p), err) } + if err := oprot.WriteBinary(ctx, p.Raw); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.raw (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:raw: ", p), err) } + return err +} + +func (p *TPKEServiceAesEncryptArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceAesEncryptArgs(%+v)", *p) +} + +// Attributes: +// - Success +type TPKEServiceAesEncryptResult struct { + Success []byte `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewTPKEServiceAesEncryptResult() *TPKEServiceAesEncryptResult { + return &TPKEServiceAesEncryptResult{} +} + +var TPKEServiceAesEncryptResult_Success_DEFAULT []byte + +func (p *TPKEServiceAesEncryptResult) GetSuccess() []byte { + return p.Success +} +func (p *TPKEServiceAesEncryptResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *TPKEServiceAesEncryptResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRING { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceAesEncryptResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + p.Success = v +} + return nil +} + +func (p *TPKEServiceAesEncryptResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "aesEncrypt_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceAesEncryptResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRING, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := oprot.WriteBinary(ctx, p.Success); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *TPKEServiceAesEncryptResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceAesEncryptResult(%+v)", *p) +} + +// Attributes: +// - Key +// - EncMes +type TPKEServiceAesDecryptArgs struct { + Key *AESKey `thrift:"key,1" db:"key" json:"key"` + EncMes []byte `thrift:"encMes,2" db:"encMes" json:"encMes"` +} + +func NewTPKEServiceAesDecryptArgs() *TPKEServiceAesDecryptArgs { + return &TPKEServiceAesDecryptArgs{} +} + +var TPKEServiceAesDecryptArgs_Key_DEFAULT *AESKey +func (p *TPKEServiceAesDecryptArgs) GetKey() *AESKey { + if !p.IsSetKey() { + return TPKEServiceAesDecryptArgs_Key_DEFAULT + } +return p.Key +} + +func (p *TPKEServiceAesDecryptArgs) GetEncMes() []byte { + return p.EncMes +} +func (p *TPKEServiceAesDecryptArgs) IsSetKey() bool { + return p.Key != nil +} + +func (p *TPKEServiceAesDecryptArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceAesDecryptArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &AESKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *TPKEServiceAesDecryptArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.EncMes = v +} + return nil +} + +func (p *TPKEServiceAesDecryptArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "aesDecrypt_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceAesDecryptArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *TPKEServiceAesDecryptArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "encMes", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:encMes: ", p), err) } + if err := oprot.WriteBinary(ctx, p.EncMes); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.encMes (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:encMes: ", p), err) } + return err +} + +func (p *TPKEServiceAesDecryptArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceAesDecryptArgs(%+v)", *p) +} + +// Attributes: +// - Success +type TPKEServiceAesDecryptResult struct { + Success []byte `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewTPKEServiceAesDecryptResult() *TPKEServiceAesDecryptResult { + return &TPKEServiceAesDecryptResult{} +} + +var TPKEServiceAesDecryptResult_Success_DEFAULT []byte + +func (p *TPKEServiceAesDecryptResult) GetSuccess() []byte { + return p.Success +} +func (p *TPKEServiceAesDecryptResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *TPKEServiceAesDecryptResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRING { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TPKEServiceAesDecryptResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + p.Success = v +} + return nil +} + +func (p *TPKEServiceAesDecryptResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "aesDecrypt_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TPKEServiceAesDecryptResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRING, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := oprot.WriteBinary(ctx, p.Success); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *TPKEServiceAesDecryptResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TPKEServiceAesDecryptResult(%+v)", *p) +} + + diff --git a/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/go.mod b/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/go.mod new file mode 100644 index 00000000..86164ec5 --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/go.mod @@ -0,0 +1,5 @@ +module encryption + +go 1.17 + +require github.com/apache/thrift v0.16.0 diff --git a/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/go.sum b/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/go.sum new file mode 100644 index 00000000..d37f0dee --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/go.sum @@ -0,0 +1,15 @@ +github.com/apache/thrift v0.16.0 h1:qEy6UW60iVOlUy+b9ZR0d5WzUWYGOo4HfopoyBaNmoY= +github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= +github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/t_p_k_e_service-remote/t_p_k_e_service-remote.go b/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/t_p_k_e_service-remote/t_p_k_e_service-remote.go new file mode 100755 index 00000000..dd33f74f --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/thrift/gen-go/encryption/t_p_k_e_service-remote/t_p_k_e_service-remote.go @@ -0,0 +1,415 @@ +// Code generated by Thrift Compiler (0.16.0). DO NOT EDIT. + +package main + +import ( + "context" + "flag" + "fmt" + "math" + "net" + "net/url" + "os" + "strconv" + "strings" + thrift "github.com/apache/thrift/lib/go/thrift" + "encryption" +) + +var _ = encryption.GoUnusedProtection__ + +func Usage() { + fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") + flag.PrintDefaults() + fmt.Fprintln(os.Stderr, "\nFunctions:") + fmt.Fprintln(os.Stderr, " i32 lagrange(TPKEPublicKeyThrift PubKey, S, i32 j)") + fmt.Fprintln(os.Stderr, " EncryptedMessageThrift encrypt(TPKEPublicKeyThrift PubKey, string m)") + fmt.Fprintln(os.Stderr, " string combineShares(TPKEPublicKeyThrift PubKey, EncryptedMessageThrift em, shares)") + fmt.Fprintln(os.Stderr, " string decryptShare(TPKEPrivateKeyThrift PrivKey, EncryptedMessageThrift em)") + fmt.Fprintln(os.Stderr, " DealerThrift dealer(i32 players, i32 k)") + fmt.Fprintln(os.Stderr, " string aesEncrypt(AESKey key, string raw)") + fmt.Fprintln(os.Stderr, " string aesDecrypt(AESKey key, string encMes)") + fmt.Fprintln(os.Stderr) + os.Exit(0) +} + +type httpHeaders map[string]string + +func (h httpHeaders) String() string { + var m map[string]string = h + return fmt.Sprintf("%s", m) +} + +func (h httpHeaders) Set(value string) error { + parts := strings.Split(value, ": ") + if len(parts) != 2 { + return fmt.Errorf("header should be of format 'Key: Value'") + } + h[parts[0]] = parts[1] + return nil +} + +func main() { + flag.Usage = Usage + var host string + var port int + var protocol string + var urlString string + var framed bool + var useHttp bool + headers := make(httpHeaders) + var parsedUrl *url.URL + var trans thrift.TTransport + _ = strconv.Atoi + _ = math.Abs + flag.Usage = Usage + flag.StringVar(&host, "h", "localhost", "Specify host and port") + flag.IntVar(&port, "p", 9090, "Specify port") + flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") + flag.StringVar(&urlString, "u", "", "Specify the url") + flag.BoolVar(&framed, "framed", false, "Use framed transport") + flag.BoolVar(&useHttp, "http", false, "Use http") + flag.Var(headers, "H", "Headers to set on the http(s) request (e.g. -H \"Key: Value\")") + flag.Parse() + + if len(urlString) > 0 { + var err error + parsedUrl, err = url.Parse(urlString) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + host = parsedUrl.Host + useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" || parsedUrl.Scheme == "https" + } else if useHttp { + _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + } + + cmd := flag.Arg(0) + var err error + var cfg *thrift.TConfiguration = nil + if useHttp { + trans, err = thrift.NewTHttpClient(parsedUrl.String()) + if len(headers) > 0 { + httptrans := trans.(*thrift.THttpClient) + for key, value := range headers { + httptrans.SetHeader(key, value) + } + } + } else { + portStr := fmt.Sprint(port) + if strings.Contains(host, ":") { + host, portStr, err = net.SplitHostPort(host) + if err != nil { + fmt.Fprintln(os.Stderr, "error with host:", err) + os.Exit(1) + } + } + trans = thrift.NewTSocketConf(net.JoinHostPort(host, portStr), cfg) + if err != nil { + fmt.Fprintln(os.Stderr, "error resolving address:", err) + os.Exit(1) + } + if framed { + trans = thrift.NewTFramedTransportConf(trans, cfg) + } + } + if err != nil { + fmt.Fprintln(os.Stderr, "Error creating transport", err) + os.Exit(1) + } + defer trans.Close() + var protocolFactory thrift.TProtocolFactory + switch protocol { + case "compact": + protocolFactory = thrift.NewTCompactProtocolFactoryConf(cfg) + break + case "simplejson": + protocolFactory = thrift.NewTSimpleJSONProtocolFactoryConf(cfg) + break + case "json": + protocolFactory = thrift.NewTJSONProtocolFactory() + break + case "binary", "": + protocolFactory = thrift.NewTBinaryProtocolFactoryConf(cfg) + break + default: + fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) + Usage() + os.Exit(1) + } + iprot := protocolFactory.GetProtocol(trans) + oprot := protocolFactory.GetProtocol(trans) + client := encryption.NewTPKEServiceClient(thrift.NewTStandardClient(iprot, oprot)) + if err := trans.Open(); err != nil { + fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) + os.Exit(1) + } + + switch cmd { + case "lagrange": + if flag.NArg() - 1 != 3 { + fmt.Fprintln(os.Stderr, "Lagrange requires 3 args") + flag.Usage() + } + arg32 := flag.Arg(1) + mbTrans33 := thrift.NewTMemoryBufferLen(len(arg32)) + defer mbTrans33.Close() + _, err34 := mbTrans33.WriteString(arg32) + if err34 != nil { + Usage() + return + } + factory35 := thrift.NewTJSONProtocolFactory() + jsProt36 := factory35.GetProtocol(mbTrans33) + argvalue0 := encryption.NewTPKEPublicKeyThrift() + err37 := argvalue0.Read(context.Background(), jsProt36) + if err37 != nil { + Usage() + return + } + value0 := argvalue0 + arg38 := flag.Arg(2) + mbTrans39 := thrift.NewTMemoryBufferLen(len(arg38)) + defer mbTrans39.Close() + _, err40 := mbTrans39.WriteString(arg38) + if err40 != nil { + Usage() + return + } + factory41 := thrift.NewTJSONProtocolFactory() + jsProt42 := factory41.GetProtocol(mbTrans39) + containerStruct1 := encryption.NewTPKEServiceLagrangeArgs() + err43 := containerStruct1.ReadField2(context.Background(), jsProt42) + if err43 != nil { + Usage() + return + } + argvalue1 := containerStruct1.S + value1 := argvalue1 + tmp2, err44 := (strconv.Atoi(flag.Arg(3))) + if err44 != nil { + Usage() + return + } + argvalue2 := int32(tmp2) + value2 := argvalue2 + fmt.Print(client.Lagrange(context.Background(), value0, value1, value2)) + fmt.Print("\n") + break + case "encrypt": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "Encrypt requires 2 args") + flag.Usage() + } + arg45 := flag.Arg(1) + mbTrans46 := thrift.NewTMemoryBufferLen(len(arg45)) + defer mbTrans46.Close() + _, err47 := mbTrans46.WriteString(arg45) + if err47 != nil { + Usage() + return + } + factory48 := thrift.NewTJSONProtocolFactory() + jsProt49 := factory48.GetProtocol(mbTrans46) + argvalue0 := encryption.NewTPKEPublicKeyThrift() + err50 := argvalue0.Read(context.Background(), jsProt49) + if err50 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + fmt.Print(client.Encrypt(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "combineShares": + if flag.NArg() - 1 != 3 { + fmt.Fprintln(os.Stderr, "CombineShares requires 3 args") + flag.Usage() + } + arg52 := flag.Arg(1) + mbTrans53 := thrift.NewTMemoryBufferLen(len(arg52)) + defer mbTrans53.Close() + _, err54 := mbTrans53.WriteString(arg52) + if err54 != nil { + Usage() + return + } + factory55 := thrift.NewTJSONProtocolFactory() + jsProt56 := factory55.GetProtocol(mbTrans53) + argvalue0 := encryption.NewTPKEPublicKeyThrift() + err57 := argvalue0.Read(context.Background(), jsProt56) + if err57 != nil { + Usage() + return + } + value0 := argvalue0 + arg58 := flag.Arg(2) + mbTrans59 := thrift.NewTMemoryBufferLen(len(arg58)) + defer mbTrans59.Close() + _, err60 := mbTrans59.WriteString(arg58) + if err60 != nil { + Usage() + return + } + factory61 := thrift.NewTJSONProtocolFactory() + jsProt62 := factory61.GetProtocol(mbTrans59) + argvalue1 := encryption.NewEncryptedMessageThrift() + err63 := argvalue1.Read(context.Background(), jsProt62) + if err63 != nil { + Usage() + return + } + value1 := argvalue1 + arg64 := flag.Arg(3) + mbTrans65 := thrift.NewTMemoryBufferLen(len(arg64)) + defer mbTrans65.Close() + _, err66 := mbTrans65.WriteString(arg64) + if err66 != nil { + Usage() + return + } + factory67 := thrift.NewTJSONProtocolFactory() + jsProt68 := factory67.GetProtocol(mbTrans65) + containerStruct2 := encryption.NewTPKEServiceCombineSharesArgs() + err69 := containerStruct2.ReadField3(context.Background(), jsProt68) + if err69 != nil { + Usage() + return + } + argvalue2 := containerStruct2.Shares + value2 := argvalue2 + fmt.Print(client.CombineShares(context.Background(), value0, value1, value2)) + fmt.Print("\n") + break + case "decryptShare": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "DecryptShare requires 2 args") + flag.Usage() + } + arg70 := flag.Arg(1) + mbTrans71 := thrift.NewTMemoryBufferLen(len(arg70)) + defer mbTrans71.Close() + _, err72 := mbTrans71.WriteString(arg70) + if err72 != nil { + Usage() + return + } + factory73 := thrift.NewTJSONProtocolFactory() + jsProt74 := factory73.GetProtocol(mbTrans71) + argvalue0 := encryption.NewTPKEPrivateKeyThrift() + err75 := argvalue0.Read(context.Background(), jsProt74) + if err75 != nil { + Usage() + return + } + value0 := argvalue0 + arg76 := flag.Arg(2) + mbTrans77 := thrift.NewTMemoryBufferLen(len(arg76)) + defer mbTrans77.Close() + _, err78 := mbTrans77.WriteString(arg76) + if err78 != nil { + Usage() + return + } + factory79 := thrift.NewTJSONProtocolFactory() + jsProt80 := factory79.GetProtocol(mbTrans77) + argvalue1 := encryption.NewEncryptedMessageThrift() + err81 := argvalue1.Read(context.Background(), jsProt80) + if err81 != nil { + Usage() + return + } + value1 := argvalue1 + fmt.Print(client.DecryptShare(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "dealer": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "Dealer requires 2 args") + flag.Usage() + } + tmp0, err82 := (strconv.Atoi(flag.Arg(1))) + if err82 != nil { + Usage() + return + } + argvalue0 := int32(tmp0) + value0 := argvalue0 + tmp1, err83 := (strconv.Atoi(flag.Arg(2))) + if err83 != nil { + Usage() + return + } + argvalue1 := int32(tmp1) + value1 := argvalue1 + fmt.Print(client.Dealer(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "aesEncrypt": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "AesEncrypt requires 2 args") + flag.Usage() + } + arg84 := flag.Arg(1) + mbTrans85 := thrift.NewTMemoryBufferLen(len(arg84)) + defer mbTrans85.Close() + _, err86 := mbTrans85.WriteString(arg84) + if err86 != nil { + Usage() + return + } + factory87 := thrift.NewTJSONProtocolFactory() + jsProt88 := factory87.GetProtocol(mbTrans85) + argvalue0 := encryption.NewAESKey() + err89 := argvalue0.Read(context.Background(), jsProt88) + if err89 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := []byte(flag.Arg(2)) + value1 := argvalue1 + fmt.Print(client.AesEncrypt(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "aesDecrypt": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "AesDecrypt requires 2 args") + flag.Usage() + } + arg91 := flag.Arg(1) + mbTrans92 := thrift.NewTMemoryBufferLen(len(arg91)) + defer mbTrans92.Close() + _, err93 := mbTrans92.WriteString(arg91) + if err93 != nil { + Usage() + return + } + factory94 := thrift.NewTJSONProtocolFactory() + jsProt95 := factory94.GetProtocol(mbTrans92) + argvalue0 := encryption.NewAESKey() + err96 := argvalue0.Read(context.Background(), jsProt95) + if err96 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := []byte(flag.Arg(2)) + value1 := argvalue1 + fmt.Print(client.AesDecrypt(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "": + Usage() + break + default: + fmt.Fprintln(os.Stderr, "Invalid function ", cmd) + } +} diff --git a/honeybadgerbft/crypto/threshenc/thrift/gen-py/__init__.py b/honeybadgerbft/crypto/threshenc/thrift/gen-py/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/TPKEService-remote b/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/TPKEService-remote new file mode 100755 index 00000000..a7fa2fbf --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/TPKEService-remote @@ -0,0 +1,159 @@ +#!/usr/bin/env python +# +# Autogenerated by Thrift Compiler (0.16.0) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + +import sys +import pprint +if sys.version_info[0] > 2: + from urllib.parse import urlparse +else: + from urlparse import urlparse +from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient +from thrift.protocol.TBinaryProtocol import TBinaryProtocol + +from encryption import TPKEService +from encryption.ttypes import * + +if len(sys.argv) <= 1 or sys.argv[1] == '--help': + print('') + print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] [-novalidate] [-ca_certs certs] [-keyfile keyfile] [-certfile certfile] function [arg1 [arg2...]]') + print('') + print('Functions:') + print(' i32 lagrange(TPKEPublicKeyThrift PubKey, S, i32 j)') + print(' EncryptedMessageThrift encrypt(TPKEPublicKeyThrift PubKey, string m)') + print(' string combineShares(TPKEPublicKeyThrift PubKey, EncryptedMessageThrift em, shares)') + print(' string decryptShare(TPKEPrivateKeyThrift PrivKey, EncryptedMessageThrift em)') + print(' DealerThrift dealer(i32 players, i32 k)') + print(' string aesEncrypt(AESKey key, string raw)') + print(' string aesDecrypt(AESKey key, string encMes)') + print('') + sys.exit(0) + +pp = pprint.PrettyPrinter(indent=2) +host = 'localhost' +port = 9090 +uri = '' +framed = False +ssl = False +validate = True +ca_certs = None +keyfile = None +certfile = None +http = False +argi = 1 + +if sys.argv[argi] == '-h': + parts = sys.argv[argi + 1].split(':') + host = parts[0] + if len(parts) > 1: + port = int(parts[1]) + argi += 2 + +if sys.argv[argi] == '-u': + url = urlparse(sys.argv[argi + 1]) + parts = url[1].split(':') + host = parts[0] + if len(parts) > 1: + port = int(parts[1]) + else: + port = 80 + uri = url[2] + if url[4]: + uri += '?%s' % url[4] + http = True + argi += 2 + +if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed': + framed = True + argi += 1 + +if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl': + ssl = True + argi += 1 + +if sys.argv[argi] == '-novalidate': + validate = False + argi += 1 + +if sys.argv[argi] == '-ca_certs': + ca_certs = sys.argv[argi+1] + argi += 2 + +if sys.argv[argi] == '-keyfile': + keyfile = sys.argv[argi+1] + argi += 2 + +if sys.argv[argi] == '-certfile': + certfile = sys.argv[argi+1] + argi += 2 + +cmd = sys.argv[argi] +args = sys.argv[argi + 1:] + +if http: + transport = THttpClient.THttpClient(host, port, uri) +else: + if ssl: + socket = TSSLSocket.TSSLSocket(host, port, validate=validate, ca_certs=ca_certs, keyfile=keyfile, certfile=certfile) + else: + socket = TSocket.TSocket(host, port) + if framed: + transport = TTransport.TFramedTransport(socket) + else: + transport = TTransport.TBufferedTransport(socket) +protocol = TBinaryProtocol(transport) +client = TPKEService.Client(protocol) +transport.open() + +if cmd == 'lagrange': + if len(args) != 3: + print('lagrange requires 3 args') + sys.exit(1) + pp.pprint(client.lagrange(eval(args[0]), eval(args[1]), eval(args[2]),)) + +elif cmd == 'encrypt': + if len(args) != 2: + print('encrypt requires 2 args') + sys.exit(1) + pp.pprint(client.encrypt(eval(args[0]), args[1],)) + +elif cmd == 'combineShares': + if len(args) != 3: + print('combineShares requires 3 args') + sys.exit(1) + pp.pprint(client.combineShares(eval(args[0]), eval(args[1]), eval(args[2]),)) + +elif cmd == 'decryptShare': + if len(args) != 2: + print('decryptShare requires 2 args') + sys.exit(1) + pp.pprint(client.decryptShare(eval(args[0]), eval(args[1]),)) + +elif cmd == 'dealer': + if len(args) != 2: + print('dealer requires 2 args') + sys.exit(1) + pp.pprint(client.dealer(eval(args[0]), eval(args[1]),)) + +elif cmd == 'aesEncrypt': + if len(args) != 2: + print('aesEncrypt requires 2 args') + sys.exit(1) + pp.pprint(client.aesEncrypt(eval(args[0]), args[1],)) + +elif cmd == 'aesDecrypt': + if len(args) != 2: + print('aesDecrypt requires 2 args') + sys.exit(1) + pp.pprint(client.aesDecrypt(eval(args[0]), args[1],)) + +else: + print('Unrecognized method %s' % cmd) + sys.exit(1) + +transport.close() diff --git a/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/TPKEService.py b/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/TPKEService.py new file mode 100644 index 00000000..fd700cf2 --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/TPKEService.py @@ -0,0 +1,1531 @@ +# +# Autogenerated by Thrift Compiler (0.16.0) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +from thrift.TRecursive import fix_spec + +import sys +import logging +from .ttypes import * +from thrift.Thrift import TProcessor +from thrift.transport import TTransport +all_structs = [] + + +class Iface(object): + def lagrange(self, PubKey, S, j): + """ + Parameters: + - PubKey + - S + - j + + """ + pass + + def encrypt(self, PubKey, m): + """ + Parameters: + - PubKey + - m + + """ + pass + + def combineShares(self, PubKey, em, shares): + """ + Parameters: + - PubKey + - em + - shares + + """ + pass + + def decryptShare(self, PrivKey, em): + """ + Parameters: + - PrivKey + - em + + """ + pass + + def dealer(self, players, k): + """ + Parameters: + - players + - k + + """ + pass + + def aesEncrypt(self, key, raw): + """ + Parameters: + - key + - raw + + """ + pass + + def aesDecrypt(self, key, encMes): + """ + Parameters: + - key + - encMes + + """ + pass + + +class Client(Iface): + def __init__(self, iprot, oprot=None): + self._iprot = self._oprot = iprot + if oprot is not None: + self._oprot = oprot + self._seqid = 0 + + def lagrange(self, PubKey, S, j): + """ + Parameters: + - PubKey + - S + - j + + """ + self.send_lagrange(PubKey, S, j) + return self.recv_lagrange() + + def send_lagrange(self, PubKey, S, j): + self._oprot.writeMessageBegin('lagrange', TMessageType.CALL, self._seqid) + args = lagrange_args() + args.PubKey = PubKey + args.S = S + args.j = j + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_lagrange(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = lagrange_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "lagrange failed: unknown result") + + def encrypt(self, PubKey, m): + """ + Parameters: + - PubKey + - m + + """ + self.send_encrypt(PubKey, m) + return self.recv_encrypt() + + def send_encrypt(self, PubKey, m): + self._oprot.writeMessageBegin('encrypt', TMessageType.CALL, self._seqid) + args = encrypt_args() + args.PubKey = PubKey + args.m = m + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_encrypt(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = encrypt_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "encrypt failed: unknown result") + + def combineShares(self, PubKey, em, shares): + """ + Parameters: + - PubKey + - em + - shares + + """ + self.send_combineShares(PubKey, em, shares) + return self.recv_combineShares() + + def send_combineShares(self, PubKey, em, shares): + self._oprot.writeMessageBegin('combineShares', TMessageType.CALL, self._seqid) + args = combineShares_args() + args.PubKey = PubKey + args.em = em + args.shares = shares + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_combineShares(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = combineShares_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "combineShares failed: unknown result") + + def decryptShare(self, PrivKey, em): + """ + Parameters: + - PrivKey + - em + + """ + self.send_decryptShare(PrivKey, em) + return self.recv_decryptShare() + + def send_decryptShare(self, PrivKey, em): + self._oprot.writeMessageBegin('decryptShare', TMessageType.CALL, self._seqid) + args = decryptShare_args() + args.PrivKey = PrivKey + args.em = em + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_decryptShare(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = decryptShare_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "decryptShare failed: unknown result") + + def dealer(self, players, k): + """ + Parameters: + - players + - k + + """ + self.send_dealer(players, k) + return self.recv_dealer() + + def send_dealer(self, players, k): + self._oprot.writeMessageBegin('dealer', TMessageType.CALL, self._seqid) + args = dealer_args() + args.players = players + args.k = k + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_dealer(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = dealer_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "dealer failed: unknown result") + + def aesEncrypt(self, key, raw): + """ + Parameters: + - key + - raw + + """ + self.send_aesEncrypt(key, raw) + return self.recv_aesEncrypt() + + def send_aesEncrypt(self, key, raw): + self._oprot.writeMessageBegin('aesEncrypt', TMessageType.CALL, self._seqid) + args = aesEncrypt_args() + args.key = key + args.raw = raw + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_aesEncrypt(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = aesEncrypt_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "aesEncrypt failed: unknown result") + + def aesDecrypt(self, key, encMes): + """ + Parameters: + - key + - encMes + + """ + self.send_aesDecrypt(key, encMes) + return self.recv_aesDecrypt() + + def send_aesDecrypt(self, key, encMes): + self._oprot.writeMessageBegin('aesDecrypt', TMessageType.CALL, self._seqid) + args = aesDecrypt_args() + args.key = key + args.encMes = encMes + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_aesDecrypt(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = aesDecrypt_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "aesDecrypt failed: unknown result") + + +class Processor(Iface, TProcessor): + def __init__(self, handler): + self._handler = handler + self._processMap = {} + self._processMap["lagrange"] = Processor.process_lagrange + self._processMap["encrypt"] = Processor.process_encrypt + self._processMap["combineShares"] = Processor.process_combineShares + self._processMap["decryptShare"] = Processor.process_decryptShare + self._processMap["dealer"] = Processor.process_dealer + self._processMap["aesEncrypt"] = Processor.process_aesEncrypt + self._processMap["aesDecrypt"] = Processor.process_aesDecrypt + self._on_message_begin = None + + def on_message_begin(self, func): + self._on_message_begin = func + + def process(self, iprot, oprot): + (name, type, seqid) = iprot.readMessageBegin() + if self._on_message_begin: + self._on_message_begin(name, type, seqid) + if name not in self._processMap: + iprot.skip(TType.STRUCT) + iprot.readMessageEnd() + x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) + oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) + x.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + return + else: + self._processMap[name](self, seqid, iprot, oprot) + return True + + def process_lagrange(self, seqid, iprot, oprot): + args = lagrange_args() + args.read(iprot) + iprot.readMessageEnd() + result = lagrange_result() + try: + result.success = self._handler.lagrange(args.PubKey, args.S, args.j) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("lagrange", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_encrypt(self, seqid, iprot, oprot): + args = encrypt_args() + args.read(iprot) + iprot.readMessageEnd() + result = encrypt_result() + try: + result.success = self._handler.encrypt(args.PubKey, args.m) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("encrypt", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_combineShares(self, seqid, iprot, oprot): + args = combineShares_args() + args.read(iprot) + iprot.readMessageEnd() + result = combineShares_result() + try: + result.success = self._handler.combineShares(args.PubKey, args.em, args.shares) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("combineShares", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_decryptShare(self, seqid, iprot, oprot): + args = decryptShare_args() + args.read(iprot) + iprot.readMessageEnd() + result = decryptShare_result() + try: + result.success = self._handler.decryptShare(args.PrivKey, args.em) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("decryptShare", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_dealer(self, seqid, iprot, oprot): + args = dealer_args() + args.read(iprot) + iprot.readMessageEnd() + result = dealer_result() + try: + result.success = self._handler.dealer(args.players, args.k) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("dealer", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_aesEncrypt(self, seqid, iprot, oprot): + args = aesEncrypt_args() + args.read(iprot) + iprot.readMessageEnd() + result = aesEncrypt_result() + try: + result.success = self._handler.aesEncrypt(args.key, args.raw) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("aesEncrypt", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_aesDecrypt(self, seqid, iprot, oprot): + args = aesDecrypt_args() + args.read(iprot) + iprot.readMessageEnd() + result = aesDecrypt_result() + try: + result.success = self._handler.aesDecrypt(args.key, args.encMes) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("aesDecrypt", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + +# HELPER FUNCTIONS AND STRUCTURES + + +class lagrange_args(object): + """ + Attributes: + - PubKey + - S + - j + + """ + + + def __init__(self, PubKey=None, S=None, j=None,): + self.PubKey = PubKey + self.S = S + self.j = j + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.PubKey = TPKEPublicKeyThrift() + self.PubKey.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.SET: + self.S = set() + (_etype17, _size14) = iprot.readSetBegin() + for _i18 in range(_size14): + _elem19 = iprot.readI32() + self.S.add(_elem19) + iprot.readSetEnd() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.I32: + self.j = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('lagrange_args') + if self.PubKey is not None: + oprot.writeFieldBegin('PubKey', TType.STRUCT, 1) + self.PubKey.write(oprot) + oprot.writeFieldEnd() + if self.S is not None: + oprot.writeFieldBegin('S', TType.SET, 2) + oprot.writeSetBegin(TType.I32, len(self.S)) + for iter20 in self.S: + oprot.writeI32(iter20) + oprot.writeSetEnd() + oprot.writeFieldEnd() + if self.j is not None: + oprot.writeFieldBegin('j', TType.I32, 3) + oprot.writeI32(self.j) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(lagrange_args) +lagrange_args.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'PubKey', [TPKEPublicKeyThrift, None], None, ), # 1 + (2, TType.SET, 'S', (TType.I32, None, False), None, ), # 2 + (3, TType.I32, 'j', None, None, ), # 3 +) + + +class lagrange_result(object): + """ + Attributes: + - success + + """ + + + def __init__(self, success=None,): + self.success = success + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.I32: + self.success = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('lagrange_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.I32, 0) + oprot.writeI32(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(lagrange_result) +lagrange_result.thrift_spec = ( + (0, TType.I32, 'success', None, None, ), # 0 +) + + +class encrypt_args(object): + """ + Attributes: + - PubKey + - m + + """ + + + def __init__(self, PubKey=None, m=None,): + self.PubKey = PubKey + self.m = m + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.PubKey = TPKEPublicKeyThrift() + self.PubKey.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.m = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('encrypt_args') + if self.PubKey is not None: + oprot.writeFieldBegin('PubKey', TType.STRUCT, 1) + self.PubKey.write(oprot) + oprot.writeFieldEnd() + if self.m is not None: + oprot.writeFieldBegin('m', TType.STRING, 2) + oprot.writeString(self.m.encode('utf-8') if sys.version_info[0] == 2 else self.m) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(encrypt_args) +encrypt_args.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'PubKey', [TPKEPublicKeyThrift, None], None, ), # 1 + (2, TType.STRING, 'm', 'UTF8', None, ), # 2 +) + + +class encrypt_result(object): + """ + Attributes: + - success + + """ + + + def __init__(self, success=None,): + self.success = success + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRUCT: + self.success = EncryptedMessageThrift() + self.success.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('encrypt_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(encrypt_result) +encrypt_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [EncryptedMessageThrift, None], None, ), # 0 +) + + +class combineShares_args(object): + """ + Attributes: + - PubKey + - em + - shares + + """ + + + def __init__(self, PubKey=None, em=None, shares=None,): + self.PubKey = PubKey + self.em = em + self.shares = shares + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.PubKey = TPKEPublicKeyThrift() + self.PubKey.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.em = EncryptedMessageThrift() + self.em.read(iprot) + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.MAP: + self.shares = {} + (_ktype22, _vtype23, _size21) = iprot.readMapBegin() + for _i25 in range(_size21): + _key26 = iprot.readI32() + _val27 = iprot.readBinary() + self.shares[_key26] = _val27 + iprot.readMapEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('combineShares_args') + if self.PubKey is not None: + oprot.writeFieldBegin('PubKey', TType.STRUCT, 1) + self.PubKey.write(oprot) + oprot.writeFieldEnd() + if self.em is not None: + oprot.writeFieldBegin('em', TType.STRUCT, 2) + self.em.write(oprot) + oprot.writeFieldEnd() + if self.shares is not None: + oprot.writeFieldBegin('shares', TType.MAP, 3) + oprot.writeMapBegin(TType.I32, TType.STRING, len(self.shares)) + for kiter28, viter29 in self.shares.items(): + oprot.writeI32(kiter28) + oprot.writeBinary(viter29) + oprot.writeMapEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(combineShares_args) +combineShares_args.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'PubKey', [TPKEPublicKeyThrift, None], None, ), # 1 + (2, TType.STRUCT, 'em', [EncryptedMessageThrift, None], None, ), # 2 + (3, TType.MAP, 'shares', (TType.I32, None, TType.STRING, 'BINARY', False), None, ), # 3 +) + + +class combineShares_result(object): + """ + Attributes: + - success + + """ + + + def __init__(self, success=None,): + self.success = success + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readBinary() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('combineShares_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeBinary(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(combineShares_result) +combineShares_result.thrift_spec = ( + (0, TType.STRING, 'success', 'BINARY', None, ), # 0 +) + + +class decryptShare_args(object): + """ + Attributes: + - PrivKey + - em + + """ + + + def __init__(self, PrivKey=None, em=None,): + self.PrivKey = PrivKey + self.em = em + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.PrivKey = TPKEPrivateKeyThrift() + self.PrivKey.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.em = EncryptedMessageThrift() + self.em.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('decryptShare_args') + if self.PrivKey is not None: + oprot.writeFieldBegin('PrivKey', TType.STRUCT, 1) + self.PrivKey.write(oprot) + oprot.writeFieldEnd() + if self.em is not None: + oprot.writeFieldBegin('em', TType.STRUCT, 2) + self.em.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(decryptShare_args) +decryptShare_args.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'PrivKey', [TPKEPrivateKeyThrift, None], None, ), # 1 + (2, TType.STRUCT, 'em', [EncryptedMessageThrift, None], None, ), # 2 +) + + +class decryptShare_result(object): + """ + Attributes: + - success + + """ + + + def __init__(self, success=None,): + self.success = success + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readBinary() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('decryptShare_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeBinary(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(decryptShare_result) +decryptShare_result.thrift_spec = ( + (0, TType.STRING, 'success', 'BINARY', None, ), # 0 +) + + +class dealer_args(object): + """ + Attributes: + - players + - k + + """ + + + def __init__(self, players=None, k=None,): + self.players = players + self.k = k + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.players = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.I32: + self.k = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('dealer_args') + if self.players is not None: + oprot.writeFieldBegin('players', TType.I32, 1) + oprot.writeI32(self.players) + oprot.writeFieldEnd() + if self.k is not None: + oprot.writeFieldBegin('k', TType.I32, 2) + oprot.writeI32(self.k) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(dealer_args) +dealer_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'players', None, None, ), # 1 + (2, TType.I32, 'k', None, None, ), # 2 +) + + +class dealer_result(object): + """ + Attributes: + - success + + """ + + + def __init__(self, success=None,): + self.success = success + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRUCT: + self.success = DealerThrift() + self.success.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('dealer_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(dealer_result) +dealer_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [DealerThrift, None], None, ), # 0 +) + + +class aesEncrypt_args(object): + """ + Attributes: + - key + - raw + + """ + + + def __init__(self, key=None, raw=None,): + self.key = key + self.raw = raw + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.key = AESKey() + self.key.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.raw = iprot.readBinary() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('aesEncrypt_args') + if self.key is not None: + oprot.writeFieldBegin('key', TType.STRUCT, 1) + self.key.write(oprot) + oprot.writeFieldEnd() + if self.raw is not None: + oprot.writeFieldBegin('raw', TType.STRING, 2) + oprot.writeBinary(self.raw) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(aesEncrypt_args) +aesEncrypt_args.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'key', [AESKey, None], None, ), # 1 + (2, TType.STRING, 'raw', 'BINARY', None, ), # 2 +) + + +class aesEncrypt_result(object): + """ + Attributes: + - success + + """ + + + def __init__(self, success=None,): + self.success = success + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readBinary() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('aesEncrypt_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeBinary(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(aesEncrypt_result) +aesEncrypt_result.thrift_spec = ( + (0, TType.STRING, 'success', 'BINARY', None, ), # 0 +) + + +class aesDecrypt_args(object): + """ + Attributes: + - key + - encMes + + """ + + + def __init__(self, key=None, encMes=None,): + self.key = key + self.encMes = encMes + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.key = AESKey() + self.key.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.encMes = iprot.readBinary() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('aesDecrypt_args') + if self.key is not None: + oprot.writeFieldBegin('key', TType.STRUCT, 1) + self.key.write(oprot) + oprot.writeFieldEnd() + if self.encMes is not None: + oprot.writeFieldBegin('encMes', TType.STRING, 2) + oprot.writeBinary(self.encMes) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(aesDecrypt_args) +aesDecrypt_args.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'key', [AESKey, None], None, ), # 1 + (2, TType.STRING, 'encMes', 'BINARY', None, ), # 2 +) + + +class aesDecrypt_result(object): + """ + Attributes: + - success + + """ + + + def __init__(self, success=None,): + self.success = success + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readBinary() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('aesDecrypt_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeBinary(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(aesDecrypt_result) +aesDecrypt_result.thrift_spec = ( + (0, TType.STRING, 'success', 'BINARY', None, ), # 0 +) +fix_spec(all_structs) +del all_structs diff --git a/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/__init__.py b/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/__init__.py new file mode 100644 index 00000000..a63415c2 --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/__init__.py @@ -0,0 +1 @@ +__all__ = ['ttypes', 'constants', 'TPKEService'] diff --git a/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/constants.py b/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/constants.py new file mode 100644 index 00000000..82c674e0 --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/constants.py @@ -0,0 +1,14 @@ +# +# Autogenerated by Thrift Compiler (0.16.0) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +from thrift.TRecursive import fix_spec + +import sys +from .ttypes import * diff --git a/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/ttypes.py b/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/ttypes.py new file mode 100644 index 00000000..a9b3f67a --- /dev/null +++ b/honeybadgerbft/crypto/threshenc/thrift/gen-py/encryption/ttypes.py @@ -0,0 +1,600 @@ +# +# Autogenerated by Thrift Compiler (0.16.0) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +from thrift.TRecursive import fix_spec + +import sys + +from thrift.transport import TTransport +all_structs = [] + + +class VerificationKeyThrift(object): + """ + Attributes: + - key + + """ + + + def __init__(self, key=None,): + self.key = key + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.key = iprot.readBinary() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('VerificationKeyThrift') + if self.key is not None: + oprot.writeFieldBegin('key', TType.STRING, 1) + oprot.writeBinary(self.key) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.key is None: + raise TProtocolException(message='Required field key is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class PrivateKeyThrift(object): + """ + Attributes: + - key + + """ + + + def __init__(self, key=None,): + self.key = key + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.key = iprot.readBinary() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('PrivateKeyThrift') + if self.key is not None: + oprot.writeFieldBegin('key', TType.STRING, 1) + oprot.writeBinary(self.key) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.key is None: + raise TProtocolException(message='Required field key is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class EncryptedMessageThrift(object): + """ + Attributes: + - U + - V + - W + + """ + + + def __init__(self, U=None, V=None, W=None,): + self.U = U + self.V = V + self.W = W + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.U = iprot.readBinary() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.V = iprot.readBinary() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRING: + self.W = iprot.readBinary() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('EncryptedMessageThrift') + if self.U is not None: + oprot.writeFieldBegin('U', TType.STRING, 1) + oprot.writeBinary(self.U) + oprot.writeFieldEnd() + if self.V is not None: + oprot.writeFieldBegin('V', TType.STRING, 2) + oprot.writeBinary(self.V) + oprot.writeFieldEnd() + if self.W is not None: + oprot.writeFieldBegin('W', TType.STRING, 3) + oprot.writeBinary(self.W) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.U is None: + raise TProtocolException(message='Required field U is unset!') + if self.V is None: + raise TProtocolException(message='Required field V is unset!') + if self.W is None: + raise TProtocolException(message='Required field W is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class TPKEPublicKeyThrift(object): + """ + Attributes: + - l + - k + - VK + - VKs + + """ + + + def __init__(self, l=None, k=None, VK=None, VKs=None,): + self.l = l + self.k = k + self.VK = VK + self.VKs = VKs + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.l = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.I32: + self.k = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.VK = VerificationKeyThrift() + self.VK.read(iprot) + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.LIST: + self.VKs = [] + (_etype3, _size0) = iprot.readListBegin() + for _i4 in range(_size0): + _elem5 = VerificationKeyThrift() + _elem5.read(iprot) + self.VKs.append(_elem5) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('TPKEPublicKeyThrift') + if self.l is not None: + oprot.writeFieldBegin('l', TType.I32, 1) + oprot.writeI32(self.l) + oprot.writeFieldEnd() + if self.k is not None: + oprot.writeFieldBegin('k', TType.I32, 2) + oprot.writeI32(self.k) + oprot.writeFieldEnd() + if self.VK is not None: + oprot.writeFieldBegin('VK', TType.STRUCT, 3) + self.VK.write(oprot) + oprot.writeFieldEnd() + if self.VKs is not None: + oprot.writeFieldBegin('VKs', TType.LIST, 4) + oprot.writeListBegin(TType.STRUCT, len(self.VKs)) + for iter6 in self.VKs: + iter6.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.l is None: + raise TProtocolException(message='Required field l is unset!') + if self.k is None: + raise TProtocolException(message='Required field k is unset!') + if self.VK is None: + raise TProtocolException(message='Required field VK is unset!') + if self.VKs is None: + raise TProtocolException(message='Required field VKs is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class TPKEPrivateKeyThrift(object): + """ + Attributes: + - PubKey + - SK + - i + + """ + + + def __init__(self, PubKey=None, SK=None, i=None,): + self.PubKey = PubKey + self.SK = SK + self.i = i + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.PubKey = TPKEPublicKeyThrift() + self.PubKey.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.SK = PrivateKeyThrift() + self.SK.read(iprot) + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.I32: + self.i = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('TPKEPrivateKeyThrift') + if self.PubKey is not None: + oprot.writeFieldBegin('PubKey', TType.STRUCT, 1) + self.PubKey.write(oprot) + oprot.writeFieldEnd() + if self.SK is not None: + oprot.writeFieldBegin('SK', TType.STRUCT, 2) + self.SK.write(oprot) + oprot.writeFieldEnd() + if self.i is not None: + oprot.writeFieldBegin('i', TType.I32, 3) + oprot.writeI32(self.i) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.PubKey is None: + raise TProtocolException(message='Required field PubKey is unset!') + if self.SK is None: + raise TProtocolException(message='Required field SK is unset!') + if self.i is None: + raise TProtocolException(message='Required field i is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class DealerThrift(object): + """ + Attributes: + - PubKey + - PrivKeys + + """ + + + def __init__(self, PubKey=None, PrivKeys=None,): + self.PubKey = PubKey + self.PrivKeys = PrivKeys + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.PubKey = TPKEPublicKeyThrift() + self.PubKey.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.LIST: + self.PrivKeys = [] + (_etype10, _size7) = iprot.readListBegin() + for _i11 in range(_size7): + _elem12 = TPKEPrivateKeyThrift() + _elem12.read(iprot) + self.PrivKeys.append(_elem12) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('DealerThrift') + if self.PubKey is not None: + oprot.writeFieldBegin('PubKey', TType.STRUCT, 1) + self.PubKey.write(oprot) + oprot.writeFieldEnd() + if self.PrivKeys is not None: + oprot.writeFieldBegin('PrivKeys', TType.LIST, 2) + oprot.writeListBegin(TType.STRUCT, len(self.PrivKeys)) + for iter13 in self.PrivKeys: + iter13.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.PubKey is None: + raise TProtocolException(message='Required field PubKey is unset!') + if self.PrivKeys is None: + raise TProtocolException(message='Required field PrivKeys is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class AESKey(object): + """ + Attributes: + - key + + """ + + + def __init__(self, key=None,): + self.key = key + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.key = iprot.readBinary() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('AESKey') + if self.key is not None: + oprot.writeFieldBegin('key', TType.STRING, 1) + oprot.writeBinary(self.key) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.key is None: + raise TProtocolException(message='Required field key is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(VerificationKeyThrift) +VerificationKeyThrift.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'key', 'BINARY', None, ), # 1 +) +all_structs.append(PrivateKeyThrift) +PrivateKeyThrift.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'key', 'BINARY', None, ), # 1 +) +all_structs.append(EncryptedMessageThrift) +EncryptedMessageThrift.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'U', 'BINARY', None, ), # 1 + (2, TType.STRING, 'V', 'BINARY', None, ), # 2 + (3, TType.STRING, 'W', 'BINARY', None, ), # 3 +) +all_structs.append(TPKEPublicKeyThrift) +TPKEPublicKeyThrift.thrift_spec = ( + None, # 0 + (1, TType.I32, 'l', None, None, ), # 1 + (2, TType.I32, 'k', None, None, ), # 2 + (3, TType.STRUCT, 'VK', [VerificationKeyThrift, None], None, ), # 3 + (4, TType.LIST, 'VKs', (TType.STRUCT, [VerificationKeyThrift, None], False), None, ), # 4 +) +all_structs.append(TPKEPrivateKeyThrift) +TPKEPrivateKeyThrift.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'PubKey', [TPKEPublicKeyThrift, None], None, ), # 1 + (2, TType.STRUCT, 'SK', [PrivateKeyThrift, None], None, ), # 2 + (3, TType.I32, 'i', None, None, ), # 3 +) +all_structs.append(DealerThrift) +DealerThrift.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'PubKey', [TPKEPublicKeyThrift, None], None, ), # 1 + (2, TType.LIST, 'PrivKeys', (TType.STRUCT, [TPKEPrivateKeyThrift, None], False), None, ), # 2 +) +all_structs.append(AESKey) +AESKey.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'key', 'BINARY', None, ), # 1 +) +fix_spec(all_structs) +del all_structs diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..17d404b0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +gevent~=21.12.0 +ecdsa~=0.17.0 +gmpy2~=2.1.2 +zfec~=1.5.7.2 +gipc~=1.4.0 +setuptools~=41.2.0 +numpy~=1.21.2 +matplotlib~=3.5.1 +enum34~=1.1.10 +coincurve~=17.0.0 +thrift~=0.16.0 \ No newline at end of file