docs(tools): 国密链真链复现脚本与证据入库,避免散落 /tmp 后丢失
- 新增 tools/fisco-realnode/:真链实证期用过的 Python SDK 发送器 (fj-sdk/)、Java JNI 独立交叉验证探针 (jni/)、TARS 编解码辅助 (tars/), 作为审计轨迹留档,便于回看签名口径根因。 - 新增 example.chain.json(非密钥,可入库)与 README.md 索引:明确 规范入口 (selftest-fisco-contract.py 主门禁第22条) 与审计轨迹的分工、 复现所需环境变量、下载项、密钥与诚实边界。 - .gitignore 屏蔽私钥 (*.pem/*.key)、下载型二进制 (jar/tar.gz) 与大证据 blob,防止密钥或体积大的文件进 git 历史。
This commit is contained in:
1 parent
237e646962
commit
3ad3f30929
36 files changed
+1110
No files matched your search
@@ -0,0 +1,74 @@
|
||||
import org.fisco.bcos.sdk.jni.common.JniLibLoader;
|
||||
import org.fisco.bcos.sdk.jni.utilities.tx.TransactionStructBuilderJniObj;
|
||||
import org.fisco.bcos.sdk.jni.utilities.tx.TransactionDataV1;
|
||||
|
||||
/**
|
||||
* 用官方 JNI 编码同一份 TransactionData,输出官方 TARS hex + 官方 hash。
|
||||
*
|
||||
* 用法: java -cp bcos-sdk-jni.jar Encode <jsonFile>
|
||||
*/
|
||||
public class Encode {
|
||||
static final int SM = 0;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
JniLibLoader.loadJniLibrary();
|
||||
String text = new String(java.nio.file.Files.readAllBytes(
|
||||
java.nio.file.Paths.get(args[0])), "utf-8");
|
||||
|
||||
TransactionDataV1 d = new TransactionDataV1();
|
||||
d.setVersion((int) jlong(text, "version"));
|
||||
d.setChainId(jstr(text, "chainId"));
|
||||
d.setGroupId(jstr(text, "groupId"));
|
||||
d.setNonce(jstr(text, "nonce"));
|
||||
d.setTo(jstr(text, "to"));
|
||||
d.setAbi(jstr(text, "abi"));
|
||||
d.setBlockLimit(jlong(text, "blockLimit"));
|
||||
d.setInput(fromHex(jstr(text, "input")));
|
||||
d.setValue(jstr(text, "value"));
|
||||
d.setGasPrice(jstr(text, "gasPrice"));
|
||||
d.setGasLimit(jlong(text, "gasLimit"));
|
||||
d.setMaxFeePerGas(jstr(text, "maxFeePerGas"));
|
||||
d.setMaxPriorityFeePerGas(jstr(text, "maxPriorityFeePerGas"));
|
||||
|
||||
String hash = TransactionStructBuilderJniObj.calcTransactionDataStructHash(SM, d);
|
||||
String enc = TransactionStructBuilderJniObj.encodeTransactionDataStruct(d);
|
||||
System.out.println("OFFICIAL_HASH=" + hash);
|
||||
System.out.println("OFFICIAL_TARS=" + enc);
|
||||
System.out.println("OFFICIAL_TARS_LEN=" + (enc.length() / 2));
|
||||
}
|
||||
|
||||
static byte[] fromHex(String h) {
|
||||
if (h == null) return new byte[0];
|
||||
h = h.startsWith("0x") ? h.substring(2) : h;
|
||||
int n = h.length() / 2;
|
||||
byte[] out = new byte[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
out[i] = (byte) Integer.parseInt(h.substring(i * 2, i * 2 + 2), 16);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static String jstr(String text, String key) {
|
||||
String pat = "\"" + key + "\"";
|
||||
int i = text.indexOf(pat);
|
||||
if (i < 0) return "";
|
||||
int c = text.indexOf(':', i);
|
||||
int q = text.indexOf('"', c + 1);
|
||||
if (q < 0) return "";
|
||||
int e = text.indexOf('"', q + 1);
|
||||
if (e < 0) return "";
|
||||
return text.substring(q + 1, e);
|
||||
}
|
||||
|
||||
static long jlong(String text, String key) {
|
||||
String pat = "\"" + key + "\"";
|
||||
int i = text.indexOf(pat);
|
||||
if (i < 0) return 0;
|
||||
int c = text.indexOf(':', i);
|
||||
int s = c + 1;
|
||||
while (s < text.length() && Character.isWhitespace(text.charAt(s))) s++;
|
||||
int e = s;
|
||||
while (e < text.length() && (Character.isDigit(text.charAt(e)) || text.charAt(e) == '-')) e++;
|
||||
return Long.parseLong(text.substring(s, e));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user