Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add BLSToExecutionEhange signature feature #23

Merged
merged 7 commits into from
Mar 30, 2023

Conversation

xiaoguang1010
Copy link
Collaborator

@xiaoguang1010 xiaoguang1010 commented Mar 30, 2023

LABS-1429

genesis_validators_root: &Node,
) -> Result<Domain, MerkleizationError> {
if domain_type.len() != 4 {
//todo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 todo 是什么意思?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个本来是想加一个长度校验呢,后来看了一下没必要,所以删掉就行。

fn it_works() {
assert_eq!(2 + 2, 4);
}
pub fn hex_to_bytes(value: &str) -> Result<Vec<u8>> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个其实最好放在共用的library中

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token-core中目前没有一个公共使用的工具库,后续根据需要再加上吧。

@@ -22,7 +22,7 @@ tiny-bip39 = "0.7.3"
ed25519-bip32 = "0.3.2"
blake2b_simd = "1.0.0"
iop-keyvault = "0.0.5"
bls-signatures = "0.13.0"
bls-signatures = { git = "https://github.com/XuNeal/bls-signatures.git", branch = "feat/pop_dst" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blst 库支持 自定义 cipher suite https://github.com/supranational/blst
示例代码参见

use blst::{min_pk, min_sig, PublicKey, SecretKey};

fn main() {
    // 生成密钥对
    let sk = SecretKey::key_gen(&[42; 32]).unwrap();
    let pk = PublicKey::from(&sk);

    // 签名
    let msg = b"Hello, BLS!";
    let dst = b"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_";
    let sig = min_sig::sign(msg, &sk, dst).unwrap();

    // 验证签名
    let result = min_pk::verify(&sig, msg, &pk, dst);
    assert!(result.is_ok());
}

可以尝试把这个fork的 bls-signatures 替换一下

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已使用blst库替换。
另外blst sign函数传入参数的正确顺序为:
let sig = min_sig::sign(msg, dst, aug).unwrap();

@xiaoguang1010
Copy link
Collaborator Author

build

@XuNeal XuNeal merged commit d61e0e4 into main Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants