feat: remove useless file

This commit is contained in:
sangge-redmi 2025-04-03 13:50:12 +08:00
parent f03fc66c1e
commit dd86253162
10 changed files with 44 additions and 268 deletions

2
.gitignore vendored
View File

@ -39,4 +39,4 @@ include
*-blx.bib
*.run.xml
.coverage

View File

@ -1,19 +0,0 @@
FROM python:3.12-slim
COPY requirements.txt /app/
# 设置目标平台参数
#ARG TARGETPLATFORM
# 根据目标平台复制相应架构的库文件
#COPY lib/${TARGETPLATFORM}/* /lib/
COPY lib/* /usr/local/lib/
WORKDIR /app
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install --index-url https://git.mamahaha.work/api/packages/sangge/pypi/simple/ ecc-rs
RUN ldconfig

View File

@ -1,10 +1,24 @@
FROM git.mamahaha.work/sangge/tpre:base
COPY src /app
COPY requirements.txt /app/requirements.txt
FROM python:3.13-slim AS base
WORKDIR /app
COPY ./pyproject.toml /app/
COPY lib/* /usr/local/lib/
RUN ldconfig && \
pip install -i https://git.mamahaha.work/api/packages/sangge/pypi/simple/ ecc-rs==0.1.2 --no-cache-dir
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# Development stage
FROM base AS dev
RUN pip install -e ".[dev]" -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir
# Test stage
FROM base AS test
COPY ./tests /app/tests
RUN pip install -e ".[test]" -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir
ENTRYPOINT ["pytest", "/app/tests"]
CMD ["-xvs"]
# Deployment stage
FROM base AS deploy
WORKDIR /app
COPY --from=base /usr/local/lib/* /usr/local/lib/
COPY src /app
RUN ldconfig

6
package-lock.json generated
View File

@ -1,6 +0,0 @@
{
"name": "tpre-python",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}

21
pyproject.toml Normal file
View File

@ -0,0 +1,21 @@
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "tpre-python"
version = "0.1.1"
description = "tpre-python"
authors = [
{ name = "Liang Junyong", email = "liangjunyong06@gmail.com" },
{ name = "Jiang Chao", email = "2384899431@qq.com" },
{ name = "Deng Qinyu", email = "1016751306@qq.com" },
{ name = "Ran Sitong", email = "2624758301@qq.com" },
{ name = "Yu Haichuan", email = "haichuanyu243@gmail.com" },
]
requires-python = ">=3.8"
dependencies = ["gmssl-python>=2.2.2,<3.0.0", "fastapi", "uvicorn", "requests"]
[project.optional-dependencies]
test = ["httpx", "pytest"]
dev = ["httpx", "pytest", "pyright", "ruff"]

View File

@ -1,63 +0,0 @@
from web3 import Web3
import json
rpc_url = "https://ethereum-holesky-rpc.publicnode.com"
chain = Web3(Web3.HTTPProvider(rpc_url))
contract_address = "0x642C23F91bf8339044A00251BC09d1D98110C433"
contract_abi = json.loads(
"""[
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "string",
"name": "msg",
"type": "string"
}
],
"name": "messageLog",
"type": "event"
},
{
"inputs": [
{
"internalType": "string",
"name": "text",
"type": "string"
}
],
"name": "logmessage",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
]"""
)
contract = chain.eth.contract(address=contract_address, abi=contract_abi)
wallet_address = "0xe02666Cb63b3645E7B03C9082a24c4c1D7C9EFf6"
pk = "ae66ae3711a69079efd3d3e9b55f599ce7514eb29dfe4f9551404d3f361438c6"
def call_eth_logger(wallet_address, pk, message: str):
transaction = contract.functions.logmessage(message).build_transaction(
{
"chainId": 17000,
"gas": 30000,
"gasPrice": chain.to_wei("10", "gwei"),
"nonce": chain.eth.get_transaction_count(wallet_address, "pending"),
}
)
signed_tx = chain.eth.account.sign_transaction(transaction, private_key=pk)
tx_hash = chain.eth.send_raw_transaction(signed_tx.raw_transaction)
print(tx_hash)
receipt = chain.eth.wait_for_transaction_receipt(tx_hash)
transfer_event = contract.events.messageLog().process_receipt(receipt)
for event in transfer_event:
print(event["args"]["msg"])

View File

@ -1,10 +0,0 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract logger{
event messageLog(string msg);
function logmessage(string memory text) public returns (bool){
emit messageLog(text);
return true;
}
}

View File

@ -1,17 +1,13 @@
import asyncio
import json
import logging
import os
import socket
import threading
import time
from contextlib import asynccontextmanager
import requests
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from eth_logger import call_eth_logger
from tpre import ReEncrypt, capsule
@ -178,15 +174,6 @@ async def send_user_des_message(
print("send stauts:", response.text)
def log_message():
while True:
global message_list
payload = json.dumps(message_list)
message_list = []
call_eth_logger(wallet_address, wallet_pk, payload)
time.sleep(2)
wallet_address = (
"0xe02666Cb63b3645E7B03C9082a24c4c1D7C9EFf6" # 修改成要使用的钱包地址/私钥
)

View File

@ -1,148 +0,0 @@
12th Gen Intel(R) Core(TM) i5-12490F
0.01 cores
当前门限值: N = 20, T = 10
密钥生成运行时间:0.9953160285949707秒
加密算法运行时间:0.006381511688232422秒
重加密密钥生成算法运行时间:12.903082609176636秒
重加密算法运行时间:0.989858603477478秒
解密算法运行时间:19.69758915901184秒
成功解密: b'hello world'
算法总运行时间:34.59222791194916秒
0.1 cores
当前门限值: N = 20, T = 10
密钥生成运行时间:0.004191160202026367秒
加密算法运行时间:0.09498381614685059秒
重加密密钥生成算法运行时间:0.7050104141235352秒
重加密算法运行时间:0.09499671459197997秒
解密算法运行时间:1.5005874633789062秒
成功解密: b'hello world'
算法总运行时间:2.3997695684432983秒
1 cores
当前门限值: N = 20, T = 10
密钥生成运行时间:0.0030488967895507812秒
加密算法运行时间:0.005570888519287109秒
重加密密钥生成算法运行时间:0.07791781425476074秒
重加密算法运行时间:0.006881630420684815秒
解密算法运行时间:0.08786344528198242秒
成功解密: b'hello world'
算法总运行时间:0.18128267526626587秒
4 cores
当前门限值: N = 20, T = 10
密钥生成运行时间:0.0026373863220214844秒
加密算法运行时间:0.004965305328369141秒
重加密密钥生成算法运行时间:0.07313323020935059秒
重加密算法运行时间:0.006896591186523438秒
解密算法运行时间:0.08880448341369629秒
成功解密: b'hello world'
算法总运行时间:0.17643699645996094秒
rk3399
0.01 cores
当前门限值: N = 20, T = 10
密钥生成运行时间:3.9984750747680664秒
加密算法运行时间:9.599598169326782秒
重加密密钥生成算法运行时间:132.99906015396118秒
重加密算法运行时间:12.120013177394867秒
解密算法运行时间:153.29800581932068秒
成功解密: b'hello world'
算法总运行时间:312.0151523947716秒
0.1 cores
当前门限值: N = 20, T = 10
密钥生成运行时间:0.09907650947570801秒
加密算法运行时间:0.205247163772583秒
重加密密钥生成算法运行时间:7.498294830322266秒
重加密算法运行时间:0.7300507187843323秒
解密算法运行时间:8.998314619064331秒
成功解密: b'hello world'
算法总运行时间:17.53098384141922秒
1 cores
当前门限值: N = 20, T = 10
密钥生成运行时间:0.008650541305541992秒
加密算法运行时间:0.02130866050720215秒
重加密密钥生成算法运行时间:0.30187034606933594秒
重加密算法运行时间:0.0274674654006958秒
解密算法运行时间:0.3521096706390381秒
成功解密: b'hello world'
算法总运行时间:0.7114066839218139秒
4 cores
当前门限值: N = 20, T = 10
密钥生成运行时间:0.00883340835571289秒
加密算法运行时间:0.021309614181518555秒
重加密密钥生成算法运行时间:0.3036940097808838秒
重加密算法运行时间:0.0277299165725708秒
解密算法运行时间:0.3464491367340088秒
成功解密: b'hello world'
算法总运行时间:0.7080160856246949秒
12th Gen Intel(R) Core(TM) i5-12490F
当前门限值: N = 20, T = 10
明文长度:110
密钥生成运行时间:0.0033216476440429688秒
加密算法运行时间:0.00811624526977539秒
重加密密钥生成算法运行时间:0.11786699295043945秒
重加密算法运行时间:0.009650790691375732秒
解密算法运行时间:0.12125396728515625秒
成功解密:
算法总运行时间:0.2602096438407898秒
明文长度:1100
密钥生成运行时间:0.0034990310668945312秒
加密算法运行时间:0.008537054061889648秒
重加密密钥生成算法运行时间:0.10165071487426758秒
重加密算法运行时间:0.009756004810333252秒
解密算法运行时间:0.13438773155212402秒
成功解密:
算法总运行时间:0.257830536365509秒
明文长度:11000
密钥生成运行时间:0.0035142898559570312秒
加密算法运行时间:0.005819797515869141秒
重加密密钥生成算法运行时间:0.1130058765411377秒
重加密算法运行时间:0.010429942607879638秒
解密算法运行时间:0.1242990493774414秒
成功解密:
算法总运行时间:0.25706895589828493秒
明文长度:110000
密钥生成运行时间:0.002706289291381836秒
加密算法运行时间:0.00833749771118164秒
重加密密钥生成算法运行时间:0.11022734642028809秒
重加密算法运行时间:0.010864639282226562秒
解密算法运行时间:0.13867974281311035秒
成功解密:
算法总运行时间:0.2708155155181885秒
明文长度:1100000
密钥生成运行时间:0.003710031509399414秒
加密算法运行时间:0.04558920860290527秒
重加密密钥生成算法运行时间:0.10261368751525879秒
重加密算法运行时间:0.009720635414123536秒
解密算法运行时间:0.15311646461486816秒
成功解密:
算法总运行时间:0.3147500276565552秒
明文长度:11000000
密钥生成运行时间:0.008045673370361328秒
加密算法运行时间:0.3575568199157715秒
重加密密钥生成算法运行时间:0.09267783164978027秒
重加密算法运行时间:0.009347784519195556秒
解密算法运行时间:0.4754812717437744秒
成功解密:
算法总运行时间:0.9431093811988831秒
当前门限值: N = 94, T = 47
算法总运行时间:0.967951292687274秒
当前门限值: N = 95, T = 47
算法总运行时间:0.9765587304767809秒
当前门限值: N = 96, T = 48
算法总运行时间:1.019304744899273秒