fil-bls-sign-rs
Jni :也可以在项目文件 Cargo.toml 点击jni项目左边进入jni官方介绍
需自己打包Android所需的so包,cargo-config.toml 中的ndk地址为自己本地的ndk地址;
Java项目使用方法:
1.创建seed Java_com_lxx_nativerust_FilecoinBlsSignUtil_generateBlsSeed
//输出值为已hex字符串
String hexSeed = FilecoinBlsSignUtil.generateBlsSeed();
2.通过privateKey获取publicKey Java_com_lxx_nativerust_FilecoinBlsSignUtil_filPrivateKeyPublicKey
//都是已hex的值
String hexPrivateKey = Hex.toHexString(privateKeyBytes);
String hexPublicKey = FilecoinBlsSignUtil.filPrivateKeyPublicKey(hexPrivateKey);
3.通过seed创建私钥 Java_com_lxx_nativerust_FilecoinBlsSignUtil_filPrivateKeyGenerateWithSeed
String hexPrivateKey = FilecoinBlsSignUtil.filPrivateKeyGenerateWithSeed(hexSeed);
4.进行bls签名 Java_com_lxx_nativerust_FilecoinBlsSignUtil_filPrivateKeySign
/**
* cid的方式与Secp256k1签名方式一致,需将cid的字节数组转换为hex值,传入进来,
* 输出值为已经hex的签名的值,最后需要将其转换为base64,放到message中,传入接口
*/
Stirng hexCidMessage = Hex.toHexString(cidBytes)
String hexSign = FilecoinBlsSignUtil.filPrivateKeySign(hexPrivateKey,hexCidMessage);