简单远程多签签名服务架构设计



 

优势

  • 服务暂时就两个,交易、签名服务
  • 支持已有trade服务,即不改变已有api服务,无缝连接
  • 协议走proto3,字节小+安全
  • 支持同步和异步服务
  • 支持机器人push
  • 支持多终端,web UI采用react,backend用golang1.12
  • 网络隔离
  • 支持m of N的多签的钱包交易

 劣势

  • 编程难度提升
  • 存在安全隐患

客户公司早期使用的Java语言作为服务端

syntax = "proto3";

option java_multiple_files = true;
option java_package = "com.peckshield.dapp";
option java_outer_classname = "SignatureProto";
option objc_class_prefix = "SIGN";

package protos;


service SignatureRemote {

  rpc sign (SignatureRequest) returns (SignatureResponse) {} ;
}

message SignatureRequest {
  string nonce =1;

  int64 amount =2 ;

  uint64 gasLimit =3;

  int64 gasPrice=4;

  string toaddress = 5;
}


message SignatureResponse {
  string data = 1;
}

区块链服务采用golang开发:

type Server struct{}
func (s *Server) sign(context context.Context, in *pb.SignatureRequest)(*pb.SignatureResponse, error) {
        tx := types.NewTransaction(nonce, tokenAddress, value, gasLimit*2, gasPrice, data)
	signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, privateKey)
	if err != nil {
		log.Fatal(err)
	}
	data, _ := rlp.EncodeToBytes(signedTx)
	fmt.Println(common.ToHex(data2))

	return &pb.SignatureResponse{Message: data}, nil


}
func main() {
 listen, err := net.Listen("tcp", grpcPort)
 if err != nil {
  fmt.Printf("failed to listen: %v\n", err)
  return
 }
 fmt.Printf("SUCCESS")

猜你喜欢

转载自cywhoyi.iteye.com/blog/2440862